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/features/projects/settings/access_tokens_spec.rb')
-rw-r--r--spec/features/projects/settings/access_tokens_spec.rb77
1 files changed, 57 insertions, 20 deletions
diff --git a/spec/features/projects/settings/access_tokens_spec.rb b/spec/features/projects/settings/access_tokens_spec.rb
index 122bf267021..88f9a50b093 100644
--- a/spec/features/projects/settings/access_tokens_spec.rb
+++ b/spec/features/projects/settings/access_tokens_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe 'Project > Settings > Access Tokens', :js do
+ include Spec::Support::Helpers::ModalHelpers
+
let_it_be(:user) { create(:user) }
let_it_be(:bot_user) { create(:user, :project_bot) }
let_it_be(:group) { create(:group) }
@@ -14,7 +16,6 @@ RSpec.describe 'Project > Settings > Access Tokens', :js do
end
before do
- stub_feature_flags(bootstrap_confirmation_modals: false)
sign_in(user)
end
@@ -24,6 +25,11 @@ RSpec.describe 'Project > Settings > Access Tokens', :js do
create(:personal_access_token, user: bot_user)
end
+ def role_dropdown_options
+ role_dropdown = page.find_by_id('resource_access_token_access_level')
+ role_dropdown.all('option').map(&:text)
+ end
+
context 'when user is not a project maintainer' do
before do
project.add_developer(user)
@@ -33,37 +39,68 @@ RSpec.describe 'Project > Settings > Access Tokens', :js do
end
describe 'token creation' do
- it_behaves_like 'resource access tokens creation', 'project'
+ context 'when user is a project owner' do
+ before do
+ project.add_owner(user)
+ end
- context 'when token creation is not allowed' do
- it_behaves_like 'resource access tokens creation disallowed', 'Project access token creation is disabled in this group. You can still use and manage existing tokens.'
+ it_behaves_like 'resource access tokens creation', 'project'
- context 'with a project in a personal namespace' do
- let(:personal_project) { create(:project) }
+ it 'shows Owner option' do
+ visit resource_settings_access_tokens_path
- before do
- personal_project.add_maintainer(user)
- end
+ expect(role_dropdown_options).to include('Owner')
+ end
+ end
- it 'shows access token creation form and text' do
- visit project_settings_access_tokens_path(personal_project)
+ context 'when user is a project maintainer' do
+ before_all do
+ project.add_maintainer(user)
+ end
+
+ it_behaves_like 'resource access tokens creation', 'project'
+
+ it 'does not show Owner option for a maintainer' do
+ visit resource_settings_access_tokens_path
- expect(page).to have_selector('#new_resource_access_token')
- expect(page).to have_text('Generate project access tokens scoped to this project for your applications that need access to the GitLab API.')
- end
+ expect(role_dropdown_options).not_to include('Owner')
end
end
end
- describe 'active tokens' do
- let!(:resource_access_token) { create_resource_access_token }
+ context 'when token creation is not allowed' do
+ it_behaves_like 'resource access tokens creation disallowed', 'Project access token creation is disabled in this group. You can still use and manage existing tokens.'
- it_behaves_like 'active resource access tokens'
+ context 'with a project in a personal namespace' do
+ let(:personal_project) { create(:project) }
+
+ before do
+ personal_project.add_maintainer(user)
+ end
+
+ it 'shows access token creation form and text' do
+ visit project_settings_access_tokens_path(personal_project)
+
+ expect(page).to have_selector('#js-new-access-token-form')
+ end
+ end
end
- describe 'inactive tokens' do
- let!(:resource_access_token) { create_resource_access_token }
+ describe 'viewing tokens' do
+ before_all do
+ project.add_maintainer(user)
+ end
+
+ describe 'active tokens' do
+ let!(:resource_access_token) { create_resource_access_token }
+
+ it_behaves_like 'active resource access tokens'
+ end
- it_behaves_like 'inactive resource access tokens', 'This project has no active access tokens.'
+ describe 'inactive tokens' do
+ let!(:resource_access_token) { create_resource_access_token }
+
+ it_behaves_like 'inactive resource access tokens', 'This project has no active access tokens.'
+ end
end
end