diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/security/group/internal_access_spec.rb | 10 | ||||
-rw-r--r-- | spec/features/security/group/private_access_spec.rb | 10 | ||||
-rw-r--r-- | spec/features/security/group/public_access_spec.rb | 12 | ||||
-rw-r--r-- | spec/finders/joined_groups_finder_spec.rb | 80 | ||||
-rw-r--r-- | spec/finders/projects_finder_spec.rb | 2 | ||||
-rw-r--r-- | spec/finders/snippets_finder_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/group_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 4 |
8 files changed, 65 insertions, 59 deletions
diff --git a/spec/features/security/group/internal_access_spec.rb b/spec/features/security/group/internal_access_spec.rb index d76eb454fe5..71b783b7276 100644 --- a/spec/features/security/group/internal_access_spec.rb +++ b/spec/features/security/group/internal_access_spec.rb @@ -15,11 +15,11 @@ describe 'Internal Group access', feature: true do let(:project_guest) { create(:user) } before do - group.add_user(owner, Gitlab::Access::OWNER) - group.add_user(master, Gitlab::Access::MASTER) - group.add_user(developer, Gitlab::Access::DEVELOPER) - group.add_user(reporter, Gitlab::Access::REPORTER) - group.add_user(guest, Gitlab::Access::GUEST) + group.add_owner(owner) + group.add_master(master) + group.add_developer(developer) + group.add_reporter(reporter) + group.add_guest(guest) project.team << [project_guest, :guest] end diff --git a/spec/features/security/group/private_access_spec.rb b/spec/features/security/group/private_access_spec.rb index 8ca4a0ac83b..cc9aee802f9 100644 --- a/spec/features/security/group/private_access_spec.rb +++ b/spec/features/security/group/private_access_spec.rb @@ -15,11 +15,11 @@ describe 'Private Group access', feature: true do let(:project_guest) { create(:user) } before do - group.add_user(owner, Gitlab::Access::OWNER) - group.add_user(master, Gitlab::Access::MASTER) - group.add_user(developer, Gitlab::Access::DEVELOPER) - group.add_user(reporter, Gitlab::Access::REPORTER) - group.add_user(guest, Gitlab::Access::GUEST) + group.add_owner(owner) + group.add_master(master) + group.add_developer(developer) + group.add_reporter(reporter) + group.add_guest(guest) project.team << [project_guest, :guest] end diff --git a/spec/features/security/group/public_access_spec.rb b/spec/features/security/group/public_access_spec.rb index f556fabb51e..db986683dbe 100644 --- a/spec/features/security/group/public_access_spec.rb +++ b/spec/features/security/group/public_access_spec.rb @@ -15,12 +15,12 @@ describe 'Public Group access', feature: true do let(:project_guest) { create(:user) } before do - group.add_user(owner, Gitlab::Access::OWNER) - group.add_user(master, Gitlab::Access::MASTER) - group.add_user(developer, Gitlab::Access::DEVELOPER) - group.add_user(reporter, Gitlab::Access::REPORTER) - group.add_user(guest, Gitlab::Access::GUEST) - + group.add_owner(owner) + group.add_master(master) + group.add_developer(developer) + group.add_reporter(reporter) + group.add_guest(guest) + project.team << [project_guest, :guest] end diff --git a/spec/finders/joined_groups_finder_spec.rb b/spec/finders/joined_groups_finder_spec.rb index 7b6fc837e5f..66a250f9dd1 100644 --- a/spec/finders/joined_groups_finder_spec.rb +++ b/spec/finders/joined_groups_finder_spec.rb @@ -5,64 +5,70 @@ describe JoinedGroupsFinder do let!(:profile_owner) { create(:user) } let!(:profile_visitor) { create(:user) } - let!(:private_group) { create(:group, visibility_level: Gitlab::VisibilityLevel::PRIVATE) } - let!(:private_group_2) { create(:group, visibility_level: Gitlab::VisibilityLevel::PRIVATE) } - let!(:internal_group) { create(:group, visibility_level: Gitlab::VisibilityLevel::INTERNAL) } - let!(:internal_group_2) { create(:group, visibility_level: Gitlab::VisibilityLevel::INTERNAL) } - let!(:public_group) { create(:group, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } - let!(:public_group_2) { create(:group, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let!(:private_group) { create(:group, :private) } + let!(:private_group_2) { create(:group, :private) } + let!(:internal_group) { create(:group, :internal) } + let!(:internal_group_2) { create(:group, :internal) } + let!(:public_group) { create(:group, :public) } + let!(:public_group_2) { create(:group, :public) } let!(:finder) { described_class.new(profile_owner) } - describe 'execute' do - context 'without a user only shows public groups from profile owner' do - before { public_group.add_user(profile_owner, Gitlab::Access::MASTER)} - subject { finder.execute } - - it { is_expected.to eq([public_group]) } + context 'without a user' do + before do + public_group.add_master(profile_owner) end - context 'only shows groups where both users are authorized to see' do - subject { finder.execute(profile_visitor) } + it 'only shows public groups from profile owner' do + expect(finder.execute).to eq([public_group]) + end + end - before do - private_group.add_user(profile_owner, Gitlab::Access::MASTER) - private_group.add_user(profile_visitor, Gitlab::Access::DEVELOPER) - internal_group.add_user(profile_owner, Gitlab::Access::MASTER) - public_group.add_user(profile_owner, Gitlab::Access::MASTER) - end + context "with a user" do + before do + private_group.add_master(profile_owner) + private_group.add_developer(profile_visitor) + internal_group.add_master(profile_owner) + public_group.add_master(profile_owner) + end - it { is_expected.to eq([public_group, internal_group, private_group]) } + it 'only shows groups where both users are authorized to see' do + expect(finder.execute(profile_visitor)).to eq([public_group, internal_group, private_group]) end - context 'shows group if profile visitor is in one of its projects' do + context 'if profile visitor is in one of its projects' do before do - public_group.add_user(profile_owner, Gitlab::Access::MASTER) - private_group.add_user(profile_owner, Gitlab::Access::MASTER) + public_group.add_master(profile_owner) + private_group.add_master(profile_owner) project = create(:project, :private, group: private_group, name: 'B', path: 'B') - project.team.add_user(profile_visitor, Gitlab::Access::DEVELOPER) + project.team.add_developer(profile_visitor) end - subject { finder.execute(profile_visitor) } - - it { is_expected.to eq([public_group, private_group]) } + it 'shows group' do + expect(finder.execute(profile_visitor)).to eq([public_group, private_group]) + end 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) + public_group.add_master(profile_owner) + internal_group.add_master(profile_owner) end - subject { finder.execute(profile_visitor) } - - it "doest not show internal groups if not member" do - expect(subject).to eq([public_group]) + context 'if not a member' do + it "does not show internal groups" do + expect(finder.execute(profile_visitor)).to eq([public_group]) + end 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]) + context "if authorized" do + before do + internal_group.add_master(profile_visitor) + end + + it "shows internal groups if authorized" do + expect(finder.execute(profile_visitor)).to eq([public_group, internal_group]) + end end end end diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb index 194c9543772..0a1cc3b3df7 100644 --- a/spec/finders/projects_finder_spec.rb +++ b/spec/finders/projects_finder_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe ProjectsFinder do describe '#execute' do let(:user) { create(:user) } - let(:group) { create(:group, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let(:group) { create(:group, :public) } let!(:private_project) do create(:project, :private, name: 'A', path: 'A') diff --git a/spec/finders/snippets_finder_spec.rb b/spec/finders/snippets_finder_spec.rb index b8940483dfb..810016c9658 100644 --- a/spec/finders/snippets_finder_spec.rb +++ b/spec/finders/snippets_finder_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe SnippetsFinder do let(:user) { create :user } let(:user1) { create :user } - let(:group) { create :group, visibility_level: Gitlab::VisibilityLevel::PUBLIC } + let(:group) { create :group, :public } let(:project1) { create(:empty_project, :public, group: group) } let(:project2) { create(:empty_project, :private, group: group) } diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 68e213f4816..7bfca1e72c3 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -67,9 +67,9 @@ describe Group, models: true do end describe 'public_and_internal_only' do - subject { described_class.public_and_internal_only.to_a.sort } + subject { described_class.public_and_internal_only.to_a } - it{ is_expected.to eq([group, internal_group].sort) } + it{ is_expected.to match_array([group, internal_group]) } end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 757324184bd..20f06f4b7e1 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -721,8 +721,8 @@ describe Project, models: true do let(:private_group) { create(:group, visibility_level: 0) } let(:internal_group) { create(:group, visibility_level: 10) } - let(:private_project) { create :project, group: private_group, visibility_level: Gitlab::VisibilityLevel::PRIVATE } - let(:internal_project) { create :project, group: internal_group, visibility_level: Gitlab::VisibilityLevel::INTERNAL } + let(:private_project) { create :project, :private, group: private_group } + let(:internal_project) { create :project, :internal, group: internal_group } context 'when group is private project can not be internal' do it { expect(private_project.visibility_level_allowed?(Gitlab::VisibilityLevel::INTERNAL)).to be_falsey } |