Upgrade to Rails 2.2.0
As a side benefit, fix an (non-user-visible) bug in display_s5(). Also fixed a bug where removing orphaned pages did not expire cached summary pages.
This commit is contained in:
parent
39348c65c2
commit
7600aef48b
827 changed files with 123652 additions and 11027 deletions
74
vendor/rails/activemodel/test/state_machine/state_test.rb
vendored
Normal file
74
vendor/rails/activemodel/test/state_machine/state_test.rb
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
||||
|
||||
class StateTestSubject
|
||||
include ActiveModel::StateMachine
|
||||
|
||||
state_machine do
|
||||
end
|
||||
end
|
||||
|
||||
class StateTest < ActiveModel::TestCase
|
||||
def setup
|
||||
@name = :astate
|
||||
@machine = StateTestSubject.state_machine
|
||||
@options = { :crazy_custom_key => 'key', :machine => @machine }
|
||||
end
|
||||
|
||||
def new_state(options={})
|
||||
ActiveModel::StateMachine::State.new(@name, @options.merge(options))
|
||||
end
|
||||
|
||||
test 'sets the name' do
|
||||
assert_equal :astate, new_state.name
|
||||
end
|
||||
|
||||
test 'sets the display_name from name' do
|
||||
assert_equal "Astate", new_state.display_name
|
||||
end
|
||||
|
||||
test 'sets the display_name from options' do
|
||||
assert_equal "A State", new_state(:display => "A State").display_name
|
||||
end
|
||||
|
||||
test 'sets the options and expose them as options' do
|
||||
@options.delete(:machine)
|
||||
assert_equal @options, new_state.options
|
||||
end
|
||||
|
||||
test 'equals a symbol of the same name' do
|
||||
assert_equal new_state, :astate
|
||||
end
|
||||
|
||||
test 'equals a State of the same name' do
|
||||
assert_equal new_state, new_state
|
||||
end
|
||||
|
||||
uses_mocha 'state actions' do
|
||||
test 'should send a message to the record for an action if the action is present as a symbol' do
|
||||
state = new_state(:entering => :foo)
|
||||
|
||||
record = stub
|
||||
record.expects(:foo)
|
||||
|
||||
state.call_action(:entering, record)
|
||||
end
|
||||
|
||||
test 'should send a message to the record for an action if the action is present as a string' do
|
||||
state = new_state(:entering => 'foo')
|
||||
|
||||
record = stub
|
||||
record.expects(:foo)
|
||||
|
||||
state.call_action(:entering, record)
|
||||
end
|
||||
|
||||
test 'should call a proc, passing in the record for an action if the action is present' do
|
||||
state = new_state(:entering => Proc.new {|r| r.foobar})
|
||||
|
||||
record = stub
|
||||
record.expects(:foobar)
|
||||
|
||||
state.call_action(:entering, record)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue