Commit c93e8f24 authored by Michael Kozono's avatar Michael Kozono

Add post-nested group Share lock integration tests

parent a1a4754b
...@@ -4,50 +4,106 @@ feature 'Project > Members > Share with Group', :js do ...@@ -4,50 +4,106 @@ feature 'Project > Members > Share with Group', :js do
include Select2Helper include Select2Helper
include ActionView::Helpers::DateHelper include ActionView::Helpers::DateHelper
describe 'Share Lock' do
let(:master) { create(:user) } let(:master) { create(:user) }
let(:group) { create(:group) }
let!(:other_group) { create(:group) } describe 'Share Lock' do
let(:project) { create(:project, namespace: group) } shared_examples 'the project can be shared with groups' do
scenario 'the "Share with group" tab exists' do
visit project_settings_members_path(project)
expect(page).to have_selector('#share-with-group-tab')
end
end
shared_examples 'the project cannot be shared with groups' do
scenario 'the "Share with group" tab does not exist' do
visit project_settings_members_path(project)
expect(page).to have_selector('#add-member-tab')
expect(page).not_to have_selector('#share-with-group-tab')
end
end
context 'for a project in a root group' do
let!(:group_to_share_with) { create(:group) }
let(:project) { create(:project, namespace: create(:group)) }
background do background do
project.add_master(master) project.add_master(master)
sign_in(master) sign_in(master)
end end
context 'when the group does not have "Share lock" enabled' do context 'when the group has "Share lock" disabled' do
before do it_behaves_like 'the project can be shared with groups'
scenario 'the project can be shared with another group' do
visit project_settings_members_path(project) visit project_settings_members_path(project)
click_on 'share-with-group-tab' click_on 'share-with-group-tab'
select2 other_group.id, from: '#link_group_id' select2 group_to_share_with.id, from: '#link_group_id'
page.find('body').click page.find('body').click
find('.btn-create').trigger('click') find('.btn-create').trigger('click')
end
scenario 'the group link appears in the existing groups list' do
page.within('.project-members-groups') do page.within('.project-members-groups') do
expect(page).to have_content(other_group.name) expect(page).to have_content(group_to_share_with.name)
end end
end end
end end
context 'when the group has "Share lock" enabled' do context 'when the group has "Share lock" enabled' do
before do before do
group.update_column(:share_with_group_lock, true) project.namespace.update_column(:share_with_group_lock, true)
visit project_settings_members_path(project)
end end
scenario 'the "Share with group" tab does not exist' do it_behaves_like 'the project cannot be shared with groups'
expect(page).to have_selector('#add-member-tab') end
expect(page).not_to have_selector('#share-with-group-tab') end
context 'for a project in a subgroup', :postgresql do
let!(:group_to_share_with) { create(:group) }
let(:root_group) { create(:group) }
let(:subgroup) { create(:group, parent: root_group) }
let(:project) { create(:project, namespace: subgroup) }
background do
project.add_master(master)
sign_in(master)
end
context 'when the root_group has "Share lock" disabled' do
context 'when the subgroup has "Share lock" disabled' do
it_behaves_like 'the project can be shared with groups'
end
context 'when the subgroup has "Share lock" enabled' do
before do
subgroup.update_column(:share_with_group_lock, true)
end
it_behaves_like 'the project cannot be shared with groups'
end
end
context 'when the root_group has "Share lock" enabled' do
before do
root_group.update_column(:share_with_group_lock, true)
end
context 'when the subgroup has "Share lock" disabled (parent overridden)' do
it_behaves_like 'the project can be shared with groups'
end
context 'when the subgroup has "Share lock" enabled' do
before do
subgroup.update_column(:share_with_group_lock, true)
end
it_behaves_like 'the project cannot be shared with groups'
end
end end
end end
end end
describe 'setting an expiration date for a group link' do describe 'setting an expiration date for a group link' do
let(:master) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
let!(:group) { create(:group) } let!(:group) { create(:group) }
...@@ -83,17 +139,14 @@ feature 'Project > Members > Share with Group', :js do ...@@ -83,17 +139,14 @@ feature 'Project > Members > Share with Group', :js do
describe 'the groups dropdown' do describe 'the groups dropdown' do
context 'with multiple groups to choose from' do context 'with multiple groups to choose from' do
let(:master) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
let(:group) { create(:group) }
background do background do
project.add_master(master) project.add_master(master)
sign_in(master) sign_in(master)
group_two = create(:group) create(:group).add_owner(master)
group.add_owner(master) create(:group).add_owner(master)
group_two.add_owner(master)
visit project_settings_members_path(project) visit project_settings_members_path(project)
execute_script 'GroupsSelect.PER_PAGE = 1;' execute_script 'GroupsSelect.PER_PAGE = 1;'
...@@ -110,17 +163,16 @@ feature 'Project > Members > Share with Group', :js do ...@@ -110,17 +163,16 @@ feature 'Project > Members > Share with Group', :js do
end end
context 'for a project in a nested group' do context 'for a project in a nested group' do
let(:master) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
let!(:nested_group) { create(:group, parent: group) } let!(:nested_group) { create(:group, parent: group) }
let!(:another_group) { create(:group) } let!(:group_to_share_with) { create(:group) }
let!(:project) { create(:project, namespace: nested_group) } let!(:project) { create(:project, namespace: nested_group) }
background do background do
project.add_master(master) project.add_master(master)
sign_in(master) sign_in(master)
group.add_master(master) group.add_master(master)
another_group.add_master(master) group_to_share_with.add_master(master)
end end
scenario 'the groups dropdown does not show ancestors', :nested_groups do scenario 'the groups dropdown does not show ancestors', :nested_groups do
...@@ -130,7 +182,7 @@ feature 'Project > Members > Share with Group', :js do ...@@ -130,7 +182,7 @@ feature 'Project > Members > Share with Group', :js do
click_link 'Search for a group' click_link 'Search for a group'
page.within '.select2-drop' do page.within '.select2-drop' do
expect(page).to have_content(another_group.name) expect(page).to have_content(group_to_share_with.name)
expect(page).not_to have_content(group.name) expect(page).not_to have_content(group.name)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment