Skip to content

Commit

Permalink
Extend TokenPolicy spec
Browse files Browse the repository at this point in the history
  • Loading branch information
saraycp committed Feb 14, 2023
1 parent 7101152 commit 72c3b94
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/api/spec/policies/token_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
it { is_expected.to permit(token_user, user_token) }
end

permissions :show? do
permissions :show?, :create?, :update? do
it { is_expected.to permit(token_user, workflow_token) }
end

Expand All @@ -29,6 +29,18 @@
it { is_expected.not_to permit(unconfirmed_user, token_of_unconfirmed_user) }
end

# New action is permitted on any kind of token and user
permissions :new? do
it { is_expected.to permit(token_user, Token.new) }
it { is_expected.to permit(unconfirmed_user, Token.new) }
end

# Create and update are permitted when the user and the executor are the same
permissions :create?, :update? do
it { is_expected.to permit(token_user, rss_token) }
it { is_expected.not_to permit(other_user, rss_token) }
end

describe TokenPolicy::Scope do
describe '#resolve' do
let!(:scope) { Token }
Expand Down

0 comments on commit 72c3b94

Please sign in to comment.