Closed ilyasovd closed 5 years ago
@ilyasovd thanks for PR. Could you rebase from current master branch? (I dropped support for <2.3 ruby versions and added 2.6)
Also, I think I found a bug in this solution (correct me please if I'm wrong). If we register alias and after that register ability for alias we will call alias ability instead new ability.
Example:
class Post::Abilities
include Kan::Abilities
register(:edit) { |_, _| true }
register_alias(:correct, 'edit')
register(:correct) { |_, _| false }
end
abilities = Kan::Application.new(
post: Post::Abilities.new
)
abilities['post.correct'].call(current_user, post) # => true
WDYT? Could you also add tests for this case?
@davydovanton yeah, I agree with you. Do you think that it should return the last ability result or raising an error that name has already taken? I think the last ability result will be better.
@davydovanton I've rebased request but Travis CI still red. Looks like ruby 2.6.2 have to be 2.6.0. :)
Reference to https://github.com/davydovanton/kan/issues/33