aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/autosave_association_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-08-07 11:58:45 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-08-07 11:58:45 -0700
commit06afa48c8c7bb7bf75f9e7ae48e06528f8ff82ed (patch)
tree9cecacc58dce4ed33885c2c143c10aca5feadb6d /activerecord/test/cases/autosave_association_test.rb
parent010a0c92eb573cd4c216c51371356adddfde11cf (diff)
parent5f0c425e8d106df4cdf844ac4859fc373f9c43e1 (diff)
downloadrails-06afa48c8c7bb7bf75f9e7ae48e06528f8ff82ed.tar.gz
rails-06afa48c8c7bb7bf75f9e7ae48e06528f8ff82ed.tar.bz2
rails-06afa48c8c7bb7bf75f9e7ae48e06528f8ff82ed.zip
Merge branch 'oracle_enhanced'
Diffstat (limited to 'activerecord/test/cases/autosave_association_test.rb')
-rw-r--r--activerecord/test/cases/autosave_association_test.rb46
1 files changed, 36 insertions, 10 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index ddca5e962d..271086af8e 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -154,7 +154,8 @@ class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::Test
end
def test_save_fails_for_invalid_belongs_to
- assert log = AuditLog.create(:developer_id => 0, :message => "")
+ # Oracle saves empty string as NULL therefore :message changed to one space
+ assert log = AuditLog.create(:developer_id => 0, :message => " ")
log.developer = Developer.new
assert !log.developer.valid?
@@ -164,7 +165,8 @@ class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::Test
end
def test_save_succeeds_for_invalid_belongs_to_with_validate_false
- assert log = AuditLog.create(:developer_id => 0, :message=> "")
+ # Oracle saves empty string as NULL therefore :message changed to one space
+ assert log = AuditLog.create(:developer_id => 0, :message=> " ")
log.unvalidated_developer = Developer.new
assert !log.unvalidated_developer.valid?
@@ -666,7 +668,12 @@ class TestAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase
@pirate.catchphrase = ''
@pirate.ship.name = ''
@pirate.save(false)
- assert_equal ['', ''], [@pirate.reload.catchphrase, @pirate.ship.name]
+ # Oracle saves empty string as NULL
+ if current_adapter?(:OracleAdapter)
+ assert_equal [nil, nil], [@pirate.reload.catchphrase, @pirate.ship.name]
+ else
+ assert_equal ['', ''], [@pirate.reload.catchphrase, @pirate.ship.name]
+ end
end
def test_should_allow_to_bypass_validations_on_associated_models_at_any_depth
@@ -678,7 +685,12 @@ class TestAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase
@pirate.save(false)
values = [@pirate.reload.catchphrase, @pirate.ship.name, *@pirate.ship.parts.map(&:name)]
- assert_equal ['', '', '', ''], values
+ # Oracle saves empty string as NULL
+ if current_adapter?(:OracleAdapter)
+ assert_equal [nil, nil, nil, nil], values
+ else
+ assert_equal ['', '', '', ''], values
+ end
end
def test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that
@@ -756,7 +768,12 @@ class TestAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase
@ship.pirate.catchphrase = ''
@ship.name = ''
@ship.save(false)
- assert_equal ['', ''], [@ship.reload.name, @ship.pirate.catchphrase]
+ # Oracle saves empty string as NULL
+ if current_adapter?(:OracleAdapter)
+ assert_equal [nil, nil], [@ship.reload.name, @ship.pirate.catchphrase]
+ else
+ assert_equal ['', ''], [@ship.reload.name, @ship.pirate.catchphrase]
+ end
end
def test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that
@@ -837,11 +854,20 @@ module AutosaveAssociationOnACollectionAssociationTests
@pirate.send(@association_name).each { |child| child.name = '' }
assert @pirate.save(false)
- assert_equal ['', '', ''], [
- @pirate.reload.catchphrase,
- @pirate.send(@association_name).first.name,
- @pirate.send(@association_name).last.name
- ]
+ # Oracle saves empty string as NULL
+ if current_adapter?(:OracleAdapter)
+ assert_equal [nil, nil, nil], [
+ @pirate.reload.catchphrase,
+ @pirate.send(@association_name).first.name,
+ @pirate.send(@association_name).last.name
+ ]
+ else
+ assert_equal ['', '', ''], [
+ @pirate.reload.catchphrase,
+ @pirate.send(@association_name).first.name,
+ @pirate.send(@association_name).last.name
+ ]
+ end
end
def test_should_validation_the_associated_models_on_create