Ticket #8218: reload_models.patch
| File reload_models.patch, 3.9 kB (added by JakeB, 1 year ago) |
|---|
-
activerecord/test/fixtures/topic.rb
old new 14 14 id 15 15 end 16 16 17 # The following two methods are used in test_conditional_validation_* 18 def condition_is_true 19 return true 20 end 21 22 def condition_is_true_but_its_not 23 return false 24 end 25 17 26 protected 18 27 def default_written_on 19 28 self.written_on = Time.now unless attribute_present?("written_on") -
activerecord/test/validations_test.rb
old new 3 3 require 'fixtures/reply' 4 4 require 'fixtures/developer' 5 5 6 # The following methods in Topic are used in test_conditional_validation_*7 class Topic8 def condition_is_true9 return true10 end11 12 def condition_is_true_but_its_not13 return false14 end15 end16 17 6 class ValidationsTest < Test::Unit::TestCase 18 7 fixtures :topics, :developers 19 8 … … 21 10 Topic.write_inheritable_attribute(:validate, nil) 22 11 Topic.write_inheritable_attribute(:validate_on_create, nil) 23 12 Topic.write_inheritable_attribute(:validate_on_update, nil) 13 14 # Reset the model classes used 15 [:Reply, :SillyReply, :Topic, :Developer, :DeveloperSalary, :DeveloperWithAggregate, :DeveloperWithBeforeDestroyRaise].each do |c| 16 Object.send(:remove_const, c) 17 end 18 load 'fixtures/topic.rb' 19 load 'fixtures/reply.rb' 20 load 'fixtures/developer.rb' 24 21 end 25 22 26 23 def test_single_field_validation … … 892 899 def test_validates_format_of_with_custom_error_using_quotes 893 900 Developer.validates_format_of :name, :with => /^(A-Z*)$/, :message=> "format 'single' and \"double\" quotes" 894 901 d = Developer.new 895 d.name = d.name _confirmation= "John 32"902 d.name = d.name = "John 32" 896 903 assert !d.valid? 897 904 assert_equal "format 'single' and \"double\" quotes", d.errors.on(:name) 898 905 end … … 910 917 d = Developer.new 911 918 d.name = "Jeffrey" 912 919 assert !d.valid? 913 assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) .first920 assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) 914 921 end 915 922 916 923 def test_validates_length_of_with_custom_too_short_using_quotes … … 918 925 d = Developer.new 919 926 d.name = "Joe" 920 927 assert !d.valid? 921 assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) .first928 assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) 922 929 end 923 930 924 931 def test_validates_length_of_with_custom_message_using_quotes … … 926 933 d = Developer.new 927 934 d.name = "Joe" 928 935 assert !d.valid? 929 assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) .first936 assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) 930 937 end 931 938 932 939 def test_validates_presence_of_with_custom_message_using_quotes … … 942 949 d = Developer.new 943 950 d.name = "David" 944 951 assert !d.valid? 945 assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) .first952 assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) 946 953 end 947 954 948 955 def test_validates_associated_with_custom_message_using_quotes … … 951 958 r = Reply.create("title" => "A reply", "content" => "with content!") 952 959 r.topic = Topic.create("title" => "uhohuhoh") 953 960 assert !r.valid? 954 assert_equal "This string contains 'single' and \"double\" quotes", r.errors.on(:topic) .first961 assert_equal "This string contains 'single' and \"double\" quotes", r.errors.on(:topic) 955 962 end 956 963 957 964 def test_conditional_validation_using_method_true