Commit cdc8962f authored by Alex Buijs's avatar Alex Buijs

Add start_trial policy

parent 716890a1
......@@ -117,6 +117,8 @@ module EE
condition(:over_storage_limit, scope: :subject) { @subject.over_storage_limit? }
condition(:eligible_for_trial, scope: :subject) { @subject.eligible_for_trial? }
rule { public_group | logged_in_viewable }.policy do
enable :read_wiki
enable :download_wiki_code
......@@ -310,6 +312,8 @@ module EE
rule { admin & is_gitlab_com }.enable :update_subscription_limit
rule { maintainer & eligible_for_trial }.enable :start_trial
rule { over_storage_limit }.policy do
prevent :create_projects
prevent :create_epic
......
......@@ -1395,5 +1395,36 @@ RSpec.describe GroupPolicy do
it { is_expected.to(allowed ? be_allowed(policy) : be_disallowed(policy)) }
end
end
describe ':start_trial' do
using RSpec::Parameterized::TableSyntax
let(:policy) { :start_trial }
where(:role, :eligible_for_trial, :allowed) do
:guest | true | false
:guest | false | false
:reporter | true | false
:reporter | false | false
:developer | true | false
:developer | false | false
:maintainer | true | true
:maintainer | false | false
:owner | true | true
:owner | false | false
:admin | true | true
:admin | false | false
end
with_them do
let(:current_user) { public_send(role) }
before do
allow(group).to receive(:eligible_for_trial?).and_return(eligible_for_trial)
end
it { is_expected.to(allowed ? be_allowed(policy) : be_disallowed(policy)) }
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