summaryrefslogtreecommitdiff
path: root/spec/lib/sidebars/projects/menus/project_information_menu_spec.rb
blob: 7ff06ac229e153e67d7cdae093b1c0632b92c45c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Sidebars::Projects::Menus::ProjectInformationMenu do
  let_it_be_with_reload(:project) { create(:project, :repository) }

  let(:user) { project.first_owner }
  let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project) }

  describe '#container_html_options' do
    subject { described_class.new(context).container_html_options }

    specify { is_expected.to match(hash_including(class: 'shortcuts-project-information has-sub-items')) }
  end

  describe 'Menu Items' do
    subject { described_class.new(context).renderable_items.index { |e| e.item_id == item_id } }

    describe 'Labels' do
      let(:item_id) { :labels }

      specify { is_expected.not_to be_nil }

      context 'when merge requests are disabled' do
        before do
          project.project_feature.update_attribute(:merge_requests_access_level, Featurable::DISABLED)
        end

        specify { is_expected.not_to be_nil }
      end

      context 'when issues are disabled' do
        before do
          project.project_feature.update_attribute(:issues_access_level, Featurable::DISABLED)
        end

        specify { is_expected.not_to be_nil }
      end

      context 'when merge requests and issues are disabled' do
        before do
          project.project_feature.update_attribute(:merge_requests_access_level, Featurable::DISABLED)
          project.project_feature.update_attribute(:issues_access_level, Featurable::DISABLED)
        end

        specify { is_expected.to be_nil }
      end
    end

    describe 'Members' do
      let(:item_id) { :members }

      specify { is_expected.not_to be_nil }

      describe 'when the user does not have access' do
        let(:user) { nil }

        specify { is_expected.to be_nil }
      end
    end
  end
end