mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-20 17:20:12 +01:00
add test for #1068
This commit is contained in:
parent
72b2d4dfc9
commit
6744a22633
2 changed files with 51 additions and 3 deletions
|
|
@ -110,9 +110,9 @@ class RecurringTodosControllerTest < ActionController::TestCase
|
||||||
@yearly.every_other1 = target_date.day
|
@yearly.every_other1 = target_date.day
|
||||||
@yearly.every_other2 = target_date.month
|
@yearly.every_other2 = target_date.month
|
||||||
@yearly.show_from_delta = 10
|
@yearly.show_from_delta = 10
|
||||||
# unless @yearly.valid?
|
# unless @yearly.valid?
|
||||||
# @yearly.errors.each {|obj, error| puts error}
|
# @yearly.errors.each {|obj, error| puts error}
|
||||||
# end
|
# end
|
||||||
assert @yearly.save
|
assert @yearly.save
|
||||||
|
|
||||||
# toggle twice to force generation of new todo
|
# toggle twice to force generation of new todo
|
||||||
|
|
@ -236,4 +236,5 @@ class RecurringTodosControllerTest < ActionController::TestCase
|
||||||
assert_equal "due_date", recurring_todo.target
|
assert_equal "due_date", recurring_todo.target
|
||||||
assert_equal true, recurring_todo.show_always?
|
assert_equal true, recurring_todo.show_always?
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
47
test/integration/recurring_todos_test.rb
Normal file
47
test/integration/recurring_todos_test.rb
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
require 'todos_controller'
|
||||||
|
require 'recurring_todos_controller'
|
||||||
|
|
||||||
|
class RecurringTodosTest < ActionController::IntegrationTest
|
||||||
|
fixtures :users, :preferences, :projects, :contexts, :todos, :tags, :taggings, :recurring_todos
|
||||||
|
|
||||||
|
def logs_in_as(user,plain_pass)
|
||||||
|
@user = user
|
||||||
|
post "/login", :user_login => @user.login,
|
||||||
|
:user_password => plain_pass,
|
||||||
|
:user_noexpiry => 'n'
|
||||||
|
assert_response :redirect
|
||||||
|
follow_redirect!
|
||||||
|
assert_response :success
|
||||||
|
assert_template "todos/index"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
assert rt.todos.size, 1 # and it has one todos referencing it
|
||||||
|
|
||||||
|
# when I toggle the todo complete
|
||||||
|
todo = Todo.find_by_recurring_todo_id(1)
|
||||||
|
post "/todos/toggle_check/#{todo.id}", :_source_view => 'todo'
|
||||||
|
todo.reload
|
||||||
|
assert todo.completed?
|
||||||
|
|
||||||
|
rt.reload # then there should be two todos referencing
|
||||||
|
assert rt.todos.size, 2
|
||||||
|
todo2 = Todo.find(:first, :conditions => {:recurring_todo_id => rt.id, :state => 'active'})
|
||||||
|
assert_not_equal todo2.id, todo.id # and the todos should be different
|
||||||
|
|
||||||
|
# when I delete the recurring todo
|
||||||
|
delete_via_redirect "/recurring_todos/#{rt.id}", :_source_view => 'todo'
|
||||||
|
|
||||||
|
todo.reload
|
||||||
|
todo2.reload
|
||||||
|
|
||||||
|
assert todo.recurring_todo_id.nil?
|
||||||
|
assert todo2.recurring_todo_id.nil?
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue