2022-10-11 01:57:18 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Sidebars::Groups::Menus::ObservabilityMenu do
|
|
|
|
let_it_be(:owner) { create(:user) }
|
|
|
|
let_it_be(:root_group) do
|
|
|
|
build(:group, :private).tap do |g|
|
|
|
|
g.add_owner(owner)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:group) { root_group }
|
|
|
|
let(:user) { owner }
|
|
|
|
let(:context) { Sidebars::Groups::Context.new(current_user: user, container: group) }
|
|
|
|
let(:menu) { described_class.new(context) }
|
|
|
|
|
|
|
|
describe '#render?' do
|
|
|
|
before do
|
|
|
|
allow(menu).to receive(:can?).and_call_original
|
|
|
|
end
|
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
context 'when observability is enabled' do
|
2022-10-11 01:57:18 +05:30
|
|
|
before do
|
2023-03-17 16:20:25 +05:30
|
|
|
allow(Gitlab::Observability).to receive(:observability_enabled?).and_return(true)
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns true' do
|
|
|
|
expect(menu.render?).to eq true
|
2023-03-17 16:20:25 +05:30
|
|
|
expect(Gitlab::Observability).to have_received(:observability_enabled?).with(user, group)
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
context 'when observability is disabled' do
|
2022-10-11 01:57:18 +05:30
|
|
|
before do
|
2023-03-17 16:20:25 +05:30
|
|
|
allow(Gitlab::Observability).to receive(:observability_enabled?).and_return(false)
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns false' do
|
|
|
|
expect(menu.render?).to eq false
|
2023-03-17 16:20:25 +05:30
|
|
|
expect(Gitlab::Observability).to have_received(:observability_enabled?).with(user, group)
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|