Commit 0833f49b authored by Andrew Smith's avatar Andrew Smith

Add tests for prefilling Personal Access Token name and scopes

parent cab35ea0
...@@ -64,5 +64,17 @@ RSpec.describe Profiles::PersonalAccessTokensController do ...@@ -64,5 +64,17 @@ RSpec.describe Profiles::PersonalAccessTokensController do
it "retrieves newly created personal access token value" do it "retrieves newly created personal access token value" do
expect(assigns(:new_personal_access_token)).to eql(token_value) expect(assigns(:new_personal_access_token)).to eql(token_value)
end end
it "sets PAT name and scopes" do
name = 'My PAT'
scopes = 'api,read_user'
get :index, params: { name: name, scopes: scopes }
expect(assigns(:personal_access_token)).to have_attributes(
name: eq(name),
scopes: contain_exactly(:api, :read_user)
)
end
end end
end end
...@@ -149,4 +149,15 @@ RSpec.describe 'Profile > Personal Access Tokens', :js do ...@@ -149,4 +149,15 @@ RSpec.describe 'Profile > Personal Access Tokens', :js do
expect(page).to have_pushed_frontend_feature_flags(personalAccessTokensScopedToProjects: true) expect(page).to have_pushed_frontend_feature_flags(personalAccessTokensScopedToProjects: true)
end end
it "prefills token details" do
name = 'My PAT'
scopes = 'api,read_user'
visit profile_personal_access_tokens_path({ name: name, scopes: scopes })
expect(page).to have_field("Token name", with: name)
expect(find("#personal_access_token_scopes_api")).to be_checked
expect(find("#personal_access_token_scopes_read_user")).to be_checked
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment