2014-09-02 18:07:02 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ProjectsFinder do
|
|
|
|
let(:user) { create :user }
|
|
|
|
let(:group) { create :group }
|
|
|
|
|
|
|
|
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) }
|
|
|
|
|
|
|
|
context 'non authenticated' do
|
|
|
|
subject { ProjectsFinder.new.execute(nil, group: group) }
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
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-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'authenticated' do
|
|
|
|
subject { ProjectsFinder.new.execute(user, group: group) }
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
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-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'authenticated, project member' do
|
|
|
|
before { project3.team << [user, :developer] }
|
|
|
|
|
|
|
|
subject { ProjectsFinder.new.execute(user, group: group) }
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
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-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'authenticated, group member' do
|
2015-09-11 14:41:01 +05:30
|
|
|
before { group.add_developer(user) }
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
subject { ProjectsFinder.new.execute(user, group: group) }
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
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-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|