diff options
author | Stan Hu <stanhu@gmail.com> | 2019-08-03 02:43:18 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-08-05 16:42:34 +0300 |
commit | fbd5a6c6cc1e8541096e0118868a2d83a0d91996 (patch) | |
tree | 452b8115fbcee0e82481ef628ae22916c27cb33d /spec | |
parent | d3a3db4218e10c65c2e87c763ad02169f3736883 (diff) |
Add spec for User#accessible_deploy_keys
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/user_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 35c335c5b5c..46b86e8393d 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -794,6 +794,24 @@ describe User do end end + describe '#accessible_deploy_keys' do + let(:user) { create(:user) } + let(:project) { create(:project) } + let!(:private_deploy_keys_project) { create(:deploy_keys_project) } + let!(:public_deploy_keys_project) { create(:deploy_keys_project) } + let!(:accessible_deploy_keys_project) { create(:deploy_keys_project, project: project) } + + before do + public_deploy_keys_project.deploy_key.update(public: true) + project.add_developer(user) + end + + it 'user can only see deploy keys accessible to right projects' do + expect(user.accessible_deploy_keys).to match_array([public_deploy_keys_project.deploy_key, + accessible_deploy_keys_project.deploy_key]) + end + end + describe '#deploy_keys' do include_context 'user keys' |