Skip to content

Commit

Permalink
Use of_entry_or_its_account for readable policy specs
Browse files Browse the repository at this point in the history
  • Loading branch information
tf committed Aug 22, 2017
1 parent 4d96847 commit a5b7459
Showing 1 changed file with 15 additions and 30 deletions.
45 changes: 15 additions & 30 deletions spec/policies/pageflow/entry_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,35 @@ module Pageflow
it_behaves_like 'a membership-based permission that',
allows: :manager,
but_forbids: :publisher,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :manage,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :manager,
but_forbids: :publisher,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :add_member_to,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :manager,
but_forbids: :publisher,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :edit_role_on,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :manager,
but_forbids: :publisher,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :destroy_membership_on,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :publisher,
but_forbids: :editor,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :publish,
topic: -> { create(:entry) }

Expand All @@ -58,77 +53,67 @@ module Pageflow
it_behaves_like 'a membership-based permission that',
allows: :publisher,
but_forbids: :editor,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :duplicate,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :editor,
but_forbids: :previewer,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :edit,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :editor,
but_forbids: :previewer,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :index_widgets_for,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :editor,
but_forbids: :previewer,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :edit_outline,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :editor,
but_forbids: :previewer,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :restore,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :editor,
but_forbids: :previewer,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :snapshot,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :editor,
but_forbids: :previewer,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :confirm_encoding,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :previewer,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :preview,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :previewer,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :read,
topic: -> { create(:entry) }

it_behaves_like 'a membership-based permission that',
allows: :previewer,
of_entry: -> (topic) { topic },
of_account: -> (topic) { topic.account },
of_entry_or_its_account: -> (topic) { topic },
to: :use_files,
topic: -> { create(:entry) }

Expand Down

0 comments on commit a5b7459

Please sign in to comment.