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:
authorDouwe Maan <douwe@gitlab.com>2015-06-15 10:42:24 +0300
committerDouwe Maan <douwe@gitlab.com>2015-06-15 10:42:24 +0300
commit6617e9bbf3cd3de65dd93272a3da2ab1298779a5 (patch)
tree29b5abcfe7d2de4772de9f2914633421c2faf9ad /spec/services
parent5890d3d5e6e2a865c9d0f2f1a2bee76ce558cd1b (diff)
parentd45112258e066da307975c17c5ca19ea9a17222b (diff)
Merge branch 'fix-post-receive-external-tracker' into 'master'
Fix post-receive errors on a push when an external issue tracker is configured ### What does this MR do? This MR improves upon !766, fixing errors upon a git push that occur only when an external issue tracker (not JIRA) is used. This MR takes into account that external issue trackers, such as JIRA, may close issues. Disabling the processing of post-receive commits when an external issue tracker is configured seems like the wrong behavior. ### Why was this MR needed? When a user adds an issue reference, the refactoring in 8f8a8ab and a6defd157 caused `project.get_issue` to be called, causing `ExternalIssue` to be returned when an external issue tracker was configured. This object does not have a `close` method, as needed in `CloseService`. Nor does it make sense to associate a `SystemNote` with this object. GitLab EE uses a [special case for JIRA](https://gitlab.com/gitlab-org/gitlab-ee/blob/master/app/services/git_push_service.rb#L87). I would recommend moving this logic into `CloseService` too. ### What are the relevant issue numbers? * Closes #1700 * Closes #1720 See merge request !804
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/git_push_service_spec.rb9
-rw-r--r--spec/services/issues/close_service_spec.rb10
2 files changed, 19 insertions, 0 deletions
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index e7558f28768..d0941fa2e07 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -233,6 +233,15 @@ describe GitPushService do
expect(Issue.find(issue.id)).to be_opened
end
+
+ it "doesn't close issues when external issue tracker is in use" do
+ allow(project).to receive(:default_issues_tracker?).and_return(false)
+
+ # The push still shouldn't create cross-reference notes.
+ expect {
+ service.execute(project, user, @oldrev, @newrev, 'refs/heads/hurf')
+ }.not_to change { Note.where(project_id: project.id, system: true).count }
+ end
end
describe "empty project" do
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb
index 0e5ae724bf7..db547ce0d50 100644
--- a/spec/services/issues/close_service_spec.rb
+++ b/spec/services/issues/close_service_spec.rb
@@ -31,5 +31,15 @@ describe Issues::CloseService do
expect(note.note).to include "Status changed to closed"
end
end
+
+ context "external issue tracker" do
+ before do
+ allow(project).to receive(:default_issues_tracker?).and_return(false)
+ @issue = Issues::CloseService.new(project, user, {}).execute(issue)
+ end
+
+ it { expect(@issue).to be_valid }
+ it { expect(@issue).to be_opened }
+ end
end
end