2014-02-25 12:21:53 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe MergeRequestsFinder do
|
2014-03-19 03:55:59 -04:00
|
|
|
let(:user) { create :user }
|
2014-02-25 12:21:53 -05:00
|
|
|
let(:user2) { create :user }
|
2014-03-19 03:55:59 -04:00
|
|
|
|
2014-02-25 12:21:53 -05:00
|
|
|
let(:project1) { create(:project) }
|
2014-04-03 04:47:56 -04:00
|
|
|
let(:project2) { create(:project, forked_from_project: project1) }
|
2014-03-19 03:55:59 -04:00
|
|
|
|
2014-04-03 04:47:56 -04:00
|
|
|
let!(:merge_request1) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project1) }
|
|
|
|
let!(:merge_request2) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project1, state: 'closed') }
|
2014-03-19 03:55:59 -04:00
|
|
|
let!(:merge_request3) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project2) }
|
2014-02-25 12:21:53 -05:00
|
|
|
|
|
|
|
before do
|
|
|
|
project1.team << [user, :master]
|
|
|
|
project2.team << [user, :developer]
|
|
|
|
project2.team << [user2, :developer]
|
|
|
|
end
|
|
|
|
|
2014-03-19 03:55:59 -04:00
|
|
|
describe "#execute" do
|
2014-02-25 12:21:53 -05:00
|
|
|
it 'should filter by scope' do
|
|
|
|
params = { scope: 'authored', state: 'opened' }
|
|
|
|
merge_requests = MergeRequestsFinder.new.execute(user, params)
|
2014-04-03 04:47:56 -04:00
|
|
|
merge_requests.size.should == 2
|
2014-02-25 12:21:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should filter by project' do
|
|
|
|
params = { project_id: project1.id, scope: 'authored', state: 'opened' }
|
|
|
|
merge_requests = MergeRequestsFinder.new.execute(user, params)
|
|
|
|
merge_requests.size.should == 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|