Sha256: 77e0a587e517503873f4d1dc999dbc44578e871db3e59d967256dc659e24f687

Contents?: true

Size: 523 Bytes

Versions: 6

Compression:

Stored size: 523 Bytes

Contents

require_relative 'helper'

class Post < Sohm::Model
  include Sohm::AutoId
end

class User < Sohm::Model
  include Sohm::AutoId
  include Sohm::IndexAll

  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')
end

test '#exists? returns true if the given id is included in the set' do
  user = User.create
  post = Post.create
  user.posts.add(post)

  assert user.posts.exists?(post.id)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sohm-0.10.5 test/set.rb
sohm-0.10.4 test/set.rb
sohm-0.10.3 test/set.rb
sohm-0.10.2 test/set.rb
sohm-0.10.1 test/set.rb
sohm-0.10.0 test/set.rb