aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rwxr-xr-xactiverecord/test/abstract_unit.rb2
-rw-r--r--activerecord/test/fixtures/developer.rb6
-rw-r--r--activerecord/test/fixtures/developers.yml3
-rwxr-xr-xactiverecord/test/validations_test.rb9
4 files changed, 15 insertions, 5 deletions
diff --git a/activerecord/test/abstract_unit.rb b/activerecord/test/abstract_unit.rb
index 293f3ba6b3..67984a4609 100755
--- a/activerecord/test/abstract_unit.rb
+++ b/activerecord/test/abstract_unit.rb
@@ -4,6 +4,8 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
require 'test/unit'
require 'active_record'
require 'active_record/fixtures'
+require 'active_record/support/binding_of_caller'
+require 'active_record/support/breakpoint'
require 'connection'
class Test::Unit::TestCase #:nodoc:
diff --git a/activerecord/test/fixtures/developer.rb b/activerecord/test/fixtures/developer.rb
index 1c4cc30506..78f8f54db7 100644
--- a/activerecord/test/fixtures/developer.rb
+++ b/activerecord/test/fixtures/developer.rb
@@ -1,8 +1,6 @@
class Developer < ActiveRecord::Base
has_and_belongs_to_many :projects
- protected
- def validate
- errors.add_on_boundary_breaking("name", 3..20)
- end
+ validates_inclusion_of :salary, :in => 50000..200000
+ validates_length_of :name, :within => 3..20
end
diff --git a/activerecord/test/fixtures/developers.yml b/activerecord/test/fixtures/developers.yml
index 733455f789..fc33af99b6 100644
--- a/activerecord/test/fixtures/developers.yml
+++ b/activerecord/test/fixtures/developers.yml
@@ -1,13 +1,16 @@
david:
id: 1
name: David
+ salary: 80000
jamis:
id: 2
name: Jamis
+ salary: 150000
<% for digit in 3..10 %>
dev_<%= digit %>:
id: <%= digit %>
name: fixture_<%= digit %>
+ salary: 100000
<% end %> \ No newline at end of file
diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb
index b6c9cfed7d..8949206706 100755
--- a/activerecord/test/validations_test.rb
+++ b/activerecord/test/validations_test.rb
@@ -348,4 +348,11 @@ class ValidationsTest < Test::Unit::TestCase
assert_equal "hoo 5", t.errors["title"]
end
-end
+
+ def test_throw_away_typing
+ d = Developer.create "name" => "David", "salary" => "100,000"
+ assert !d.valid?
+ assert_not_equal "100,000", d.salary
+ assert_equal "100,000", d.salary_before_type_cast
+ end
+end \ No newline at end of file