summaryrefslogtreecommitdiff
path: root/spec/models/issue_spec.rb
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-04-15 09:50:53 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-04-15 09:50:53 +0530
commit953bafff90f33d93d1b138501643a94beda11d53 (patch)
treeb1d77a923b50cbac451a76e2f4ba4a64fe21904a /spec/models/issue_spec.rb
parentf5ce601c2b052b18398d2207c64ce8828b628521 (diff)
parenta1497ba39c69cf57f0446a705448bef2aafcd7f0 (diff)
downloadgitlab-ce-953bafff90f33d93d1b138501643a94beda11d53.tar.gz
Merge remote-tracking branch 'origin/master' into 14566-confidential-issue-branches
Diffstat (limited to 'spec/models/issue_spec.rb')
-rw-r--r--spec/models/issue_spec.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index ed982d8a9d4..da1c673653a 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -195,7 +195,7 @@ describe Issue, models: true do
before do
allow(subject.project.repository).to receive(:branch_names).
- and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name, "branch-#{subject.iid}"])
+ and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name, "#{subject.iid}-branch"])
# Without this stub, the `create(:merge_request)` above fails because it can't find
# the source branch. This seems like a reasonable compromise, in comparison with
@@ -204,17 +204,24 @@ describe Issue, models: true do
end
it "selects the right branches when there are no referenced merge requests" do
- expect(subject.related_branches(user)).to eq([subject.to_branch_name, "branch-#{subject.iid}"])
+ expect(subject.related_branches(user)).to eq([subject.to_branch_name, "#{subject.iid}-branch"])
end
it "selects the right branches when there is a referenced merge request" do
merge_request = create(:merge_request, { description: "Closes ##{subject.iid}",
source_project: subject.project,
- source_branch: "branch-#{subject.iid}" })
+ source_branch: "#{subject.iid}-branch" })
merge_request.create_cross_references!(user)
expect(subject.referenced_merge_requests).to_not be_empty
expect(subject.related_branches(user)).to eq([subject.to_branch_name])
end
+
+ it 'excludes stable branches from the related branches' do
+ allow(subject.project.repository).to receive(:branch_names).
+ and_return(["#{subject.iid}-0-stable"])
+
+ expect(subject.related_branches(user)).to eq []
+ end
end
it_behaves_like 'an editable mentionable' do
@@ -231,12 +238,12 @@ describe Issue, models: true do
describe "#to_branch_name" do
let(:issue) { create(:issue, title: 'testing-issue') }
- it "ends with the issue iid" do
- expect(issue.to_branch_name).to match /-#{issue.iid}\z/
+ it 'starts with the issue iid' do
+ expect(issue.to_branch_name).to match /\A#{issue.iid}-[A-Za-z\-]+\z/
end
it "contains the issue title if not confidential" do
- expect(issue.to_branch_name).to match /\Atesting-issue/
+ expect(issue.to_branch_name).to match /testing-issue\z/
end
it "does not contain the issue title if confidential" do