test/model.rb in ohm-2.0.0.alpha4 vs test/model.rb in ohm-2.0.0.alpha5
- old
+ new
@@ -55,16 +55,10 @@
def validate
assert_present :name
end
end
-class Invoice < Ohm::Model
- def _initialize_id
- @id = "_custom_id"
- end
-end
-
test "booleans" do
post = Post.new(body: true, published: false)
post.save
@@ -75,19 +69,10 @@
assert_equal "true", post.body
assert_equal nil, post.published
end
-test "customized ID" do
- inv = Invoice.create
- assert_equal "_custom_id", inv.id
-
- i = Invoice.create(:id => "_diff_id")
- assert_equal "_diff_id", i.id
- assert_equal i, Invoice["_diff_id"]
-end
-
test "empty model is ok" do
class Foo < Ohm::Model
end
Foo.create
@@ -133,12 +118,12 @@
test "assign an ID and save the object" do
event1 = Event.create(:name => "Ruby Tuesday")
event2 = Event.create(:name => "Ruby Meetup")
- assert "1" == event1.id
- assert "2" == event2.id
+ assert 1 == event1.id
+ assert 2 == event2.id
end
test "updates attributes" do
event = Meetup.create(:name => "Ruby Tuesday")
event.update(:name => "Ruby Meetup")
@@ -284,11 +269,11 @@
event2.save
assert !event1.new?
assert !event2.new?
- assert "1" == event1.id
- assert "2" == event2.id
+ assert 1 == event1.id
+ assert 2 == event2.id
end
# Saving a model
test "create the model if it is new" do
event = Event.new(:name => "Foo").save