diff options
author | Alessio Caiazza <acaiazza@gitlab.com> | 2018-12-13 14:08:53 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-12-31 06:05:56 +0300 |
commit | 1ea2d9faa518f6b769b05a71a1f93b4ea0226bc1 (patch) | |
tree | 291cd8d7a6c6113e75219dc873e24fb414df119d /spec/finders/releases_finder_spec.rb | |
parent | c07bf1abf2a5c3751e575ee5926e9a052fa0b341 (diff) |
Add releases API
This commit introduces Releases API under /api/v4/projects/:id/releases
* We are introducing release policies at project level.
* We are deprecating releases changes from tags, both api and web
interface.
* Tags::CreateService no longer create a release
This feature is controlled by :releases_page feature flag
Diffstat (limited to 'spec/finders/releases_finder_spec.rb')
-rw-r--r-- | spec/finders/releases_finder_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/finders/releases_finder_spec.rb b/spec/finders/releases_finder_spec.rb new file mode 100644 index 00000000000..aa7163021cb --- /dev/null +++ b/spec/finders/releases_finder_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe ReleasesFinder do + let(:user) { create(:user) } + let(:project) { create(:project, :repository) } + 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)} + + before do + now = Time.now + v1_0_0.update_attribute(:created_at, now - 2.days) + v1_1_0.update_attribute(:created_at, now - 1.day) + end + + describe '#execute' do + context 'when the user is not part of the project' do + it 'returns no releases' do + releases = subject.execute + + expect(releases).to be_empty + end + end + + context 'when the user is a project developer' do + before do + project.add_developer(user) + end + + it 'sorts by creation date' do + releases = subject.execute + + expect(releases).to be_present + expect(releases.size).to eq(2) + expect(releases).to eq([v1_1_0, v1_0_0]) + end + end + end +end |