Sha256: 97f7e25bdd20ed0cc9caec1333d6b7d6437709663f7e4951979953c3be75603e
Contents?: true
Size: 832 Bytes
Versions: 3
Compression:
Stored size: 832 Bytes
Contents
require File.join(File.dirname(__FILE__), "test_helper") class IndicesTest < Test::Unit::TestCase class User < Ohm::Model attribute :email index :email end context "A model with an indexed attribute" do setup do Ohm.redis.flushdb @user1 = User.create(:email => "foo") @user2 = User.create(:email => "bar") end should "be able to find by the given attribute" do assert_equal [@user1], User.find(:email, "foo") end should "update indices when changing attribute values" do @user1.email = "baz" @user1.save assert_equal [], User.find(:email, "foo") assert_equal [@user1], User.find(:email, "baz") end should "remove from the index after deleting" do @user2.delete assert_equal [], User.find(:email, "bar") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ohm-0.0.5 | test/indices_test.rb |
ohm-0.0.6 | test/indices_test.rb |
ohm-0.0.7 | test/indices_test.rb |