diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 15:09:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 15:09:17 +0300 |
commit | cd52759ee33051b8ad7b88b02ba7954e4fad7018 (patch) | |
tree | f1096c68e457aef7f5201acd16e4a751ff538026 /spec/models | |
parent | 18f7828977b74bf6e5153594a098ef90e773b3b7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/build_spec.rb | 23 | ||||
-rw-r--r-- | spec/models/key_spec.rb | 49 |
2 files changed, 62 insertions, 10 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 757c158e16a..6c77b16f908 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -2542,6 +2542,8 @@ describe Ci::Build do <<~ROUTEMAP - source: 'bar/branch-test.txt' public: '/bar/branches' + - source: 'with space/README.md' + public: '/README' ROUTEMAP end @@ -2556,10 +2558,27 @@ describe Ci::Build do let(:environment) { create(:environment, project: merge_request.project, name: "foo-#{project.default_branch}") } let(:build) { create(:ci_build, pipeline: pipeline, environment: environment.name) } + let(:full_urls) do + [ + File.join(environment.external_url, '/bar/branches'), + File.join(environment.external_url, '/README') + ] + end + it 'populates CI_MERGE_REQUEST_CHANGED_PAGES_* variables' do expect(subject).to include( - { key: 'CI_MERGE_REQUEST_CHANGED_PAGE_PATHS', value: '/bar/branches', public: true, masked: false }, - { key: 'CI_MERGE_REQUEST_CHANGED_PAGE_URLS', value: File.join(environment.external_url, '/bar/branches'), public: true, masked: false } + { + key: 'CI_MERGE_REQUEST_CHANGED_PAGE_PATHS', + value: '/bar/branches,/README', + public: true, + masked: false + }, + { + key: 'CI_MERGE_REQUEST_CHANGED_PAGE_URLS', + value: full_urls.join(','), + public: true, + masked: false + } ) end diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index c9b41c9d82e..8cdedbcdedf 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -181,16 +181,49 @@ describe Key, :mailer do end context 'callbacks' do - it 'adds new key to authorized_file' do - key = build(:personal_key, id: 7) - expect(GitlabShellWorker).to receive(:perform_async).with(:add_key, key.shell_id, key.key) - key.save! + let(:key) { build(:personal_key) } + + context 'authorized keys file is enabled' do + before do + stub_application_setting(authorized_keys_enabled: true) + end + + it 'adds new key to authorized_file' do + allow(AuthorizedKeysWorker).to receive(:perform_async) + + key.save! + + # Check after the fact so we have access to Key#id + expect(AuthorizedKeysWorker).to have_received(:perform_async).with(:add_key, key.shell_id, key.key) + end + + it 'removes key from authorized_file' do + key.save! + + expect(AuthorizedKeysWorker).to receive(:perform_async).with(:remove_key, key.shell_id) + + key.destroy + end end - it 'removes key from authorized_file' do - key = create(:personal_key) - expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, key.shell_id) - key.destroy + context 'authorized_keys file is disabled' do + before do + stub_application_setting(authorized_keys_enabled: false) + end + + it 'does not add the key on creation' do + expect(AuthorizedKeysWorker).not_to receive(:perform_async) + + key.save! + end + + it 'does not remove the key on destruction' do + key.save! + + expect(AuthorizedKeysWorker).not_to receive(:perform_async) + + key.destroy + end end end |