diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-04-12 09:13:15 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-04-12 09:13:15 +0300 |
commit | 5d88de092f37497d9c08878954b099c425376bda (patch) | |
tree | 6733e2a9142a73eec0c8567ae3b9f613039042dd /spec/models/issue_spec.rb | |
parent | 377b59da3029786f2265058972ad0bc6aefd8b53 (diff) |
Refactor `Issue#related_branches`
- Previously, the controller held the logic to calculate
related branches, which was:
`<branches ending with `issue.iid`> - <branches with a merge request referenced in the current issue>`
- This logic belongs in the `related_branches` method, not in the
controller. This commit makes this change.
- This means that `Issue#related_branches` now needs to take a `User`.
When we find the branches that have a merge request referenced in the
current issue, this is limited to merge requests that the current user
has access to.
- This is not directly related to #14566, but is a related refactoring.
Diffstat (limited to 'spec/models/issue_spec.rb')
-rw-r--r-- | spec/models/issue_spec.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 15052aaca28..f33b705810e 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -192,10 +192,11 @@ describe Issue, models: true do describe '#related_branches' do it "selects the right branches" do + user = build(:user) allow(subject.project.repository).to receive(:branch_names). and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name]) - expect(subject.related_branches).to eq([subject.to_branch_name]) + expect(subject.related_branches(user)).to eq([subject.to_branch_name]) end end |