Skip to content

Commit c370fff

Browse files
authored
Merge pull request #126 from pulibrary/display-subguide-images
Display images and fix CI
2 parents d64620a + 174165a commit c370fff

File tree

10 files changed

+50
-25
lines changed

10 files changed

+50
-25
lines changed

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ group :development, :test do
7676
gem 'selenium-webdriver'
7777
gem 'simplecov'
7878
gem 'simplecov-lcov', '~> 0.8.0'
79-
gem 'webdrivers'
8079
end
8180

8281
group :development do

Gemfile.lock

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ GEM
6666
i18n (>= 1.6, < 2)
6767
minitest (>= 5.1)
6868
tzinfo (~> 2.0)
69-
addressable (2.8.4)
69+
addressable (2.8.5)
7070
public_suffix (>= 2.0.2, < 6.0)
7171
airbrussh (1.4.1)
7272
sshkit (>= 1.6.1, != 1.7.0)
@@ -92,7 +92,7 @@ GEM
9292
capistrano-rails-console (2.3.0)
9393
capistrano (>= 3.5.0, < 4.0.0)
9494
sshkit-interactive (~> 0.3.0)
95-
capybara (3.39.0)
95+
capybara (3.39.2)
9696
addressable
9797
matrix
9898
mini_mime (>= 0.1.3)
@@ -155,7 +155,7 @@ GEM
155155
marcel (1.0.2)
156156
matrix (0.4.2)
157157
method_source (1.0.0)
158-
mini_mime (1.1.2)
158+
mini_mime (1.1.5)
159159
minitest (5.18.0)
160160
msgpack (1.6.1)
161161
net-imap (0.3.4)
@@ -171,9 +171,9 @@ GEM
171171
net-protocol
172172
net-ssh (7.1.0)
173173
nio4r (2.5.9)
174-
nokogiri (1.14.3-arm64-darwin)
174+
nokogiri (1.15.4-arm64-darwin)
175175
racc (~> 1.4)
176-
nokogiri (1.14.3-x86_64-linux)
176+
nokogiri (1.15.4-x86_64-linux)
177177
racc (~> 1.4)
178178
parallel (1.22.1)
179179
parser (3.2.1.1)
@@ -185,11 +185,11 @@ GEM
185185
pry-byebug (3.10.1)
186186
byebug (~> 11.0)
187187
pry (>= 0.13, < 0.15)
188-
public_suffix (5.0.1)
188+
public_suffix (5.0.3)
189189
puma (5.6.7)
190190
nio4r (~> 2.0)
191-
racc (1.6.2)
192-
rack (2.2.6.4)
191+
racc (1.7.1)
192+
rack (2.2.8)
193193
rack-proxy (0.7.6)
194194
rack
195195
rack-test (2.1.0)
@@ -222,10 +222,10 @@ GEM
222222
zeitwerk (~> 2.5)
223223
rainbow (3.1.1)
224224
rake (13.0.6)
225-
regexp_parser (2.7.0)
225+
regexp_parser (2.8.1)
226226
reline (0.3.2)
227227
io-console (~> 0.5)
228-
rexml (3.2.5)
228+
rexml (3.2.6)
229229
rspec-core (3.12.1)
230230
rspec-support (~> 3.12.0)
231231
rspec-expectations (3.12.2)
@@ -261,7 +261,7 @@ GEM
261261
rubocop (>= 1.33.0, < 2.0)
262262
ruby-progressbar (1.13.0)
263263
rubyzip (2.3.2)
264-
selenium-webdriver (4.9.0)
264+
selenium-webdriver (4.11.0)
265265
rexml (~> 3.2, >= 3.2.5)
266266
rubyzip (>= 1.2.2, < 3.0)
267267
websocket (~> 1.0)
@@ -312,10 +312,6 @@ GEM
312312
activemodel (>= 6.0.0)
313313
bindex (>= 0.4.0)
314314
railties (>= 6.0.0)
315-
webdrivers (5.2.0)
316-
nokogiri (~> 1.6)
317-
rubyzip (>= 1.3.0)
318-
selenium-webdriver (~> 4.0)
319315
websocket (1.2.9)
320316
websocket-driver (0.7.5)
321317
websocket-extensions (>= 0.1.0)
@@ -359,7 +355,6 @@ DEPENDENCIES
359355
tzinfo-data
360356
vite_rails
361357
web-console
362-
webdrivers
363358

364359
RUBY VERSION
365360
ruby 3.2.0p0

app/controllers/sub_guide_cards_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ def index; end
66

77
def show
88
@sub_guide_card = SubGuideCard.find(params[:id])
9+
@card_images = CardImage.where(path: @sub_guide_card.path)
910
end
1011
end

app/models/card_image.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# frozen_string_literal: true
22

3+
# Class for CardImage data models
34
class CardImage < ApplicationRecord
5+
def iiif_url
6+
"https://puliiif.princeton.edu/iiif/2/#{image_name.gsub('.tif', '')}/full/,500/0/default.jpg"
7+
end
48
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
<h1>SubGuideCards#show</h1>
22
<p>Find me in app/views/sub_guide_cards/show.html.erb</p>
33
<%= @sub_guide_card.heading %>
4+
<% @card_images.each do |image| %>
5+
<%= image_tag(image.iiif_url) %>
6+
<% end %>

spec/models/card_image_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@
99
ci.image_name = 'imagecat-disk5-0338-A5977-0000.0001.tif'
1010
ci.save
1111
end
12+
it 'has a iiif url' do
13+
ci = CardImage.new
14+
ci.path = '5/0338/A5977'
15+
ci.image_name = 'imagecat-disk1-0675-B1764-0000.0219.tif'
16+
ci.save
17+
expect(ci.iiif_url).to eq 'https://puliiif.princeton.edu/iiif/2/imagecat-disk1-0675-B1764-0000.0219/full/,500/0/default.jpg'
18+
end
1219
end

spec/rails_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
require 'rspec/rails'
1010
require 'capybara/rails'
1111
require 'capybara/rspec'
12-
require 'webdrivers'
1312
# Add additional requires below this line. Rails is not loaded until this point!
1413

1514
# Requires supporting ruby files with custom matchers and macros, etc, in

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# the additional setup, and require it from the spec files that actually need
1515
# it.
1616
require 'simplecov'
17+
require 'ruby-progressbar/outputs/null'
1718

1819
SimpleCov.start 'rails' do
1920
if ENV['CI']

spec/support/system_specs.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
RSpec.configure do |config|
44
config.before(:each, type: :system) do
5-
Webdrivers::Chromedriver.required_version = '114.0.5735.90'
65
driven_by(:rack_test)
76
end
87

@@ -12,14 +11,8 @@
1211
else
1312
driven_by(:selenium_headless)
1413
end
15-
16-
# Make the screen larger so the save button is alway on screen. This avoids random `Element is not clickable` errors
17-
Capybara.page.driver.browser.manage.window.resize_to(2000, 2000)
1814
end
1915
config.before(:each, type: :system, js: true, in_browser: true) do
2016
driven_by(:selenium)
21-
22-
# Make the screen larger so the save button is alway on screen. This avoids random `Element is not clickable` errors
23-
Capybara.page.driver.browser.manage.window.resize_to(2000, 2000)
2417
end
2518
end

spec/system/subguide_cards_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
require 'ruby-progressbar/outputs/null'
5+
6+
RSpec.describe 'SubGuideCards', type: :system, js: true do
7+
let(:subguide_card_fixture) { Rails.root.join('spec', 'fixtures', 'subguide_card_fixture.csv') }
8+
before do
9+
SubGuideLoadingService.new(csv_location: subguide_card_fixture,
10+
progressbar: ProgressBar.create(output: ProgressBar::Outputs::Null)).import
11+
end
12+
13+
describe 'show page' do
14+
it 'displays card images as links' do
15+
ci = CardImage.new
16+
ci.path = SubGuideCard.find(2).path
17+
ci.image_name = 'imagecat-disk1-0675-B1764-0000.0219.tif'
18+
ci.save
19+
visit '/sub_guide_cards/2'
20+
expect(page).to have_selector('img')
21+
end
22+
end
23+
end

0 commit comments

Comments
 (0)