diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-03-18 01:42:46 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-03-18 01:42:46 +0300 |
commit | 0a7f7161198feaa9a4cae7c16669a0e6187aed33 (patch) | |
tree | 445dcbd9f473be2af293a299b634525725a70666 /spec/finders | |
parent | a18ac62756573a2da2c42ca50b6f30033be6fa63 (diff) |
Code fixes
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/groups_finder_spec.rb | 9 | ||||
-rw-r--r-- | spec/finders/joined_groups_finder_spec.rb | 19 | ||||
-rw-r--r-- | spec/finders/personal_projects_finder_spec.rb | 15 |
3 files changed, 41 insertions, 2 deletions
diff --git a/spec/finders/groups_finder_spec.rb b/spec/finders/groups_finder_spec.rb index ed24954af7a..d0fd7af8cc3 100644 --- a/spec/finders/groups_finder_spec.rb +++ b/spec/finders/groups_finder_spec.rb @@ -18,7 +18,14 @@ describe GroupsFinder do describe 'with a user' do subject { finder.execute(user) } - it { is_expected.to eq([public_group, internal_group]) } + context 'normal user' do + it { is_expected.to eq([public_group, internal_group]) } + end + + context 'external user' do + before { user.update_attribute(external: true) } + it { is_expected.to eq([public_group]) } + end end end end diff --git a/spec/finders/joined_groups_finder_spec.rb b/spec/finders/joined_groups_finder_spec.rb index e2f6c593638..7b6fc837e5f 100644 --- a/spec/finders/joined_groups_finder_spec.rb +++ b/spec/finders/joined_groups_finder_spec.rb @@ -46,6 +46,25 @@ describe JoinedGroupsFinder do it { is_expected.to eq([public_group, private_group]) } end + + context 'external users' do + before do + profile_visitor.update_attributes(external: true) + public_group.add_user(profile_owner, Gitlab::Access::MASTER) + internal_group.add_user(profile_owner, Gitlab::Access::MASTER) + end + + subject { finder.execute(profile_visitor) } + + it "doest not show internal groups if not member" do + expect(subject).to eq([public_group]) + end + + it "shows internal groups if authorized" do + internal_group.add_user(profile_visitor, Gitlab::Access::MASTER) + expect(subject).to eq([public_group, internal_group]) + end + end end end end diff --git a/spec/finders/personal_projects_finder_spec.rb b/spec/finders/personal_projects_finder_spec.rb index 38817add456..8758f61903c 100644 --- a/spec/finders/personal_projects_finder_spec.rb +++ b/spec/finders/personal_projects_finder_spec.rb @@ -16,6 +16,11 @@ describe PersonalProjectsFinder do path: 'B') end + let!(:internal_project) do + create(:project, :internal, namespace: source_user.namespace, name: 'c', + path: 'C') + end + before do private_project.team << [current_user, Gitlab::Access::DEVELOPER] end @@ -29,6 +34,14 @@ describe PersonalProjectsFinder do describe 'with a current user' do subject { finder.execute(current_user) } - it { is_expected.to eq([private_project, public_project]) } + context 'normal user' do + it { is_expected.to eq([internal_project, private_project, public_project]) } + end + + context 'external' do + before { current_user.update_attributes(external: true) } + + it { is_expected.to eq([private_project, public_project]) } + end end end |