diff options
Diffstat (limited to 'spec/helpers/groups_helper_spec.rb')
-rw-r--r-- | spec/helpers/groups_helper_spec.rb | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index 540a8674ec2..b5b22174faf 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -1,11 +1,11 @@ -require 'spec_helper' +require "spec_helper" describe GroupsHelper do include ApplicationHelper - describe 'group_icon_url' do - it 'returns an url for the avatar' do - avatar_file_path = File.join('spec', 'fixtures', 'banana_sample.gif') + describe "group_icon_url" do + it "returns an url for the avatar" do + avatar_file_path = File.join("spec", "fixtures", "banana_sample.gif") group = create(:group) group.avatar = fixture_file_upload(avatar_file_path) @@ -14,14 +14,14 @@ describe GroupsHelper do .to match(group.avatar.url) end - it 'gives default avatar_icon when no avatar is present' do + it "gives default avatar_icon when no avatar is present" do group = create(:group) group.save! - expect(group_icon_url(group.path)).to match_asset_path('group_avatar.png') + expect(group_icon_url(group.path)).to match_asset_path("group_avatar.png") end end - describe 'group_lfs_status' do + describe "group_lfs_status" do let(:group) { create(:group) } let!(:project) { create(:project, namespace_id: group.id) } @@ -29,75 +29,75 @@ describe GroupsHelper do allow(Gitlab.config.lfs).to receive(:enabled).and_return(true) end - context 'only one project in group' do + context "only one project in group" do before do group.update_attribute(:lfs_enabled, true) end - it 'returns all projects as enabled' do - expect(group_lfs_status(group)).to include('Enabled for all projects') + it "returns all projects as enabled" do + expect(group_lfs_status(group)).to include("Enabled for all projects") end - it 'returns all projects as disabled' do + it "returns all projects as disabled" do project.update_attribute(:lfs_enabled, false) - expect(group_lfs_status(group)).to include('Enabled for 0 out of 1 project') + expect(group_lfs_status(group)).to include("Enabled for 0 out of 1 project") end end - context 'more than one project in group' do + context "more than one project in group" do before do create(:project, namespace_id: group.id) end - context 'LFS enabled in group' do + context "LFS enabled in group" do before do group.update_attribute(:lfs_enabled, true) end - it 'returns both projects as enabled' do - expect(group_lfs_status(group)).to include('Enabled for all projects') + it "returns both projects as enabled" do + expect(group_lfs_status(group)).to include("Enabled for all projects") end - it 'returns only one as enabled' do + it "returns only one as enabled" do project.update_attribute(:lfs_enabled, false) - expect(group_lfs_status(group)).to include('Enabled for 1 out of 2 projects') + expect(group_lfs_status(group)).to include("Enabled for 1 out of 2 projects") end end - context 'LFS disabled in group' do + context "LFS disabled in group" do before do group.update_attribute(:lfs_enabled, false) end - it 'returns both projects as disabled' do - expect(group_lfs_status(group)).to include('Disabled for all projects') + it "returns both projects as disabled" do + expect(group_lfs_status(group)).to include("Disabled for all projects") end - it 'returns only one as disabled' do + it "returns only one as disabled" do project.update_attribute(:lfs_enabled, true) - expect(group_lfs_status(group)).to include('Disabled for 1 out of 2 projects') + expect(group_lfs_status(group)).to include("Disabled for 1 out of 2 projects") end end end end - describe 'group_title', :nested_groups do + describe "group_title", :nested_groups do let(:group) { create(:group) } let(:nested_group) { create(:group, parent: group) } let(:deep_nested_group) { create(:group, parent: nested_group) } let!(:very_deep_nested_group) { create(:group, parent: deep_nested_group) } - it 'outputs the groups in the correct order' do + it "outputs the groups in the correct order" do expect(helper.group_title(very_deep_nested_group)) .to match(%r{<li style="text-indent: 16px;"><a.*>#{deep_nested_group.name}.*</li>.*<a.*>#{very_deep_nested_group.name}</a>}m) end end # rubocop:disable Layout/SpaceBeforeComma - describe '#share_with_group_lock_help_text', :nested_groups do + describe "#share_with_group_lock_help_text", :nested_groups do let!(:root_group) { create(:group) } let!(:subgroup) { create(:group, parent: root_group) } let!(:sub_subgroup) { create(:group, parent: subgroup) } @@ -109,20 +109,20 @@ 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: %r{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 with group lock from .+/, - ancestor_locked_and_has_been_overridden: /This setting is applied on .+ and has been overridden on this subgroup/ + ancestor_locked_and_has_been_overridden: /This setting is applied on .+ and has been overridden on this subgroup/, } end let(:possible_linked_ancestors) do { root_group: root_group, - subgroup: subgroup + subgroup: subgroup, } end let(:users) do { root_owner: root_owner, sub_owner: sub_owner, - sub_sub_owner: sub_sub_owner + sub_sub_owner: sub_sub_owner, } end subject { helper.share_with_group_lock_help_text(sub_subgroup) } @@ -152,7 +152,7 @@ describe GroupsHelper do [true , true , false , :sub_sub_owner , :ancestor_locked_and_has_been_overridden , :root_group], [true , true , true , :root_owner , :ancestor_locked_but_you_can_override , :root_group], [true , true , true , :sub_owner , :ancestor_locked_so_ask_the_owner , :root_group], - [true , true , true , :sub_sub_owner , :ancestor_locked_so_ask_the_owner , :root_group] + [true , true , true , :sub_sub_owner , :ancestor_locked_so_ask_the_owner , :root_group], ] end @@ -168,28 +168,28 @@ describe GroupsHelper do allow(helper).to receive(:current_user).and_return(users[current_user]) allow(helper).to receive(:can?) - .with(users[current_user], :change_share_with_group_lock, subgroup) - .and_return(Ability.allowed?(users[current_user], :change_share_with_group_lock, subgroup)) + .with(users[current_user], :change_share_with_group_lock, subgroup) + .and_return(Ability.allowed?(users[current_user], :change_share_with_group_lock, subgroup)) ancestor = possible_linked_ancestors[linked_ancestor] if ancestor allow(helper).to receive(:can?) - .with(users[current_user], :read_group, ancestor) - .and_return(Ability.allowed?(users[current_user], :read_group, ancestor)) + .with(users[current_user], :read_group, ancestor) + .and_return(Ability.allowed?(users[current_user], :read_group, ancestor)) allow(helper).to receive(:can?) - .with(users[current_user], :admin_group, ancestor) - .and_return(Ability.allowed?(users[current_user], :admin_group, ancestor)) + .with(users[current_user], :admin_group, ancestor) + .and_return(Ability.allowed?(users[current_user], :admin_group, ancestor)) end end - it 'has the correct help text with correct ancestor links' do + it "has the correct help text with correct ancestor links" do expect(subject).to match(possible_help_texts[help_text]) expect(subject).to match(possible_linked_ancestors[linked_ancestor].name) unless help_text == :default_help end end end - describe '#group_sidebar_links' do + describe "#group_sidebar_links" do let(:group) { create(:group, :public) } let(:user) { create(:user) } before do @@ -199,25 +199,25 @@ describe GroupsHelper do helper.instance_variable_set(:@group, group) end - it 'returns all the expected links' do + it "returns all the expected links" do links = [ :overview, :activity, :issues, :labels, :milestones, :merge_requests, - :group_members, :settings + :group_members, :settings, ] expect(helper.group_sidebar_links).to include(*links) end - it 'includes settings when the user can admin the group' do + it "includes settings when the user can admin the group" do expect(helper).to receive(:current_user) { user } expect(helper).to receive(:can?).with(user, :admin_group, group) { false } expect(helper.group_sidebar_links).not_to include(:settings) end - it 'excludes cross project features when the user cannot read cross project' do + it "excludes cross project features when the user cannot read cross project" do cross_project_features = [:activity, :issues, :labels, :milestones, - :merge_requests] + :merge_requests,] allow(Ability).to receive(:allowed?).and_call_original cross_project_features.each do |feature| |