summaryrefslogtreecommitdiff
path: root/spec/lib/sidebars/projects/menus/snippets_menu_spec.rb
blob: c5fd407dae99ff3098f752cf2682a7f81ffa3dee (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Sidebars::Projects::Menus::SnippetsMenu, feature_category: :navigation do
  let(:project) { build(:project) }
  let(:user) { project.first_owner }
  let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project) }

  subject { described_class.new(context) }

  it_behaves_like 'serializable as super_sidebar_menu_args' do
    let(:menu) { subject }
    let(:extra_attrs) do
      {
        super_sidebar_parent: ::Sidebars::Projects::Menus::RepositoryMenu,
        super_sidebar_before: :contributors,
        item_id: :project_snippets
      }
    end
  end

  describe '#render?' do
    context 'when user cannot access snippets' do
      let(:user) { nil }

      it 'returns false' do
        expect(subject.render?).to eq false
      end
    end

    context 'when user can access snippets' do
      it 'returns true' do
        expect(subject.render?).to eq true
      end
    end
  end
end