Changeset 9192
- Timestamp:
- 04/01/08 06:46:40 (3 months ago)
- Files:
-
- trunk/activerecord/test/cases/validations_test.rb (modified) (7 diffs)
- trunk/activerecord/test/models/topic.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/test/cases/validations_test.rb
r9168 r9192 9 9 # The following methods in Topic are used in test_conditional_validation_* 10 10 class Topic 11 has_many :unique_replies, :dependent => :destroy, :foreign_key => "parent_id" 12 has_many :silly_unique_replies, :dependent => :destroy, :foreign_key => "parent_id" 13 11 14 def condition_is_true 12 returntrue15 true 13 16 end 14 17 15 18 def condition_is_true_but_its_not 16 returnfalse19 false 17 20 end 18 21 end … … 35 38 end 36 39 37 class Topic < ActiveRecord::Base38 has_many :unique_replies, :dependent => :destroy, :foreign_key => "parent_id"39 has_many :silly_unique_replies, :dependent => :destroy, :foreign_key => "parent_id"40 end41 42 40 class Wizard < ActiveRecord::Base 43 41 self.abstract_class = true … … 55 53 class Thaumaturgist < IneptWizard 56 54 end 55 57 56 58 57 class ValidationsTest < ActiveRecord::TestCase … … 961 960 def test_optionally_validates_length_of_using_within_utf8 962 961 with_kcode('UTF8') do 963 Topic.validates_length_of :title, :content, :within => 3..5, :allow_nil => true 964 965 t = Topic.create('title' => 'äžäºäž', 'content' => 'äžäºäžåäº') 966 assert t.valid? 962 Topic.validates_length_of :title, :within => 3..5, :allow_nil => true 963 964 t = Topic.create(:title => "äžäºäžåäº") 965 assert t.valid?, t.errors.inspect 966 967 t = Topic.create(:title => "äžäºäž") 968 assert t.valid?, t.errors.inspect 967 969 968 970 t.title = nil 969 assert t.valid? 971 assert t.valid?, t.errors.inspect 970 972 end 971 973 end … … 973 975 def test_optionally_validates_length_of_using_within_on_create_utf8 974 976 with_kcode('UTF8') do 975 Topic.validates_length_of :title, : content, :within => 5..10, :on => :create, :too_long => "é·ãããŸã: %d"977 Topic.validates_length_of :title, :within => 5..10, :on => :create, :too_long => "é·ãããŸã: %d" 976 978 977 979 t = Topic.create("title" => "äžäºäžåäºå … … 1003 1005 def test_optionally_validates_length_of_using_within_on_update_utf8 1004 1006 with_kcode('UTF8') do 1005 Topic.validates_length_of :title, : content, :within => 5..10, :on => :update, :too_short => "çãããŸã: %d"1007 Topic.validates_length_of :title, :within => 5..10, :on => :update, :too_short => "çãããŸã: %d" 1006 1008 1007 1009 t = Topic.create("title" => "äžäºäž4", "content" => "whatever") … … 1014 1016 assert_equal "çãããŸã: 5", t.errors[:title] 1015 1017 1016 t.title = "valid" 1017 t.content = "äžäºäžåäºå 1018 t.title = "äžäºäžåäºå 1018 1019 äžå 1019 1020 «ä¹åA" 1020 1021 assert !t.save 1021 assert t.errors.on(: content)1022 1023 t. content= "äžäº345"1022 assert t.errors.on(:title) 1023 1024 t.title = "äžäº345" 1024 1025 assert t.save 1025 1026 end trunk/activerecord/test/models/topic.rb
r9084 r9192 27 27 named_scope :named_extension, :extend => NamedExtension 28 28 named_scope :multiple_extensions, :extend => [MultipleExtensionTwo, MultipleExtensionOne] 29 29 30 30 has_many :replies, :dependent => :destroy, :foreign_key => "parent_id" 31 31 serialize :content … … 42 42 id 43 43 end 44 45 44 46 45 protected