Commit 95cf4b0c authored by Etienne Baqué's avatar Etienne Baqué

Added project_id to with_release scope

parent f40d8c1c
......@@ -585,7 +585,7 @@ class IssuableFinder
elsif filter_by_any_release?
items.any_release
else
items.with_release(params[:release_tag])
items.with_release(params[:release_tag], params[:project_id])
end
end
......
......@@ -101,7 +101,7 @@ module Issuable
scope :any_milestone, -> { where('milestone_id IS NOT NULL') }
scope :with_milestone, ->(title) { left_joins_milestones.where(milestones: { title: title }) }
scope :any_release, -> { joins_milestone_releases }
scope :with_release, -> (tag) { joins_milestone_releases.where( milestones: { releases: { tag: tag } } ) }
scope :with_release, -> (tag, project_id) { joins_milestone_releases.where( milestones: { releases: { tag: tag, project_id: project_id } } ) }
scope :opened, -> { with_state(:opened) }
scope :only_opened, -> { with_state(:opened) }
scope :closed, -> { with_state(:closed) }
......
......@@ -891,36 +891,36 @@ describe Issuable do
describe '#with_release' do
it 'returns the issues tied a specfic release' do
expect(items.with_release('v1.0')).to contain_exactly(issue_1, issue_2, issue_3)
expect(items.with_release('v1.0', project.id)).to contain_exactly(issue_1, issue_2, issue_3)
end
context 'when a release has a milestone with one issue and another one with no issue' do
it 'returns that one issue' do
expect(items.with_release('v2.0')).to contain_exactly(issue_3)
expect(items.with_release('v2.0', project.id)).to contain_exactly(issue_3)
end
context 'when the milestone with no issue is added as a filter' do
it 'returns an empty list' do
expect(items.with_release('v2.0').with_milestone('m3')).to be_empty
expect(items.with_release('v2.0', project.id).with_milestone('m3')).to be_empty
end
end
context 'when the milestone with the issue is added as a filter' do
it 'returns this issue' do
expect(items.with_release('v2.0').with_milestone('m2')).to contain_exactly(issue_3)
expect(items.with_release('v2.0', project.id).with_milestone('m2')).to contain_exactly(issue_3)
end
end
end
context 'when there is no issue under a specific release' do
it 'returns no issue' do
expect(items.with_release('v4.0')).to be_empty
expect(items.with_release('v4.0', project.id)).to be_empty
end
end
context 'when a non-existent release tag is passed in' do
it 'returns no issue' do
expect(items.with_release('v999.0')).to be_empty
expect(items.with_release('v999.0', project.id)).to be_empty
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment