Skip to content

Commit

Permalink
These methods became obsolete when IriTemplateService was created
Browse files Browse the repository at this point in the history
Ref PR #187 Create models for IRI templates and use IRI template service to build URLs
  • Loading branch information
elrayle committed Jan 9, 2019
1 parent b995a9b commit 586c1cc
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 150 deletions.
14 changes: 0 additions & 14 deletions lib/qa/authorities/linked_data/config/search_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,6 @@ def subauthority_replacement_pattern
default = url_mappings[pattern.to_sym][:default]
@subauthority_replacement_pattern ||= { pattern: pattern, default: default }
end

# Build a linked data authority search url
# @param [String] the query
# @param [String] (optional) subauthority key
# @param [Hash] (optional) replacement values with { pattern_name (defined in YAML config) => value }
# @return [String] the search encoded url
def url_with_replacements(query, sub_auth = nil, search_replacements = {})
return nil unless supports_search?
sub_auth = sub_auth.to_sym if sub_auth.present?
url = Config.replace_pattern(url_template, qa_replacement_patterns[:query], query, qa_replacement_encoded?(:query))
url = Config.process_subauthority(url, subauthority_replacement_pattern, subauthorities, sub_auth) if subauthorities?
url = Config.apply_replacements(url, replacements, search_replacements) if replacements?
url
end
end
end
end
14 changes: 0 additions & 14 deletions lib/qa/authorities/linked_data/config/term_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,6 @@ def term_subauthority_replacement_pattern
pattern = term_qa_replacement_patterns[:subauth]
@term_subauthority_replacement_pattern ||= { pattern: pattern, default: term_url_mappings[pattern.to_sym][:default] }
end

# Build a linked data authority term url
# @param [String] the id
# @param [String] (optional) subauthority key
# @param [Hash] (optional) replacement values with { pattern_name (defined in YAML config) => value }
# @return [String] the term encoded url
def term_url_with_replacements(id, sub_auth = nil, replacements = {})
return nil unless supports_term?
sub_auth = sub_auth.to_sym if sub_auth.is_a? String
url = Config.replace_pattern(term_url_template, term_qa_replacement_patterns[:term_id], id, term_qa_replacement_encoded?(:term_id))
url = Config.process_subauthority(url, term_subauthority_replacement_pattern, term_subauthorities, sub_auth) if term_subauthorities?
url = Config.apply_replacements(url, term_replacements, replacements) if term_replacements?
url
end
end
end
end
61 changes: 0 additions & 61 deletions spec/lib/authorities/linked_data/search_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,65 +335,4 @@
expect(full_config.subauthority_replacement_pattern).to eq expected_hash
end
end

# rubocop:disable RSpec/RepeatedExample
describe '#search_url_with_replacements' do
it 'returns nil if only term configuration is defined' do
expect(term_only_config.url_with_replacements('Smith')).to eq nil
end
context 'when subauthorities ARE defined' do
it 'returns the url with query substitution applied' do
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith&param1=delta&param2=echo'
expect(full_config.url_with_replacements('Smith')).to eq expected_url
end
it 'returns the url with default subauthority when NOT specified' do
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith&param1=delta&param2=echo'
expect(full_config.url_with_replacements('Smith')).to eq expected_url
end
it 'returns the url with subauthority substitution when specified' do
expected_url = 'http://localhost/test_default/search?subauth=search_sub3_name&query=Smith&param1=delta&param2=echo'
expect(full_config.url_with_replacements('Smith', 'search_sub3_key')).to eq expected_url
end
it 'returns the url with default values when replacements are NOT specified' do
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith&param1=delta&param2=echo'
expect(full_config.url_with_replacements('Smith')).to eq expected_url
end
it 'returns the url with replacement substitution values when replacements are specified' do
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith&param1=golf&param2=hotel'
expect(full_config.url_with_replacements('Smith', nil, param1: 'golf', param2: 'hotel')).to eq expected_url
end
end

context 'when subauthorities are not defined' do
it 'returns the url with query substitution applied' do
expected_url = 'http://localhost/test_default/search?query=Smith'
expect(min_config.url_with_replacements('Smith')).to eq expected_url
end
it 'and subauth param is included returns the url with query substitution applied ignoring the subauth' do
expected_url = 'http://localhost/test_default/search?query=Smith'
expect(min_config.url_with_replacements('Smith', 'fake_subauth_key')).to eq expected_url
end
end

context 'when replacements are not defined' do
it 'returns the url with query substitution applied' do
expected_url = 'http://localhost/test_default/search?query=Smith'
expect(min_config.url_with_replacements('Smith')).to eq expected_url
end
it 'and replacements param is included returns the url with query substitution applied ignoring the replacements' do
expected_url = 'http://localhost/test_default/search?query=Smith'
expect(min_config.url_with_replacements('Smith', nil, fake_replacement_key: 'fake_value')).to eq expected_url
end
end

context 'with encoding specified in config' do
it 'returns the uri as the url' do
expected_url = 'http://localhost/test_default/search?query=encoded%20because%3Aencode%3Dtrue&yes%3Aencoded%20here&no:encoding here&defaults:to not encoded'
query = 'encoded because:encode=true'
replacements = { encode_true: 'yes:encoded here', encode_false: 'no:encoding here', encode_not_specified: 'defaults:to not encoded' }
expect(encoding_config.url_with_replacements(query, nil, replacements)).to eq expected_url
end
end
end
# rubocop:enable RSpec/RepeatedExample
end
61 changes: 0 additions & 61 deletions spec/lib/authorities/linked_data/term_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -369,65 +369,4 @@
expect(full_config.term_subauthority_replacement_pattern).to eq expected_hash
end
end

# rubocop:disable RSpec/RepeatedExample
describe '#term_url_with_replacements' do
it 'returns nil if only search configuration is defined' do
expect(search_only_config.term_url_with_replacements('C123')).to eq nil
end
context 'when subauthorities ARE defined' do
it 'returns the url with query substitution applied' do
expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha&param2=beta'
expect(full_config.term_url_with_replacements('C123')).to eq expected_url
end
it 'returns the url with default subauthority when NOT specified' do
expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha&param2=beta'
expect(full_config.term_url_with_replacements('C123')).to eq expected_url
end
it 'returns the url with subauthority substitution when specified' do
expected_url = 'http://localhost/test_default/term/term_sub3_name/C123?param1=alpha&param2=beta'
expect(full_config.term_url_with_replacements('C123', 'term_sub3_key')).to eq expected_url
end
it 'returns the url with default values when replacements are NOT specified' do
expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha&param2=beta'
expect(full_config.term_url_with_replacements('C123')).to eq expected_url
end
it 'returns the url with replacement substitution values when replacements are specified' do
expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=golf&param2=hotel'
expect(full_config.term_url_with_replacements('C123', nil, param1: 'golf', param2: 'hotel')).to eq expected_url
end
end

context 'when subauthorities are NOT defined' do
it 'returns the url with query substitution applied' do
expected_url = 'http://localhost/test_default/term/C123'
expect(min_config.term_url_with_replacements('C123')).to eq expected_url
end
it 'and subauth param is included returns the url with query substitution applied ignoring the subauth' do
expected_url = 'http://localhost/test_default/term/C123'
expect(min_config.term_url_with_replacements('C123', 'fake_subauth_key')).to eq expected_url
end
end

context 'when replacements are not defined' do
it 'returns the url with query substitution applied' do
expected_url = 'http://localhost/test_default/term/C123'
expect(min_config.term_url_with_replacements('C123')).to eq expected_url
end
it 'and replacements param is included returns the url with query substitution applied ignoring the replacements' do
expected_url = 'http://localhost/test_default/term/C123'
expect(min_config.term_url_with_replacements('C123', nil, fake_replacement_key: 'fake_value')).to eq expected_url
end
end

context 'with encoding specified in config' do
it 'returns the uri as the url' do
expected_url = 'http://localhost/test_default/term?uri=http%3A%2F%2Fencoded%2Ebecause%3Fencode%3Dtrue&yes%3Aencoded%20here&no:encoding here&defaults:to not encoded'
term_uri = 'http://encoded.because?encode=true'
replacements = { encode_true: 'yes:encoded here', encode_false: 'no:encoding here', encode_not_specified: 'defaults:to not encoded' }
expect(encoding_config.term_url_with_replacements(term_uri, nil, replacements)).to eq expected_url
end
end
end
# rubocop:enable RSpec/RepeatedExample
end

0 comments on commit 586c1cc

Please sign in to comment.