File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,10 +52,14 @@ def documents
5252 def handle_parser_error ( response )
5353 raise AllsearchError . new (
5454 problem : 'UPSTREAM_ERROR' ,
55- msg : "Query to upstream failed with #{ ActionController :: Base . helpers . strip_tags ( response ) } "
55+ msg : "Query to upstream failed with #{ strip_html_tags ( response ) } "
5656 )
5757 end
5858
59+ def strip_html_tags ( text )
60+ text . gsub ( /<[^>]*>/ , '' )
61+ end
62+
5963 def query_is_too_long?
6064 @query_terms . length > maximum_characters
6165 end
Original file line number Diff line number Diff line change @@ -19,15 +19,15 @@ def service
1919 end
2020
2121 def title
22- document [ :readonly_title_ssim ] & .first
22+ Array ( document [ :readonly_title_ssim ] ) . first
2323 end
2424
2525 def creator
26- document [ :readonly_creator_ssim ] & .first
26+ Array ( document [ :readonly_creator_ssim ] ) . first
2727 end
2828
2929 def publisher
30- document [ :readonly_publisher_ssim ] & .first
30+ Array ( document [ :readonly_publisher_ssim ] ) . first
3131 end
3232
3333 def type
Original file line number Diff line number Diff line change @@ -47,13 +47,16 @@ def status_code
4747 end
4848
4949 def as_json
50- {
51- text :,
52- display_banner : display? ,
53- alert_status : status_code ,
54- dismissible :,
55- autoclear :
56- } . to_json
50+ require 'active_support/json'
51+ ActiveSupport ::JSON . encode (
52+ {
53+ text :,
54+ display_banner : display? ,
55+ alert_status : status_code ,
56+ dismissible :,
57+ autoclear :
58+ }
59+ )
5760 end
5861 end
5962 end
Original file line number Diff line number Diff line change 22
33require_relative 'boot'
44
5+ require 'active_record'
6+
57require_relative 'lando_env'
68require_relative 'db_connection'
79
810# Require the gems listed in Gemfile, including any gems
911# you've limited to :test, :development, or :production.
1012Bundler . require ( *CURRENT_ENVIRONMENT . bundler_groups )
1113
12- module BentoRailsApi
13- class Application < Rails ::Application
14- # Initialize configuration defaults for originally generated Rails version.
15- config . load_defaults 8.0
16-
17- # Use the sql format so that we can capture our postgres custom search configuration
18- config . active_record . schema_format = :sql
19-
20- # Configuration for the application, engines, and railties goes here.
21- #
22- # These settings can be overridden in specific environments using the files
23- # in config/environments, which are processed later.
24- #
25- # config.time_zone = "Central Time (US & Canada)"
26- # config.eager_load_paths << Rails.root.join("extras")
27- end
28- end
14+ # Use the sql format so that we can capture our postgres custom search configuration
15+ ActiveRecord . schema_format = :sql
Original file line number Diff line number Diff line change 8484 end
8585 end
8686
87- context 'when Rails raises NoMethodError during CSVLoadingService initialization' do
87+ context 'when rom_container raises NoMethodError during CSVLoadingService initialization' do
8888 it 'falls back to RomFactory and still works' do
89- allow ( Rails ) . to receive ( :application ) . and_raise ( NoMethodError )
90- expect { described_class . new . run } . to change ( best_bet , :count ) . by ( 7 )
89+ broken_rom = instance_double ( ROM ::Container )
90+ allow ( broken_rom ) . to receive ( :relations ) . and_raise ( NoMethodError )
91+ service = described_class . new ( rom_container : broken_rom )
92+ expect { service . run } . to change ( best_bet , :count ) . by ( 7 )
9193 end
9294 end
9395end
You can’t perform that action at this time.
0 commit comments