diff options
author | Aditya Chadha <aditya@sublucid.com> | 2009-05-02 18:32:45 -0400 |
---|---|---|
committer | Aditya Chadha <aditya@sublucid.com> | 2009-05-02 18:32:45 -0400 |
commit | 7a17ad3f2b89baea94450af8e63a640ace570938 (patch) | |
tree | 89cd60c05d4a812b3c8636373a05689b1df5bf75 /activerecord/test | |
parent | 5469a0be1a517a0c2d8ee553b704df4e6f7df306 (diff) | |
parent | 1b32f882091ed7744654f74238f3f3b1ba6701ae (diff) | |
download | rails-7a17ad3f2b89baea94450af8e63a640ace570938.tar.gz rails-7a17ad3f2b89baea94450af8e63a640ace570938.tar.bz2 rails-7a17ad3f2b89baea94450af8e63a640ace570938.zip |
Merge branch 'master' of git@github.com:lifo/docrails
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/eager_load_nested_include_test.rb | 10 | ||||
-rw-r--r-- | activerecord/test/cases/autosave_association_test.rb | 22 | ||||
-rwxr-xr-x | activerecord/test/cases/base_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 8 | ||||
-rw-r--r-- | activerecord/test/cases/method_scoping_test.rb | 2 |
6 files changed, 36 insertions, 14 deletions
diff --git a/activerecord/test/cases/associations/eager_load_nested_include_test.rb b/activerecord/test/cases/associations/eager_load_nested_include_test.rb index 1b2e0fc11e..677226ec89 100644 --- a/activerecord/test/cases/associations/eager_load_nested_include_test.rb +++ b/activerecord/test/cases/associations/eager_load_nested_include_test.rb @@ -1,6 +1,6 @@ require 'cases/helper' -require 'models/author' require 'models/post' +require 'models/author' require 'models/comment' require 'models/category' require 'models/categorization' @@ -66,13 +66,13 @@ class EagerLoadPolyAssocsTest < ActiveRecord::TestCase def setup generate_test_object_graphs end - + def teardown - [Circle, Square, Triangle, PaintColor, PaintTexture, + [Circle, Square, Triangle, PaintColor, PaintTexture, ShapeExpression, NonPolyOne, NonPolyTwo].each do |c| c.delete_all end - + end @@ -127,4 +127,4 @@ class EagerLoadNestedIncludeWithMissingDataTest < ActiveRecord::TestCase Author.all :include => includes, :conditions => {:authors => {:name => @davey_mcdave.name}}, :order => 'categories.name' end end -end
\ No newline at end of file +end diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index 436f50d395..919b6f857c 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -38,6 +38,17 @@ class TestAutosaveAssociationsInGeneral < ActiveRecord::TestCase end class TestDefaultAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase + def test_should_save_parent_but_not_invalid_child + firm = Firm.new(:name => 'GlobalMegaCorp') + assert firm.valid? + + firm.build_account_using_primary_key + assert !firm.build_account_using_primary_key.valid? + + assert firm.save + assert firm.account_using_primary_key.new_record? + end + def test_save_fails_for_invalid_has_one firm = Firm.find(:first) assert firm.valid? @@ -126,6 +137,17 @@ class TestDefaultAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCas end class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase + def test_should_save_parent_but_not_invalid_child + client = Client.new(:name => 'Joe (the Plumber)') + assert client.valid? + + client.build_firm + assert !client.firm.valid? + + assert client.save + assert client.firm.new_record? + end + def test_save_fails_for_invalid_belongs_to assert log = AuditLog.create(:developer_id => 0, :message => "") diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index d97cd17d75..7ca2807f7e 100755 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1,4 +1,5 @@ require "cases/helper" +require 'models/post' require 'models/author' require 'models/topic' require 'models/reply' @@ -12,7 +13,6 @@ require 'models/auto_id' require 'models/column_name' require 'models/subscriber' require 'models/keyboard' -require 'models/post' require 'models/comment' require 'models/minimalistic' require 'models/warehouse_thing' @@ -1115,7 +1115,7 @@ class BasicsTest < ActiveRecord::TestCase Time.zone = nil Topic.skip_time_zone_conversion_for_attributes = [] end - + def test_multiparameter_attributes_on_time_only_column_with_time_zone_aware_attributes_does_not_do_time_zone_conversion ActiveRecord::Base.time_zone_aware_attributes = true ActiveRecord::Base.default_timezone = :utc @@ -1439,7 +1439,7 @@ class BasicsTest < ActiveRecord::TestCase topic = Topic.create("content" => myobj).reload assert_equal(myobj, topic.content) end - + def test_serialized_string_attribute myobj = "Yes" topic = Topic.create("content" => myobj).reload diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 56dcdea110..fd455e0864 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -233,7 +233,7 @@ class CalculationsTest < ActiveRecord::TestCase assert_equal 8, c['Jadedpixel'] end - def test_should_group_by_summed_field_with_conditions_and_having + def test_should_group_by_summed_field_through_association_and_having c = companies(:rails_core).companies.sum(:id, :group => :name, :having => 'sum(id) > 7') assert_nil c['Leetsoft'] diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index d8778957c0..28eb311618 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -1,4 +1,5 @@ require "cases/helper" +require 'models/post' require 'models/author' require 'models/categorization' require 'models/comment' @@ -7,7 +8,6 @@ require 'models/topic' require 'models/reply' require 'models/entrant' require 'models/developer' -require 'models/post' require 'models/customer' require 'models/job' require 'models/categorization' @@ -94,16 +94,16 @@ class FinderTest < ActiveRecord::TestCase assert_raise(NoMethodError) { Topic.exists?([1,2]) } end - + def test_exists_returns_true_with_one_record_and_no_args assert Topic.exists? end - + def test_does_not_exist_with_empty_table_and_no_args_given Topic.delete_all assert !Topic.exists? end - + def test_exists_with_aggregate_having_three_mappings existing_address = customers(:david).address assert Customer.exists?(:address => existing_address) diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb index 3c34cdeade..2165d2f7e8 100644 --- a/activerecord/test/cases/method_scoping_test.rb +++ b/activerecord/test/cases/method_scoping_test.rb @@ -1,9 +1,9 @@ require "cases/helper" +require 'models/post' require 'models/author' require 'models/developer' require 'models/project' require 'models/comment' -require 'models/post' require 'models/category' class MethodScopingTest < ActiveRecord::TestCase |