Sha256: f152caae78a44b1c1234ab29036f34a5b22f0384b328cc2df0cf75306951594c
Contents?: true
Size: 731 Bytes
Versions: 4
Compression:
Stored size: 731 Bytes
Contents
require 'test_helper' class ControllerTest < ActiveSupport::TestCase test 'can helper' do assert controller.send(:can?, :create, post) end test 'cannot helper' do assert controller.send(:cannot?, :read, post) end test 'authorize helper' do assert_nothing_raised do controller.send :authorize!, :create, post end assert_raises Abilities::AccessDenied do controller.send :authorize!, :read, post end end private def controller @controller ||= ActionController::Base.new.tap do |controller| controller.class_eval do define_method :current_user do @user ||= User.new end end end end def post @post ||= Post.new end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
abilities-0.1.2 | test/controller_test.rb |
abilities-0.1.0 | test/controller_test.rb |
abilities-0.0.4 | test/controller_test.rb |
abilities-0.0.3 | test/controller_test.rb |