aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/associations_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-07-01 17:20:04 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-07-01 17:20:04 +0000
commitf2a29ca43cb0de38a25bf7f68bca5c11871692ce (patch)
tree49fafc3247a77dc1b8797e4425b28923af6a51d0 /activerecord/test/associations_test.rb
parent64612db7cf85aee8434e7b9b4fd8d6d0249c60e4 (diff)
downloadrails-f2a29ca43cb0de38a25bf7f68bca5c11871692ce.tar.gz
rails-f2a29ca43cb0de38a25bf7f68bca5c11871692ce.tar.bz2
rails-f2a29ca43cb0de38a25bf7f68bca5c11871692ce.zip
Added support for ODBC connections to MS SQL Server so you can connect from a non-Windows machine #1569 [Mark Imbriaco/DeLynn Berry] Added support for limit/offset with the MS SQL Server driver so that pagination will now work #1569 [DeLynn Berry]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1583 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_test.rb')
-rwxr-xr-xactiverecord/test/associations_test.rb28
1 files changed, 24 insertions, 4 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index 0218f7e6c7..e7160c9365 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -902,6 +902,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
no_of_devels = Developer.count
no_of_projects = Project.count
now = Date.today
+ sqlnow = Time.now.strftime("%Y/%m/%d 00:00:00")
ken = Developer.new("name" => "Ken")
ken.projects.push_with_attributes( Project.find(1), :joined_on => now )
p = Project.new("name" => "Foomatic")
@@ -916,7 +917,13 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
assert_equal 2, ken.projects(true).size
kenReloaded = Developer.find_by_name 'Ken'
- kenReloaded.projects.each { |prj| assert_equal(now.to_s, prj.joined_on.to_s) }
+ # SQL Server doesn't have a separate column type just for dates,
+ # so the time is in the string and incorrectly formatted
+ if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter and ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)
+ kenReloaded.projects.each { |prj| assert_equal(sqlnow, prj.joined_on.to_s) }
+ else
+ kenReloaded.projects.each { |prj| assert_equal(now.to_s, prj.joined_on.to_s) }
+ end
end
def test_build
@@ -1004,7 +1011,13 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
end
def test_additional_columns_from_join_table
- assert_equal Date.new(2004, 10, 10).to_s, Developer.find(1).projects.first.joined_on.to_s
+ # SQL Server doesn't have a separate column type just for dates,
+ # so the time is in the string and incorrectly formatted
+ if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter and ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)
+ assert_equal Time.mktime(2004, 10, 10).strftime("%Y/%m/%d 00:00:00"), Developer.find(1).projects.first.joined_on.to_s
+ else
+ assert_equal Date.new(2004, 10, 10).to_s, Developer.find(1).projects.first.joined_on.to_s
+ end
end
def test_destroy_all
@@ -1019,8 +1032,15 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
def test_rich_association
jamis = developers(:jamis)
jamis.projects.push_with_attributes(projects(:action_controller), :joined_on => Date.today)
- assert_equal Date.today.to_s, jamis.projects.select { |p| p.name == projects(:action_controller).name }.first.joined_on.to_s
- assert_equal Date.today.to_s, developers(:jamis).projects.select { |p| p.name == projects(:action_controller).name }.first.joined_on.to_s
+ # SQL Server doesn't have a separate column type just for dates,
+ # so the time is in the string and incorrectly formatted
+ if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter and ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)
+ assert_equal Time.now.strftime("%Y/%m/%d 00:00:00"), jamis.projects.select { |p| p.name == projects(:action_controller).name }.first.joined_on.to_s
+ assert_equal Time.now.strftime("%Y/%m/%d 00:00:00"), developers(:jamis).projects.select { |p| p.name == projects(:action_controller).name }.first.joined_on.to_s
+ else
+ assert_equal Date.today.to_s, jamis.projects.select { |p| p.name == projects(:action_controller).name }.first.joined_on.to_s
+ assert_equal Date.today.to_s, developers(:jamis).projects.select { |p| p.name == projects(:action_controller).name }.first.joined_on.to_s
+ end
end
def test_associations_with_conditions