debian-mirror-gitlab/spec/lib/sidebars/projects/menus/snippets_menu_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
952 B
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe Sidebars::Projects::Menus::SnippetsMenu, feature_category: :navigation do
2021-06-08 01:23:25 +05:30
let(:project) { build(:project) }
2022-04-04 11:22:00 +05:30
let(:user) { project.first_owner }
2021-06-08 01:23:25 +05:30
let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project) }
subject { described_class.new(context) }
2023-05-27 22:25:52 +05:30
it_behaves_like 'serializable as super_sidebar_menu_args' do
let(:menu) { subject }
let(:extra_attrs) do
{
2023-06-20 00:43:36 +05:30
super_sidebar_parent: ::Sidebars::Projects::SuperSidebarMenus::CodeMenu,
2023-05-27 22:25:52 +05:30
item_id: :project_snippets
}
end
end
2021-06-08 01:23:25 +05:30
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