mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +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')
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class MessageGateway < ActionMailer::Base
|
|||
|
||||
def get_user_from_env_setting
|
||||
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?
|
||||
return user
|
||||
end
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ class Todo < ActiveRecord::Base
|
|||
return unless predecessor_list.kind_of? String
|
||||
|
||||
@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
|
||||
end
|
||||
|
|
@ -316,7 +316,7 @@ class Todo < ActiveRecord::Base
|
|||
# value will be a string. In that case convert to 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
|
||||
|
||||
alias_method :original_context=, :context=
|
||||
|
|
@ -324,7 +324,7 @@ class Todo < ActiveRecord::Base
|
|||
if value.is_a? Context
|
||||
self.original_context=(value)
|
||||
else
|
||||
c = Context.find_by_name(value[:name])
|
||||
c = Context.where(:name => value[:name]).first
|
||||
c = Context.create(value) if c.nil?
|
||||
self.original_context=(c)
|
||||
end
|
||||
|
|
@ -340,7 +340,7 @@ class Todo < ActiveRecord::Base
|
|||
if value.is_a? Project
|
||||
self.original_project=(value)
|
||||
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?
|
||||
self.original_project=(p)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class User < ActiveRecord::Base
|
|||
:order => 'position ASC',
|
||||
:dependent => :delete_all do
|
||||
def find_by_params(params)
|
||||
find_by_id(params['id'] || params['context_id']) || nil
|
||||
find(params['id'] || params['context_id']) || nil
|
||||
end
|
||||
def update_positions(context_ids)
|
||||
context_ids.each_with_index {|id, position|
|
||||
|
|
@ -29,7 +29,7 @@ class User < ActiveRecord::Base
|
|||
:order => 'projects.position ASC',
|
||||
:dependent => :delete_all do
|
||||
def find_by_params(params)
|
||||
find_by_id(params['id'] || params['project_id'])
|
||||
find(params['id'] || params['project_id'])
|
||||
end
|
||||
def update_positions(project_ids)
|
||||
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)
|
||||
unless tag_name.blank?
|
||||
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?
|
||||
tags << tag
|
||||
rescue ActiveRecord::StatementInvalid => e
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ module LoginSystem
|
|||
def login_from_cookie
|
||||
return unless cookies[:auth_token] && !logged_in?
|
||||
token = cookies[:auth_token]
|
||||
user = User.find_by_remember_token(token)
|
||||
user = User.where(:remember_token => token).first
|
||||
if user && user.remember_token?
|
||||
session['user_id'] = user.id
|
||||
set_current_user(user)
|
||||
|
|
@ -72,7 +72,7 @@ module LoginSystem
|
|||
|
||||
def login_or_feed_token_required
|
||||
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)
|
||||
return true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class ContextXmlApiTest < ActionController::IntegrationTest
|
|||
authenticated_post_xml_to_context_create
|
||||
assert_response 201
|
||||
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"
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class ProjectXmlApiTest < ActionController::IntegrationTest
|
|||
def test_fails_with_comma_in_name
|
||||
authenticated_post_xml_to_project_create "<project><name>foo,bar</name></project>"
|
||||
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"
|
||||
end
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ class ProjectXmlApiTest < ActionController::IntegrationTest
|
|||
authenticated_post_xml_to_project_create
|
||||
assert_response :created
|
||||
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"
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class RecurringTodosTest < ActionController::IntegrationTest
|
|||
assert_equal 1, rt.todos.size # and it has one todo referencing it
|
||||
|
||||
# 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'
|
||||
todo.reload
|
||||
assert todo.completed?
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
|||
</todo>"
|
||||
|
||||
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 !todo.uncompleted_predecessors.empty?
|
||||
end
|
||||
|
|
@ -76,7 +76,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
|||
</todo>"
|
||||
|
||||
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 !todo.uncompleted_predecessors.empty?
|
||||
end
|
||||
|
|
@ -95,7 +95,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
|||
</todo>"
|
||||
|
||||
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_equal "starred, starred1, starred2", todo.tag_list
|
||||
assert todo.starred?
|
||||
|
|
@ -113,7 +113,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
|||
</todo>"
|
||||
|
||||
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_equal "tracks", todo.tag_list
|
||||
end
|
||||
|
|
@ -133,7 +133,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
|||
</todo>"
|
||||
|
||||
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_equal "bar, bingo, foo", todo.tag_list
|
||||
authenticated_post_xml_to_todo_create "
|
||||
|
|
@ -149,7 +149,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
|||
</todo>"
|
||||
|
||||
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_equal "bar, bingo, foo", todo.tag_list
|
||||
end
|
||||
|
|
@ -165,7 +165,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
|||
</todo>"
|
||||
|
||||
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.context
|
||||
assert_equal todo.context.name, "@SomeNewContext"
|
||||
|
|
@ -182,7 +182,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
|||
</todo>"
|
||||
|
||||
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.context
|
||||
assert_equal contexts(:office).name, todo.context.name
|
||||
|
|
@ -200,7 +200,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
|||
</todo>"
|
||||
|
||||
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.project
|
||||
assert_equal todo.project.name, "Make even more money"
|
||||
|
|
@ -217,7 +217,7 @@ class TodoXmlApiTest < ActionController::IntegrationTest
|
|||
</todo>"
|
||||
|
||||
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.project
|
||||
assert_equal projects(:timemachine).name, todo.project.name
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class UsersXmlApiTest < ActionController::IntegrationTest
|
|||
authenticated_post_xml_to_user_create @@johnny_postdata
|
||||
assert_response_and_body 200, "User created."
|
||||
end
|
||||
johnny1 = User.find_by_login('johnny')
|
||||
johnny1 = User.where(:login => 'johnny').first
|
||||
assert_not_nil johnny1, "expected user johnny to be created"
|
||||
johnny2 = User.authenticate('johnny','barracuda')
|
||||
assert_not_nil johnny2, "expected user johnny to be authenticated"
|
||||
|
|
|
|||
|
|
@ -4,39 +4,39 @@ class TagTest < ActiveSupport::TestCase
|
|||
fixtures :tags
|
||||
|
||||
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?
|
||||
end
|
||||
|
||||
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?
|
||||
end
|
||||
|
||||
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?
|
||||
end
|
||||
|
||||
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?
|
||||
|
||||
tag = Tag.find_or_create_by_name("8.1.2")
|
||||
tag = Tag.where(:name => "8.1.2").first_or_create
|
||||
assert !tag.new_record?
|
||||
end
|
||||
|
||||
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?
|
||||
|
||||
upper = Tag.find_by_name("upper")
|
||||
upper = Tag.where(:name => "upper").first
|
||||
assert_not_nil upper
|
||||
assert upper.name == "upper"
|
||||
end
|
||||
|
||||
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.name == "strip spaces"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ class TaggingTest < ActiveSupport::TestCase
|
|||
|
||||
tagging.destroy
|
||||
|
||||
assert_nil Tag.find_by_name("hello")
|
||||
assert_nil Tag.where(:name => "hello").first
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -276,9 +276,9 @@ class TodoTest < ActiveSupport::TestCase
|
|||
todo.tag_list = "a, b, c"
|
||||
todo.save!
|
||||
|
||||
tag_a = Tag.find_by_name("a")
|
||||
tag_b = Tag.find_by_name("b")
|
||||
tag_c = Tag.find_by_name("c")
|
||||
tag_a = Tag.where(:name => "a").first
|
||||
tag_b = Tag.where(:name => "b").first
|
||||
tag_c = Tag.where(:name => "c").first
|
||||
|
||||
todos_with_a = Todo.with_tag(tag_a)
|
||||
assert_equal 1, todos_with_a.count
|
||||
|
|
@ -292,7 +292,7 @@ class TodoTest < ActiveSupport::TestCase
|
|||
todo2.tag_list = "a, c, d"
|
||||
todo2.save!
|
||||
|
||||
tag_d = Tag.find_by_name("d")
|
||||
tag_d = Tag.where(:name => "d").first
|
||||
|
||||
todos_with_a = Todo.with_tag(tag_a)
|
||||
assert_equal 2, todos_with_a.count
|
||||
|
|
@ -310,10 +310,10 @@ class TodoTest < ActiveSupport::TestCase
|
|||
todo2.tag_list = "a, c, d"
|
||||
todo2.save!
|
||||
|
||||
tag_a = Tag.find_by_name("a")
|
||||
tag_b = Tag.find_by_name("b")
|
||||
tag_c = Tag.find_by_name("c")
|
||||
tag_d = Tag.find_by_name("d")
|
||||
tag_a = Tag.where(:name => "a").first
|
||||
tag_b = Tag.where(:name => "b").first
|
||||
tag_c = Tag.where(:name => "c").first
|
||||
tag_d = Tag.where(:name => "d").first
|
||||
|
||||
# overlapping tags
|
||||
tag_ids = [tag_a.id, tag_c.id]
|
||||
|
|
@ -335,8 +335,8 @@ class TodoTest < ActiveSupport::TestCase
|
|||
todo2.tag_list = "a, c, d"
|
||||
todo2.save!
|
||||
|
||||
tag_a_id = Tag.find_by_name("a").id
|
||||
tag_b_id = Tag.find_by_name("b").id
|
||||
tag_a_id = Tag.where(:name => "a").first.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])
|
||||
assert_equal 1, todos_with_a_and_b.count
|
||||
|
|
@ -352,9 +352,9 @@ class TodoTest < ActiveSupport::TestCase
|
|||
todo2.tag_list = "a, c, d"
|
||||
todo2.save!
|
||||
|
||||
tag_a_id = Tag.find_by_name("a").id
|
||||
tag_b_id = Tag.find_by_name("b").id
|
||||
tag_c_id = Tag.find_by_name("c").id
|
||||
tag_a_id = Tag.where(:name => "a").first.id
|
||||
tag_b_id = Tag.where(:name => "b").first.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])
|
||||
assert_equal 1, todos_with_aORc_and_b.count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue