From 41b8d22631053e66043d05695d65f4961b91efd8 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 18 Mar 2016 12:47:36 +0100 Subject: Tweaked performance of Issue#related_branches Requesting the branch names of a repository works even when it's empty, thus there's no need to explicitly check for an empty repository. Removing this check cuts down the amount of Git operations which in turn cuts down request timings a bit. The regular expression used to compare branches was also moved out of the loop so it's created only once. --- spec/models/issue_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/models') diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 540a62eb1f8..77d046fb0eb 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -133,9 +133,9 @@ describe Issue, models: true do describe '#related_branches' do it "selects the right branches" do allow(subject.project.repository).to receive(:branch_names). - and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name]) + and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name]) - expect(subject.related_branches).to eq [subject.to_branch_name] + expect(subject.related_branches).to eq([subject.to_branch_name]) end end -- cgit v1.2.1