Sha256: 10314219781609822800be8c7744691dbcb029a4e7fb4c0f57877e68edc38b9b
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require 'test_helper' class DecisionTest < Minitest::Test def setup StrongActions.config.config_files = File.join(File.dirname(__FILE__), 'config', 'acl.yml') end def decision @decision ||= StrongActions::Decision.new(self) end def current_user @user ||= User.new end def test_controller_true assert decision.call('current_user', 'books') end def test_controller_false assert ! decision.call('current_user', 'end_of_services') end def test_action_true assert decision.call('current_user', 'welcome', 'index') end def test_action_false assert ! decision.call('current_user', 'welcome', 'destroy') end def test_action_default_to_index assert decision.call('current_user', 'welcome') assert ! decision.call('current_user', 'sessions') end def test_admin_for_new current_user.admin = false assert decision.call('current_user', 'stores') assert ! decision.call('current_user', 'stores', 'new') current_user.admin = true assert decision.call('current_user', 'stores') assert decision.call('current_user', 'stores', 'new') end def test_role_undefined_and_not_needed assert decision.call('current_user', 'some_actions') assert decision.call('undefined', 'some_actions') end end class User attr_accessor :admin def admin? admin end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
strong_actions-0.0.5 | test/decision_test.rb |