1
0
Fork 0
mirror of https://github.com/varvet/pundit.git synced 2022-11-09 12:30:11 -05:00
Commit graph

23 commits

Author SHA1 Message Date
Jay Hayes
b9b2fdc162 Replace calls to hide_action with protected access modifier
* Rails 5 beta removes this interface
  https://github.com/rails/rails/pull/18371
* Using protected over private so that subclasses of the including class
  may still access these methods.
* Since these methods are called directly in test, we raise the access
  modifier to public for them to preserve the test behavior.
2016-02-02 13:43:23 -06:00
Jonas Nicklas
d079c86ebb Add Rubocop. 2016-01-14 15:30:03 +01:00
Jonas Nicklas
9862b60249 Add permitted_attributes_for_#{action} hook
Allows separate attributes for different actions. Closes #340
2016-01-14 14:43:51 +01:00
Jonas Nicklas
12df09400e Merge branch 'master' of https://github.com/ramaboo/pundit into ramaboo-master 2016-01-14 13:34:27 +01:00
David Singer
4f22dc1568 Better handling of policy finder for arrays and scoped models 2015-11-20 19:02:56 -08:00
Andrey Novikov
db74632a90 Fixes and simplifications for previous commit (to be squashed) 2015-07-15 12:58:54 +03:00
Andrey Novikov
12602720a5
Add autodetection and override of param key for permitted_attributes helper.
First, trying to get param key for ActiveModel objects, as Rails' `form_for` helper uses it to generate key for parameters hash. See 9f44aa0863/actionview/lib/action_view/helpers/form_helper.rb (L433) for reference.

Second, allowing to redefine it with `param_key` option (as element in optional second argument hash), it is useful in case of single table inheritance, when the param key is differs from actual class (as it is getting defined at runtime).

And last, use previous behaviour otherwise.

Fixes https://github.com/elabs/pundit/issues/286
2015-07-13 16:56:55 +03:00
Jason Daly
bb7ec831fb Fixes unexpected symbol-to-policy resolution described in #280 2015-05-08 20:55:02 -04:00
Jonas Nicklas
68372c9c17 Add permitted attributes helper, closes #141
See discussion in #141. This provides a convenient helper which aids in permitting attributes in the controller.
2015-03-30 09:20:03 +02:00
Thomas Walpole
2e3ccd4a4d test policy_scope with active record relations 2015-03-27 10:09:26 -07:00
Jonas Nicklas
66ba305eb8 Use #inspect over #to_s, closes #200 2015-03-27 10:22:41 +01:00
Jonas Nicklas and Kim Burgestrand
56a8bdee5a Implement authorize class method separately
This is a little less DRY, but `Pundit.authorize` doesn't have to take an extra policy as an argument.

Conflicts:
	lib/pundit.rb
	spec/spec_helper.rb
2015-03-26 10:34:45 +01:00
Jonas Nicklas and Kim Burgestrand
36ae4adabc Put blank check into finder, so we get better errors everywhere 2015-03-26 10:25:21 +01:00
Jonas Nicklas and Kim Burgestrand
52f42cf6a5 Merge branch 'namespaced-headless-policies' of https://github.com/techery/pundit into techery-namespaced-headless-policies 2015-03-26 10:03:11 +01:00
Eduardo Gutierrez
8ee11ef2fc Fix tests on ActiveSupport v4.2.x
* Remove use of `Kernel#capture` to find RSpec deprecation warnings
  because it has has been deprecated.
* Add `require "active_support"` to setup auto-loading.

Closes #252.
2015-03-10 09:31:04 -04:00
Sergey Stupachenko
9711b4896b Add array-based syntax for namespaced headless policies
Before to namespace headless policy we needed to use following syntax:
  authorize :'project/dashboard'

Now we can use array to specify each constant separately so it looks cleaner
  authorize [:project, :dashboard]
2014-10-11 16:05:10 +03:00
Jonas Nicklas
753bb0a2b6 Revert namespaces 2014-08-22 11:19:36 +02:00
Jonas Nicklas
9d578a0a2d Make sure Pundit doesn’t generate any deprecation warnings with any version of RSpec 2014-07-18 16:20:48 +02:00
Jonas Nicklas
1942db052b Merge pull request #168 from elabs/headless-policies
Enable headless policies
2014-07-17 11:31:37 +02:00
Unknown_Guy
bf29cae128 find correct policy when model is namespaced 2014-07-15 13:08:08 +03:00
Thomas Klemm
b18d16ca10 Enable headless policies
Enables `policy(:dashboard) # => DashboardPolicy`.

Policies without a matching model can come in handy when a controller
isn't modeled alongside a resource, e.g. a `DashboardsController`.

The policy lookup by symbol also helps with strong parameters,
since I prefer `policy(:post)` or `policy(@post || :post)` over `policy(@post || Post)`.
2014-07-13 12:48:45 +02:00
Eduardo Gutierrez
4c7d3c4dd6 Lookup policies in the current namespace
Addresses #12. If the policy is not defined in `namespace`, `const_get`
will search through the inheritance change of `namespace` to find the
policy.
2014-05-22 12:55:34 -04:00
Dillon Benson
30b7861431 moved class definitions from pundit_spec.rb to spec_helper.rb 2014-04-23 22:58:38 -04:00