BigW Consortium Gitlab

Commit 1feeea9c by Michael Kozono

Refer to “Share with group lock” consistently

parent a887194a
......@@ -108,9 +108,9 @@ module GroupsHelper
end
end
def remove_the_share_lock_from_ancestor(group)
def remove_the_share_with_group_lock_from_ancestor(group)
ancestor = oldest_consecutively_locked_ancestor(group)
text = s_("GroupSettings|remove the share lock from %{ancestor_group_name}") % { ancestor_group_name: ancestor.name }
text = s_("GroupSettings|remove the share with group lock from %{ancestor_group_name}") % { ancestor_group_name: ancestor.name }
if can?(current_user, :admin_group, ancestor)
link_to text, edit_group_path(ancestor)
else
......@@ -129,11 +129,11 @@ module GroupsHelper
end
def ancestor_locked_but_you_can_override(group)
s_("GroupSettings|This setting is applied on %{ancestor_group}. You can override the setting or %{remove_ancestor_share_lock}.").html_safe % { ancestor_group: ancestor_group(group), remove_ancestor_share_lock: remove_the_share_lock_from_ancestor(group) }
s_("GroupSettings|This setting is applied on %{ancestor_group}. You can override the setting or %{remove_ancestor_share_with_group_lock}.").html_safe % { ancestor_group: ancestor_group(group), remove_ancestor_share_with_group_lock: remove_the_share_with_group_lock_from_ancestor(group) }
end
def ancestor_locked_so_ask_the_owner(group)
s_("GroupSettings|This setting is applied on %{ancestor_group}. To share projects in this group with another group, ask the owner to override the setting or %{remove_ancestor_share_lock}.").html_safe % { ancestor_group: ancestor_group(group), remove_ancestor_share_lock: remove_the_share_lock_from_ancestor(group) }
s_("GroupSettings|This setting is applied on %{ancestor_group}. To share projects in this group with another group, ask the owner to override the setting or %{remove_ancestor_share_with_group_lock}.").html_safe % { ancestor_group: ancestor_group(group), remove_ancestor_share_with_group_lock: remove_the_share_with_group_lock_from_ancestor(group) }
end
def ancestor_locked_and_has_been_overridden(group)
......
......@@ -15,8 +15,8 @@ class GroupPolicy < BasePolicy
condition(:nested_groups_supported, scope: :global) { Group.supports_nested_groups? }
condition(:share_locked, scope: :subject) { @subject.share_with_group_lock? }
condition(:parent_share_locked, scope: :subject) { @subject.parent&.share_with_group_lock? }
condition(:share_with_group_locked, scope: :subject) { @subject.share_with_group_lock? }
condition(:parent_share_with_group_locked, scope: :subject) { @subject.parent&.share_with_group_lock? }
condition(:can_change_parent_share_with_group_lock) { @subject.has_parent? && can?(:change_share_with_group_lock, @subject.parent) }
condition(:has_projects) do
......@@ -58,7 +58,7 @@ class GroupPolicy < BasePolicy
rule { ~can?(:view_globally) }.prevent :request_access
rule { has_access }.prevent :request_access
rule { owner & (~share_locked | ~parent_share_locked | can_change_parent_share_with_group_lock) }.enable :change_share_with_group_lock
rule { owner & (~share_with_group_locked | ~parent_share_with_group_locked | can_change_parent_share_with_group_lock) }.enable :change_share_with_group_lock
def access_level
return GroupMember::NO_ACCESS if @user.nil?
......
......@@ -30,7 +30,7 @@ module Groups
return true unless changing_share_with_group_lock?
return true if can?(current_user, :change_share_with_group_lock, group)
group.errors.add(:share_with_group_lock, s_('GroupSettings|cannot be disabled when the parent group Share with group lock is enabled, except by the owner of the parent group'))
group.errors.add(:share_with_group_lock, s_('GroupSettings|cannot be disabled when the parent group "Share with group lock" is enabled, except by the owner of the parent group'))
false
end
......
......@@ -30,7 +30,7 @@
.form-group
%label.control-label
= s_("GroupSettings|Share lock")
= s_("GroupSettings|Share with group lock")
.col-sm-10
.checkbox
= f.label :share_with_group_lock do
......
require 'spec_helper'
feature 'Group share lock' do
feature 'Group share with group lock' do
given(:root_owner) { create(:user) }
given(:root_group) { create(:group) }
......@@ -12,8 +12,8 @@ feature 'Group share lock' do
context 'with a subgroup', :nested_groups do
given!(:subgroup) { create(:group, parent: root_group) }
context 'when enabling the parent group share lock' do
scenario 'the subgroup share lock becomes enabled' do
context 'when enabling the parent group share with group lock' do
scenario 'the subgroup share with group lock becomes enabled' do
visit edit_group_path(root_group)
check 'group_share_with_group_lock'
......@@ -23,15 +23,15 @@ feature 'Group share lock' do
end
end
context 'when disabling the parent group share lock (which was already enabled)' do
context 'when disabling the parent group share with group lock (which was already enabled)' do
background do
visit edit_group_path(root_group)
check 'group_share_with_group_lock'
click_on 'Save group'
end
context 'and the subgroup share lock is enabled' do
scenario 'the subgroup share lock does not change' do
context 'and the subgroup share with group lock is enabled' do
scenario 'the subgroup share with group lock does not change' do
visit edit_group_path(root_group)
uncheck 'group_share_with_group_lock'
......@@ -41,14 +41,14 @@ feature 'Group share lock' do
end
end
context 'but the subgroup share lock is disabled' do
context 'but the subgroup share with group lock is disabled' do
background do
visit edit_group_path(subgroup)
uncheck 'group_share_with_group_lock'
click_on 'Save group'
end
scenario 'the subgroup share lock does not change' do
scenario 'the subgroup share with group lock does not change' do
visit edit_group_path(root_group)
uncheck 'group_share_with_group_lock'
......
......@@ -6,7 +6,7 @@ feature 'Project > Members > Share with Group', :js do
let(:master) { create(:user) }
describe 'Share Lock' do
describe 'Share with group lock' do
shared_examples 'the project can be shared with groups' do
scenario 'the "Share with group" tab exists' do
visit project_settings_members_path(project)
......@@ -31,7 +31,7 @@ feature 'Project > Members > Share with Group', :js do
sign_in(master)
end
context 'when the group has "Share lock" disabled' do
context 'when the group has "Share with group lock" disabled' do
it_behaves_like 'the project can be shared with groups'
scenario 'the project can be shared with another group' do
......@@ -49,7 +49,7 @@ feature 'Project > Members > Share with Group', :js do
end
end
context 'when the group has "Share lock" enabled' do
context 'when the group has "Share with group lock" enabled' do
before do
project.namespace.update_column(:share_with_group_lock, true)
end
......@@ -69,12 +69,12 @@ feature 'Project > Members > Share with Group', :js do
sign_in(master)
end
context 'when the root_group has "Share lock" disabled' do
context 'when the subgroup has "Share lock" disabled' do
context 'when the root_group has "Share with group lock" disabled' do
context 'when the subgroup has "Share with group lock" disabled' do
it_behaves_like 'the project can be shared with groups'
end
context 'when the subgroup has "Share lock" enabled' do
context 'when the subgroup has "Share with group lock" enabled' do
before do
subgroup.update_column(:share_with_group_lock, true)
end
......@@ -83,16 +83,16 @@ feature 'Project > Members > Share with Group', :js do
end
end
context 'when the root_group has "Share lock" enabled' do
context 'when the root_group has "Share with group 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
context 'when the subgroup has "Share with group 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
context 'when the subgroup has "Share with group lock" enabled' do
before do
subgroup.update_column(:share_with_group_lock, true)
end
......
......@@ -108,7 +108,7 @@ describe GroupsHelper do
{
default_help: "This setting will be applied to all subgroups unless overridden by a group owner",
ancestor_locked_but_you_can_override: /This setting is applied on <a .+>.+<\/a>\. You can override the setting or .+/,
ancestor_locked_so_ask_the_owner: /This setting is applied on .+\. To share projects in this group with another group, ask the owner to override the setting or remove the share lock from .+/,
ancestor_locked_so_ask_the_owner: /This setting is applied on .+\. To share projects in this group with another group, ask the owner to override the setting or remove the share with group lock from .+/,
ancestor_locked_and_has_been_overridden: /This setting is applied on .+ and has been overridden on this subgroup/
}
end
......@@ -127,7 +127,7 @@ describe GroupsHelper do
end
subject { helper.share_with_group_lock_help_text(sub_subgroup) }
where(:root_share_locked, :subgroup_share_locked, :sub_subgroup_share_locked, :current_user, :help_text, :linked_ancestor) do
where(:root_share_with_group_locked, :subgroup_share_with_group_locked, :sub_subgroup_share_with_group_locked, :current_user, :help_text, :linked_ancestor) do
[
[false , false , false , :root_owner , :default_help , nil],
[false , false , false , :sub_owner , :default_help , nil],
......@@ -162,9 +162,9 @@ describe GroupsHelper do
subgroup.add_owner(sub_owner)
sub_subgroup.add_owner(sub_sub_owner)
root_group.update_column(:share_with_group_lock, true) if root_share_locked
subgroup.update_column(:share_with_group_lock, true) if subgroup_share_locked
sub_subgroup.update_column(:share_with_group_lock, true) if sub_subgroup_share_locked
root_group.update_column(:share_with_group_lock, true) if root_share_with_group_locked
subgroup.update_column(:share_with_group_lock, true) if subgroup_share_with_group_locked
sub_subgroup.update_column(:share_with_group_lock, true) if sub_subgroup_share_with_group_locked
allow(helper).to receive(:current_user).and_return(users[current_user])
allow(helper).to receive(:can?)
......
......@@ -411,51 +411,51 @@ describe Namespace do
context 'when creating a subgroup' do
let(:subgroup) { create(:group, parent: root_group )}
context 'under a parent with share lock enabled' do
context 'under a parent with "Share with group lock" enabled' do
let(:root_group) { create(:group, share_with_group_lock: true) }
it 'enables share lock on the subgroup' do
it 'enables "Share with group lock" on the subgroup' do
expect(subgroup.share_with_group_lock).to be_truthy
end
end
context 'under a parent with share lock disabled' do
context 'under a parent with "Share with group lock" disabled' do
let(:root_group) { create(:group) }
it 'does not enable share lock on the subgroup' do
it 'does not enable "Share with group lock" on the subgroup' do
expect(subgroup.share_with_group_lock).to be_falsey
end
end
end
context 'when enabling the parent group share lock' do
context 'when enabling the parent group "Share with group lock"' do
let(:root_group) { create(:group) }
let!(:subgroup) { create(:group, parent: root_group )}
it 'the subgroup share lock becomes enabled' do
it 'the subgroup "Share with group lock" becomes enabled' do
root_group.update!(share_with_group_lock: true)
expect(subgroup.reload.share_with_group_lock).to be_truthy
end
end
context 'when disabling the parent group share lock (which was already enabled)' do
context 'when disabling the parent group "Share with group lock" (which was already enabled)' do
let(:root_group) { create(:group, share_with_group_lock: true) }
context 'and the subgroup share lock is enabled' do
context 'and the subgroup "Share with group lock" is enabled' do
let(:subgroup) { create(:group, parent: root_group, share_with_group_lock: true )}
it 'the subgroup share lock does not change' do
it 'the subgroup "Share with group lock" does not change' do
root_group.update!(share_with_group_lock: false)
expect(subgroup.reload.share_with_group_lock).to be_truthy
end
end
context 'but the subgroup share lock is disabled' do
context 'but the subgroup "Share with group lock" is disabled' do
let(:subgroup) { create(:group, parent: root_group )}
it 'the subgroup share lock does not change' do
it 'the subgroup "Share with group lock" does not change' do
root_group.update!(share_with_group_lock: false)
expect(subgroup.reload.share_with_group_lock?).to be_falsey
......@@ -465,13 +465,13 @@ describe Namespace do
# Note: Group transfers are not yet implemented
context 'when a group is transferred into a root group' do
context 'when the root group share lock is enabled' do
context 'when the root group "Share with group lock" is enabled' do
let(:root_group) { create(:group, share_with_group_lock: true) }
context 'when the subgroup share lock is enabled' do
context 'when the subgroup "Share with group lock" is enabled' do
let(:subgroup) { create(:group, share_with_group_lock: true )}
it 'the subgroup share lock does not change' do
it 'the subgroup "Share with group lock" does not change' do
subgroup.parent = root_group
subgroup.save!
......@@ -479,10 +479,10 @@ describe Namespace do
end
end
context 'when the subgroup share lock is disabled' do
context 'when the subgroup "Share with group lock" is disabled' do
let(:subgroup) { create(:group)}
it 'the subgroup share lock becomes enabled' do
it 'the subgroup "Share with group lock" becomes enabled' do
subgroup.parent = root_group
subgroup.save!
......@@ -491,13 +491,13 @@ describe Namespace do
end
end
context 'when the root group share lock is disabled' do
context 'when the root group "Share with group lock" is disabled' do
let(:root_group) { create(:group) }
context 'when the subgroup share lock is enabled' do
context 'when the subgroup "Share with group lock" is enabled' do
let(:subgroup) { create(:group, share_with_group_lock: true )}
it 'the subgroup share lock does not change' do
it 'the subgroup "Share with group lock" does not change' do
subgroup.parent = root_group
subgroup.save!
......@@ -505,10 +505,10 @@ describe Namespace do
end
end
context 'when the subgroup share lock is disabled' do
context 'when the subgroup "Share with group lock" is disabled' do
let(:subgroup) { create(:group)}
it 'the subgroup share lock does not change' do
it 'the subgroup "Share with group lock" does not change' do
subgroup.parent = root_group
subgroup.save!
......
......@@ -128,7 +128,7 @@ describe Groups::UpdateService do
result = described_class.new(subgroup, subgroup_owner, share_with_group_lock: false).execute
expect(result).to be_falsey
expect(subgroup.errors.full_messages.first).to match(/cannot be disabled when the parent group Share lock is enabled, except by the owner of the parent group/)
expect(subgroup.errors.full_messages.first).to match(/cannot be disabled when the parent group "Share with group lock" is enabled, except by the owner of the parent group/)
expect(subgroup.reload.share_with_group_lock).to be_truthy
end
end
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'groups/edit.html.haml' do
include Devise::Test::ControllerHelpers
describe 'Share lock option' do
describe '"Share with group lock" setting' do
let(:root_owner) { create(:user) }
let(:root_group) { create(:group) }
......@@ -11,7 +11,7 @@ describe 'groups/edit.html.haml' do
root_group.add_owner(root_owner)
end
shared_examples_for 'share lock option' do |checkbox_options|
shared_examples_for '"Share with group lock" setting' do |checkbox_options|
it 'should have the correct label, help text, and checkbox options' do
assign(:group, test_group)
allow(view).to receive(:can?).with(test_user, :admin_group, test_group).and_return(true)
......@@ -32,7 +32,7 @@ describe 'groups/edit.html.haml' do
let(:test_group) { root_group }
let(:test_user) { root_owner }
it_behaves_like 'share lock option', { disabled: false, checked: false }
it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false }
end
context 'for a subgroup', :nested_groups do
......@@ -40,22 +40,22 @@ describe 'groups/edit.html.haml' do
let(:sub_owner) { create(:user) }
let(:test_group) { subgroup }
context 'when the root_group has "Share lock" disabled' do
context 'when the subgroup has "Share lock" disabled' do
context 'when the root_group has "Share with group lock" disabled' do
context 'when the subgroup has "Share with group lock" disabled' do
context 'as the root_owner' do
let(:test_user) { root_owner }
it_behaves_like 'share lock option', { disabled: false, checked: false }
it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false }
end
context 'as the sub_owner' do
let(:test_user) { sub_owner }
it_behaves_like 'share lock option', { disabled: false, checked: false }
it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false }
end
end
context 'when the subgroup has "Share lock" enabled' do
context 'when the subgroup has "Share with group lock" enabled' do
before do
subgroup.update_column(:share_with_group_lock, true)
end
......@@ -63,37 +63,37 @@ describe 'groups/edit.html.haml' do
context 'as the root_owner' do
let(:test_user) { root_owner }
it_behaves_like 'share lock option', { disabled: false, checked: true }
it_behaves_like '"Share with group lock" setting', { disabled: false, checked: true }
end
context 'as the sub_owner' do
let(:test_user) { sub_owner }
it_behaves_like 'share lock option', { disabled: false, checked: true }
it_behaves_like '"Share with group lock" setting', { disabled: false, checked: true }
end
end
end
context 'when the root_group has "Share lock" enabled' do
context 'when the root_group has "Share with group 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
context 'when the subgroup has "Share with group lock" disabled (parent overridden)' do
context 'as the root_owner' do
let(:test_user) { root_owner }
it_behaves_like 'share lock option', { disabled: false, checked: false }
it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false }
end
context 'as the sub_owner' do
let(:test_user) { sub_owner }
it_behaves_like 'share lock option', { disabled: false, checked: false }
it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false }
end
end
context 'when the subgroup has "Share lock" enabled (same as parent)' do
context 'when the subgroup has "Share with group lock" enabled (same as parent)' do
before do
subgroup.update_column(:share_with_group_lock, true)
end
......@@ -101,13 +101,13 @@ describe 'groups/edit.html.haml' do
context 'as the root_owner' do
let(:test_user) { root_owner }
it_behaves_like 'share lock option', { disabled: false, checked: true }
it_behaves_like '"Share with group lock" setting', { disabled: false, checked: true }
end
context 'as the sub_owner' do
let(:test_user) { sub_owner }
it_behaves_like 'share lock option', { disabled: true, checked: true }
it_behaves_like '"Share with group lock" setting', { disabled: true, checked: true }
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