fix #1027. Several tests were broken because of the more strict validations on the recurring_todo model

This commit is contained in:
Reinier Balt 2010-05-13 18:24:26 +02:00
parent 92bb54bbf5
commit cfc6d117b8
6 changed files with 25 additions and 13 deletions

View file

@ -30,7 +30,6 @@ class RecurringTodo < ActiveRecord::Base
validates_presence_of :description
validates_presence_of :recurring_period
validates_presence_of :target
validates_presence_of :recurring_period
validates_presence_of :ends_on
validates_presence_of :context

View file

@ -1,4 +1,3 @@
<%
def today
Time.zone.now.beginning_of_day.to_s(:db)
@ -30,7 +29,7 @@ call_bill_gates_every_day:
description: Call Bill Gates every day
notes: ~
state: active
start_from: ~
start_from: <%= last_week %>
ends_on: no_end_date
end_date: ~
number_of_occurences: ~
@ -38,6 +37,7 @@ call_bill_gates_every_day:
show_from_delta: ~
recurring_period: daily
recurrence_selector: ~
show_always: 0
every_other1: 1
every_other2: ~
every_other3: ~
@ -62,6 +62,7 @@ call_bill_gates_every_workday:
number_of_occurences: ~
target: due_date
show_from_delta: ~
show_always: 0
recurring_period: daily
recurrence_selector: ~
every_other1: 1
@ -82,7 +83,7 @@ call_bill_gates_every_week:
description: Call Bill Gates every week
notes: ~
state: active
start_from: ~
start_from: <%= today %>
ends_on: no_end_date
end_date: ~
number_of_occurences: ~
@ -90,6 +91,7 @@ call_bill_gates_every_week:
show_from_delta: ~
recurring_period: weekly
recurrence_selector: ~
show_always: 0
every_other1: 2
every_other2: ~
every_other3: ~
@ -108,7 +110,7 @@ check_with_bill_every_last_friday_of_month:
description: Check with Bill every last friday of the month
notes: ~
state: active
start_from: ~
start_from: <%= today %>
ends_on: no_end_date
end_date: ~
number_of_occurences: ~
@ -116,6 +118,7 @@ check_with_bill_every_last_friday_of_month:
show_from_delta: 5
recurring_period: monthly
recurrence_selector: 1
show_always: 0
every_other1: 1
every_other2: 2
every_other3: 5
@ -134,12 +137,13 @@ birthday_reinier:
description: Congratulate Reinier on his birthday
notes: ~
state: active
start_from: ~
start_from: <%= today %>
ends_on: no_end_date
end_date: ~
number_of_occurences: ~
target: due_date
show_from_delta: 5
show_always: 0
recurring_period: yearly
recurrence_selector: 0
every_other1: 8

View file

@ -51,7 +51,7 @@ class LoginControllerTest < ActionController::TestCase
def test_login_with_no_users_redirects_to_signup
User.delete_all
get :login
assert_redirected_to :controller => 'users', :action => 'new'
assert_redirected_to signup_url
end
def test_logout

View file

@ -50,6 +50,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
"recurring_period"=>"yearly",
"recurring_show_days_before"=>"10",
"recurring_target"=>"due_date",
"recurring_show_always" => "1",
"start_from"=>"18/08/2008",
"weekly_every_x_week"=>"1",
"weekly_return_monday"=>"m",
@ -110,6 +111,9 @@ class RecurringTodosControllerTest < ActionController::TestCase
@yearly.every_other1 = target_date.day
@yearly.every_other2 = target_date.month
@yearly.show_from_delta = 10
# unless @yearly.valid?
# @yearly.errors.each {|obj, error| puts error}
# end
assert @yearly.save
# toggle twice to force generation of new todo
@ -155,6 +159,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
"recurring_period"=>"yearly",
"recurring_show_days_before"=>"0",
"recurring_target"=>"due_date",
"recurring_show_always" => "1",
"start_from"=>"1/10/2012", # adjust after 2012
"weekly_every_x_week"=>"1",
"weekly_return_monday"=>"w",

View file

@ -376,12 +376,16 @@ class TodosControllerTest < ActionController::TestCase
# change recurrence pattern to monthly and set show_from 2 days before due
# date this forces the next todo to be put in the tickler
recurring_todo_1.show_from_delta = 2
recurring_todo_1.show_always = 0
recurring_todo_1.target = 'due_date'
recurring_todo_1.recurring_period = 'monthly'
recurring_todo_1.recurrence_selector = 0
recurring_todo_1.every_other1 = 1
recurring_todo_1.every_other2 = 2
recurring_todo_1.every_other3 = 5
recurring_todo_1.save
# use assert to catch validation errors if present. we need to replace
# this with a good factory implementation
assert recurring_todo_1.save
# mark next_todo as complete by toggle_check
xhr :post, :toggle_check, :id => next_todo.id, :_source_view => 'todo'
@ -416,7 +420,7 @@ class TodosControllerTest < ActionController::TestCase
recurring_todo_1.recurrence_selector = 0
recurring_todo_1.every_other1 = today.day
recurring_todo_1.every_other2 = 1
recurring_todo_1.save
assert recurring_todo_1.save
# mark todo_1 as complete by toggle_check, this gets rid of todo_1 that was
# not correctly created from the adjusted recurring pattern we defined

View file

@ -154,19 +154,19 @@ class UsersControllerTest < ActionController::TestCase
def test_create_with_invalid_password_redirects_to_new_user_page
login_as :admin_user
post :create, :user => {:login => 'newbie', :password => '', :password_confirmation => ''}
assert_redirected_to :controller => 'users', :action => 'new'
assert_redirected_to signup_path
end
def test_create_with_invalid_login_does_not_add_a_new_user
login_as :admin_user
post :create, :user => {:login => 'n', :password => 'newbiepass', :password_confirmation => 'newbiepass'}
assert_redirected_to :controller => 'users', :action => 'new'
assert_redirected_to signup_path
end
def test_create_with_invalid_login_redirects_to_new_user_page
login_as :admin_user
post :create, :user => {:login => 'n', :password => 'newbiepass', :password_confirmation => 'newbiepass'}
assert_redirected_to :controller => 'users', :action => 'new'
assert_redirected_to signup_path
end
def test_create_with_duplicate_login_does_not_add_a_new_user
@ -179,7 +179,7 @@ class UsersControllerTest < ActionController::TestCase
def test_create_with_duplicate_login_redirects_to_new_user_page
login_as :admin_user
post :create, :user => {:login => 'jane', :password => 'newbiepass', :password_confirmation => 'newbiepass'}
assert_redirected_to :controller => 'users', :action => 'new'
assert_redirected_to signup_path
end
end