aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-06-27 14:18:49 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-06-27 14:18:49 -0700
commit997aed24be07f0b34fbc98a77fe1bab38d90fa79 (patch)
tree5af4bfeb79ba2045db9c58a903c78d66524fe4a0 /activerecord/test
parent506b2dad55f43e22f46bd85129b08bfcc7ca25dc (diff)
downloadrails-997aed24be07f0b34fbc98a77fe1bab38d90fa79.tar.gz
rails-997aed24be07f0b34fbc98a77fe1bab38d90fa79.tar.bz2
rails-997aed24be07f0b34fbc98a77fe1bab38d90fa79.zip
default create_with_value to a hash so we can eliminate conditionals, add test surrounding create_with(nil) behavior
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/relation_scoping_test.rb7
-rw-r--r--activerecord/test/cases/relation_test.rb3
2 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index 0e158df6a0..77b7648576 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -472,6 +472,13 @@ class DefaultScopingTest < ActiveRecord::TestCase
assert_equal 'Jamis', jamis.name
end
+ # FIXME: I don't know if this is *desired* behavior, but it is *today's*
+ # behavior.
+ def test_create_with_empty_hash_will_not_reset
+ jamis = PoorDeveloperCalledJamis.create_with(:name => 'Aaron').create_with({}).new
+ assert_equal 'Aaron', jamis.name
+ end
+
def test_unscoped_with_named_scope_should_not_have_default_scope
assert_equal [DeveloperCalledJamis.find(developers(:poor_jamis).id)], DeveloperCalledJamis.poor
diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb
index 12e58bd340..9110e81127 100644
--- a/activerecord/test/cases/relation_test.rb
+++ b/activerecord/test/cases/relation_test.rb
@@ -20,7 +20,7 @@ module ActiveRecord
end
def test_single_values
- assert_equal [:limit, :offset, :lock, :readonly, :create_with, :from, :reorder, :reverse_order].map(&:to_s).sort,
+ assert_equal [:limit, :offset, :lock, :readonly, :from, :reorder, :reverse_order].map(&:to_s).sort,
Relation::SINGLE_VALUE_METHODS.map(&:to_s).sort
end
@@ -103,6 +103,7 @@ module ActiveRecord
relation = Relation.new Post, Post.arel_table
hash = { :hello => 'world' }
relation.create_with_value = hash
+ p relation.method(:create_with_value).source_location
assert_equal hash, relation.scope_for_create
end