Ticket #785: validates_confirmation_of_ticket_785.diff
| File validates_confirmation_of_ticket_785.diff, 1.6 kB (added by z@wzph.com, 2 years ago) |
|---|
-
rails/activerecord/test/validations_test.rb
old new 172 172 assert developer.save 173 173 end 174 174 175 def test_ title_confirmation_no_confirm175 def test_no_title_confirmation 176 176 Topic.validates_confirmation_of(:title) 177 177 178 t = Topic.create( "title" => "We should not be confirmed")178 t = Topic.create( "author_name" => "Plutarch") 179 179 assert t.save 180 181 t.title_confirmation = "Parallel Lives" 182 assert t.save 183 184 t.title_confirmation = nil 185 t.title = "Parallel Lives" 186 assert !t.save 187 188 t.title_confirmation = "Parallel Lives" 189 assert t.save 180 190 end 181 191 182 192 def test_title_confirmation -
rails/activerecord/lib/active_record/validations.rb
old new 333 333 attr_accessor *(attr_names.map { |n| "#{n}_confirmation" }) 334 334 335 335 validates_each(attr_names, configuration) do |record, attr_name, value| 336 record.errors.add(attr_name, configuration[:message]) unless record.send( "#{attr_name}_confirmation").nil? or value == record.send("#{attr_name}_confirmation")336 record.errors.add(attr_name, configuration[:message]) unless record.send( attr_name ).nil? or value == record.send("#{attr_name}_confirmation") 337 337 end 338 338 end 339 339