mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-17 07:40:12 +01:00
another set of dynamic finder migrations. All non-cucumber tests pass
This commit is contained in:
parent
64a198d45a
commit
ef91dd0c64
18 changed files with 66 additions and 66 deletions
|
|
@ -350,7 +350,7 @@ class ProjectsController < ApplicationController
|
||||||
p.delete('default_context_name')
|
p.delete('default_context_name')
|
||||||
|
|
||||||
unless default_context_name.blank?
|
unless default_context_name.blank?
|
||||||
default_context = current_user.contexts.find_or_create_by_name(default_context_name)
|
default_context = current_user.contexts.where(:name => default_context_name).first_or_create
|
||||||
p['default_context_id'] = default_context.id
|
p['default_context_id'] = default_context.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class MessageGateway < ActionMailer::Base
|
||||||
|
|
||||||
def get_user_from_env_setting
|
def get_user_from_env_setting
|
||||||
Rails.logger.info "All received email goes to #{ENV['TRACKS_MAIL_RECEIVER']}"
|
Rails.logger.info "All received email goes to #{ENV['TRACKS_MAIL_RECEIVER']}"
|
||||||
user = User.find_by_login(ENV['TRACKS_MAIL_RECEIVER'])
|
user = User.where(:login => ENV['TRACKS_MAIL_RECEIVER'])
|
||||||
Rails.logger.info "WARNING: Unknown user set for TRACKS_MAIL_RECEIVER (#{ENV['TRACKS_MAIL_RECEIVER']})" if user.nil?
|
Rails.logger.info "WARNING: Unknown user set for TRACKS_MAIL_RECEIVER (#{ENV['TRACKS_MAIL_RECEIVER']})" if user.nil?
|
||||||
return user
|
return user
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,7 @@ class Todo < ActiveRecord::Base
|
||||||
return unless predecessor_list.kind_of? String
|
return unless predecessor_list.kind_of? String
|
||||||
|
|
||||||
@predecessor_array=predecessor_list.split(",").inject([]) do |list, todo_id|
|
@predecessor_array=predecessor_list.split(",").inject([]) do |list, todo_id|
|
||||||
predecessor = self.user.todos.find_by_id( todo_id.to_i ) unless todo_id.blank?
|
predecessor = self.user.todos.find( todo_id.to_i ) unless todo_id.blank?
|
||||||
list << predecessor unless predecessor.nil?
|
list << predecessor unless predecessor.nil?
|
||||||
list
|
list
|
||||||
end
|
end
|
||||||
|
|
@ -316,7 +316,7 @@ class Todo < ActiveRecord::Base
|
||||||
# value will be a string. In that case convert to array
|
# value will be a string. In that case convert to array
|
||||||
deps = [deps] unless deps.class == Array
|
deps = [deps] unless deps.class == Array
|
||||||
|
|
||||||
deps.each { |dep| self.add_predecessor(self.user.todos.find_by_id(dep.to_i)) unless dep.blank? }
|
deps.each { |dep| self.add_predecessor(self.user.todos.find(dep.to_i)) unless dep.blank? }
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :original_context=, :context=
|
alias_method :original_context=, :context=
|
||||||
|
|
@ -324,7 +324,7 @@ class Todo < ActiveRecord::Base
|
||||||
if value.is_a? Context
|
if value.is_a? Context
|
||||||
self.original_context=(value)
|
self.original_context=(value)
|
||||||
else
|
else
|
||||||
c = Context.find_by_name(value[:name])
|
c = Context.where(:name => value[:name]).first
|
||||||
c = Context.create(value) if c.nil?
|
c = Context.create(value) if c.nil?
|
||||||
self.original_context=(c)
|
self.original_context=(c)
|
||||||
end
|
end
|
||||||
|
|
@ -340,7 +340,7 @@ class Todo < ActiveRecord::Base
|
||||||
if value.is_a? Project
|
if value.is_a? Project
|
||||||
self.original_project=(value)
|
self.original_project=(value)
|
||||||
elsif !(value.nil? || value.is_a?(NullProject))
|
elsif !(value.nil? || value.is_a?(NullProject))
|
||||||
p = Project.find_by_name(value[:name])
|
p = Project.where(:name => value[:name]).first
|
||||||
p = Project.create(value) if p.nil?
|
p = Project.create(value) if p.nil?
|
||||||
self.original_project=(p)
|
self.original_project=(p)
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class User < ActiveRecord::Base
|
||||||
:order => 'position ASC',
|
:order => 'position ASC',
|
||||||
:dependent => :delete_all do
|
:dependent => :delete_all do
|
||||||
def find_by_params(params)
|
def find_by_params(params)
|
||||||
find_by_id(params['id'] || params['context_id']) || nil
|
find(params['id'] || params['context_id']) || nil
|
||||||
end
|
end
|
||||||
def update_positions(context_ids)
|
def update_positions(context_ids)
|
||||||
context_ids.each_with_index {|id, position|
|
context_ids.each_with_index {|id, position|
|
||||||
|
|
@ -29,7 +29,7 @@ class User < ActiveRecord::Base
|
||||||
:order => 'projects.position ASC',
|
:order => 'projects.position ASC',
|
||||||
:dependent => :delete_all do
|
:dependent => :delete_all do
|
||||||
def find_by_params(params)
|
def find_by_params(params)
|
||||||
find_by_id(params['id'] || params['project_id'])
|
find(params['id'] || params['project_id'])
|
||||||
end
|
end
|
||||||
def update_positions(project_ids)
|
def update_positions(project_ids)
|
||||||
project_ids.each_with_index {|id, position|
|
project_ids.each_with_index {|id, position|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ module IsTaggable
|
||||||
# added following check to prevent empty tags from being saved (which will fail)
|
# added following check to prevent empty tags from being saved (which will fail)
|
||||||
unless tag_name.blank?
|
unless tag_name.blank?
|
||||||
begin
|
begin
|
||||||
tag = Tag.find_or_create_by_name(tag_name)
|
tag = Tag.where(:name => tag_name).first_or_create
|
||||||
raise Tag::Error, "tag could not be saved: #{tag_name}" if tag.new_record?
|
raise Tag::Error, "tag could not be saved: #{tag_name}" if tag.new_record?
|
||||||
tags << tag
|
tags << tag
|
||||||
rescue ActiveRecord::StatementInvalid => e
|
rescue ActiveRecord::StatementInvalid => e
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ module LoginSystem
|
||||||
def login_from_cookie
|
def login_from_cookie
|
||||||
return unless cookies[:auth_token] && !logged_in?
|
return unless cookies[:auth_token] && !logged_in?
|
||||||
token = cookies[:auth_token]
|
token = cookies[:auth_token]
|
||||||
user = User.find_by_remember_token(token)
|
user = User.where(:remember_token => token).first
|
||||||
if user && user.remember_token?
|
if user && user.remember_token?
|
||||||
session['user_id'] = user.id
|
session['user_id'] = user.id
|
||||||
set_current_user(user)
|
set_current_user(user)
|
||||||
|
|
@ -72,7 +72,7 @@ module LoginSystem
|
||||||
|
|
||||||
def login_or_feed_token_required
|
def login_or_feed_token_required
|
||||||
if ['rss', 'atom', 'txt', 'ics'].include?(params[:format])
|
if ['rss', 'atom', 'txt', 'ics'].include?(params[:format])
|
||||||
if user = User.find_by_token(params[:token])
|
if user = User.where(:token => params[:token]).first
|
||||||
set_current_user(user)
|
set_current_user(user)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class LoginControllerTest < ActionController::TestCase
|
||||||
def test_login_with_valid_admin_user
|
def test_login_with_valid_admin_user
|
||||||
@request.session['return-to'] = "/bogus/location"
|
@request.session['return-to'] = "/bogus/location"
|
||||||
post :login, {:user_login => 'admin', :user_password => 'abracadabra', :user_noexpiry => 'on'}
|
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_not_nil user
|
||||||
assert_equal user.id, session['user_id']
|
assert_equal user.id, session['user_id']
|
||||||
assert_equal user.login, "admin"
|
assert_equal user.login, "admin"
|
||||||
|
|
@ -31,7 +31,7 @@ class LoginControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_login_with_valid_standard_user
|
def test_login_with_valid_standard_user
|
||||||
post :login, {:user_login => 'jane', :user_password => 'sesame', :user_noexpiry => 'off'}
|
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_not_nil user
|
||||||
assert_equal user.id, session['user_id']
|
assert_equal user.id, session['user_id']
|
||||||
assert_equal user.login, "jane"
|
assert_equal user.login, "jane"
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
|
||||||
assert recurring_todo_1.completed?
|
assert recurring_todo_1.completed?
|
||||||
|
|
||||||
# remove remaining todo
|
# 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.recurring_todo_id = 2
|
||||||
todo.save
|
todo.save
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
|
||||||
assert_equal todo_count+1, Todo.count
|
assert_equal todo_count+1, Todo.count
|
||||||
|
|
||||||
# find the new todo and check its description
|
# 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
|
assert_equal "Call Bill Gates every day", new_todo.description
|
||||||
end
|
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=>""
|
||||||
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
|
# 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
|
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
|
assert_equal orig_todo_count+1, Todo.count
|
||||||
|
|
||||||
# find the newly created todo
|
# 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?
|
assert !new_todo.nil?
|
||||||
|
|
||||||
# the date should be 31 march 2013
|
# the date should be 31 march 2013
|
||||||
|
|
@ -224,7 +224,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
|
||||||
assert_equal orig_todo_count+1, Todo.count
|
assert_equal orig_todo_count+1, Todo.count
|
||||||
|
|
||||||
# find the newly created recurring todo
|
# 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 !recurring_todo.nil?
|
||||||
|
|
||||||
assert_equal "due_date", recurring_todo.target
|
assert_equal "due_date", recurring_todo.target
|
||||||
|
|
@ -235,7 +235,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
|
|
||||||
rt = RecurringTodo.find(recurring_todos(:call_bill_gates_every_day).id)
|
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_not_nil todo
|
||||||
assert_equal "active", todo.state, "todo should be active"
|
assert_equal "active", todo.state, "todo should be active"
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
def test_find_tagged_with
|
def test_find_tagged_with
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
@user = User.find(@request.session['user_id'])
|
@user = User.find(@request.session['user_id'])
|
||||||
tag = Tag.find_by_name('foo').taggings
|
tag = Tag.where(:name => 'foo').first.taggings
|
||||||
@tagged = tag.count
|
@tagged = tag.count
|
||||||
get :tag, :name => 'foo'
|
get :tag, :name => 'foo'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
@ -260,7 +260,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# find a,b,c and d
|
# find a,b,c and d
|
||||||
%w{a b c d}.each do |todo|
|
%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'"
|
eval "assert !@#{todo}.nil?, 'a todo with description \"#{todo}\" should just have been added'"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -275,7 +275,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
def test_destroy_todo
|
def test_destroy_todo
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
xhr :post, :destroy, :id => 1, :_source_view => 'todo'
|
xhr :post, :destroy, :id => 1, :_source_view => 'todo'
|
||||||
todo = Todo.find_by_id(1)
|
todo = Todo.where(:id=>1).first
|
||||||
assert_nil todo
|
assert_nil todo
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -551,7 +551,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
"show_from(1i)"=>"", "show_from(2i)"=>"", "show_from(3i)"=>"",
|
"show_from(1i)"=>"", "show_from(2i)"=>"", "show_from(3i)"=>"",
|
||||||
"project_id"=>"1",
|
"project_id"=>"1",
|
||||||
"notes"=>"test notes", "description"=>"test_mobile_create_action"}}
|
"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_not_nil t
|
||||||
assert_equal 2, t.context_id
|
assert_equal 2, t.context_id
|
||||||
assert_equal 1, t.project_id
|
assert_equal 1, t.project_id
|
||||||
|
|
@ -590,7 +590,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# link todo_1 and recurring_todo_1
|
# link todo_1 and recurring_todo_1
|
||||||
recurring_todo_1 = RecurringTodo.find(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
|
# mark todo_1 as complete by toggle_check
|
||||||
xhr :post, :toggle_check, :id => todo_1.id, :_source_view => 'todo'
|
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
|
# link todo_1 and recurring_todo_1
|
||||||
recurring_todo_1 = RecurringTodo.find(1)
|
recurring_todo_1 = RecurringTodo.find(1)
|
||||||
#set_user_to_current_time_zone(recurring_todo_1.user)
|
#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
|
today = Time.zone.now.at_midnight
|
||||||
|
|
||||||
# change recurrence pattern to monthly and set show_from to today
|
# change recurrence pattern to monthly and set show_from to today
|
||||||
|
|
@ -694,7 +694,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
|
|
||||||
recurring_todo_1 = RecurringTodo.find(5)
|
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?
|
assert @todo.from_recurring_todo?
|
||||||
# rewire @todo to yearly recurring todo
|
# rewire @todo to yearly recurring todo
|
||||||
@todo.recurring_todo_id = 5
|
@todo.recurring_todo_id = 5
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,14 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
User.per_page = 1
|
User.per_page = 1
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index
|
get :index
|
||||||
assert_equal assigns['users'],[User.find_by_login('admin')]
|
assert_equal assigns['users'],[User.where(:login => 'admin').first]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_pagination_page_2
|
def test_index_pagination_page_2
|
||||||
User.per_page = 1
|
User.per_page = 1
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index, :page => 2
|
get :index, :page => 2
|
||||||
assert_equal assigns['users'],[User.find_by_login('jane')]
|
assert_equal assigns['users'],[User.where(:login => 'jane').first]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_user
|
def test_destroy_user
|
||||||
|
|
@ -90,7 +90,7 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
def test_create_adds_a_new_nonadmin_user
|
def test_create_adds_a_new_nonadmin_user
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
post :create, :user => {:login => 'newbie', :password => 'newbiepass', :password_confirmation => 'newbiepass'}
|
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_equal newbie.login, "newbie"
|
||||||
assert newbie.is_admin == false || newbie.is_admin == 0
|
assert newbie.is_admin == false || newbie.is_admin == 0
|
||||||
assert_not_nil newbie.preference # have user preferences been created?
|
assert_not_nil newbie.preference # have user preferences been created?
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class ContextXmlApiTest < ActionController::IntegrationTest
|
||||||
authenticated_post_xml_to_context_create
|
authenticated_post_xml_to_context_create
|
||||||
assert_response 201
|
assert_response 201
|
||||||
end
|
end
|
||||||
context1 = Context.find_by_name(@@context_name)
|
context1 = Context.where(:name => @@context_name).first
|
||||||
assert_not_nil context1, "expected context '#{@@context_name}' to be created"
|
assert_not_nil context1, "expected context '#{@@context_name}' to be created"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class ProjectXmlApiTest < ActionController::IntegrationTest
|
||||||
def test_fails_with_comma_in_name
|
def test_fails_with_comma_in_name
|
||||||
authenticated_post_xml_to_project_create "<project><name>foo,bar</name></project>"
|
authenticated_post_xml_to_project_create "<project><name>foo,bar</name></project>"
|
||||||
assert_response :created
|
assert_response :created
|
||||||
project1 = Project.find_by_name("foo,bar")
|
project1 = Project.where(:name => "foo,bar").first
|
||||||
assert_not_nil project1, "expected project 'foo,bar' to be created"
|
assert_not_nil project1, "expected project 'foo,bar' to be created"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ class ProjectXmlApiTest < ActionController::IntegrationTest
|
||||||
authenticated_post_xml_to_project_create
|
authenticated_post_xml_to_project_create
|
||||||
assert_response :created
|
assert_response :created
|
||||||
end
|
end
|
||||||
project1 = Project.find_by_name(@@project_name)
|
project1 = Project.where(:name => @@project_name).first
|
||||||
assert_not_nil project1, "expected project '#{@@project_name}' to be created"
|
assert_not_nil project1, "expected project '#{@@project_name}' to be created"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class RecurringTodosTest < ActionController::IntegrationTest
|
||||||
assert_equal 1, rt.todos.size # and it has one todo referencing it
|
assert_equal 1, rt.todos.size # and it has one todo referencing it
|
||||||
|
|
||||||
# when I toggle the todo complete
|
# when I toggle the todo complete
|
||||||
todo = Todo.find_by_recurring_todo_id(1)
|
todo = Todo.where(:recurring_todo_id => 1).first
|
||||||
put "/todos/#{todo.id}/toggle_check", :_source_view => 'todo'
|
put "/todos/#{todo.id}/toggle_check", :_source_view => 'todo'
|
||||||
todo.reload
|
todo.reload
|
||||||
assert todo.completed?
|
assert todo.completed?
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
</todo>"
|
</todo>"
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
todo = @user.todos.find_by_description("this will succeed 2.0")
|
todo = @user.todos.where(:description => "this will succeed 2.0").first
|
||||||
assert_not_nil todo
|
assert_not_nil todo
|
||||||
assert !todo.uncompleted_predecessors.empty?
|
assert !todo.uncompleted_predecessors.empty?
|
||||||
end
|
end
|
||||||
|
|
@ -76,7 +76,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
</todo>"
|
</todo>"
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
todo = @user.todos.find_by_description("this will succeed 2.1")
|
todo = @user.todos.where(:description => "this will succeed 2.1").first
|
||||||
assert_not_nil todo
|
assert_not_nil todo
|
||||||
assert !todo.uncompleted_predecessors.empty?
|
assert !todo.uncompleted_predecessors.empty?
|
||||||
end
|
end
|
||||||
|
|
@ -95,7 +95,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
</todo>"
|
</todo>"
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
todo = @user.todos.find_by_description("this will succeed 3")
|
todo = @user.todos.where(:description => "this will succeed 3").first
|
||||||
assert_not_nil todo
|
assert_not_nil todo
|
||||||
assert_equal "starred, starred1, starred2", todo.tag_list
|
assert_equal "starred, starred1, starred2", todo.tag_list
|
||||||
assert todo.starred?
|
assert todo.starred?
|
||||||
|
|
@ -113,7 +113,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
</todo>"
|
</todo>"
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
todo = @user.todos.find_by_description("this will succeed 3.1")
|
todo = @user.todos.where(:description => "this will succeed 3.1").first
|
||||||
assert_not_nil todo
|
assert_not_nil todo
|
||||||
assert_equal "tracks", todo.tag_list
|
assert_equal "tracks", todo.tag_list
|
||||||
end
|
end
|
||||||
|
|
@ -133,7 +133,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
</todo>"
|
</todo>"
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
todo = @user.todos.find_by_description("this will succeed 3")
|
todo = @user.todos.where(:description => "this will succeed 3").first
|
||||||
assert_not_nil todo
|
assert_not_nil todo
|
||||||
assert_equal "bar, bingo, foo", todo.tag_list
|
assert_equal "bar, bingo, foo", todo.tag_list
|
||||||
authenticated_post_xml_to_todo_create "
|
authenticated_post_xml_to_todo_create "
|
||||||
|
|
@ -149,7 +149,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
</todo>"
|
</todo>"
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
todo = @user.todos.find_by_description("this will succeed 4")
|
todo = @user.todos.where(:description => "this will succeed 4").first
|
||||||
assert_not_nil todo
|
assert_not_nil todo
|
||||||
assert_equal "bar, bingo, foo", todo.tag_list
|
assert_equal "bar, bingo, foo", todo.tag_list
|
||||||
end
|
end
|
||||||
|
|
@ -165,7 +165,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
</todo>"
|
</todo>"
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
todo = @user.todos.find_by_description("this will succeed 4")
|
todo = @user.todos.where(:description => "this will succeed 4").first
|
||||||
assert_not_nil todo
|
assert_not_nil todo
|
||||||
assert_not_nil todo.context
|
assert_not_nil todo.context
|
||||||
assert_equal todo.context.name, "@SomeNewContext"
|
assert_equal todo.context.name, "@SomeNewContext"
|
||||||
|
|
@ -182,7 +182,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
</todo>"
|
</todo>"
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
todo = @user.todos.find_by_description("this will succeed 4")
|
todo = @user.todos.where(:description => "this will succeed 4").first
|
||||||
assert_not_nil todo
|
assert_not_nil todo
|
||||||
assert_not_nil todo.context
|
assert_not_nil todo.context
|
||||||
assert_equal contexts(:office).name, todo.context.name
|
assert_equal contexts(:office).name, todo.context.name
|
||||||
|
|
@ -200,7 +200,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
</todo>"
|
</todo>"
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
todo = @user.todos.find_by_description("this will succeed 5")
|
todo = @user.todos.where(:description => "this will succeed 5").first
|
||||||
assert_not_nil todo
|
assert_not_nil todo
|
||||||
assert_not_nil todo.project
|
assert_not_nil todo.project
|
||||||
assert_equal todo.project.name, "Make even more money"
|
assert_equal todo.project.name, "Make even more money"
|
||||||
|
|
@ -217,7 +217,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
||||||
</todo>"
|
</todo>"
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
todo = @user.todos.find_by_description("this will succeed 5")
|
todo = @user.todos.where(:description => "this will succeed 5").first
|
||||||
assert_not_nil todo
|
assert_not_nil todo
|
||||||
assert_not_nil todo.project
|
assert_not_nil todo.project
|
||||||
assert_equal projects(:timemachine).name, todo.project.name
|
assert_equal projects(:timemachine).name, todo.project.name
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class UsersXmlApiTest < ActionController::IntegrationTest
|
||||||
authenticated_post_xml_to_user_create @@johnny_postdata
|
authenticated_post_xml_to_user_create @@johnny_postdata
|
||||||
assert_response_and_body 200, "User created."
|
assert_response_and_body 200, "User created."
|
||||||
end
|
end
|
||||||
johnny1 = User.find_by_login('johnny')
|
johnny1 = User.where(:login => 'johnny').first
|
||||||
assert_not_nil johnny1, "expected user johnny to be created"
|
assert_not_nil johnny1, "expected user johnny to be created"
|
||||||
johnny2 = User.authenticate('johnny','barracuda')
|
johnny2 = User.authenticate('johnny','barracuda')
|
||||||
assert_not_nil johnny2, "expected user johnny to be authenticated"
|
assert_not_nil johnny2, "expected user johnny to be authenticated"
|
||||||
|
|
|
||||||
|
|
@ -4,39 +4,39 @@ class TagTest < ActiveSupport::TestCase
|
||||||
fixtures :tags
|
fixtures :tags
|
||||||
|
|
||||||
def test_find_or_create_with_single_word
|
def test_find_or_create_with_single_word
|
||||||
tag = Tag.find_or_create_by_name("test")
|
tag = Tag.where(:name => "test").first_or_create
|
||||||
assert !tag.new_record?
|
assert !tag.new_record?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_find_or_create_with_space
|
def test_find_or_create_with_space
|
||||||
tag = Tag.find_or_create_by_name("test test")
|
tag = Tag.where(:name => "test test").first_or_create
|
||||||
assert !tag.new_record?
|
assert !tag.new_record?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_find_or_create_with_dot
|
def test_find_or_create_with_dot
|
||||||
tag = Tag.find_or_create_by_name("a.b.c")
|
tag = Tag.where(:name => "a.b.c").first_or_create
|
||||||
assert !tag.new_record?
|
assert !tag.new_record?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_find_or_create_with_number_as_string
|
def test_find_or_create_with_number_as_string
|
||||||
tag = Tag.find_or_create_by_name("12343")
|
tag = Tag.where(:name => "12343").first_or_create
|
||||||
assert !tag.new_record?
|
assert !tag.new_record?
|
||||||
|
|
||||||
tag = Tag.find_or_create_by_name("8.1.2")
|
tag = Tag.where(:name => "8.1.2").first_or_create
|
||||||
assert !tag.new_record?
|
assert !tag.new_record?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_tag_name_always_lowercase
|
def test_tag_name_always_lowercase
|
||||||
tag = Tag.find_or_create_by_name("UPPER")
|
tag = Tag.where(:name => "UPPER").first_or_create
|
||||||
assert !tag.new_record?
|
assert !tag.new_record?
|
||||||
|
|
||||||
upper = Tag.find_by_name("upper")
|
upper = Tag.where(:name => "upper").first
|
||||||
assert_not_nil upper
|
assert_not_nil upper
|
||||||
assert upper.name == "upper"
|
assert upper.name == "upper"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_tag_name_stripped_of_spaces
|
def test_tag_name_stripped_of_spaces
|
||||||
tag = Tag.find_or_create_by_name(" strip spaces ")
|
tag = Tag.where(:name => " strip spaces ").first_or_create
|
||||||
assert !tag.new_record?
|
assert !tag.new_record?
|
||||||
|
|
||||||
assert tag.name == "strip spaces"
|
assert tag.name == "strip spaces"
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,6 @@ class TaggingTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
tagging.destroy
|
tagging.destroy
|
||||||
|
|
||||||
assert_nil Tag.find_by_name("hello")
|
assert_nil Tag.where(:name => "hello").first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -276,9 +276,9 @@ class TodoTest < ActiveSupport::TestCase
|
||||||
todo.tag_list = "a, b, c"
|
todo.tag_list = "a, b, c"
|
||||||
todo.save!
|
todo.save!
|
||||||
|
|
||||||
tag_a = Tag.find_by_name("a")
|
tag_a = Tag.where(:name => "a").first
|
||||||
tag_b = Tag.find_by_name("b")
|
tag_b = Tag.where(:name => "b").first
|
||||||
tag_c = Tag.find_by_name("c")
|
tag_c = Tag.where(:name => "c").first
|
||||||
|
|
||||||
todos_with_a = Todo.with_tag(tag_a)
|
todos_with_a = Todo.with_tag(tag_a)
|
||||||
assert_equal 1, todos_with_a.count
|
assert_equal 1, todos_with_a.count
|
||||||
|
|
@ -292,7 +292,7 @@ class TodoTest < ActiveSupport::TestCase
|
||||||
todo2.tag_list = "a, c, d"
|
todo2.tag_list = "a, c, d"
|
||||||
todo2.save!
|
todo2.save!
|
||||||
|
|
||||||
tag_d = Tag.find_by_name("d")
|
tag_d = Tag.where(:name => "d").first
|
||||||
|
|
||||||
todos_with_a = Todo.with_tag(tag_a)
|
todos_with_a = Todo.with_tag(tag_a)
|
||||||
assert_equal 2, todos_with_a.count
|
assert_equal 2, todos_with_a.count
|
||||||
|
|
@ -310,10 +310,10 @@ class TodoTest < ActiveSupport::TestCase
|
||||||
todo2.tag_list = "a, c, d"
|
todo2.tag_list = "a, c, d"
|
||||||
todo2.save!
|
todo2.save!
|
||||||
|
|
||||||
tag_a = Tag.find_by_name("a")
|
tag_a = Tag.where(:name => "a").first
|
||||||
tag_b = Tag.find_by_name("b")
|
tag_b = Tag.where(:name => "b").first
|
||||||
tag_c = Tag.find_by_name("c")
|
tag_c = Tag.where(:name => "c").first
|
||||||
tag_d = Tag.find_by_name("d")
|
tag_d = Tag.where(:name => "d").first
|
||||||
|
|
||||||
# overlapping tags
|
# overlapping tags
|
||||||
tag_ids = [tag_a.id, tag_c.id]
|
tag_ids = [tag_a.id, tag_c.id]
|
||||||
|
|
@ -335,8 +335,8 @@ class TodoTest < ActiveSupport::TestCase
|
||||||
todo2.tag_list = "a, c, d"
|
todo2.tag_list = "a, c, d"
|
||||||
todo2.save!
|
todo2.save!
|
||||||
|
|
||||||
tag_a_id = Tag.find_by_name("a").id
|
tag_a_id = Tag.where(:name => "a").first.id
|
||||||
tag_b_id = Tag.find_by_name("b").id
|
tag_b_id = Tag.where(:name => "b").first.id
|
||||||
|
|
||||||
todos_with_a_and_b = Todo.with_tags([tag_a_id]).with_tags([tag_b_id])
|
todos_with_a_and_b = Todo.with_tags([tag_a_id]).with_tags([tag_b_id])
|
||||||
assert_equal 1, todos_with_a_and_b.count
|
assert_equal 1, todos_with_a_and_b.count
|
||||||
|
|
@ -352,9 +352,9 @@ class TodoTest < ActiveSupport::TestCase
|
||||||
todo2.tag_list = "a, c, d"
|
todo2.tag_list = "a, c, d"
|
||||||
todo2.save!
|
todo2.save!
|
||||||
|
|
||||||
tag_a_id = Tag.find_by_name("a").id
|
tag_a_id = Tag.where(:name => "a").first.id
|
||||||
tag_b_id = Tag.find_by_name("b").id
|
tag_b_id = Tag.where(:name => "b").first.id
|
||||||
tag_c_id = Tag.find_by_name("c").id
|
tag_c_id = Tag.where(:name => "c").first.id
|
||||||
|
|
||||||
todos_with_aORc_and_b = Todo.with_tags([tag_a_id, tag_c_id]).with_tags([tag_b_id])
|
todos_with_aORc_and_b = Todo.with_tags([tag_a_id, tag_c_id]).with_tags([tag_b_id])
|
||||||
assert_equal 1, todos_with_aORc_and_b.count
|
assert_equal 1, todos_with_aORc_and_b.count
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue