diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-30 18:08:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-30 18:08:07 +0000 |
commit | 2c72daf2f1744f2b8c8c6674c266907e9ef55558 (patch) | |
tree | e489b6e87557d3f6d8a94f2e7d4d47e633d646b5 /spec/support | |
parent | 4e9acbfba3682c552b3de707c535e6257ef41054 (diff) | |
download | gitlab-ce-2c72daf2f1744f2b8c8c6674c266907e9ef55558.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
4 files changed, 73 insertions, 4 deletions
diff --git a/spec/support/helpers/lets_encrypt_helpers.rb b/spec/support/helpers/lets_encrypt_helpers.rb index 2857416ad95..0f378893895 100644 --- a/spec/support/helpers/lets_encrypt_helpers.rb +++ b/spec/support/helpers/lets_encrypt_helpers.rb @@ -11,7 +11,8 @@ module LetsEncryptHelpers status: 'pending', token: 'tokenvalue', file_content: 'hereisfilecontent', - request_validation: true + request_validation: true, + error: nil }.freeze def stub_lets_encrypt_settings @@ -43,16 +44,17 @@ module LetsEncryptHelpers challenge end - def acme_authorization_double + def acme_authorization_double(challenge = acme_challenge_double) authorization = instance_double('Acme::Client::Resources::Authorization') - allow(authorization).to receive(:http).and_return(acme_challenge_double) + allow(authorization).to receive(:http).and_return(challenge) + allow(authorization).to receive(:challenges).and_return([challenge]) authorization end def acme_order_double(attributes = {}) acme_order = instance_double('Acme::Client::Resources::Order') allow(acme_order).to receive_messages(ACME_ORDER_METHODS.merge(attributes)) - allow(acme_order).to receive(:authorizations).and_return([acme_authorization_double]) + allow(acme_order).to receive(:authorizations).and_return([acme_authorization_double]) unless attributes[:authorizations] allow(acme_order).to receive(:finalize) acme_order end diff --git a/spec/support/shared_examples/controllers/cache_control_shared_examples.rb b/spec/support/shared_examples/controllers/cache_control_shared_examples.rb new file mode 100644 index 00000000000..426d7f95222 --- /dev/null +++ b/spec/support/shared_examples/controllers/cache_control_shared_examples.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'project cache control headers' do + before do + project.update(visibility_level: visibility_level) + end + + context 'when project is public' do + let(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC } + + it 'returns cache_control public header to true' do + subject + + expect(response.cache_control[:public]).to be_truthy + end + end + + context 'when project is private' do + let(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } + + it 'returns cache_control public header to true' do + subject + + expect(response.cache_control[:public]).to be_falsey + end + end + + context 'when project is internal' do + let(:visibility_level) { Gitlab::VisibilityLevel::INTERNAL } + + it 'returns cache_control public header to true' do + subject + + expect(response.cache_control[:public]).to be_falsey + end + end +end diff --git a/spec/support/shared_examples/controllers/content_disposition_shared_examples.rb b/spec/support/shared_examples/controllers/content_disposition_shared_examples.rb new file mode 100644 index 00000000000..a1ece5fcc7f --- /dev/null +++ b/spec/support/shared_examples/controllers/content_disposition_shared_examples.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'content disposition headers' do + it 'sets content disposition to inline' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response.header['Content-Disposition']).to match(/inline/) + end + + context 'when inline param is false' do + let(:inline) { 'false' } + + it 'sets content disposition to attachment' do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response.header['Content-Disposition']).to match(/attachment/) + end + end +end diff --git a/spec/support/shared_examples/services/jira_import/start_import_service_shared_examples.rb b/spec/support/shared_examples/services/jira_import/start_import_service_shared_examples.rb new file mode 100644 index 00000000000..c5e56ed3539 --- /dev/null +++ b/spec/support/shared_examples/services/jira_import/start_import_service_shared_examples.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +shared_examples 'responds with error' do |message| + it 'returns error' do + expect(subject).to be_a(ServiceResponse) + expect(subject).to be_error + expect(subject.message).to eq(message) + end +end |