aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb13
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb16
-rw-r--r--activerecord/test/cases/dup_test.rb2
-rw-r--r--activerecord/test/cases/forbidden_attributes_protection_test.rb10
-rw-r--r--activerecord/test/cases/persistence_test.rb40
-rw-r--r--activerecord/test/models/bulb.rb6
6 files changed, 4 insertions, 83 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 83128628ef..66b5ea939e 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1558,19 +1558,6 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal "RED!", car.bulbs.to_a.first.color
end
- def test_new_is_called_with_attributes_and_options
- car = Car.create(:name => 'honda')
-
- bulb = car.bulbs.build
- assert_equal Bulb, bulb.class
-
- bulb = car.bulbs.build(:bulb_type => :custom)
- assert_equal Bulb, bulb.class
-
- bulb = car.bulbs.build({ :bulb_type => :custom }, :as => :admin)
- assert_equal CustomBulb, bulb.class
- end
-
def test_abstract_class_with_polymorphic_has_many
post = SubStiPost.create! :title => "fooo", :body => "baa"
tagging = Tagging.create! :taggable => post
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb
index a7ec0f2709..2d3cb654df 100644
--- a/activerecord/test/cases/associations/has_one_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_associations_test.rb
@@ -446,22 +446,6 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
assert_equal pirate.id, ship.pirate_id
end
- def test_new_is_called_with_attributes_and_options
- car = Car.create(:name => 'honda')
-
- bulb = car.build_bulb
- assert_equal Bulb, bulb.class
-
- bulb = car.build_bulb
- assert_equal Bulb, bulb.class
-
- bulb = car.build_bulb(:bulb_type => :custom)
- assert_equal Bulb, bulb.class
-
- bulb = car.build_bulb({ :bulb_type => :custom }, :as => :admin)
- assert_equal CustomBulb, bulb.class
- end
-
def test_build_with_block
car = Car.create(:name => 'honda')
diff --git a/activerecord/test/cases/dup_test.rb b/activerecord/test/cases/dup_test.rb
index 9705a11387..71b2b16608 100644
--- a/activerecord/test/cases/dup_test.rb
+++ b/activerecord/test/cases/dup_test.rb
@@ -49,7 +49,7 @@ module ActiveRecord
dbtopic = Topic.first
topic = Topic.new
- topic.attributes = dbtopic.attributes
+ topic.attributes = dbtopic.attributes.except("id")
#duped has no timestamp values
duped = dbtopic.dup
diff --git a/activerecord/test/cases/forbidden_attributes_protection_test.rb b/activerecord/test/cases/forbidden_attributes_protection_test.rb
index 4706eaec2b..9a2172f41e 100644
--- a/activerecord/test/cases/forbidden_attributes_protection_test.rb
+++ b/activerecord/test/cases/forbidden_attributes_protection_test.rb
@@ -46,14 +46,4 @@ class ForbiddenAttributesProtectionTest < ActiveRecord::TestCase
assert_equal 'Guille', person.first_name
assert_equal 'm', person.gender
end
-
- def test_protected_attributes_cannot_be_used_for_mass_assignment
- params = ProtectedParams.new(id: 1, first_name: 'Guille', gender: 'm')
- params.permit!
- person = Person.new(params)
-
- assert_equal 'Guille', person.first_name
- assert_equal 'm', person.gender
- assert_not_equal 1, person.id
- end
end
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb
index 4ffa4836e0..b5f32a57b2 100644
--- a/activerecord/test/cases/persistence_test.rb
+++ b/activerecord/test/cases/persistence_test.rb
@@ -608,26 +608,6 @@ class PersistencesTest < ActiveRecord::TestCase
assert_equal "The First Topic", topic.title
end
- def test_update_attributes_as_admin
- person = TightPerson.create({ "first_name" => 'Joshua' })
- person.update_attributes({ "first_name" => 'Josh', "gender" => 'm', "comments" => 'from NZ' }, :as => :admin)
- person.reload
-
- assert_equal 'Josh', person.first_name
- assert_equal 'm', person.gender
- assert_equal 'from NZ', person.comments
- end
-
- def test_update_attributes_without_protection
- person = TightPerson.create({ "first_name" => 'Joshua' })
- person.update_attributes({ "first_name" => 'Josh', "gender" => 'm', "comments" => 'from NZ' }, :without_protection => true)
- person.reload
-
- assert_equal 'Josh', person.first_name
- assert_equal 'm', person.gender
- assert_equal 'from NZ', person.comments
- end
-
def test_update_attributes!
Reply.validates_presence_of(:title)
reply = Reply.find(2)
@@ -649,26 +629,6 @@ class PersistencesTest < ActiveRecord::TestCase
Reply.reset_callbacks(:validate)
end
- def test_update_attributes_with_bang_as_admin
- person = TightPerson.create({ "first_name" => 'Joshua' })
- person.update_attributes!({ "first_name" => 'Josh', "gender" => 'm', "comments" => 'from NZ' }, :as => :admin)
- person.reload
-
- assert_equal 'Josh', person.first_name
- assert_equal 'm', person.gender
- assert_equal 'from NZ', person.comments
- end
-
- def test_update_attributestes_with_bang_without_protection
- person = TightPerson.create({ "first_name" => 'Joshua' })
- person.update_attributes!({ "first_name" => 'Josh', "gender" => 'm', "comments" => 'from NZ' }, :without_protection => true)
- person.reload
-
- assert_equal 'Josh', person.first_name
- assert_equal 'm', person.gender
- assert_equal 'from NZ', person.comments
- end
-
def test_destroyed_returns_boolean
developer = Developer.first
assert_equal false, developer.destroyed?
diff --git a/activerecord/test/models/bulb.rb b/activerecord/test/models/bulb.rb
index 967f733fe3..e4c0278c0d 100644
--- a/activerecord/test/models/bulb.rb
+++ b/activerecord/test/models/bulb.rb
@@ -18,12 +18,12 @@ class Bulb < ActiveRecord::Base
self[:color] = color.upcase + "!"
end
- def self.new(attributes = {}, options = {}, &block)
+ def self.new(attributes = {}, &block)
bulb_type = (attributes || {}).delete(:bulb_type)
- if options && options[:as] == :admin && bulb_type.present?
+ if bulb_type.present?
bulb_class = "#{bulb_type.to_s.camelize}Bulb".constantize
- bulb_class.new(attributes, options, &block)
+ bulb_class.new(attributes, &block)
else
super
end