debian-mirror-gitlab/spec/helpers/projects/cluster_agents_helper_spec.rb

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

50 lines
1.4 KiB
Ruby
Raw Normal View History

2021-11-18 22:05:49 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::ClusterAgentsHelper do
describe '#js_cluster_agent_details_data' do
let_it_be(:project) { create(:project) }
2022-04-04 11:22:00 +05:30
let_it_be(:current_user) { create(:user) }
2021-11-18 22:05:49 +05:30
2022-04-04 11:22:00 +05:30
let(:user_can_admin_vulerability) { true }
2022-05-07 20:08:51 +05:30
let(:user_can_admin_cluster) { false }
2021-11-18 22:05:49 +05:30
let(:agent_name) { 'agent-name' }
2022-04-04 11:22:00 +05:30
before do
allow(helper).to receive(:current_user).and_return(current_user)
allow(helper)
.to receive(:can?)
.with(current_user, :admin_vulnerability, project)
.and_return(user_can_admin_vulerability)
2022-05-07 20:08:51 +05:30
allow(helper)
.to receive(:can?)
.with(current_user, :admin_cluster, project)
.and_return(user_can_admin_cluster)
2021-11-18 22:05:49 +05:30
end
2022-04-04 11:22:00 +05:30
subject { helper.js_cluster_agent_details_data(agent_name, project) }
2022-03-02 08:16:31 +05:30
2022-04-04 11:22:00 +05:30
it {
is_expected.to match({
agent_name: agent_name,
project_path: project.full_path,
activity_empty_state_image: kind_of(String),
empty_state_svg_path: kind_of(String),
2022-05-07 20:08:51 +05:30
can_admin_vulnerability: "true",
kas_address: Gitlab::Kas.external_url,
2022-07-16 23:28:13 +05:30
kas_version: Gitlab::Kas.version_info,
2022-05-07 20:08:51 +05:30
can_admin_cluster: "false"
2022-04-04 11:22:00 +05:30
})
}
2022-05-07 20:08:51 +05:30
context 'user has admin cluster permissions' do
let(:user_can_admin_cluster) { true }
it 'displays that the user can admin cluster' do
expect(subject[:can_admin_cluster]).to eq("true")
end
end
2021-11-18 22:05:49 +05:30
end
end