Sha256: 9cbdbb00c656f16c5a60af85eb8bc005d8732aa5edc79822a6b656b8c1938ca9

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

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

class MaintenanceTest < Test::Unit::TestCase

  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
    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

6 entries across 6 versions & 3 rubygems

Version Path
stffn-declarative_authorization-0.3.1 test/maintenance_test.rb
stffn-declarative_authorization-0.3.2.1 test/maintenance_test.rb
stffn-declarative_authorization-0.3.2 test/maintenance_test.rb
tma-declarative_authorization-0.3.2.1 test/maintenance_test.rb
tma-declarative_authorization-0.3.2.2 test/maintenance_test.rb
uhees-declarative_authorization-0.3.1 test/maintenance_test.rb