Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-29 21:08:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-29 21:08:47 +0300
commit6b9d3a4e8351e662c4586b24bb152de78ae9e3bf (patch)
tree883e9db60c047c54418fc1d2b1c5517f97e0f185 /spec/support/shared_examples/services
parent23288f62da73fb0e30d8e7ce306665e8fda1b932 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/shared_examples/services')
-rw-r--r--spec/support/shared_examples/services/metrics/dashboard_shared_examples.rb35
1 files changed, 35 insertions, 0 deletions
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