Sha256: 9014b80efabcbac773af700def9376d704cf1006ae21c26cb1ac6775a2656e42

Contents?: true

Size: 1 KB

Versions: 16

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

describe Object do
  context "bullet_key" do
    it "should return class and id composition" do
      post = Post.first
      expect(post.bullet_key).to eq("Post:#{post.id}")
    end

    if mongoid?
      it "should return class with namesapce and id composition" do
        post = Mongoid::Post.first
        expect(post.bullet_key).to eq("Mongoid::Post:#{post.id}")
      end
    end
  end

  context "primary_key_value" do
    it "should return id" do
      post = Post.first
      expect(post.primary_key_value).to eq(post.id)
    end

    it "should return primary key value" do
      post = Post.first
      Post.primary_key = 'name'
      expect(post.primary_key_value).to eq(post.name)
      Post.primary_key = 'id'
    end

    it "should return value for multiple primary keys" do
      post = Post.first
      allow(Post).to receive(:primary_keys).and_return([:category_id, :writer_id])
      expect(post.primary_key_value).to eq("#{post.category_id},#{post.writer_id}")
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
bullet-5.6.0 spec/bullet/ext/object_spec.rb
bullet-5.5.1 spec/bullet/ext/object_spec.rb
bullet-5.5.0 spec/bullet/ext/object_spec.rb
bullet-5.4.3 spec/bullet/ext/object_spec.rb
bullet-5.4.2 spec/bullet/ext/object_spec.rb
bullet-5.4.1 spec/bullet/ext/object_spec.rb
bullet-5.4.0 spec/bullet/ext/object_spec.rb
bullet-5.3.0 spec/bullet/ext/object_spec.rb
bullet-5.2.1 spec/bullet/ext/object_spec.rb
bullet-5.2.0 spec/bullet/ext/object_spec.rb
bullet-5.1.1 spec/bullet/ext/object_spec.rb
bullet-5.1.0 spec/bullet/ext/object_spec.rb
bullet-5.0.0 spec/bullet/ext/object_spec.rb
bullet-4.14.10 spec/bullet/ext/object_spec.rb
bullet-4.14.9 spec/bullet/ext/object_spec.rb
bullet-4.14.8 spec/bullet/ext/object_spec.rb