diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 00:07:43 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 00:07:43 +0000 |
commit | 2b3bfe8fc59ed4cdc385955cdb38cbd481b45426 (patch) | |
tree | 6b570a8d134fb2beeacf11bbcc79ff22123156ec /spec/models | |
parent | d203316c80aa27cf747aa29df9f7c2d374965b5f (diff) | |
download | gitlab-ce-2b3bfe8fc59ed4cdc385955cdb38cbd481b45426.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/commit_spec.rb | 11 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 9 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 26 |
3 files changed, 46 insertions, 0 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 930ec889206..a9d79454dd5 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -390,6 +390,17 @@ eos expect(commit.closes_issues).to include(issue) expect(commit.closes_issues).to include(other_issue) end + + it 'ignores referenced issues when auto-close is disabled' do + project.update!(autoclose_referenced_issues: false) + + allow(commit).to receive_messages( + safe_message: "Fixes ##{issue.iid}", + committer_email: committer.email + ) + + expect(commit.closes_issues).to be_empty + end end it_behaves_like 'a mentionable' do diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 0e151475128..7e28736954c 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -963,6 +963,15 @@ describe MergeRequest do expect(subject.closes_issues).to be_empty end + + it 'ignores referenced issues when auto-close is disabled' do + subject.project.update!(autoclose_referenced_issues: false) + + allow(subject.project).to receive(:default_branch) + .and_return(subject.target_branch) + + expect(subject.closes_issues).to be_empty + end end describe '#issues_mentioned_but_not_closing' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index c1c29ac9c29..e2fb7674d62 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -474,6 +474,32 @@ describe Project do end end + describe '#autoclose_referenced_issues' do + context 'when DB entry is nil' do + let(:project) { create(:project, autoclose_referenced_issues: nil) } + + it 'returns true' do + expect(project.autoclose_referenced_issues).to be_truthy + end + end + + context 'when DB entry is true' do + let(:project) { create(:project, autoclose_referenced_issues: true) } + + it 'returns true' do + expect(project.autoclose_referenced_issues).to be_truthy + end + end + + context 'when DB entry is false' do + let(:project) { create(:project, autoclose_referenced_issues: false) } + + it 'returns false' do + expect(project.autoclose_referenced_issues).to be_falsey + end + end + end + describe 'project token' do it 'sets an random token if none provided' do project = FactoryBot.create(:project, runners_token: '') |