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-03-23 15:09:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-23 15:09:47 +0300
commit8f9beefac3774b30e911fb00a68f4c7a5244cf27 (patch)
tree919c3a043f8c10bc3f78f3f6e029acfb6b972556 /spec/services/metrics
parente4bf776a8829e5186a0f63603c0be627b891d80e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/metrics')
-rw-r--r--spec/services/metrics/dashboard/update_dashboard_service_spec.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/services/metrics/dashboard/update_dashboard_service_spec.rb b/spec/services/metrics/dashboard/update_dashboard_service_spec.rb
index 227041344d7..6ba4b4035e4 100644
--- a/spec/services/metrics/dashboard/update_dashboard_service_spec.rb
+++ b/spec/services/metrics/dashboard/update_dashboard_service_spec.rb
@@ -92,6 +92,8 @@ describe Metrics::Dashboard::UpdateDashboardService, :use_clean_rails_memory_sto
end
context 'Files::UpdateService success' do
+ let(:merge_request) { project.merge_requests.last }
+
before do
allow(::Files::UpdateService).to receive(:new).and_return(double(execute: { status: :success }))
end
@@ -107,6 +109,31 @@ describe Metrics::Dashboard::UpdateDashboardService, :use_clean_rails_memory_sto
expect(service_call[:status]).to be :success
expect(service_call[:http_status]).to be :created
expect(service_call[:dashboard]).to match dashboard_details
+ expect(service_call[:merge_request]).to eq(Gitlab::UrlBuilder.build(merge_request))
+ end
+
+ context 'when the merge request does not succeed' do
+ let(:error_message) { 'There was an error' }
+
+ let(:merge_request) do
+ build(:merge_request, target_project: project, source_project: project, author: user)
+ end
+
+ before do
+ merge_request.errors.add(:base, error_message)
+ allow_next_instance_of(::MergeRequests::CreateService) do |mr|
+ allow(mr).to receive(:execute).and_return(merge_request)
+ end
+ end
+
+ it 'returns an appropriate message and status code', :aggregate_failures do
+ result = service_call
+
+ expect(result.keys).to contain_exactly(:message, :http_status, :status, :last_step)
+ expect(result[:status]).to eq(:error)
+ expect(result[:http_status]).to eq(:bad_request)
+ expect(result[:message]).to eq(error_message)
+ end
end
context 'with escaped characters in file name' do
@@ -125,6 +152,25 @@ describe Metrics::Dashboard::UpdateDashboardService, :use_clean_rails_memory_sto
expect(service_call[:dashboard]).to match dashboard_details
end
end
+
+ context 'when pushing to the default branch' do
+ let(:branch) { 'master' }
+
+ it 'does not create a merge request', :aggregate_failures do
+ dashboard_details = {
+ path: '.gitlab/dashboards/custom_dashboard.yml',
+ display_name: 'custom_dashboard.yml',
+ default: false,
+ system_dashboard: false
+ }
+
+ expect(::MergeRequests::CreateService).not_to receive(:new)
+ expect(service_call.keys).to contain_exactly(:dashboard, :http_status, :status)
+ expect(service_call[:status]).to be :success
+ expect(service_call[:http_status]).to be :created
+ expect(service_call[:dashboard]).to match dashboard_details
+ end
+ end
end
context 'Files::UpdateService fails' do