test/set.rb in ohm-2.0.0.rc1 vs test/set.rb in ohm-2.0.0.rc2
- old
+ new
@@ -2,10 +2,14 @@
class Post < Ohm::Model
end
class User < Ohm::Model
+ attribute :name
+
+ index :name
+
set :posts, :Post
end
test '#exists? returns false if the given id is not included in the set' do
assert !User.create.posts.exists?('nonexistent')
@@ -15,6 +19,19 @@
user = User.create
post = Post.create
user.posts.add(post)
assert user.posts.exists?(post.id)
+end
+
+test "#ids returns an array with the ids" do
+ user_ids = [
+ User.create(name: "John").id,
+ User.create(name: "Jane").id
+ ]
+
+ assert_equal user_ids, User.all.ids
+
+ result = User.find(name: "John").union(name: "Jane")
+
+ assert_equal user_ids, result.ids
end