debian-mirror-gitlab/spec/controllers/projects/learn_gitlab_controller_spec.rb

43 lines
1.2 KiB
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::LearnGitlabController do
describe 'GET #index' do
let_it_be(:user) { create(:user) }
2022-01-26 12:08:38 +05:30
let_it_be(:project) { create(:project, namespace: create(:group)) }
2021-03-11 19:13:27 +05:30
2021-11-11 11:23:49 +05:30
let(:learn_gitlab_enabled) { true }
2021-03-11 19:13:27 +05:30
let(:params) { { namespace_id: project.namespace.to_param, project_id: project } }
2022-01-26 12:08:38 +05:30
subject(:action) { get :index, params: params }
2021-03-11 19:13:27 +05:30
before do
2022-01-26 12:08:38 +05:30
project.namespace.add_owner(user)
2021-11-11 11:23:49 +05:30
allow(controller.helpers).to receive(:learn_gitlab_enabled?).and_return(learn_gitlab_enabled)
2021-03-11 19:13:27 +05:30
end
context 'unauthenticated user' do
it { is_expected.to have_gitlab_http_status(:redirect) }
end
context 'authenticated user' do
before do
sign_in(user)
end
it { is_expected.to render_template(:index) }
context 'learn_gitlab experiment not enabled' do
2021-11-11 11:23:49 +05:30
let(:learn_gitlab_enabled) { false }
2021-03-11 19:13:27 +05:30
it { is_expected.to have_gitlab_http_status(:not_found) }
end
2022-01-26 12:08:38 +05:30
it_behaves_like 'tracks assignment and records the subject', :invite_for_help_continuous_onboarding, :namespace do
subject { project.namespace }
end
2021-03-11 19:13:27 +05:30
end
end
end