Sha256: 396f47a98c024503954019ae9f50a17771fd4eeb3baf62a9a642b99b9ed71d3b
Contents?: true
Size: 731 Bytes
Versions: 2
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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
abilities-0.0.2 | test/controller_test.rb |
abilities-0.0.1 | test/controller_test.rb |