aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb4
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb2
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb6
-rw-r--r--activerecord/test/cases/timestamp_test.rb18
4 files changed, 23 insertions, 7 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index 28234ebe49..742513230e 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -75,8 +75,8 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
end
def test_eager_loading_with_primary_key
- apple = Firm.create("name" => "Apple")
- citibank = Client.create("name" => "Citibank", :firm_name => "Apple")
+ Firm.create("name" => "Apple")
+ Client.create("name" => "Citibank", :firm_name => "Apple")
citibank_result = Client.find(:first, :conditions => {:name => "Citibank"}, :include => :firm_with_primary_key)
assert_not_nil citibank_result.instance_variable_get("@firm_with_primary_key")
end
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index ed7d9a782c..c726fedd13 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -109,7 +109,7 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
record = con.select_rows(sql).last
assert_not_nil record[2]
assert_not_nil record[3]
- if current_adapter?(:Mysql2Adapter)
+ if current_adapter?(:Mysql2Adapter, :OracleAdapter)
assert_match %r{\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}}, record[2].to_s(:db)
assert_match %r{\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}}, record[3].to_s(:db)
else
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index a698f23fb6..9b3cc47c79 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -120,9 +120,9 @@ class AttributeMethodsTest < ActiveRecord::TestCase
assert_equal developer.created_at_before_type_cast, "345643456"
assert_equal developer.created_at, nil
- developer.created_at = "2010-03-21T21:23:32+01:00"
- assert_equal developer.created_at_before_type_cast, "2010-03-21T21:23:32+01:00"
- assert_equal developer.created_at, Time.parse("2010-03-21T21:23:32+01:00")
+ developer.created_at = "2010-03-21 21:23:32"
+ assert_equal developer.created_at_before_type_cast, "2010-03-21 21:23:32"
+ assert_equal developer.created_at, Time.parse("2010-03-21 21:23:32")
end
end
end
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb
index fce27d8972..db7accfc40 100644
--- a/activerecord/test/cases/timestamp_test.rb
+++ b/activerecord/test/cases/timestamp_test.rb
@@ -3,13 +3,15 @@ require 'models/developer'
require 'models/owner'
require 'models/pet'
require 'models/toy'
+require 'models/car'
class TimestampTest < ActiveRecord::TestCase
- fixtures :developers, :owners, :pets, :toys
+ fixtures :developers, :owners, :pets, :toys, :cars
def setup
@developer = Developer.first
@previously_updated_at = @developer.updated_at
+ @car = Car.first
end
def test_saving_a_changed_record_updates_its_timestamp
@@ -38,6 +40,16 @@ class TimestampTest < ActiveRecord::TestCase
assert_equal previous_salary, @developer.salary
end
+ def test_saving_when_record_timestamps_is_false_doesnt_update_its_timestamp
+ Developer.record_timestamps = false
+ @developer.name = "John Smith"
+ @developer.save!
+
+ assert_equal @previously_updated_at, @developer.updated_at
+ ensure
+ Developer.record_timestamps = true
+ end
+
def test_touching_a_different_attribute
previously_created_at = @developer.created_at
@developer.touch(:created_at)
@@ -48,6 +60,10 @@ class TimestampTest < ActiveRecord::TestCase
assert_not_equal @previously_updated_at, @developer.updated_at
end
+ def test_touch_a_record_without_timestamps
+ assert_nothing_raised { @car.touch }
+ end
+
def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at
pet = Pet.first
owner = pet.owner