mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-06 01:08:50 +01:00
migrating to aasm - code part
This commit is contained in:
parent
65e3a8ff30
commit
00819ce27b
54 changed files with 2656 additions and 839 deletions
|
|
@ -58,7 +58,7 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
login_as(:admin_user)
|
||||
xhr :post, :update, :id => 1, "project"=>{"name"=>p.name, "description"=>p.description, "state"=>"hidden"}
|
||||
todos.each do |t|
|
||||
assert_equal :project_hidden, t.reload().current_state
|
||||
assert_equal :project_hidden, t.reload().aasm_current_state
|
||||
end
|
||||
assert p.reload().hidden?
|
||||
end
|
||||
|
|
@ -70,7 +70,7 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
xhr :post, :update, :id => 1, "project"=>{"name"=>p.name, "description"=>p.description, "state"=>"hidden"}
|
||||
xhr :post, :update, :id => 1, "project"=>{"name"=>p.name, "description"=>p.description, "state"=>"active"}
|
||||
todos.each do |t|
|
||||
assert_equal :active, t.reload().current_state
|
||||
assert_equal :active, t.reload().aasm_current_state
|
||||
end
|
||||
assert p.reload().active?
|
||||
end
|
||||
|
|
|
|||
|
|
@ -53,26 +53,26 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_project_initial_state_is_active
|
||||
assert_equal :active, @timemachine.current_state
|
||||
assert_equal :active, @timemachine.aasm_current_state
|
||||
assert @timemachine.active?
|
||||
end
|
||||
|
||||
def test_hide_project
|
||||
@timemachine.hide!
|
||||
assert_equal :hidden, @timemachine.current_state
|
||||
assert_equal :hidden, @timemachine.aasm_current_state
|
||||
assert @timemachine.hidden?
|
||||
end
|
||||
|
||||
def test_activate_project
|
||||
@timemachine.activate!
|
||||
assert_equal :active, @timemachine.current_state
|
||||
assert_equal :active, @timemachine.aasm_current_state
|
||||
assert @timemachine.active?
|
||||
end
|
||||
|
||||
def test_complete_project
|
||||
assert_nil @timemachine.completed_at
|
||||
@timemachine.complete!
|
||||
assert_equal :completed, @timemachine.current_state
|
||||
assert_equal :completed, @timemachine.aasm_current_state
|
||||
assert @timemachine.completed?
|
||||
assert_not_nil @timemachine.completed_at, "completed_at not expected to be nil"
|
||||
assert_in_delta Time.now, @timemachine.completed_at, 1
|
||||
|
|
@ -141,25 +141,27 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_transition_to_another_state
|
||||
assert_equal :active, @timemachine.current_state
|
||||
assert_equal :active, @timemachine.aasm_current_state
|
||||
@timemachine.transition_to(:hidden)
|
||||
assert_equal :hidden, @timemachine.current_state
|
||||
assert_equal :hidden, @timemachine.aasm_current_state
|
||||
@timemachine.transition_to(:completed)
|
||||
assert_equal :completed, @timemachine.current_state
|
||||
assert_equal :completed, @timemachine.aasm_current_state
|
||||
@timemachine.transition_to(:active)
|
||||
assert_equal :active, @timemachine.current_state
|
||||
assert_equal :active, @timemachine.aasm_current_state
|
||||
end
|
||||
|
||||
def test_transition_to_same_state
|
||||
assert_equal :active, @timemachine.current_state
|
||||
assert_equal :active, @timemachine.aasm_current_state
|
||||
@timemachine.transition_to(:active)
|
||||
assert_equal :active, @timemachine.current_state
|
||||
assert_equal :active, @timemachine.aasm_current_state
|
||||
end
|
||||
|
||||
def test_deferred_todo_count
|
||||
assert_equal 1, @timemachine.deferred_todos.count
|
||||
assert_equal 0, @moremoney.deferred_todos.count
|
||||
@moremoney.todos[0].show_from = next_week
|
||||
@moremoney.todos[0].save
|
||||
assert_equal :deferred, @moremoney.todos[0].aasm_current_state
|
||||
assert_equal 1, @moremoney.deferred_todos.count
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -276,11 +276,11 @@ class RecurringTodoTest < ActiveSupport::TestCase
|
|||
|
||||
def test_toggle_completion
|
||||
t = @yearly
|
||||
assert_equal :active, t.current_state
|
||||
assert_equal :active, t.aasm_current_state
|
||||
t.toggle_completion!
|
||||
assert_equal :completed, t.current_state
|
||||
assert_equal :completed, t.aasm_current_state
|
||||
t.toggle_completion!
|
||||
assert_equal :active, t.current_state
|
||||
assert_equal :active, t.aasm_current_state
|
||||
end
|
||||
|
||||
def test_starred
|
||||
|
|
|
|||
|
|
@ -77,10 +77,10 @@ class TodoTest < ActiveSupport::TestCase
|
|||
|
||||
def test_defer_an_existing_todo
|
||||
@not_completed2
|
||||
assert_equal :active, @not_completed2.current_state
|
||||
assert_equal :active, @not_completed2.aasm_current_state
|
||||
@not_completed2.show_from = next_week
|
||||
assert @not_completed2.save, "should have saved successfully" + @not_completed2.errors.to_xml
|
||||
assert_equal :deferred, @not_completed2.current_state
|
||||
assert_equal :deferred, @not_completed2.aasm_current_state
|
||||
end
|
||||
|
||||
def test_create_a_new_deferred_todo
|
||||
|
|
@ -88,16 +88,16 @@ class TodoTest < ActiveSupport::TestCase
|
|||
todo = user.todos.build
|
||||
todo.show_from = next_week
|
||||
todo.context_id = 1
|
||||
todo.description = 'foo'
|
||||
todo.description = 'foo'
|
||||
assert todo.save, "should have saved successfully" + todo.errors.to_xml
|
||||
assert_equal :deferred, todo.current_state
|
||||
assert_equal :deferred, todo.aasm_current_state
|
||||
end
|
||||
|
||||
def test_create_a_new_deferred_todo_by_passing_attributes
|
||||
user = users(:other_user)
|
||||
todo = user.todos.build(:show_from => next_week, :context_id => 1, :description => 'foo')
|
||||
todo = user.todos.build(:show_from => next_week, :context_id => 1, :description => 'foo')
|
||||
assert todo.save, "should have saved successfully" + todo.errors.to_xml
|
||||
assert_equal :deferred, todo.current_state
|
||||
assert_equal :deferred, todo.aasm_current_state
|
||||
end
|
||||
|
||||
def test_feed_options
|
||||
|
|
@ -108,11 +108,11 @@ class TodoTest < ActiveSupport::TestCase
|
|||
|
||||
def test_toggle_completion
|
||||
t = @not_completed1
|
||||
assert_equal :active, t.current_state
|
||||
assert_equal :active, t.aasm_current_state
|
||||
t.toggle_completion!
|
||||
assert_equal :completed, t.current_state
|
||||
assert_equal :completed, t.aasm_current_state
|
||||
t.toggle_completion!
|
||||
assert_equal :active, t.current_state
|
||||
assert_equal :active, t.aasm_current_state
|
||||
end
|
||||
|
||||
def test_activate_also_saves
|
||||
|
|
@ -154,7 +154,7 @@ class TodoTest < ActiveSupport::TestCase
|
|||
t.context_id = 1
|
||||
t.save!
|
||||
t.reload
|
||||
assert_equal :active, t.current_state
|
||||
assert_equal :active, t.aasm_current_state
|
||||
end
|
||||
|
||||
def test_initial_state_is_deferred_when_show_from_in_future
|
||||
|
|
@ -165,7 +165,7 @@ class TodoTest < ActiveSupport::TestCase
|
|||
t.show_from = 1.week.from_now.to_date
|
||||
t.save!
|
||||
t.reload
|
||||
assert_equal :deferred, t.current_state
|
||||
assert_equal :deferred, t.aasm_current_state
|
||||
end
|
||||
|
||||
def test_todo_is_not_starred
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue