diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/requests/groups | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) | |
download | gitlab-ce-aee0a117a889461ce8ced6fcf73207fe017f1d99.tar.gz |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/requests/groups')
-rw-r--r-- | spec/requests/groups/crm/contacts_controller_spec.rb | 101 | ||||
-rw-r--r-- | spec/requests/groups/crm/organizations_controller_spec.rb | 91 |
2 files changed, 192 insertions, 0 deletions
diff --git a/spec/requests/groups/crm/contacts_controller_spec.rb b/spec/requests/groups/crm/contacts_controller_spec.rb new file mode 100644 index 00000000000..a4b2a28e77a --- /dev/null +++ b/spec/requests/groups/crm/contacts_controller_spec.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Groups::Crm::ContactsController do + let_it_be(:user) { create(:user) } + + shared_examples 'response with 404 status' do + it 'returns 404' do + subject + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + shared_examples 'ok response with index template' do + it 'renders the index template' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:index) + end + end + + shared_examples 'ok response with index template if authorized' do + context 'private group' do + let(:group) { create(:group, :private) } + + context 'with authorized user' do + before do + group.add_reporter(user) + sign_in(user) + end + + context 'when feature flag is enabled' do + it_behaves_like 'ok response with index template' + end + + context 'when feature flag is not enabled' do + before do + stub_feature_flags(customer_relations: false) + end + + it_behaves_like 'response with 404 status' + end + end + + context 'with unauthorized user' do + before do + sign_in(user) + end + + it_behaves_like 'response with 404 status' + end + + context 'with anonymous user' do + it 'blah' do + subject + + expect(response).to have_gitlab_http_status(:found) + expect(response).to redirect_to(new_user_session_path) + end + end + end + + context 'public group' do + let(:group) { create(:group, :public) } + + context 'with anonymous user' do + it_behaves_like 'ok response with index template' + end + end + end + + describe 'GET #index' do + subject do + get group_crm_contacts_path(group) + response + end + + it_behaves_like 'ok response with index template if authorized' + end + + describe 'GET #new' do + subject do + get new_group_crm_contact_path(group) + response + end + + it_behaves_like 'ok response with index template if authorized' + end + + describe 'GET #edit' do + subject do + get edit_group_crm_contact_path(group, id: 1) + response + end + + it_behaves_like 'ok response with index template if authorized' + end +end diff --git a/spec/requests/groups/crm/organizations_controller_spec.rb b/spec/requests/groups/crm/organizations_controller_spec.rb new file mode 100644 index 00000000000..7595950350d --- /dev/null +++ b/spec/requests/groups/crm/organizations_controller_spec.rb @@ -0,0 +1,91 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Groups::Crm::OrganizationsController do + let_it_be(:user) { create(:user) } + + shared_examples 'response with 404 status' do + it 'returns 404' do + subject + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + shared_examples 'ok response with index template' do + it 'renders the index template' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:index) + end + end + + shared_examples 'ok response with index template if authorized' do + context 'private group' do + let(:group) { create(:group, :private) } + + context 'with authorized user' do + before do + group.add_reporter(user) + sign_in(user) + end + + context 'when feature flag is enabled' do + it_behaves_like 'ok response with index template' + end + + context 'when feature flag is not enabled' do + before do + stub_feature_flags(customer_relations: false) + end + + it_behaves_like 'response with 404 status' + end + end + + context 'with unauthorized user' do + before do + sign_in(user) + end + + it_behaves_like 'response with 404 status' + end + + context 'with anonymous user' do + it 'blah' do + subject + + expect(response).to have_gitlab_http_status(:found) + expect(response).to redirect_to(new_user_session_path) + end + end + end + + context 'public group' do + let(:group) { create(:group, :public) } + + context 'with anonymous user' do + it_behaves_like 'ok response with index template' + end + end + end + + describe 'GET #index' do + subject do + get group_crm_organizations_path(group) + response + end + + it_behaves_like 'ok response with index template if authorized' + end + + describe 'GET #new' do + subject do + get new_group_crm_organization_path(group) + end + + it_behaves_like 'ok response with index template if authorized' + end +end |