Skip to content

Commit

Permalink
Allow :create Entry only for publishers on accounts, not on entries
Browse files Browse the repository at this point in the history
The previous implementation also allowed entry publishers as long as
they were also publishers of at least one (possibly unrelated)
account.
  • Loading branch information
aviav authored and tf committed Aug 22, 2017
1 parent 574c1e5 commit 82ac17e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/policies/pageflow/entry_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def publish?
end

def create?
publish? && AccountPolicy::Scope.new(user, Account).entry_creatable.any?
query.has_at_least_account_role?(:publisher)
end

def duplicate?
Expand Down
7 changes: 6 additions & 1 deletion spec/policies/pageflow/entry_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ module Pageflow
it_behaves_like 'a membership-based permission that',
allows: :publisher,
but_forbids: :editor,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
to: :create,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
forbids: :manager,
of_entry: -> (topic) { topic },
to: :create,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :publisher,
but_forbids: :editor,
Expand Down

0 comments on commit 82ac17e

Please sign in to comment.