File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff 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 =~ /\A R[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'
Original file line number Diff line number Diff line change 11FactoryBot . 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
77end
88
Original file line number Diff line number Diff line change 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
1337end
You can’t perform that action at this time.
0 commit comments