Test for aasm guard arguments (#485)
This commit is contained in:
parent
cc45d56773
commit
851dcc36fd
|
@ -0,0 +1,17 @@
|
||||||
|
class GuardArgumentsCheck
|
||||||
|
include AASM
|
||||||
|
|
||||||
|
aasm do
|
||||||
|
state :new, :reviewed, :finalized
|
||||||
|
|
||||||
|
event :mark_as_reviewed,
|
||||||
|
:guard => proc { |*args| arguments_list(*args) } do
|
||||||
|
transitions :from => :new, :to => :reviewed
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def arguments_list(arg1, arg2)
|
||||||
|
return false unless arg1.nil?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "nil as first argument" do
|
||||||
|
let(:guard) { GuardArgumentsCheck.new }
|
||||||
|
|
||||||
|
it 'does not raise errors' do
|
||||||
|
expect { guard.mark_as_reviewed(nil, 'second arg') }.not_to raise_error
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue