test/model.rb in ohm-2.0.0.alpha3 vs test/model.rb in ohm-2.0.0.alpha4
- old
+ new
@@ -40,10 +40,14 @@
module SomeNamespace
class Foo < Ohm::Model
attribute :name
end
+
+ class Bar < Ohm::Model
+ reference :foo, 'SomeNamespace::Foo'
+ end
end
class Meetup < Ohm::Model
attribute :name
attribute :location
@@ -777,12 +781,15 @@
# namespaced models
test "be persisted" do
SomeNamespace::Foo.create(:name => "foo")
+ SomeNamespace::Bar.create(:foo => SomeNamespace::Foo[1])
+
assert "hash" == Ohm.redis.call("TYPE", "SomeNamespace::Foo:1")
assert "foo" == SomeNamespace::Foo[1].name
+ assert "foo" == SomeNamespace::Bar[1].foo.name
end
test "typecast attributes" do
class Option < Ohm::Model
attribute :votes, lambda { |x| x.to_i }