Sha256: 514c259b286990ebe738c16cf2269085494e783d73916d49f746dddbd70e5620

Contents?: true

Size: 1.46 KB

Versions: 50

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe "Blacklight::User" do

  subject { User.create! :email => 'xyz@example.com', :password => 'xyz12345' }

  def mock_bookmark document_id
    Bookmark.new document_id: document_id, document_type: SolrDocument.to_s
  end
  
  describe "#bookmarks_for_documents" do
    before do
      subject.bookmarks << mock_bookmark(1)
      subject.bookmarks << mock_bookmark(2)
      subject.bookmarks << mock_bookmark(3)
    end
    
    it "should return all the bookmarks that match the given documents" do
      bookmarks = subject.bookmarks_for_documents([SolrDocument.new(id: 1), SolrDocument.new(id: 2)])
      expect(bookmarks).to have(2).items
      expect(bookmarks.first.document_id).to eq "1"
      expect(bookmarks.last.document_id).to eq "2"
    end
  end
  
  describe "#document_is_bookmarked?" do
    before do
      subject.bookmarks << mock_bookmark(1)
    end
    
    it "should  be true if the document is bookmarked" do
      expect(subject).to be_document_is_bookmarked(SolrDocument.new(id: 1))
    end

    it "should be false if the document is not bookmarked" do
      expect(subject).to_not be_document_is_bookmarked(SolrDocument.new(id: 2))
    end
  end

  describe "#existing_bookmark_for" do
    before do
      subject.bookmarks << mock_bookmark(1)
    end
    
    it "should return the bookmark for that document id" do
      expect(subject.existing_bookmark_for(SolrDocument.new(id: 1))).to eq subject.bookmarks.first
    end
  end

end    

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
blacklight-5.13.0 spec/lib/blacklight/user_spec.rb
blacklight-5.11.3 spec/lib/blacklight/user_spec.rb
blacklight-5.12.1 spec/lib/blacklight/user_spec.rb
blacklight-5.12.0 spec/lib/blacklight/user_spec.rb
blacklight-5.10.3 spec/lib/blacklight/user_spec.rb
blacklight-5.9.4 spec/lib/blacklight/user_spec.rb
blacklight-5.11.2 spec/lib/blacklight/user_spec.rb
blacklight-5.11.1 spec/lib/blacklight/user_spec.rb
blacklight-5.11.0 spec/lib/blacklight/user_spec.rb
blacklight-5.10.2 spec/lib/blacklight/user_spec.rb
blacklight-5.10.1 spec/lib/blacklight/user_spec.rb
blacklight-5.10.0 spec/lib/blacklight/user_spec.rb
blacklight-5.9.3 spec/lib/blacklight/user_spec.rb
blacklight-5.9.2 spec/lib/blacklight/user_spec.rb
blacklight-5.9.1 spec/lib/blacklight/user_spec.rb
blacklight-5.9.0 spec/lib/blacklight/user_spec.rb
blacklight-5.8.2 spec/lib/blacklight/user_spec.rb
blacklight-5.8.1 spec/lib/blacklight/user_spec.rb
blacklight-5.8.0 spec/lib/blacklight/user_spec.rb
blacklight-5.7.2 spec/lib/blacklight/user_spec.rb