diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-09-06 11:31:45 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-09-06 12:07:21 -0700 |
commit | 1feeea9c6af5d683f18c021df16e4eedfa9306e0 (patch) | |
tree | 4869cd4d3b9e839a4eba612c9da5205b73dafbe6 | |
parent | a887194abd2ea0c0cbcd24f0ff7630800d3eec12 (diff) | |
download | gitlab-ce-1feeea9c6af5d683f18c021df16e4eedfa9306e0.tar.gz |
Refer to “Share with group lock” consistentlyimprove-share-locking-feature-for-subgroups
-rw-r--r-- | app/helpers/groups_helper.rb | 8 | ||||
-rw-r--r-- | app/policies/group_policy.rb | 6 | ||||
-rw-r--r-- | app/services/groups/update_service.rb | 2 | ||||
-rw-r--r-- | app/views/groups/edit.html.haml | 2 | ||||
-rw-r--r-- | spec/features/groups/share_lock_spec.rb | 16 | ||||
-rw-r--r-- | spec/features/projects/members/share_with_group_spec.rb | 18 | ||||
-rw-r--r-- | spec/helpers/groups_helper_spec.rb | 10 | ||||
-rw-r--r-- | spec/models/namespace_spec.rb | 42 | ||||
-rw-r--r-- | spec/services/groups/update_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/views/groups/edit.html.haml_spec.rb | 34 |
10 files changed, 70 insertions, 70 deletions
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 58daf5c97e6..36b79da1bde 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -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) diff --git a/app/policies/group_policy.rb b/app/policies/group_policy.rb index 70622ba553c..db889892da0 100644 --- a/app/policies/group_policy.rb +++ b/app/policies/group_policy.rb @@ -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? diff --git a/app/services/groups/update_service.rb b/app/services/groups/update_service.rb index 246aff6c0fa..08e3efb96e3 100644 --- a/app/services/groups/update_service.rb +++ b/app/services/groups/update_service.rb @@ -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 diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml index 45450a1ca98..0d3308833b7 100644 --- a/app/views/groups/edit.html.haml +++ b/app/views/groups/edit.html.haml @@ -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 diff --git a/spec/features/groups/share_lock_spec.rb b/spec/features/groups/share_lock_spec.rb index cf1079bb6d6..8842d1391aa 100644 --- a/spec/features/groups/share_lock_spec.rb +++ b/spec/features/groups/share_lock_spec.rb @@ -1,6 +1,6 @@ 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' diff --git a/spec/features/projects/members/share_with_group_spec.rb b/spec/features/projects/members/share_with_group_spec.rb index 9a9cedf1a0e..3b368f8e25d 100644 --- a/spec/features/projects/members/share_with_group_spec.rb +++ b/spec/features/projects/members/share_with_group_spec.rb @@ -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 diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index 7c5d954763c..36031ac1a28 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -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?) diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 6e583dc3e93..a0831cf8f38 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -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! diff --git a/spec/services/groups/update_service_spec.rb b/spec/services/groups/update_service_spec.rb index 80e9c0c81dc..1737fd0a9fc 100644 --- a/spec/services/groups/update_service_spec.rb +++ b/spec/services/groups/update_service_spec.rb @@ -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 diff --git a/spec/views/groups/edit.html.haml_spec.rb b/spec/views/groups/edit.html.haml_spec.rb index 86bb28a43c1..38cfb84f0d5 100644 --- a/spec/views/groups/edit.html.haml_spec.rb +++ b/spec/views/groups/edit.html.haml_spec.rb @@ -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 |