Consul 0.4.2 improves querying of nil powers
Previous versions of
Consul
Show archive.org snapshot
exhibited strange behavior when querying a power that returns nil
.
Consul 0.4.2+ behaves as expected:
power.notes # => returns nil
power.notes? # => returns false
power.notes! # => raises Consul::Powerless
power.note?(Note.last) # => returns false
power.note!(Note.last) # => raises Consul::Powerless
Related cards:
Consul: Querying a power that might be nil
Consul 0.6.1+ gives your Power
class a number of static methods that behave neutrally in case Power.current
is nil
. This allows you to create authorization-aware models that still work when there is no u...
Consul: Dynamically access and query powers for a given name, model class or record
Consul 0.6.1+ gives you a way to dynamically access and query powers for a given name, model class or record.
A common use case for this are generic helper methods, e.g. a method to display an "edit" link for ...
Consul 0.10.0 allows multiple power mappings for nested resources
Consul 0.10.0 now allows multiple power mappings for nested resources.
When using nested resources you probably want two power
...
Beware of params with non-string values (nil, array, hash)
Recent rails security updates have shown that people make incorrect assumptions about the possible contents of the params
hash.
Just don't make any! Treat it as what it is: potentially unsafe user input. For example:
/pages/edit?foo= --...
Consul 0.5.0 is faster for admins, allows to define multiple powers at once
When calling a scope like current_power.user?(user)
, Consul will no longer trigger a query if the users
power selects all records (SELECT * from users
). This should make such checks much faster for users who can access many records, like adm...
RSpec: Leverage the power of Capybara Finders and Matchers for view specs
View specs are a powerful tool to test several rendering paths by their cases instead of using a more costing feature spec. This is especially useful because they become quite co...
Using the full power of have_css
Capybara's has_css?
matcher has a couple of options you might find useful.
Check that a selector appears a given number of times
Use the :count
option like this:
Then /^I shoul...
Pitfall: has_defaults on virtual attributes are nil when loaded from database, of course …
It smells. Rethink your code design.
Code example with makandra/has_defaults:
class Post < ActiveRecord::Base
has_defaults tags: [] # field in db
has_defaults virtual_tags: [] # no d...
Consul 0.4.0 released
Consul 0.4.0 comes with some new features.
Dependencies
- Consul no longer requires
assignable_values
, it's optional for when you want to use theauthorize_values_for
macro. - Consul no longer uses
ActiveSupport::Memoizable
...
Consul 0.9 lets you optimize records checks
Consul 0.9 comes with many new features to optimize powers that only check access to a given record. e.g. Power.current.post?(Post.last)
. See below for details.
Powers that only check a given object
-------...