Bring shared project feature tests from EE
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
9a95b15552
commit
55ceda1204
6 changed files with 125 additions and 1 deletions
|
@ -21,6 +21,11 @@ Feature: Admin Groups
|
|||
When I select user "John Doe" from user list as "Reporter"
|
||||
Then I should see "John Doe" in team list in every project as "Reporter"
|
||||
|
||||
Scenario: Shared projects
|
||||
Given group has shared projects
|
||||
When I visit group page
|
||||
Then I should see project shared with group
|
||||
|
||||
@javascript
|
||||
Scenario: Remove user from group
|
||||
Given we have user "John Doe" in group
|
||||
|
|
|
@ -39,3 +39,8 @@ Feature: Project Team Management
|
|||
And I click link "Import team from another project"
|
||||
And I submit "Website" project for import team
|
||||
Then I should see "Mike" in team list as "Reporter"
|
||||
|
||||
Scenario: See all members of projects shared group
|
||||
Given I share project with group "OpenSource"
|
||||
And I visit project "Shop" team page
|
||||
Then I should see "Opensource" group user listing
|
||||
|
|
|
@ -73,6 +73,21 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps
|
|||
end
|
||||
end
|
||||
|
||||
step 'group has shared projects' do
|
||||
share_link = shared_project.project_group_links.new(group_access: Gitlab::Access::MASTER)
|
||||
share_link.group_id = current_group.id
|
||||
share_link.save!
|
||||
end
|
||||
|
||||
step 'I visit group page' do
|
||||
visit admin_group_path(current_group)
|
||||
end
|
||||
|
||||
step 'I should see project shared with group' do
|
||||
expect(page).to have_content(shared_project.name_with_namespace)
|
||||
expect(page).to have_content "Projects shared with"
|
||||
end
|
||||
|
||||
step 'we have user "John Doe" in group' do
|
||||
current_group.add_reporter(user_john)
|
||||
end
|
||||
|
@ -123,6 +138,10 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps
|
|||
@group ||= Group.first
|
||||
end
|
||||
|
||||
def shared_project
|
||||
@shared_project ||= create(:empty_project)
|
||||
end
|
||||
|
||||
def user_john
|
||||
@user_john ||= User.find_by(name: "John Doe")
|
||||
end
|
||||
|
|
|
@ -123,4 +123,23 @@ class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps
|
|||
click_link('Remove user from team')
|
||||
end
|
||||
end
|
||||
|
||||
step 'I share project with group "OpenSource"' do
|
||||
project = Project.find_by(name: 'Shop')
|
||||
os_group = create(:group, name: 'OpenSource')
|
||||
create(:project, group: os_group)
|
||||
@os_user1 = create(:user)
|
||||
@os_user2 = create(:user)
|
||||
os_group.add_owner(@os_user1)
|
||||
os_group.add_user(@os_user2, Gitlab::Access::DEVELOPER)
|
||||
share_link = project.project_group_links.new(group_access: Gitlab::Access::MASTER)
|
||||
share_link.group_id = os_group.id
|
||||
share_link.save!
|
||||
end
|
||||
|
||||
step 'I should see "Opensource" group user listing' do
|
||||
expect(page).to have_content("Shared with OpenSource group, members with Master role (2)")
|
||||
expect(page).to have_content(@os_user1.name)
|
||||
expect(page).to have_content(@os_user2.name)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,10 @@ describe ProjectsFinder do
|
|||
create(:project, :public, group: group, name: 'C', path: 'C')
|
||||
end
|
||||
|
||||
let!(:shared_project) do
|
||||
create(:project, :private, name: 'D', path: 'D')
|
||||
end
|
||||
|
||||
let(:finder) { described_class.new }
|
||||
|
||||
describe 'without a group' do
|
||||
|
@ -56,8 +60,36 @@ describe ProjectsFinder do
|
|||
describe 'with a user' do
|
||||
subject { finder.execute(user, group: group) }
|
||||
|
||||
describe 'without shared projects' do
|
||||
it { is_expected.to eq([public_project, internal_project]) }
|
||||
end
|
||||
|
||||
describe 'with shared projects and group membership' do
|
||||
before do
|
||||
group.add_user(user, Gitlab::Access::DEVELOPER)
|
||||
|
||||
shared_project.project_group_links.
|
||||
create(group_access: Gitlab::Access::MASTER, group: group)
|
||||
end
|
||||
|
||||
it do
|
||||
is_expected.to eq([shared_project, public_project, internal_project])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with shared projects and project membership' do
|
||||
before do
|
||||
shared_project.team.add_user(user, Gitlab::Access::DEVELOPER)
|
||||
|
||||
shared_project.project_group_links.
|
||||
create(group_access: Gitlab::Access::MASTER, group: group)
|
||||
end
|
||||
|
||||
it do
|
||||
is_expected.to eq([shared_project, public_project, internal_project])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,6 +67,50 @@ describe ProjectTeam, models: true do
|
|||
end
|
||||
end
|
||||
|
||||
describe :max_invited_level do
|
||||
let(:group) { create(:group) }
|
||||
let(:project) { create(:empty_project) }
|
||||
|
||||
before do
|
||||
project.project_group_links.create(
|
||||
group: group,
|
||||
group_access: Gitlab::Access::DEVELOPER
|
||||
)
|
||||
|
||||
group.add_user(master, Gitlab::Access::MASTER)
|
||||
group.add_user(reporter, Gitlab::Access::REPORTER)
|
||||
end
|
||||
|
||||
it { expect(project.team.max_invited_level(master.id)).to eq(Gitlab::Access::DEVELOPER) }
|
||||
it { expect(project.team.max_invited_level(reporter.id)).to eq(Gitlab::Access::REPORTER) }
|
||||
it { expect(project.team.max_invited_level(nonmember.id)).to be_nil }
|
||||
end
|
||||
|
||||
describe :max_member_access do
|
||||
let(:group) { create(:group) }
|
||||
let(:project) { create(:empty_project) }
|
||||
|
||||
before do
|
||||
project.project_group_links.create(
|
||||
group: group,
|
||||
group_access: Gitlab::Access::DEVELOPER
|
||||
)
|
||||
|
||||
group.add_user(master, Gitlab::Access::MASTER)
|
||||
group.add_user(reporter, Gitlab::Access::REPORTER)
|
||||
end
|
||||
|
||||
it { expect(project.team.max_member_access(master.id)).to eq(Gitlab::Access::DEVELOPER) }
|
||||
it { expect(project.team.max_member_access(reporter.id)).to eq(Gitlab::Access::REPORTER) }
|
||||
it { expect(project.team.max_member_access(nonmember.id)).to be_nil }
|
||||
|
||||
it "does not have an access" do
|
||||
project.namespace.update(share_with_group_lock: true)
|
||||
expect(project.team.max_member_access(master.id)).to be_nil
|
||||
expect(project.team.max_member_access(reporter.id)).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "#human_max_access" do
|
||||
it 'returns Master role' do
|
||||
user = create(:user)
|
||||
|
|
Loading…
Reference in a new issue