diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-08-15 12:33:07 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-08-15 12:33:37 +0200 |
commit | b401b3025b878d87a58cf22cee4b5be8fdfa762a (patch) | |
tree | d0a93c5913787cbfa3bd80e8ce53221cbd40a6d4 /spec/helpers | |
parent | 4a2a6d521a260981482ee8e4931ebf06cb4f5b6a (diff) | |
download | gitlab-ce-b401b3025b878d87a58cf22cee4b5be8fdfa762a.tar.gz |
Allow usage of any_projects? with an Arrayfix-any-projects-array
In some cases we pass an Array to this method which would previously
fail since Array does not respond to "limit_value".
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/3646
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 37a5e6b474e..d1efa318d14 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -432,9 +432,7 @@ describe ProjectsHelper do end describe '#any_projects?' do - before do - create(:project) - end + let!(:project) { create(:project) } it 'returns true when projects will be returned' do expect(helper.any_projects?(Project.all)).to eq(true) @@ -444,6 +442,14 @@ describe ProjectsHelper do expect(helper.any_projects?(Project.none)).to eq(false) end + it 'returns true when using a non-empty Array' do + expect(helper.any_projects?([project])).to eq(true) + end + + it 'returns false when using an empty Array' do + expect(helper.any_projects?([])).to eq(false) + end + it 'only executes a single query when a LIMIT is applied' do relation = Project.limit(1) recorder = ActiveRecord::QueryRecorder.new do |