diff options
Diffstat (limited to 'spec/support')
5 files changed, 38 insertions, 6 deletions
diff --git a/spec/support/helpers/javascript_fixtures_helpers.rb b/spec/support/helpers/javascript_fixtures_helpers.rb index fd5ad9451f7..4f11f8c6b24 100644 --- a/spec/support/helpers/javascript_fixtures_helpers.rb +++ b/spec/support/helpers/javascript_fixtures_helpers.rb @@ -62,7 +62,7 @@ module JavaScriptFixturesHelpers fixture = response.body fixture.force_encoding("utf-8") - response_mime_type = Mime::Type.lookup(response.content_type) + response_mime_type = Mime::Type.lookup(response.media_type) if response_mime_type.html? doc = Nokogiri::HTML::DocumentFragment.parse(fixture) diff --git a/spec/support/helpers/migrations_helpers.rb b/spec/support/helpers/migrations_helpers.rb index 68f71494771..5eb70f534d8 100644 --- a/spec/support/helpers/migrations_helpers.rb +++ b/spec/support/helpers/migrations_helpers.rb @@ -21,7 +21,7 @@ module MigrationsHelpers end def migration_context - ActiveRecord::MigrationContext.new(migrations_paths) + ActiveRecord::MigrationContext.new(migrations_paths, ActiveRecord::SchemaMigration) end def migrations diff --git a/spec/support/helpers/stub_configuration.rb b/spec/support/helpers/stub_configuration.rb index 0dc6e851190..6a832ca97d1 100644 --- a/spec/support/helpers/stub_configuration.rb +++ b/spec/support/helpers/stub_configuration.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require 'active_support/core_ext/hash/transform_values' require 'active_support/hash_with_indifferent_access' require 'active_support/dependencies' diff --git a/spec/support/shared_examples/controllers/repository_lfs_file_load_shared_examples.rb b/spec/support/shared_examples/controllers/repository_lfs_file_load_shared_examples.rb index b8967bc8df3..fadf428125a 100644 --- a/spec/support/shared_examples/controllers/repository_lfs_file_load_shared_examples.rb +++ b/spec/support/shared_examples/controllers/repository_lfs_file_load_shared_examples.rb @@ -41,13 +41,11 @@ RSpec.shared_examples 'a controller that can serve LFS files' do |options = {}| it 'serves the file' do lfs_uploader = LfsObjectUploader.new(lfs_object) - # Notice the filename= is omitted from the disposition; this is because - # Rails 5 will append this header in send_file expect(controller).to receive(:send_file) .with( File.join(lfs_uploader.root, lfs_uploader.store_dir, lfs_uploader.filename), filename: filename, - disposition: %Q(attachment; filename*=UTF-8''#{filename})) + disposition: 'attachment') subject diff --git a/spec/support/shared_examples/services/metrics/dashboard_shared_examples.rb b/spec/support/shared_examples/services/metrics/dashboard_shared_examples.rb index 66a6c073445..1f229d6b783 100644 --- a/spec/support/shared_examples/services/metrics/dashboard_shared_examples.rb +++ b/spec/support/shared_examples/services/metrics/dashboard_shared_examples.rb @@ -50,3 +50,38 @@ RSpec.shared_examples 'raises error for users with insufficient permissions' do it_behaves_like 'misconfigured dashboard service response', :unauthorized end end + +RSpec.shared_examples 'valid dashboard cloning process' do |dashboard_template, sequence| + context "dashboard template: #{dashboard_template}" do + let(:dashboard) { dashboard_template } + let(:dashboard_attrs) do + { + commit_message: commit_message, + branch_name: branch, + start_branch: project.default_branch, + encoding: 'text', + file_path: ".gitlab/dashboards/#{file_name}", + file_content: file_content_hash.to_yaml + } + end + + it 'delegates commit creation to Files::CreateService', :aggregate_failures do + service_instance = instance_double(::Files::CreateService) + expect(::Files::CreateService).to receive(:new).with(project, user, dashboard_attrs).and_return(service_instance) + expect(service_instance).to receive(:execute).and_return(status: :success) + + service_call + end + + context 'user has defined custom metrics' do + it 'uses external service to includes them into new file content', :aggregate_failures do + service_instance = double(::Gitlab::Metrics::Dashboard::Processor) + expect(::Gitlab::Metrics::Dashboard::Processor).to receive(:new).with(project, file_content_hash, sequence, {}).and_return(service_instance) + expect(service_instance).to receive(:process).and_return(file_content_hash) + expect(::Files::CreateService).to receive(:new).with(project, user, dashboard_attrs).and_return(double(execute: { status: :success })) + + service_call + end + end + end +end |