tracks/test/integration/recurring_todos_test.rb

34 lines
1.1 KiB
Ruby
Raw Normal View History

2014-05-16 18:03:13 -04:00
require 'test_helper'
2011-02-04 23:04:56 +01:00
2013-05-11 23:13:16 +02:00
class RecurringTodosTest < ActionDispatch::IntegrationTest
2011-02-04 23:04:56 +01:00
def test_deleting_recurring_todo_clears_reference_from_related_todos
logs_in_as(users(:admin_user), 'abracadabra')
rt = RecurringTodo.find(1)
assert !rt.nil? # given there is a recurring todo
2012-04-27 14:22:16 +02:00
assert_equal 1, rt.todos.size # and it has one todo referencing it
2011-02-04 23:04:56 +01:00
# when I toggle the todo complete
todo = Todo.where(:recurring_todo_id => 1).first
put "/todos/#{todo.id}/toggle_check", params: { :_source_view => 'todo' }
2011-02-04 23:04:56 +01:00
todo.reload
assert todo.completed?
rt.reload # then there should be two todos referencing
2012-04-27 14:22:16 +02:00
assert_equal 2, rt.todos.size
todo2 = Todo.where(:recurring_todo_id => rt.id, :state => 'active').first
refute_equal todo2.id, todo.id # and the todos should be different
2011-02-04 23:04:56 +01:00
# when I delete the recurring todo
delete "/recurring_todos/#{rt.id}", params: { :_source_view => 'todo' }
follow_redirect!
2011-02-04 23:04:56 +01:00
todo.reload
todo2.reload
assert todo.recurring_todo_id.nil?
assert todo2.recurring_todo_id.nil?
end
end