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/models/personal_access_token_spec.rb | |
parent | 6a52cda31da4becc3e342530a2bdf0868d8921cc (diff) | |
parent | b2ca28d24bfbb0a574fccdf1ea05d549ccd6bf66 (diff) |
Merge branch 'siemens/gitlab-ce-feature/openid-connect'
Diffstat (limited to 'spec/models/personal_access_token_spec.rb')
-rw-r--r-- | spec/models/personal_access_token_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/models/personal_access_token_spec.rb b/spec/models/personal_access_token_spec.rb index 7c9f4aad836..823623d96fa 100644 --- a/spec/models/personal_access_token_spec.rb +++ b/spec/models/personal_access_token_spec.rb @@ -34,4 +34,28 @@ describe PersonalAccessToken, models: true do expect(active_personal_access_token).to be_active end end + + context "validations" do + let(:personal_access_token) { build(:personal_access_token) } + + it "requires at least one scope" do + personal_access_token.scopes = [] + + expect(personal_access_token).not_to be_valid + expect(personal_access_token.errors[:scopes].first).to eq "can't be blank" + end + + it "allows creating a token with API scopes" do + personal_access_token.scopes = [:api, :read_user] + + expect(personal_access_token).to be_valid + end + + it "rejects creating a token with non-API scopes" do + personal_access_token.scopes = [:openid, :api] + + expect(personal_access_token).not_to be_valid + expect(personal_access_token.errors[:scopes].first).to eq "can only contain API scopes" + end + end end |