diff options
| author | Robert | 2017-07-04 18:59:26 +0200 |
|---|---|---|
| committer | Robert | 2017-07-04 21:54:04 +0200 |
| commit | 9d52ccea7b00b957bf6cf67a44029912ee6b171f (patch) | |
| tree | 701c2c793c4f0ff9d1cfec668986812bccf5019d /app/helpers | |
| parent | 16423b19122eefed728fc71e52d5c1660ff5575a (diff) | |
| download | chouette-core-9d52ccea7b00b957bf6cf67a44029912ee6b171f.tar.bz2 | |
Refs: #3478@3h; Policy Cleanup and Providing Policy and permissions for all models and actions
- ApplicationPolicy nondestructive permission depend on model existance
- ApplicationPolicy destructive permission default to `false`
- Tied Policy permissions at ApplicationPolicy Level: edit? → update?, new? → create?, index? → show?
- ApplicationPolicy convenience methods `delete?` & `authorizes_action?(action)`
- Refactoring of `spec/helpers/table_builder_helper_spec.rb` accordingly
- Stubbing scope in specs (cannot switch to referential with a `build_stubbed` instance)
Diffstat (limited to 'app/helpers')
| -rw-r--r-- | app/helpers/table_builder_helper/custom_links.rb | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/app/helpers/table_builder_helper/custom_links.rb b/app/helpers/table_builder_helper/custom_links.rb index 7890f3d35..68cb24c7a 100644 --- a/app/helpers/table_builder_helper/custom_links.rb +++ b/app/helpers/table_builder_helper/custom_links.rb @@ -41,23 +41,11 @@ module TableBuilderHelper end def authorized_actions - @actions.select(&method(:action_authorized?)) - end - def action_authorized?(action) - # TODO: Remove this guard when all resources have policies associated to them - return true unless policy - policy.public_send("#{action}?") - rescue NoMethodError - # TODO: When all action permissions are implemented for all policies remove this rescue clause - action_is_allowed_regardless_of_policy(action) + @actions.select(&policy.method(:authorizes_action?)) end private - def action_is_allowed_regardless_of_policy(action) - ![:delete, :edit, :archive, :unarchive, :duplicate, :actualize].include?(action) - end - def policy @__policy__ ||= Pundit.policy(user_context, object) end |
