Sha256: 6eee1f048165e27be4c5ca9e47fbd9e9b1246632723f276144886ecaf7659f67

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 Bytes

Contents

require 'test_helper'

class ActionControlTest < ActiveSupport::TestCase
	def reinstatiate
		@authorizable = Class.new do
			include ActionControl
		end
	end

	setup do
		reinstatiate
	end

	test 'should raise `AuthorizationNotPerformedError` if #authorized? is not defined' do
		assert_raise ActionControl::AuthorizationNotPerformedError do
			@authorizable.new.authorize!
		end
	end

	test 'should raise `NotAuthorizedError` if #authorized? not returns true' do
		@authorizable.class_eval do
			define_method :authorized? do
				false
			end
		end

		assert_raise ActionControl::NotAuthorizedError do
			@authorizable.new.authorize!
		end
	end

	test 'should raise no exception if #authorized? returns true' do
		@authorizable.class_eval do
			define_method :authorized? do
				true
			end
		end

		assert_nothing_raised do
			@authorizable.new.authorize!
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
action_control-0.0.2 test/action_control_test.rb