Commit fe7dcb0a authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'ajk-prometheus-service-policy' into 'master'

Replace prometheus service with a more general policy

See merge request gitlab-org/gitlab!47434
parents ce5c65f8 aa03c1ac
# frozen_string_literal: true
class PrometheusServicePolicy < ::BasePolicy
delegate { @subject.project }
class ServicePolicy < BasePolicy
delegate(:project)
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe PrometheusServicePolicy, :models do
let(:integration) { create(:prometheus_service) }
let(:project) { integration.project }
let(:user) { create(:user) }
subject(:policy) { described_class.new(user, integration) }
describe 'rules' do
it { is_expected.to be_disallowed :admin_project }
context 'when maintainer' do
before do
project.add_maintainer(user)
end
it { is_expected.to be_allowed :admin_project }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ServicePolicy, :models do
let_it_be(:user) { create(:user) }
let(:project) { integration.project }
subject(:policy) { Ability.policy_for(user, integration) }
context 'when the integration is a prometheus_service' do
let(:integration) { create(:prometheus_service) }
describe 'rules' do
it { is_expected.to be_disallowed :admin_project }
context 'when maintainer' do
before do
project.add_maintainer(user)
end
it { is_expected.to be_allowed :admin_project }
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment