Sha256: fd095feca66990c46f74d369f0973d2973fbad9bd1ef6c0b2dbf5010e0aa0be2

Contents?: true

Size: 1.32 KB

Versions: 14

Compression:

Stored size: 1.32 KB

Contents

require_relative 'base'

module ControllerExtensions
  class ConditionsTest < Base
    [:if, :unless].each do |cond|
      test "should raise ArgumentError when #{cond} is not a Symbol" do
         assert_raise ArgumentError do
          @tester.acl_block! { allow nil, cond => 123 }
        end
      end
    end

    test "allow ... :if" do
      @tester.acl_block! do
        allow nil, :if => :meth
      end
      assert_permitted nil, :call => OpenStruct.new(:meth => true)
      assert_forbidden nil, :call => OpenStruct.new(:meth => false)
    end

    test "allow ... :unless" do
      @tester.acl_block! do
        allow nil, :unless => :meth
      end
      assert_permitted nil, :call => OpenStruct.new(:meth => false)
      assert_forbidden nil, :call => OpenStruct.new(:meth => true)
    end

    test "deny ... :if" do
      @tester.acl_block! do
        default :allow
        deny nil, :if => :meth
      end
      assert_permitted nil, :call => OpenStruct.new(:meth => false)
      assert_forbidden nil, :call => OpenStruct.new(:meth => true)
    end

    test "deny ... :unless" do
      @tester.acl_block! do
        default :allow
        deny nil, :unless => :meth
      end
      assert_permitted nil, :call => OpenStruct.new(:meth => true)
      assert_forbidden nil, :call => OpenStruct.new(:meth => false)
    end

  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
careacademy-acl9-3.4.0 test/controller_extensions/conditions_test.rb
careacademy-acl9-3.3.0 test/controller_extensions/conditions_test.rb
acl9-3.2.0 test/controller_extensions/conditions_test.rb
acl9-3.1.0 test/controller_extensions/conditions_test.rb
acl9-3.0.0 test/controller_extensions/conditions_test.rb
acl9-2.1.2 test/controller_extensions/conditions_test.rb
acl9-2.1.1 test/controller_extensions/conditions_test.rb
acl9-2.1.0 test/controller_extensions/conditions_test.rb
acl9-2.0.0 test/controller_extensions/conditions_test.rb
acl9-1.3.0 test/controller_extensions/conditions_test.rb
acl9-1.2.1 test/controller_extensions/conditions_test.rb
acl9-1.2.0 test/controller_extensions/conditions_test.rb
acl9-1.1.0 test/controller_extensions/conditions_test.rb
acl9-1.0.0 test/controller_extensions/conditions_test.rb