@@ -103,148 +103,160 @@ class RecordHelperTest < ActionView::TestCase
103103  end 
104104
105105  test  'access_type returns nil if corresponding right is blank'  do 
106-     rights  =  {   
107-                 'rights'  =>  [ 
108-                   { 
109-                     'description'  =>  'foo' , 
110-                     'kind'  =>  'bar' 
111-                   } 
112-                 ] 
113-               } 
106+     rights  =  { 
107+       'rights'  =>  [ 
108+         { 
109+           'description'  =>  'foo' , 
110+           'kind'  =>  'bar' 
111+         } 
112+       ] 
113+     } 
114114    assert_nil  access_type ( rights ) 
115115  end 
116116
117117  test  'access_type returns the description of the corresponding right'  do 
118118    rights  =  { 
119-                 'rights'  =>  [ 
120-                   { 
121-                     'description'  =>  'foo' , 
122-                     'kind'  =>  'bar' 
123-                   } , 
124-                   { 
125-                     'description'  =>  'no authentication required' , 
126-                     'kind'  =>  'Access to files' 
127-                   } 
128-                 ] 
129-               } 
119+       'rights'  =>  [ 
120+         { 
121+           'description'  =>  'foo' , 
122+           'kind'  =>  'bar' 
123+         } , 
124+         { 
125+           'description'  =>  'no authentication required' , 
126+           'kind'  =>  'Access to files' 
127+         } 
128+       ] 
129+     } 
130130    assert_equal  'no authentication required' ,  access_type ( rights ) 
131131  end 
132132
133133  test  'gis_access_link returns nil if access type is blank'  do 
134134    links_no_rights  =  { 
135-                          'links'  =>  [ 
136-                            { 
137-                              'kind'  =>  'Download' , 
138-                              'text'  =>  'Data' , 
139-                              'url'  =>  'https://example.org/dz_f7regions_2016.zip' 
140-                            } , 
141-                            { 
142-                              'kind'  =>  'Website' , 
143-                              'text'  =>  'Website' , 
144-                              'url'  =>  'https://example.org/gismit:dz_f7regions_2016' 
145-                            } 
146-                          ] 
147-                        } 
135+       'links'  =>  [ 
136+         { 
137+           'kind'  =>  'Download' , 
138+           'text'  =>  'Data' , 
139+           'url'  =>  'https://example.org/dz_f7regions_2016.zip' 
140+         } , 
141+         { 
142+           'kind'  =>  'Website' , 
143+           'text'  =>  'Website' , 
144+           'url'  =>  'https://example.org/gismit:dz_f7regions_2016' 
145+         } 
146+       ] 
147+     } 
148148    assert_nil  access_type ( links_no_rights ) 
149149    assert_nil  gis_access_link ( links_no_rights ) 
150150  end 
151151
152152  test  'gis_access_link returns nil if links are blank'  do 
153153    rights_no_links  =  { 
154-                          'rights'  =>  [ 
155-                            { 
156-                              'description'  =>  'foo' , 
157-                              'kind'  =>  'bar' 
158-                            } , 
159-                            { 
160-                              'description'  =>  'no authentication required' , 
161-                              'kind'  =>  'Access to files' 
162-                            } 
163-                          ] 
164-                        } 
154+       'rights'  =>  [ 
155+         { 
156+           'description'  =>  'foo' , 
157+           'kind'  =>  'bar' 
158+         } , 
159+         { 
160+           'description'  =>  'no authentication required' , 
161+           'kind'  =>  'Access to files' 
162+         } 
163+       ] 
164+     } 
165165    assert_nil  gis_access_link ( rights_no_links ) 
166166  end 
167167
168168  test  'gis_access_link is website URL for non-MIT records'  do 
169169    access_elsewhere  =  { 
170-                           'rights'  =>  [ 
171-                             { 
172-                               'description'  =>  'foo' , 
173-                               'kind'  =>  'bar' 
174-                             } , 
175-                             { 
176-                               'description'  =>  'unknown: check with owning institution' , 
177-                               'kind'  =>  'Access to files' 
178-                             } 
179-                           ] , 
180-                           'links'  =>  [ 
181-                             { 
182-                               'kind'  =>  'Download' , 
183-                               'text'  =>  'Data' , 
184-                               'url'  =>  'https://example.org/dz_f7regions_2016.zip' 
185-                             } , 
186-                             { 
187-                               'kind'  =>  'Website' , 
188-                               'text'  =>  'Website' , 
189-                               'url'  =>  'https://example.org/gismit:dz_f7regions_2016' 
190-                             } 
191-                           ] , 
192-                           'provider'  =>  'Spelman' 
193-                         } 
170+       'rights'  =>  [ 
171+         { 
172+           'description'  =>  'foo' , 
173+           'kind'  =>  'bar' 
174+         } , 
175+         { 
176+           'description'  =>  'unknown: check with owning institution' , 
177+           'kind'  =>  'Access to files' 
178+         } 
179+       ] , 
180+       'links'  =>  [ 
181+         { 
182+           'kind'  =>  'Download' , 
183+           'text'  =>  'Data' , 
184+           'url'  =>  'https://example.org/dz_f7regions_2016.zip' 
185+         } , 
186+         { 
187+           'kind'  =>  'Website' , 
188+           'text'  =>  'Website' , 
189+           'url'  =>  'https://example.org/gismit:dz_f7regions_2016' 
190+         } 
191+       ] , 
192+       'provider'  =>  'Spelman' 
193+     } 
194194    assert_equal  'https://example.org/gismit:dz_f7regions_2016' ,  gis_access_link ( access_elsewhere ) 
195195  end 
196196
197197  test  'gis_access_link is data download URL for MIT records'  do 
198198    access_free  =  { 
199-                      'rights'  =>  [ 
200-                        { 
201-                          'description'  =>  'foo' , 
202-                          'kind'  =>  'bar' 
203-                        } , 
204-                        { 
205-                          'description'  =>  'no authentication required' , 
206-                          'kind'  =>  'Access to files' 
207-                        } 
208-                      ] , 
209-                      'links'  =>  [ 
210-                        { 
211-                          'kind'  =>  'Download' , 
212-                          'text'  =>  'Data' , 
213-                          'url'  =>  'https://example.org/dz_f7regions_2016.zip' 
214-                        } , 
215-                        { 
216-                          'kind'  =>  'Website' , 
217-                          'text'  =>  'Website' , 
218-                          'url'  =>  'https://example.org/gismit:dz_f7regions_2016' 
219-                        } 
220-                      ] 
221-                    } 
199+       'rights'  =>  [ 
200+         { 
201+           'description'  =>  'foo' , 
202+           'kind'  =>  'bar' 
203+         } , 
204+         { 
205+           'description'  =>  'no authentication required' , 
206+           'kind'  =>  'Access to files' 
207+         } 
208+       ] , 
209+       'links'  =>  [ 
210+         { 
211+           'kind'  =>  'Download' , 
212+           'text'  =>  'Data' , 
213+           'url'  =>  'https://example.org/dz_f7regions_2016.zip' 
214+         } , 
215+         { 
216+           'kind'  =>  'Website' , 
217+           'text'  =>  'Website' , 
218+           'url'  =>  'https://example.org/gismit:dz_f7regions_2016' 
219+         } 
220+       ] 
221+     } 
222222    access_auth  =  { 
223-                     'rights'  =>  [ 
224-                       { 
225-                         'description'  =>  'foo' , 
226-                         'kind'  =>  'bar' 
227-                       } , 
228-                       { 
229-                         'description'  =>  'MIT authentication required' , 
230-                         'kind'  =>  'Access to files' 
231-                       } 
232-                     ] , 
233-                     'links'  =>  [ 
234-                       { 
235-                         'kind'  =>  'Download' , 
236-                         'text'  =>  'Data' , 
237-                         'url'  =>  'https://example.org/dz_f7regions_2016.zip' 
238-                       } , 
239-                       { 
240-                         'kind'  =>  'Website' , 
241-                         'text'  =>  'Website' , 
242-                         'url'  =>  'https://example.org/gismit:dz_f7regions_2016' 
243-                       } 
244-                     ] 
245-                   } 
246-     assert_equal  'https://example.org/dz_f7regions_2016.zip' ,  gis_access_link ( access_free ) 
247-     assert_equal  'https://example.org/dz_f7regions_2016.zip' ,  gis_access_link ( access_auth ) 
223+       'rights'  =>  [ 
224+         { 
225+           'description'  =>  'foo' , 
226+           'kind'  =>  'bar' 
227+         } , 
228+         { 
229+           'description'  =>  'MIT authentication required' , 
230+           'kind'  =>  'Access to files' 
231+         } 
232+       ] , 
233+       'links'  =>  [ 
234+         { 
235+           'kind'  =>  'Download' , 
236+           'text'  =>  'Data' , 
237+           'url'  =>  'https://example.org/dz_f7regions_2016.zip' 
238+         } , 
239+         { 
240+           'kind'  =>  'Website' , 
241+           'text'  =>  'Website' , 
242+           'url'  =>  'https://example.org/gismit:dz_f7regions_2016' 
243+         } 
244+       ] 
245+     } 
246+     assert_equal  'https://example.org/dz_f7regions_2016.zip?timdexui=true' ,  gis_access_link ( access_free ) 
247+     assert_equal  'https://example.org/dz_f7regions_2016.zip?timdexui=true' ,  gis_access_link ( access_auth ) 
248+   end 
249+ 
250+   test  'append_timdexui_with_no_existing_query_values'  do 
251+     url  =  'https://example.org/dz_f7regions_2016.zip' 
252+     assert_equal ( 'https://example.org/dz_f7regions_2016.zip?timdexui=true' , 
253+                  append_timdexui ( url ) ) 
254+   end 
255+ 
256+   test  'append_timdexui_with_existing_query_values'  do 
257+     url  =  'https://example.org/dz_f7regions_2016.zip?hallo=goodbye' 
258+     assert_equal ( 'https://example.org/dz_f7regions_2016.zip?hallo=goodbye&timdexui=true' , 
259+                  append_timdexui ( url ) ) 
248260  end 
249261
250262  test  'source_metadata_available? returns true if source metadata link exists'  do 
@@ -272,7 +284,7 @@ class RecordHelperTest < ActionView::TestCase
272284
273285  test  'parse_nested_field returns nil for fields that are not nested'  do 
274286    string_field  =  'string' 
275-     array_of_strings_field  =  [ ' string' ,   ' other_string' ] 
287+     array_of_strings_field  =  %w[ string   other_string ] 
276288    assert_nil  parse_nested_field ( string_field ) 
277289    assert_nil  parse_nested_field ( array_of_strings_field ) 
278290  end 
@@ -304,8 +316,8 @@ class RecordHelperTest < ActionView::TestCase
304316
305317  test  'deduplicate_subjects returns only unique subjects'  do 
306318    # within the same subject 
307-     duplicative_subject  =  [ {  'kind'  =>  'foo' ,  'value'  =>  [ ' bar' ,   ' bar' ,   ' baz' ] } ] 
308-     assert_equal  [ [ ' bar' ,   ' baz' ] ] ,  deduplicate_subjects ( duplicative_subject ) 
319+     duplicative_subject  =  [ {  'kind'  =>  'foo' ,  'value'  =>  %w[ bar   bar   baz ]   } ] 
320+     assert_equal  [ %w[ bar   baz ] ] ,  deduplicate_subjects ( duplicative_subject ) 
309321
310322    # across multiple subjects 
311323    multiple_duplicative_subjects  =  [ {  'kind'  =>  'foo' ,  'value'  =>  [ 'bar' ]  } , 
@@ -315,7 +327,7 @@ class RecordHelperTest < ActionView::TestCase
315327
316328  test  'deduplicate_subjects ignores case'  do 
317329    # within the same subject 
318-     duplicative_subject  =  [ {  'kind'  =>  'foo' ,  'value'  =>  [ ' Bar' ,   ' BAR' ,   ' bar' ] } ] 
330+     duplicative_subject  =  [ {  'kind'  =>  'foo' ,  'value'  =>  %w[ Bar   BAR   bar ]   } ] 
319331    assert_equal  [ [ 'Bar' ] ] ,  deduplicate_subjects ( duplicative_subject ) 
320332
321333    # across multiple subjects 
0 commit comments