aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/attributes_test.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-07-03 13:01:39 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-07-03 13:01:39 +0100
commit2fe263bb328c20539f2970057f31e567ec4ab7c8 (patch)
tree63e85164fb09aca6beb78e1a5c52424fa49ed098 /activemodel/test/cases/attributes_test.rb
parentbf5ac9965f12840d469ef2a4a16e8205dbbe5253 (diff)
parenta4bdc00fec623f72592e663e6d7830eea0bc6ea4 (diff)
downloadrails-2fe263bb328c20539f2970057f31e567ec4ab7c8.tar.gz
rails-2fe263bb328c20539f2970057f31e567ec4ab7c8.tar.bz2
rails-2fe263bb328c20539f2970057f31e567ec4ab7c8.zip
Merge commit 'mainstream/master'
Conflicts: actionpack/lib/action_controller.rb actionpack/lib/action_controller/base/base.rb actionpack/lib/action_view/template/path.rb activesupport/lib/active_support/json/encoders/hash.rb
Diffstat (limited to 'activemodel/test/cases/attributes_test.rb')
-rw-r--r--activemodel/test/cases/attributes_test.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/activemodel/test/cases/attributes_test.rb b/activemodel/test/cases/attributes_test.rb
new file mode 100644
index 0000000000..5f3ea839a4
--- /dev/null
+++ b/activemodel/test/cases/attributes_test.rb
@@ -0,0 +1,30 @@
+require 'cases/helper'
+
+class AttributesTest < ActiveModel::TestCase
+ class Person
+ include ActiveModel::Attributes
+ attr_accessor :name
+ end
+
+ test "reads attribute" do
+ p = Person.new
+ assert_equal nil, p.read_attribute(:name)
+
+ p.name = "Josh"
+ assert_equal "Josh", p.read_attribute(:name)
+ end
+
+ test "writes attribute" do
+ p = Person.new
+ assert_equal nil, p.name
+
+ p.write_attribute(:name, "Josh")
+ assert_equal "Josh", p.name
+ end
+
+ test "returns all attributes" do
+ p = Person.new
+ p.name = "Josh"
+ assert_equal({"name" => "Josh"}, p.attributes)
+ end
+end