summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Newdigate <andrew@gitlab.com>2017-08-22 15:03:45 +0100
committerAndrew Newdigate <andrew@gitlab.com>2017-08-22 15:03:45 +0100
commit20b43ee264b41899102ce0eff7c37a89ab118c25 (patch)
tree6263282d7ab9a2541980c9b6a70845f1d58e15a8
parentd304fe01639e0016bd99437059f7142e22eb6388 (diff)
downloadgitlab-ce-20b43ee264b41899102ce0eff7c37a89ab118c25.tar.gz
Updated as per Jacob's comments
-rw-r--r--app/models/repository.rb7
-rw-r--r--spec/models/user_spec.rb2
2 files changed, 3 insertions, 6 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index fc15aa57f8f..3ca0a73f1e5 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -207,11 +207,8 @@ class Repository
def branch_exists?(branch_name)
if raw_repository
- @branch_exists_memo ||= {}
- return @branch_exists_memo[branch_name] if @branch_exists_memo.key?(branch_name)
- result = raw_repository.branch_exists?(branch_name)
- @branch_exists_memo[branch_name] = result
- result
+ @branch_exists_memo ||= Hash.new { |h, k| h[k] = raw_repository.branch_exists?(k) }
+ @branch_exists_memo[branch_name]
else
false
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index db9d6ff1c6c..8e04eea56a7 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1356,7 +1356,7 @@ describe User do
end
it "excludes push event if branch has been deleted" do
- allow_any_instance_of(Repository).to receive(:branch_exists?).and_return(false)
+ allow_any_instance_of(Repository).to receive(:branch_exists?).with('master').and_return(false)
expect(subject.recent_push).to eq(nil)
end