Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/organizations/organizations_controller_spec.rb')
-rw-r--r--spec/requests/organizations/organizations_controller_spec.rb70
1 files changed, 56 insertions, 14 deletions
diff --git a/spec/requests/organizations/organizations_controller_spec.rb b/spec/requests/organizations/organizations_controller_spec.rb
index 788d740504a..953adb2cbf6 100644
--- a/spec/requests/organizations/organizations_controller_spec.rb
+++ b/spec/requests/organizations/organizations_controller_spec.rb
@@ -13,25 +13,30 @@ RSpec.describe Organizations::OrganizationsController, feature_category: :cell d
end
end
- shared_examples 'action disabled by `ui_for_organizations` feature flag' do
- before do
- stub_feature_flags(ui_for_organizations: false)
- end
-
- it 'renders 404' do
+ shared_examples 'redirects to sign in page' do
+ it 'redirects to sign in page' do
gitlab_request
- expect(response).to have_gitlab_http_status(:not_found)
+ expect(response).to redirect_to(new_user_session_path)
end
end
- shared_examples 'basic organization controller action' do
- context 'when the user is not logged in' do
- it_behaves_like 'successful response'
- it_behaves_like 'action disabled by `ui_for_organizations` feature flag'
+ shared_examples 'action disabled by `ui_for_organizations` feature flag' do
+ context 'when `ui_for_organizations` feature flag is disabled' do
+ before do
+ stub_feature_flags(ui_for_organizations: false)
+ end
+
+ it 'renders 404' do
+ gitlab_request
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
end
+ end
- context 'when the user is logged in' do
+ shared_examples 'when the user is signed in' do
+ context 'when the user is signed in' do
before do
sign_in(user)
end
@@ -63,15 +68,52 @@ RSpec.describe Organizations::OrganizationsController, feature_category: :cell d
end
end
+ shared_examples 'controller action that requires authentication' do
+ context 'when the user is not signed in' do
+ it_behaves_like 'redirects to sign in page'
+
+ context 'when `ui_for_organizations` feature flag is disabled' do
+ before do
+ stub_feature_flags(ui_for_organizations: false)
+ end
+
+ it_behaves_like 'redirects to sign in page'
+ end
+ end
+
+ it_behaves_like 'when the user is signed in'
+ end
+
+ shared_examples 'controller action that does not require authentication' do
+ context 'when the user is not logged in' do
+ it_behaves_like 'successful response'
+ it_behaves_like 'action disabled by `ui_for_organizations` feature flag'
+ end
+
+ it_behaves_like 'when the user is signed in'
+ end
+
describe 'GET #show' do
subject(:gitlab_request) { get organization_path(organization) }
- it_behaves_like 'basic organization controller action'
+ it_behaves_like 'controller action that does not require authentication'
end
describe 'GET #groups_and_projects' do
subject(:gitlab_request) { get groups_and_projects_organization_path(organization) }
- it_behaves_like 'basic organization controller action'
+ it_behaves_like 'controller action that does not require authentication'
+ end
+
+ describe 'GET #new' do
+ subject(:gitlab_request) { get new_organization_path }
+
+ it_behaves_like 'controller action that requires authentication'
+ end
+
+ describe 'GET #index' do
+ subject(:gitlab_request) { get organizations_path }
+
+ it_behaves_like 'controller action that requires authentication'
end
end