2014-02-25 07:36:36 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-02-25 12:21:53 -05:00
|
|
|
describe ProjectsFinder do
|
2014-02-25 07:36:36 -05:00
|
|
|
let(:user) { create :user }
|
|
|
|
let(:group) { create :group }
|
|
|
|
|
2014-03-19 05:15:24 -04:00
|
|
|
let(:project1) { create(:empty_project, :public, group: group) }
|
|
|
|
let(:project2) { create(:empty_project, :internal, group: group) }
|
|
|
|
let(:project3) { create(:empty_project, :private, group: group) }
|
|
|
|
let(:project4) { create(:empty_project, :private, group: group) }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
|
|
|
context 'non authenticated' do
|
2014-02-25 12:21:53 -05:00
|
|
|
subject { ProjectsFinder.new.execute(nil, group: group) }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to include(project1) }
|
|
|
|
it { is_expected.not_to include(project2) }
|
|
|
|
it { is_expected.not_to include(project3) }
|
|
|
|
it { is_expected.not_to include(project4) }
|
2014-02-25 07:36:36 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'authenticated' do
|
2014-02-25 12:21:53 -05:00
|
|
|
subject { ProjectsFinder.new.execute(user, group: group) }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to include(project1) }
|
|
|
|
it { is_expected.to include(project2) }
|
|
|
|
it { is_expected.not_to include(project3) }
|
|
|
|
it { is_expected.not_to include(project4) }
|
2014-02-25 07:36:36 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'authenticated, project member' do
|
|
|
|
before { project3.team << [user, :developer] }
|
|
|
|
|
2014-02-25 12:21:53 -05:00
|
|
|
subject { ProjectsFinder.new.execute(user, group: group) }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to include(project1) }
|
|
|
|
it { is_expected.to include(project2) }
|
|
|
|
it { is_expected.to include(project3) }
|
|
|
|
it { is_expected.not_to include(project4) }
|
2014-02-25 07:36:36 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'authenticated, group member' do
|
|
|
|
before { group.add_user(user, Gitlab::Access::DEVELOPER) }
|
|
|
|
|
2014-02-25 12:21:53 -05:00
|
|
|
subject { ProjectsFinder.new.execute(user, group: group) }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to include(project1) }
|
|
|
|
it { is_expected.to include(project2) }
|
|
|
|
it { is_expected.to include(project3) }
|
|
|
|
it { is_expected.to include(project4) }
|
2014-02-25 07:36:36 -05:00
|
|
|
end
|
|
|
|
end
|