summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-24 16:16:45 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-24 16:16:45 +0000
commit8022c833207eba848817d54c98ee29d21b69fe8d (patch)
treeeee58397325abbded26d66f81322807eea4d5615 /spec
parent32a578cb598d6568fbd8289e331cf166f94a4e87 (diff)
downloadgitlab-ce-8022c833207eba848817d54c98ee29d21b69fe8d.tar.gz
Add latest changes from gitlab-org/gitlab@12-7-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/error_tracking_controller_spec.rb2
-rw-r--r--spec/fixtures/api/schemas/error_tracking/update_issue.json8
-rw-r--r--spec/services/error_tracking/issue_details_service_spec.rb19
-rw-r--r--spec/services/error_tracking/issue_latest_event_service_spec.rb19
-rw-r--r--spec/services/error_tracking/issue_update_service_spec.rb106
-rw-r--r--spec/services/error_tracking/list_issues_service_spec.rb18
-rw-r--r--spec/support/shared_contexts/sentry_error_tracking_shared_context.rb22
7 files changed, 54 insertions, 140 deletions
diff --git a/spec/controllers/projects/error_tracking_controller_spec.rb b/spec/controllers/projects/error_tracking_controller_spec.rb
index 22826938de2..588c4b05528 100644
--- a/spec/controllers/projects/error_tracking_controller_spec.rb
+++ b/spec/controllers/projects/error_tracking_controller_spec.rb
@@ -301,7 +301,7 @@ describe Projects::ErrorTrackingController do
context 'update result is successful' do
before do
expect(issue_update_service).to receive(:execute)
- .and_return(status: :success, updated: true, closed_issue_iid: 1234)
+ .and_return(status: :success, updated: true)
update_issue
end
diff --git a/spec/fixtures/api/schemas/error_tracking/update_issue.json b/spec/fixtures/api/schemas/error_tracking/update_issue.json
index 75f2c1152d9..72514ce647d 100644
--- a/spec/fixtures/api/schemas/error_tracking/update_issue.json
+++ b/spec/fixtures/api/schemas/error_tracking/update_issue.json
@@ -6,15 +6,9 @@
"properties" : {
"result": {
"type": "object",
- "required" : [
- "status",
- "updated",
- "closed_issue_iid"
- ],
"properties": {
"status": { "type": "string" },
- "updated": { "type": "boolean" },
- "closed_issue_iid": { "type": ["integer", "null"] }
+ "updated": { "type": "boolean" }
}
}
},
diff --git a/spec/services/error_tracking/issue_details_service_spec.rb b/spec/services/error_tracking/issue_details_service_spec.rb
index 26bb3b44126..4d5505bb5a9 100644
--- a/spec/services/error_tracking/issue_details_service_spec.rb
+++ b/spec/services/error_tracking/issue_details_service_spec.rb
@@ -3,7 +3,24 @@
require 'spec_helper'
describe ErrorTracking::IssueDetailsService do
- include_context 'sentry error tracking context'
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project) }
+
+ let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
+ let(:token) { 'test-token' }
+ let(:result) { subject.execute }
+
+ let(:error_tracking_setting) do
+ create(:project_error_tracking_setting, api_url: sentry_url, token: token, project: project)
+ end
+
+ subject { described_class.new(project, user) }
+
+ before do
+ expect(project).to receive(:error_tracking_setting).at_least(:once).and_return(error_tracking_setting)
+
+ project.add_reporter(user)
+ end
describe '#execute' do
context 'with authorized user' do
diff --git a/spec/services/error_tracking/issue_latest_event_service_spec.rb b/spec/services/error_tracking/issue_latest_event_service_spec.rb
index 7f53eabd717..cda15042814 100644
--- a/spec/services/error_tracking/issue_latest_event_service_spec.rb
+++ b/spec/services/error_tracking/issue_latest_event_service_spec.rb
@@ -3,7 +3,24 @@
require 'spec_helper'
describe ErrorTracking::IssueLatestEventService do
- include_context 'sentry error tracking context'
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project) }
+
+ let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
+ let(:token) { 'test-token' }
+ let(:result) { subject.execute }
+
+ let(:error_tracking_setting) do
+ create(:project_error_tracking_setting, api_url: sentry_url, token: token, project: project)
+ end
+
+ subject { described_class.new(project, user) }
+
+ before do
+ expect(project).to receive(:error_tracking_setting).at_least(:once).and_return(error_tracking_setting)
+
+ project.add_reporter(user)
+ end
describe '#execute' do
context 'with authorized user' do
diff --git a/spec/services/error_tracking/issue_update_service_spec.rb b/spec/services/error_tracking/issue_update_service_spec.rb
deleted file mode 100644
index ad1dafe6ccc..00000000000
--- a/spec/services/error_tracking/issue_update_service_spec.rb
+++ /dev/null
@@ -1,106 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe ErrorTracking::IssueUpdateService do
- include_context 'sentry error tracking context'
-
- let(:arguments) { { issue_id: 1234, status: 'resolved' } }
-
- subject { described_class.new(project, user, arguments) }
-
- shared_examples 'does not perform close issue flow' do
- it 'does not call the close issue service' do
- expect(issue_close_service)
- .not_to receive(:execute)
- end
-
- it 'does not create system note' do
- expect(SystemNoteService).not_to receive(:close_after_error_tracking_resolve)
- end
- end
-
- describe '#execute' do
- context 'with authorized user' do
- context 'when update_issue returns success' do
- let(:update_issue_response) { { updated: true } }
-
- before do
- expect(error_tracking_setting)
- .to receive(:update_issue).and_return(update_issue_response)
- end
-
- it 'returns the response' do
- expect(result).to eq(update_issue_response.merge(status: :success, closed_issue_iid: nil))
- end
-
- it 'updates any related issue' do
- expect(subject).to receive(:update_related_issue)
-
- result
- end
-
- context 'related issue and resolving' do
- let(:issue) { create(:issue, project: project) }
- let(:sentry_issue) { create(:sentry_issue, issue: issue) }
- let(:arguments) { { issue_id: sentry_issue.sentry_issue_identifier, status: 'resolved' } }
-
- let(:issue_close_service) { spy(:issue_close_service) }
-
- before do
- allow_any_instance_of(SentryIssueFinder)
- .to receive(:execute)
- .and_return(sentry_issue)
-
- allow(Issues::CloseService)
- .to receive(:new)
- .and_return(issue_close_service)
- end
-
- after do
- result
- end
-
- it 'closes the issue' do
- expect(issue_close_service)
- .to receive(:execute)
- .with(issue, system_note: false)
- .and_return(issue)
- end
-
- it 'creates a system note' do
- expect(SystemNoteService).to receive(:close_after_error_tracking_resolve)
- end
-
- it 'returns a response with closed issue' do
- closed_issue = create(:issue, :closed, project: project)
-
- expect(issue_close_service)
- .to receive(:execute)
- .with(issue, system_note: false)
- .and_return(closed_issue)
-
- expect(result).to eq(status: :success, updated: true, closed_issue_iid: closed_issue.iid)
- end
-
- context 'issue is already closed' do
- let(:issue) { create(:issue, :closed, project: project) }
-
- include_examples 'does not perform close issue flow'
- end
-
- context 'status is not resolving' do
- let(:arguments) { { issue_id: sentry_issue.sentry_issue_identifier, status: 'ignored' } }
-
- include_examples 'does not perform close issue flow'
- end
- end
- end
-
- include_examples 'error tracking service sentry error handling', :update_issue
- end
-
- include_examples 'error tracking service unauthorized user'
- include_examples 'error tracking service disabled'
- end
-end
diff --git a/spec/services/error_tracking/list_issues_service_spec.rb b/spec/services/error_tracking/list_issues_service_spec.rb
index 1e39146fd18..ecb6bcc541b 100644
--- a/spec/services/error_tracking/list_issues_service_spec.rb
+++ b/spec/services/error_tracking/list_issues_service_spec.rb
@@ -3,8 +3,8 @@
require 'spec_helper'
describe ErrorTracking::ListIssuesService do
- include_context 'sentry error tracking context'
-
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project) }
let(:params) { { search_term: 'something', sort: 'last_seen', cursor: 'some-cursor' } }
let(:list_sentry_issues_args) do
{
@@ -16,8 +16,22 @@ describe ErrorTracking::ListIssuesService do
}
end
+ let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
+ let(:token) { 'test-token' }
+ let(:result) { subject.execute }
+
+ let(:error_tracking_setting) do
+ create(:project_error_tracking_setting, api_url: sentry_url, token: token, project: project)
+ end
+
subject { described_class.new(project, user, params) }
+ before do
+ expect(project).to receive(:error_tracking_setting).at_least(:once).and_return(error_tracking_setting)
+
+ project.add_reporter(user)
+ end
+
describe '#execute' do
context 'with authorized user' do
context 'when list_sentry_issues returns issues' do
diff --git a/spec/support/shared_contexts/sentry_error_tracking_shared_context.rb b/spec/support/shared_contexts/sentry_error_tracking_shared_context.rb
deleted file mode 100644
index ba729f21e58..00000000000
--- a/spec/support/shared_contexts/sentry_error_tracking_shared_context.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-shared_context 'sentry error tracking context' do
- let_it_be(:user) { create(:user) }
- let_it_be(:project) { create(:project) }
-
- let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
- let(:token) { 'test-token' }
- let(:result) { subject.execute }
-
- subject { described_class.new(project, user) }
-
- let(:error_tracking_setting) do
- create(:project_error_tracking_setting, api_url: sentry_url, token: token, project: project)
- end
-
- before do
- expect(project).to receive(:error_tracking_setting).at_least(:once).and_return(error_tracking_setting)
-
- project.add_reporter(user)
- end
-end