summaryrefslogtreecommitdiff
path: root/spec/finders
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-01 03:06:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-01 03:06:26 +0000
commit56d96ad7fab4d4b95f5529d8080b3cc2873794a0 (patch)
tree7fe93fc8ff4d82d815000781ffb9c98d7259211a /spec/finders
parent8078bd185fd9fce86cb5a8d9a6b6209e0c23ae44 (diff)
downloadgitlab-ce-56d96ad7fab4d4b95f5529d8080b3cc2873794a0.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/finders')
-rw-r--r--spec/finders/releases_finder_spec.rb33
1 files changed, 24 insertions, 9 deletions
diff --git a/spec/finders/releases_finder_spec.rb b/spec/finders/releases_finder_spec.rb
index 5ffb8c74bf5..b9c67361f45 100644
--- a/spec/finders/releases_finder_spec.rb
+++ b/spec/finders/releases_finder_spec.rb
@@ -8,8 +8,7 @@ describe ReleasesFinder do
let(:repository) { project.repository }
let(:v1_0_0) { create(:release, project: project, tag: 'v1.0.0') }
let(:v1_1_0) { create(:release, project: project, tag: 'v1.1.0') }
-
- subject { described_class.new(project, user)}
+ let(:finder) { described_class.new(project, user) }
before do
v1_0_0.update_attribute(:released_at, 2.days.ago)
@@ -17,11 +16,13 @@ describe ReleasesFinder do
end
describe '#execute' do
+ subject { finder.execute(**args) }
+
+ let(:args) { {} }
+
context 'when the user is not part of the project' do
it 'returns no releases' do
- releases = subject.execute
-
- expect(releases).to be_empty
+ is_expected.to be_empty
end
end
@@ -31,11 +32,25 @@ describe ReleasesFinder do
end
it 'sorts by release date' do
- releases = subject.execute
+ is_expected.to be_present
+ expect(subject.size).to eq(2)
+ expect(subject).to eq([v1_1_0, v1_0_0])
+ end
+
+ it 'preloads associations' do
+ expect(Release).to receive(:preloaded).once.and_call_original
+
+ subject
+ end
+
+ context 'when preload is false' do
+ let(:args) { { preload: false } }
+
+ it 'does not preload associations' do
+ expect(Release).not_to receive(:preloaded)
- expect(releases).to be_present
- expect(releases.size).to eq(2)
- expect(releases).to eq([v1_1_0, v1_0_0])
+ subject
+ end
end
end
end