debian-mirror-gitlab/spec/models/onboarding/learn_gitlab_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
2 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
require 'spec_helper'
2022-10-11 01:57:18 +05:30
RSpec.describe Onboarding::LearnGitlab do
2020-07-28 23:09:34 +05:30
let_it_be(:current_user) { create(:user) }
2022-10-11 01:57:18 +05:30
let_it_be(:learn_gitlab_project) { create(:project, name: described_class::PROJECT_NAME) }
let_it_be(:learn_gitlab_board) { create(:board, project: learn_gitlab_project, name: described_class::BOARD_NAME) }
let_it_be(:learn_gitlab_label) { create(:label, project: learn_gitlab_project, name: described_class::LABEL_NAME) }
2020-07-28 23:09:34 +05:30
before do
learn_gitlab_project.add_developer(current_user)
end
2022-10-11 01:57:18 +05:30
describe '#available?' do
2020-07-28 23:09:34 +05:30
using RSpec::Parameterized::TableSyntax
where(:project, :board, :label, :expected_result) do
nil | nil | nil | nil
nil | nil | true | nil
nil | true | nil | nil
nil | true | true | nil
true | nil | nil | nil
true | nil | true | nil
true | true | nil | nil
true | true | true | true
end
with_them do
before do
allow_next_instance_of(described_class) do |learn_gitlab|
allow(learn_gitlab).to receive(:project).and_return(project)
allow(learn_gitlab).to receive(:board).and_return(board)
allow(learn_gitlab).to receive(:label).and_return(label)
end
end
subject { described_class.new(current_user).available? }
it { is_expected.to be expected_result }
end
end
2022-10-11 01:57:18 +05:30
describe '#project' do
2020-07-28 23:09:34 +05:30
subject { described_class.new(current_user).project }
it { is_expected.to eq learn_gitlab_project }
2022-04-04 11:22:00 +05:30
context 'when it is created during trial signup' do
2022-10-11 01:57:18 +05:30
let_it_be(:learn_gitlab_project) do
create(:project, name: described_class::PROJECT_NAME_ULTIMATE_TRIAL, path: 'learn-gitlab-ultimate-trial')
end
2022-04-04 11:22:00 +05:30
it { is_expected.to eq learn_gitlab_project }
end
2020-07-28 23:09:34 +05:30
end
2022-10-11 01:57:18 +05:30
describe '#board' do
2020-07-28 23:09:34 +05:30
subject { described_class.new(current_user).board }
it { is_expected.to eq learn_gitlab_board }
end
2022-10-11 01:57:18 +05:30
describe '#label' do
2020-07-28 23:09:34 +05:30
subject { described_class.new(current_user).label }
it { is_expected.to eq learn_gitlab_label }
end
end