diff options
Diffstat (limited to 'spec/requests/organizations/organizations_controller_spec.rb')
-rw-r--r-- | spec/requests/organizations/organizations_controller_spec.rb | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/spec/requests/organizations/organizations_controller_spec.rb b/spec/requests/organizations/organizations_controller_spec.rb index 4bf527f49a8..bfd0603eb3d 100644 --- a/spec/requests/organizations/organizations_controller_spec.rb +++ b/spec/requests/organizations/organizations_controller_spec.rb @@ -11,13 +11,6 @@ RSpec.describe Organizations::OrganizationsController, feature_category: :cell d sign_in(user) end - context 'with no association to an organization' do - let_it_be(:user) { create(:user) } - - it_behaves_like 'organization - successful response' - it_behaves_like 'organization - action disabled by `ui_for_organizations` feature flag' - end - context 'as as admin', :enable_admin_mode do let_it_be(:user) { create(:admin) } @@ -54,6 +47,40 @@ RSpec.describe Organizations::OrganizationsController, feature_category: :cell d it_behaves_like 'when the user is signed in' end + shared_examples 'controller action that requires authentication by an organization user' do + it_behaves_like 'controller action that requires authentication' + + context 'when the user is signed in' do + before do + sign_in(user) + end + + context 'with no association to an organization' do + let_it_be(:user) { create(:user) } + + it_behaves_like 'organization - not found response' + it_behaves_like 'organization - action disabled by `ui_for_organizations` feature flag' + end + end + end + + shared_examples 'controller action that requires authentication by any user' do + it_behaves_like 'controller action that requires authentication' + + context 'when the user is signed in' do + before do + sign_in(user) + end + + context 'with no association to an organization' do + let_it_be(:user) { create(:user) } + + it_behaves_like 'organization - successful response' + it_behaves_like 'organization - action disabled by `ui_for_organizations` feature flag' + end + end + end + shared_examples 'controller action that does not require authentication' do context 'when the user is not logged in' do it_behaves_like 'organization - successful response' @@ -78,18 +105,18 @@ RSpec.describe Organizations::OrganizationsController, feature_category: :cell d describe 'GET #users' do subject(:gitlab_request) { get users_organization_path(organization) } - it_behaves_like 'controller action that does not require authentication' + it_behaves_like 'controller action that requires authentication by an organization user' end describe 'GET #new' do subject(:gitlab_request) { get new_organization_path } - it_behaves_like 'controller action that requires authentication' + it_behaves_like 'controller action that requires authentication by any user' end describe 'GET #index' do subject(:gitlab_request) { get organizations_path } - it_behaves_like 'controller action that requires authentication' + it_behaves_like 'controller action that requires authentication by any user' end end |