Sha256: 1d961fd1a8bc42bebd6f5230e14f059159a07aeeb40b3716b0376b95676875b3

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require 'test_helper'
require File.join(File.dirname(__FILE__), %w{.. lib declarative_authorization maintenance})

class MaintenanceTest < Test::Unit::TestCase
  include Authorization::TestHelper

  def test_usages_by_controllers
    usage_test_controller = Class.new(ActionController::Base)
    usage_test_controller.send(:define_method, :an_action) {}
    usage_test_controller.filter_access_to :an_action

    assert Authorization::Maintenance::Usage::usages_by_controller.
              include?(usage_test_controller)
  end

  def test_without_access_control
    reader = Authorization::Reader::DSLReader.new
    reader.parse %{
      authorization do
        role :test_role do
          has_permission_on :permissions, :to => :test
        end
      end
    }
    engine = Authorization::Engine.new(reader)
    assert !engine.permit?(:test_2, :context => :permissions,
        :user => MockUser.new(:test_role))
    Authorization::Maintenance::without_access_control do
      assert engine.permit!(:test_2, :context => :permissions,
          :user => MockUser.new(:test_role))
    end
    without_access_control do
      assert engine.permit?(:test_2, :context => :permissions,
          :user => MockUser.new(:test_role))
    end
    Authorization::Maintenance::without_access_control do
      Authorization::Maintenance::without_access_control do
        assert engine.permit?(:test_2, :context => :permissions,
            :user => MockUser.new(:test_role))
      end
      assert engine.permit?(:test_2, :context => :permissions,
          :user => MockUser.new(:test_role))
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ae_declarative_authorization-0.7.1 test/maintenance_test.rb