2017-09-01 19:49:09 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Group share with group lock' do
|
|
|
|
let(:root_owner) { create(:user) }
|
|
|
|
let(:root_group) { create(:group) }
|
2017-09-01 19:49:09 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
before do
|
2017-09-01 19:49:09 -04:00
|
|
|
root_group.add_owner(root_owner)
|
|
|
|
sign_in(root_owner)
|
|
|
|
end
|
|
|
|
|
2017-09-01 21:22:55 -04:00
|
|
|
context 'with a subgroup', :nested_groups do
|
2018-07-05 02:32:05 -04:00
|
|
|
let!(:subgroup) { create(:group, parent: root_group) }
|
2017-09-01 19:49:09 -04:00
|
|
|
|
2017-09-06 14:31:45 -04:00
|
|
|
context 'when enabling the parent group share with group lock' do
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the subgroup share with group lock becomes enabled' do
|
2017-09-01 19:49:09 -04:00
|
|
|
visit edit_group_path(root_group)
|
|
|
|
|
2018-05-28 11:02:04 -04:00
|
|
|
enable_group_lock
|
2017-09-01 19:49:09 -04:00
|
|
|
|
|
|
|
expect(subgroup.reload.share_with_group_lock?).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-06 14:31:45 -04:00
|
|
|
context 'when disabling the parent group share with group lock (which was already enabled)' do
|
2018-07-05 02:32:05 -04:00
|
|
|
before do
|
2017-09-01 19:49:09 -04:00
|
|
|
visit edit_group_path(root_group)
|
2018-05-28 11:02:04 -04:00
|
|
|
|
|
|
|
enable_group_lock
|
2017-09-01 19:49:09 -04:00
|
|
|
end
|
|
|
|
|
2017-09-06 14:31:45 -04:00
|
|
|
context 'and the subgroup share with group lock is enabled' do
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the subgroup share with group lock does not change' do
|
2017-09-01 19:49:09 -04:00
|
|
|
visit edit_group_path(root_group)
|
|
|
|
|
2018-05-28 11:02:04 -04:00
|
|
|
disable_group_lock
|
2017-09-01 19:49:09 -04:00
|
|
|
|
|
|
|
expect(subgroup.reload.share_with_group_lock?).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-06 14:31:45 -04:00
|
|
|
context 'but the subgroup share with group lock is disabled' do
|
2018-07-05 02:32:05 -04:00
|
|
|
before do
|
2017-09-01 19:49:09 -04:00
|
|
|
visit edit_group_path(subgroup)
|
2018-05-28 11:02:04 -04:00
|
|
|
|
|
|
|
disable_group_lock
|
2017-09-01 19:49:09 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the subgroup share with group lock does not change' do
|
2017-09-01 19:49:09 -04:00
|
|
|
visit edit_group_path(root_group)
|
|
|
|
|
2018-05-28 11:02:04 -04:00
|
|
|
disable_group_lock
|
2017-09-01 19:49:09 -04:00
|
|
|
|
|
|
|
expect(subgroup.reload.share_with_group_lock?).to be_falsey
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-05-28 11:02:04 -04:00
|
|
|
|
|
|
|
def enable_group_lock
|
|
|
|
page.within('.gs-permissions') do
|
|
|
|
check 'group_share_with_group_lock'
|
|
|
|
click_on 'Save group'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def disable_group_lock
|
|
|
|
page.within('.gs-permissions') do
|
|
|
|
uncheck 'group_share_with_group_lock'
|
|
|
|
click_on 'Save group'
|
|
|
|
end
|
|
|
|
end
|
2017-09-01 19:49:09 -04:00
|
|
|
end
|