Sha256: 9c58539fdd4c989c77043d052946cd0212e542b9b3965d734e2d14d05e9ad729

Contents?: true

Size: 1.43 KB

Versions: 74

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

RSpec.describe "Blacklight::User", api: true 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).not_to 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

74 entries across 74 versions & 2 rubygems

Version Path
blacklight-7.40.0 spec/models/blacklight/user_spec.rb
blacklight-7.39.0 spec/models/blacklight/user_spec.rb
blacklight-7.38.0 spec/models/blacklight/user_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/models/blacklight/user_spec.rb
blacklight-7.37.0 spec/models/blacklight/user_spec.rb
blacklight-7.36.2 spec/models/blacklight/user_spec.rb
blacklight-7.36.1 spec/models/blacklight/user_spec.rb
blacklight-7.36.0 spec/models/blacklight/user_spec.rb
blacklight-7.35.0 spec/models/blacklight/user_spec.rb
blacklight-7.34.0 spec/models/blacklight/user_spec.rb
blacklight-7.33.1 spec/models/blacklight/user_spec.rb
blacklight-7.33.0 spec/models/blacklight/user_spec.rb
blacklight-7.32.0 spec/models/blacklight/user_spec.rb
blacklight-7.31.0 spec/models/blacklight/user_spec.rb
blacklight-7.30.0 spec/models/blacklight/user_spec.rb
blacklight-7.29.0 spec/models/blacklight/user_spec.rb
blacklight-7.28.0 spec/models/blacklight/user_spec.rb
blacklight-7.27.1 spec/models/blacklight/user_spec.rb
blacklight-7.27.0 spec/models/blacklight/user_spec.rb
blacklight-7.26.1 spec/models/blacklight/user_spec.rb