diff options
author | Sean McGivern <sean@gitlab.com> | 2017-03-07 19:16:08 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-03-07 19:16:08 +0300 |
commit | de37dcee90ac44ba794ad504e91f18b8fb4b13a3 (patch) | |
tree | 8be4fd7cbbe1f1a06dfdfa1da12616989e28d783 /spec/controllers/profiles | |
parent | 6a52cda31da4becc3e342530a2bdf0868d8921cc (diff) | |
parent | b2ca28d24bfbb0a574fccdf1ea05d549ccd6bf66 (diff) |
Merge branch 'siemens/gitlab-ce-feature/openid-connect'
Diffstat (limited to 'spec/controllers/profiles')
-rw-r--r-- | spec/controllers/profiles/personal_access_tokens_spec.rb | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/spec/controllers/profiles/personal_access_tokens_spec.rb b/spec/controllers/profiles/personal_access_tokens_spec.rb index ae8031a45f6..e1353406b32 100644 --- a/spec/controllers/profiles/personal_access_tokens_spec.rb +++ b/spec/controllers/profiles/personal_access_tokens_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' describe Profiles::PersonalAccessTokensController do let(:user) { create(:user) } + let(:token_attributes) { attributes_for(:personal_access_token) } before { sign_in(user) } @@ -10,41 +11,26 @@ describe Profiles::PersonalAccessTokensController do PersonalAccessToken.order(:created_at).last end - it "allows creation of a token" do + it "allows creation of a token with scopes" do name = FFaker::Product.brand + scopes = %w[api read_user] - post :create, personal_access_token: { name: name } + post :create, personal_access_token: token_attributes.merge(scopes: scopes) expect(created_token).not_to be_nil - expect(created_token.name).to eq(name) - expect(created_token.expires_at).to be_nil + expect(created_token.name).to eq(token_attributes[:name]) + expect(created_token.scopes).to eq(scopes) expect(PersonalAccessToken.active).to include(created_token) end it "allows creation of a token with an expiry date" do expires_at = 5.days.from_now.to_date - post :create, personal_access_token: { name: FFaker::Product.brand, expires_at: expires_at } + post :create, personal_access_token: token_attributes.merge(expires_at: expires_at) expect(created_token).not_to be_nil expect(created_token.expires_at).to eq(expires_at) end - - context "scopes" do - it "allows creation of a token with scopes" do - post :create, personal_access_token: { name: FFaker::Product.brand, scopes: %w(api read_user) } - - expect(created_token).not_to be_nil - expect(created_token.scopes).to eq(%w(api read_user)) - end - - it "allows creation of a token with no scopes" do - post :create, personal_access_token: { name: FFaker::Product.brand, scopes: [] } - - expect(created_token).not_to be_nil - expect(created_token.scopes).to eq([]) - end - end end describe '#index' do |