Sha256: 5c8287471f3be002c0993fda532da6ed5554ffd9695da2d6fd8d8bad8d10a598

Contents?: true

Size: 1.44 KB

Versions: 36

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

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 "returns 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 "is true if the document is bookmarked" do
      expect(subject).to be_document_is_bookmarked(SolrDocument.new(id: 1))
    end

    it "is 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 "returns 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

36 entries across 36 versions & 1 rubygems

Version Path
blacklight-6.25.0 spec/models/blacklight/user_spec.rb
blacklight-6.24.0 spec/models/blacklight/user_spec.rb
blacklight-6.23.0 spec/models/blacklight/user_spec.rb
blacklight-6.22.0 spec/models/blacklight/user_spec.rb
blacklight-6.21.0 spec/models/blacklight/user_spec.rb
blacklight-6.20.0 spec/models/blacklight/user_spec.rb
blacklight-6.19.2 spec/models/blacklight/user_spec.rb
blacklight-6.19.1 spec/models/blacklight/user_spec.rb
blacklight-6.19.0 spec/models/blacklight/user_spec.rb
blacklight-6.18.0 spec/models/blacklight/user_spec.rb
blacklight-6.17.0 spec/models/blacklight/user_spec.rb
blacklight-6.16.0 spec/models/blacklight/user_spec.rb
blacklight-6.15.0 spec/models/blacklight/user_spec.rb
blacklight-6.14.1 spec/models/blacklight/user_spec.rb
blacklight-6.14.0 spec/models/blacklight/user_spec.rb
blacklight-6.13.0 spec/models/blacklight/user_spec.rb
blacklight-6.12.0 spec/models/blacklight/user_spec.rb
blacklight-6.11.2 spec/models/blacklight/user_spec.rb
blacklight-6.11.1 spec/models/blacklight/user_spec.rb
blacklight-6.11.0 spec/models/blacklight/user_spec.rb