another set of dynamic finder migrations. All non-cucumber tests pass

This commit is contained in:
Reinier Balt 2013-02-27 11:50:49 +01:00
parent 64a198d45a
commit ef91dd0c64
18 changed files with 66 additions and 66 deletions

View file

@ -20,7 +20,7 @@ class LoginControllerTest < ActionController::TestCase
def test_login_with_valid_admin_user
@request.session['return-to'] = "/bogus/location"
post :login, {:user_login => 'admin', :user_password => 'abracadabra', :user_noexpiry => 'on'}
user = User.find_by_id(session['user_id'])
user = User.find(session['user_id'])
assert_not_nil user
assert_equal user.id, session['user_id']
assert_equal user.login, "admin"
@ -31,7 +31,7 @@ class LoginControllerTest < ActionController::TestCase
def test_login_with_valid_standard_user
post :login, {:user_login => 'jane', :user_password => 'sesame', :user_noexpiry => 'off'}
user = User.find_by_id(session['user_id'])
user = User.find(session['user_id'])
assert_not_nil user
assert_equal user.id, session['user_id']
assert_equal user.login, "jane"

View file

@ -74,7 +74,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
assert recurring_todo_1.completed?
# remove remaining todo
todo = Todo.find_by_recurring_todo_id(1)
todo = Todo.where(:recurring_todo_id => 1).first
todo.recurring_todo_id = 2
todo.save
@ -89,7 +89,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
assert_equal todo_count+1, Todo.count
# find the new todo and check its description
new_todo = Todo.find_by_recurring_todo_id 1
new_todo = Todo.where(:recurring_todo_id => 1).first
assert_equal "Call Bill Gates every day", new_todo.description
end
@ -113,7 +113,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
xhr :post, :toggle_check, :id=>5, :_source_view=>""
xhr :post, :toggle_check, :id=>5, :_source_view=>""
new_todo = Todo.find_by_recurring_todo_id 5
new_todo = Todo.where(:recurring_todo_id => 5).first
# due date should be the target_date
assert_equal users(:admin_user).at_midnight(Date.new(target_date.year, target_date.month, target_date.day)), new_todo.due
@ -171,7 +171,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
assert_equal orig_todo_count+1, Todo.count
# find the newly created todo
new_todo = Todo.find_by_description("new recurring pattern")
new_todo = Todo.where(:description => "new recurring pattern").first
assert !new_todo.nil?
# the date should be 31 march 2013
@ -224,7 +224,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
assert_equal orig_todo_count+1, Todo.count
# find the newly created recurring todo
recurring_todo = RecurringTodo.find_by_description("new recurring pattern")
recurring_todo = RecurringTodo.where(:description => "new recurring pattern").first
assert !recurring_todo.nil?
assert_equal "due_date", recurring_todo.target
@ -235,7 +235,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
login_as(:admin_user)
rt = RecurringTodo.find(recurring_todos(:call_bill_gates_every_day).id)
todo = Todo.find_by_recurring_todo_id(rt.id)
todo = Todo.where(:recurring_todo_id => rt.id).first
assert_not_nil todo
assert_equal "active", todo.state, "todo should be active"

View file

@ -114,7 +114,7 @@ class TodosControllerTest < ActionController::TestCase
def test_find_tagged_with
login_as(:admin_user)
@user = User.find(@request.session['user_id'])
tag = Tag.find_by_name('foo').taggings
tag = Tag.where(:name => 'foo').first.taggings
@tagged = tag.count
get :tag, :name => 'foo'
assert_response :success
@ -260,7 +260,7 @@ class TodosControllerTest < ActionController::TestCase
# find a,b,c and d
%w{a b c d}.each do |todo|
eval "@#{todo} = Todo.find_by_description('#{todo}')"
eval "@#{todo} = Todo.where(:description => '#{todo}').first"
eval "assert !@#{todo}.nil?, 'a todo with description \"#{todo}\" should just have been added'"
end
@ -275,7 +275,7 @@ class TodosControllerTest < ActionController::TestCase
def test_destroy_todo
login_as(:admin_user)
xhr :post, :destroy, :id => 1, :_source_view => 'todo'
todo = Todo.find_by_id(1)
todo = Todo.where(:id=>1).first
assert_nil todo
end
@ -551,7 +551,7 @@ class TodosControllerTest < ActionController::TestCase
"show_from(1i)"=>"", "show_from(2i)"=>"", "show_from(3i)"=>"",
"project_id"=>"1",
"notes"=>"test notes", "description"=>"test_mobile_create_action"}}
t = Todo.find_by_description("test_mobile_create_action")
t = Todo.where(:description => "test_mobile_create_action").first
assert_not_nil t
assert_equal 2, t.context_id
assert_equal 1, t.project_id
@ -590,7 +590,7 @@ class TodosControllerTest < ActionController::TestCase
# link todo_1 and recurring_todo_1
recurring_todo_1 = RecurringTodo.find(1)
todo_1 = Todo.find_by_recurring_todo_id(1)
todo_1 = Todo.where(:recurring_todo_id => 1).first
# mark todo_1 as complete by toggle_check
xhr :post, :toggle_check, :id => todo_1.id, :_source_view => 'todo'
@ -645,7 +645,7 @@ class TodosControllerTest < ActionController::TestCase
# link todo_1 and recurring_todo_1
recurring_todo_1 = RecurringTodo.find(1)
#set_user_to_current_time_zone(recurring_todo_1.user)
todo_1 = Todo.find_by_recurring_todo_id(1)
todo_1 = Todo.where(:recurring_todo_id => 1).first
today = Time.zone.now.at_midnight
# change recurrence pattern to monthly and set show_from to today
@ -694,7 +694,7 @@ class TodosControllerTest < ActionController::TestCase
login_as :admin_user
recurring_todo_1 = RecurringTodo.find(5)
@todo = Todo.find_by_recurring_todo_id(1)
@todo = Todo.where(:recurring_todo_id => 1).first
assert @todo.from_recurring_todo?
# rewire @todo to yearly recurring todo
@todo.recurring_todo_id = 5

View file

@ -26,14 +26,14 @@ class UsersControllerTest < ActionController::TestCase
User.per_page = 1
login_as :admin_user
get :index
assert_equal assigns['users'],[User.find_by_login('admin')]
assert_equal assigns['users'],[User.where(:login => 'admin').first]
end
def test_index_pagination_page_2
User.per_page = 1
login_as :admin_user
get :index, :page => 2
assert_equal assigns['users'],[User.find_by_login('jane')]
assert_equal assigns['users'],[User.where(:login => 'jane').first]
end
def test_destroy_user
@ -90,7 +90,7 @@ class UsersControllerTest < ActionController::TestCase
def test_create_adds_a_new_nonadmin_user
login_as :admin_user
post :create, :user => {:login => 'newbie', :password => 'newbiepass', :password_confirmation => 'newbiepass'}
newbie = User.find_by_login('newbie')
newbie = User.where(:login => 'newbie').first
assert_equal newbie.login, "newbie"
assert newbie.is_admin == false || newbie.is_admin == 0
assert_not_nil newbie.preference # have user preferences been created?