• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / orangelight / 0e37073d-109c-440c-949f-49d2aa86311b

18 Aug 2025 09:05PM UTC coverage: 0.482% (-94.9%) from 95.343%
0e37073d-109c-440c-949f-49d2aa86311b

push

circleci

web-flow
Replace per_page_options_for_select with custom component to avoid deprecation issue (#5186)

* Start creating new component to address deprecaton warning

* Replace per_page_options_for_select with custom component to avoid deprecation issue

Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

---------

Co-authored-by: Ryan Jensen <rj1044@princeton.edu>
Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

0 of 33 new or added lines in 1 file covered. (0.0%)

9374 existing lines in 213 files now uncovered.

47 of 9753 relevant lines covered (0.48%)

0.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/controllers/bookmarks_controller.rb
1
# frozen_string_literal: true
2

UNCOV
3
require 'csv'
×
4

UNCOV
5
class BookmarksController < CatalogController
×
UNCOV
6
  include Blacklight::Bookmarks
×
UNCOV
7
  configure_blacklight do |_config|
×
UNCOV
8
    blacklight_config.show.document_actions[:print] =
×
UNCOV
9
      {
×
UNCOV
10
        partial: 'document_action',
×
UNCOV
11
        name: :print,
×
UNCOV
12
        modal: false
×
UNCOV
13
      }
×
UNCOV
14
  end
×
15

UNCOV
16
  def print
×
UNCOV
17
    fetch_bookmarked_documents
×
UNCOV
18
    @url_gen_params = {}
×
UNCOV
19
    render('orangelight/record_mailer/email_record', formats: [:text])
×
UNCOV
20
  end
×
21

UNCOV
22
  def citation
×
23
    bookmarks = token_or_current_or_guest_user.bookmarks
×
24
    bookmark_ids = bookmarks.collect { |bookmark| bookmark.document_id.to_s }
×
25
    @documents = search_service.fetch(bookmark_ids, { rows: bookmark_ids.count, fl: "author_citation_display, title_citation_display, pub_citation_display, number_of_pages_citation_display, pub_date_start_sort, edition_display, format" })
×
UNCOV
26
  end
×
27

UNCOV
28
  def csv
×
UNCOV
29
    fetch_bookmarked_documents
×
UNCOV
30
    send_data csv_output, type: 'text/csv', filename: "bookmarks-#{Time.zone.today}.csv"
×
UNCOV
31
  end
×
32

UNCOV
33
  private
×
34

UNCOV
35
    def fetch_bookmarked_documents
×
UNCOV
36
      bookmark_ids = token_or_current_or_guest_user.bookmarks.collect { |bookmark| bookmark.document_id.to_s }
×
UNCOV
37
      @documents = search_service.fetch(bookmark_ids, rows: bookmark_ids.length, fl: '*')
×
UNCOV
38
    end
×
39

40
    # byte-order-mark declaring our output as UTF-8 (required for non-ASCII to be handled by Excel)
UNCOV
41
    def csv_bom
×
UNCOV
42
      %w[EF BB BF].map { |a| a.hex.chr }.join
×
UNCOV
43
    end
×
44

UNCOV
45
    def csv_fields
×
UNCOV
46
      {
×
UNCOV
47
        id: 'ID',
×
UNCOV
48
        title_citation_display: ['Title', 'Title (Original Script)'],
×
UNCOV
49
        author_display: ['Author', 'Author (Original Script)'],
×
UNCOV
50
        format: 'Format',
×
UNCOV
51
        language_facet: 'Language',
×
UNCOV
52
        pub_citation_display: 'Published/Created',
×
UNCOV
53
        pub_date_display: 'Date',
×
UNCOV
54
        description_display: 'Description',
×
UNCOV
55
        series_display: 'Series',
×
UNCOV
56
        location: 'Library',
×
UNCOV
57
        location_display: 'Location',
×
UNCOV
58
        call_number_display: 'Call Number',
×
UNCOV
59
        notes_display: 'Notes',
×
UNCOV
60
        edition_display: 'Edition'
×
UNCOV
61
      }
×
UNCOV
62
    end
×
63

UNCOV
64
    def csv_output
×
UNCOV
65
      CSV.generate(csv_bom, headers: true) do |csv|
×
UNCOV
66
        csv << csv_fields.values.flatten
×
UNCOV
67
        @documents.each do |doc|
×
UNCOV
68
          csv << csv_fields.keys.map { |field| csv_values(doc, field) }.flatten
×
UNCOV
69
        end
×
UNCOV
70
      end
×
UNCOV
71
    end
×
72

UNCOV
73
    def csv_values(doc, field)
×
UNCOV
74
      if csv_fields[field] == 'ID'
×
UNCOV
75
        "'#{doc[field]}'"
×
UNCOV
76
      elsif csv_fields[field].is_a?(Array)
×
UNCOV
77
        two_values(doc[field])
×
UNCOV
78
      else
×
UNCOV
79
        Array(doc[field]).join('; ')
×
UNCOV
80
      end
×
UNCOV
81
    end
×
82

UNCOV
83
    def two_values(arr)
×
UNCOV
84
      values = arr || ['', '']
×
UNCOV
85
      values << '' if values.length == 1
×
UNCOV
86
      values.map { |v| v.chomp(' /') }
×
UNCOV
87
    end
×
UNCOV
88
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc