Skip to content

Commit 1f2daa2

Browse files
committed
use old NDL search link if iss_itemno ends with '-00'
1 parent 29bb273 commit 1f2daa2

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

app/helpers/enju_biblio/application_helper.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ def identifier_link(identifier)
5757
when 'doi'
5858
link_to identifier.body, "https://doi.org/#{identifier.body}"
5959
when 'iss_itemno'
60-
link_to identifier.body, "https://ndlsearch.ndl.go.jp/books/#{identifier.body}"
60+
if identifier.body =~ /\AR[0-9A-Za-z]+?-I[0-9A-Za-z]+?-00\z/
61+
link_to identifier.body, "https://iss.ndl.go.jp/books/#{identifier.body}"
62+
else
63+
link_to identifier.body, "https://ndlsearch.ndl.go.jp/books/#{identifier.body}"
64+
end
6165
when 'lccn'
6266
link_to identifier.body, "https://lccn.loc.gov/#{identifier.body}"
6367
when 'ncid'

spec/factories/identifiers.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
FactoryBot.define do
22
factory :identifier do
33
sequence(:body){|n| "identifier_body_#{n}"}
4-
identifier_type_id{FactoryBot.create(:identifier_type).id}
5-
association(:manifestation)
4+
association :identifier_type
5+
association :manifestation
66
end
77
end
88

spec/helpers/enju_biblio/application_helper_spec.rb

+25-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,31 @@
77
expect(helper.form_icon(nil)).to match /src=\"\/assets\/icons\/help-/
88
end
99

10-
it "should render form_icon if carrier_type's attachment is blank " do
10+
it "should render form_icon if carrier_type's attachment is blank" do
1111
expect(helper.form_icon(FactoryBot.create(:carrier_type))).to match /src=\"\/assets\/icons\/help-/
1212
end
13+
14+
it "should link to old NDL search if iss_itemno ends with '-00'" do
15+
expect(
16+
helper.identifier_link(
17+
FactoryBot.build(
18+
:identifier,
19+
body: 'R100000039-I001413988-00',
20+
identifier_type: IdentifierType.find_by(name: 'iss_itemno')
21+
)
22+
)
23+
).to eq "<a href=\"https://iss.ndl.go.jp/books/R100000039-I001413988-00\">R100000039-I001413988-00</a>"
24+
end
25+
26+
it "should link to new NDL search if iss_itemno doesn't end with '-00'" do
27+
expect(
28+
helper.identifier_link(
29+
FactoryBot.build(
30+
:identifier,
31+
body: 'R100000039-I001413988',
32+
identifier_type: IdentifierType.find_by(name: 'iss_itemno')
33+
)
34+
)
35+
).to eq "<a href=\"https://ndlsearch.ndl.go.jp/books/R100000039-I001413988\">R100000039-I001413988</a>"
36+
end
1337
end

0 commit comments

Comments
 (0)