Skip to content

Commit fc333d1

Browse files
committed
TIMDEX source_link to sym
1 parent c8138cb commit fc333d1

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

app/helpers/search_helper.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ def format_highlight_label(field_name)
1515
end
1616

1717
def link_to_result(result)
18-
if result['source_link'].present?
19-
link_to(result[:title], result['source_link'])
18+
if result[:source_link].present?
19+
link_to(result[:title], result[:source_link])
2020
else
2121
result[:title]
2222
end
2323
end
2424

2525
def view_online(result)
26-
return unless result['source_link'].present?
26+
return unless result[:source_link].present?
2727

28-
link_to 'View online', result['source_link'], class: 'button button-primary'
28+
link_to 'View online', result[:source_link], class: 'button button-primary'
2929
end
3030

3131
def view_record(record_id)

app/models/normalize_timdex_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def normalize
2525
dates:,
2626
contributors:,
2727
highlight:,
28-
'source_link' => source_link
28+
source_link:
2929
}
3030
end
3131

test/helpers/search_helper_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SearchHelperTest < ActionView::TestCase
2727
end
2828

2929
test 'renders view_online link if source_link is present' do
30-
result = { title: 'A record', 'source_link' => 'https://example.org' }
30+
result = { title: 'A record', source_link: 'https://example.org' }
3131
assert_equal '<a class="button button-primary" href="https://example.org">View online</a>',
3232
view_online(result)
3333
end
@@ -170,7 +170,7 @@ class SearchHelperTest < ActionView::TestCase
170170
test 'link_to_result returns link when source_link is present' do
171171
result = {
172172
title: 'Sample Document Title',
173-
'source_link' => 'https://example.com/document'
173+
source_link: 'https://example.com/document'
174174
}
175175
expected_link = '<a href="https://example.com/document">Sample Document Title</a>'
176176
assert_equal expected_link, link_to_result(result)
@@ -179,15 +179,15 @@ class SearchHelperTest < ActionView::TestCase
179179
test 'link_to_result returns plain title when source_link is nil' do
180180
result = {
181181
title: 'Sample Document Title',
182-
'source_link' => nil
182+
source_link: nil
183183
}
184184
assert_equal 'Sample Document Title', link_to_result(result)
185185
end
186186

187187
test 'link_to_result returns plain title when source_link is empty string' do
188188
result = {
189189
title: 'Sample Document Title',
190-
'source_link' => ''
190+
source_link: ''
191191
}
192192
assert_equal 'Sample Document Title', link_to_result(result)
193193
end

test/models/normalize_timdex_record_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def minimal_record
204204

205205
test 'includes TIMDEX-specific source_link field' do
206206
normalized = NormalizeTimdexRecord.new(full_record, 'test').normalize
207-
assert_equal 'https://example.com/source/record/123', normalized['source_link']
207+
assert_equal 'https://example.com/source/record/123', normalized[:source_link]
208208
end
209209

210210
# Test that Primo-only fields are not included

test/models/normalize_timdex_results_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def empty_timdex_response
3131
assert_includes first_result.keys, :dates
3232
assert_includes first_result.keys, :contributors
3333
assert_includes first_result.keys, :highlight
34-
assert_includes first_result.keys, 'source_link'
34+
assert_includes first_result.keys, :source_link
3535

3636
# Check second record (minimal record)
3737
second_result = results.second

0 commit comments

Comments
 (0)