diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-18 21:27:40 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-18 21:27:40 +0000 |
commit | 9db8f3e57a0b18340b151033c53caaa4c679a801 (patch) | |
tree | c8b023b5a13c4ac0efd6c78d33351a59a80cc318 /activerecord/test | |
parent | c0ad3b6b680b15578be616206c47165b17eb4f1a (diff) | |
download | rails-9db8f3e57a0b18340b151033c53caaa4c679a801.tar.gz rails-9db8f3e57a0b18340b151033c53caaa4c679a801.tar.bz2 rails-9db8f3e57a0b18340b151033c53caaa4c679a801.zip |
SQL Server adapter gets some love (closes #4298) [rtomayko@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3949 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/base_test.rb | 17 | ||||
-rw-r--r-- | activerecord/test/finder_test.rb | 5 | ||||
-rw-r--r-- | activerecord/test/fixtures/db_definitions/sqlserver.sql | 2 | ||||
-rw-r--r-- | activerecord/test/schema_dumper_test.rb | 9 |
4 files changed, 30 insertions, 3 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 3592c09e23..0d6a8548e0 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -745,6 +745,18 @@ class BasicsTest < Test::Unit::TestCase b_true = Booleantest.find(true_id) assert b_true.value? end + + def test_boolean_cast_from_string + b_false = Booleantest.create({ "value" => "false" }) + false_id = b_false.id + b_true = Booleantest.create({ "value" => "true" }) + true_id = b_true.id + + b_false = Booleantest.find(false_id) + assert !b_false.value? + b_true = Booleantest.find(true_id) + assert b_true.value? + end def test_clone topic = Topic.find(1) @@ -1163,6 +1175,7 @@ class BasicsTest < Test::Unit::TestCase xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true) bonus_time_in_current_timezone = topics(:first).bonus_time.xmlschema written_on_in_current_timezone = topics(:first).written_on.xmlschema + last_read_in_current_timezone = topics(:first).last_read.xmlschema assert_equal "<topic>", xml.first(7) assert xml.include?(%(<title>The First Topic</title>)) assert xml.include?(%(<author-name>David</author-name>)) @@ -1172,8 +1185,8 @@ class BasicsTest < Test::Unit::TestCase assert xml.include?(%(<content>Have a nice day</content>)) assert xml.include?(%(<author-email-address>david@loudthinking.com</author-email-address>)) assert xml.include?(%(<parent-id></parent-id>)) - if current_adapter?(:SybaseAdapter) - assert xml.include?(%(<last-read type="datetime">2004-04-15T00:00:00-05:00</last-read>)) + if current_adapter?(:SybaseAdapter) or current_adapter?(:SQLServerAdapter) + assert xml.include?(%(<last-read type="datetime">#{last_read_in_current_timezone}</last-read>)) else assert xml.include?(%(<last-read type="date">2004-04-15</last-read>)) end diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb index 65e8dc9229..98537ecad7 100644 --- a/activerecord/test/finder_test.rb +++ b/activerecord/test/finder_test.rb @@ -58,6 +58,11 @@ class FinderTest < Test::Unit::TestCase assert_equal(entrants(:third).name, entrants.first.name) end + def test_find_all_with_limit_and_offset_and_multiple_orderings + developers = Developer.find(:all, :order => "salary ASC, id DESC", :limit => 3, :offset => 1) + assert_equal ["David", "fixture_10", "fixture_9"], developers.collect {|d| d.name} + end + def test_find_with_limit_and_condition developers = Developer.find(:all, :order => "id DESC", :conditions => "salary = 100000", :limit => 3, :offset =>7) assert_equal(1, developers.size) diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.sql b/activerecord/test/fixtures/db_definitions/sqlserver.sql index 2cb1df0c04..acbcaa1384 100644 --- a/activerecord/test/fixtures/db_definitions/sqlserver.sql +++ b/activerecord/test/fixtures/db_definitions/sqlserver.sql @@ -28,7 +28,7 @@ CREATE TABLE topics ( bonus_time datetime default NULL, last_read datetime default NULL, content varchar(255) default NULL, - approved tinyint default 1, + approved bit default 1, replies_count int default 0, parent_id int default NULL, type varchar(50) default NULL diff --git a/activerecord/test/schema_dumper_test.rb b/activerecord/test/schema_dumper_test.rb index 242c5c5aa8..5dd0d4e9a2 100644 --- a/activerecord/test/schema_dumper_test.rb +++ b/activerecord/test/schema_dumper_test.rb @@ -14,6 +14,15 @@ if ActiveRecord::Base.connection.respond_to?(:tables) assert_match %r{create_table "authors"}, output assert_no_match %r{create_table "schema_info"}, output end + + def test_schema_dump_includes_not_null_columns + stream = StringIO.new + + ActiveRecord::SchemaDumper.ignore_tables = [/^[^s]/] + ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) + output = stream.string + assert_match %r{:null => false}, output + end def test_schema_dump_with_string_ignored_table stream = StringIO.new |