diff --git a/config/application.rb b/config/application.rb
index 7ea7b1b2..db6e9070 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -11,14 +11,6 @@
module TimdexUi
class Application < Rails::Application
- # Before filter for Flipflop dashboard. Replace with a lambda or method name
- # defined in ApplicationController to implement access control.
- config.flipflop.dashboard_access_filter = -> { head :forbidden }
-
- # By default, when set to `nil`, strategy loading errors are suppressed in test
- # mode. Set to `true` to always raise errors, or `false` to always warn.
- config.flipflop.raise_strategy_errors = nil
-
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.2
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 9e75f029..9b673600 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,14 +1,6 @@
require "active_support/core_ext/integer/time"
Rails.application.configure do
- # Before filter for Flipflop dashboard. Replace with a lambda or method name
- # defined in ApplicationController to implement access control.
- config.flipflop.dashboard_access_filter = nil
-
- # By default, when set to `nil`, strategy loading errors are suppressed in test
- # mode. Set to `true` to always raise errors, or `false` to always warn.
- config.flipflop.raise_strategy_errors = nil
-
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded any time
diff --git a/config/environments/test.rb b/config/environments/test.rb
index a955bbbd..0eae17f6 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -6,14 +6,6 @@
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do
- # Before filter for Flipflop dashboard. Replace with a lambda or method name
- # defined in ApplicationController to implement access control.
- config.flipflop.dashboard_access_filter = nil
-
- # By default, when set to `nil`, strategy loading errors are suppressed in test
- # mode. Set to `true` to always raise errors, or `false` to always warn.
- config.flipflop.raise_strategy_errors = nil
-
# Settings specified here will take precedence over those in config/application.rb.
# While tests run files are not watched, reloading is not necessary.
diff --git a/config/features.rb b/config/features.rb
deleted file mode 100644
index fb551ec2..00000000
--- a/config/features.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-Flipflop.configure do
- # Strategies will be used in the order listed here.
- strategy :session
- strategy :default
-
- feature :gdt,
- default: ENV.fetch('GDT', false),
- description: "Enable geodata discovery features."
-
- feature :boolean_picker,
- default: ENV.fetch('BOOLEAN_PICKER', false),
- description: "Enable user configurable boolean type selection."
-end
diff --git a/config/routes.rb b/config/routes.rb
index e1c2acf6..82746036 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,4 @@
Rails.application.routes.draw do
- mount Flipflop::Engine => "/flipflop"
root "basic_search#index"
get 'analyze', to: 'tacos#analyze'
diff --git a/db/migrate/20251023203259_drop_flipflip_features.rb b/db/migrate/20251023203259_drop_flipflip_features.rb
new file mode 100644
index 00000000..6a3b4ade
--- /dev/null
+++ b/db/migrate/20251023203259_drop_flipflip_features.rb
@@ -0,0 +1,10 @@
+class DropFlipflipFeatures < ActiveRecord::Migration[7.2]
+ def change
+ drop_table :flipflop_features do |t|
+ t.string :key, null: false
+ t.boolean :enabled, null: false, default: false
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 0064da22..18a4a3ba 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,12 +10,5 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.1].define(version: 2024_02_28_201656) do
- create_table "flipflop_features", force: :cascade do |t|
- t.string "key", null: false
- t.boolean "enabled", default: false, null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
+ActiveRecord::Schema[7.2].define(version: 2025_10_23_203259) do
end
diff --git a/test/controllers/record_controller_geo_test.rb b/test/controllers/record_controller_geo_test.rb
new file mode 100644
index 00000000..dab8f852
--- /dev/null
+++ b/test/controllers/record_controller_geo_test.rb
@@ -0,0 +1,51 @@
+require 'test_helper'
+
+class RecordControllerGeoTest < ActionDispatch::IntegrationTest
+ test 'no access button displays if GDT feature is disabled' do
+ gis_record_id = 'gismit:CAMBRIDGEMEMPOLES09'
+ VCR.use_cassette('gis record mit free',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ get "/record/#{gis_record_id}"
+ assert_select 'a.access-button', count: 0
+ end
+ end
+
+ test 'access button displays for freely accessible data' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ gis_record_id = 'gismit:CAMBRIDGEMEMPOLES09'
+ VCR.use_cassette('gis record mit free',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ get "/record/#{gis_record_id}"
+ assert_select 'a.access-button', text: 'Download geodata files',
+ href: 'https://cdn.dev1.mitlibrary.net/geo/public/CAMBRIDGEMEMPOLES09.zip'
+ end
+ end
+ end
+
+ test 'access button displays for data requiring MIT auth' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ gis_record_id = 'gismit:us_ma_boston_g47parcels_2018'
+ VCR.use_cassette('gis record mit auth',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ get "/record/#{gis_record_id}"
+ assert_select 'a.access-button', text: 'Download geodata files MIT authentication',
+ href: 'https://cdn.dev1.mitlibrary.net/geo/restricted/us_ma_boston_g47parcels_2018.zip'
+ end
+ end
+ end
+
+ test 'access button displays for non-MIT GIS records' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ gis_record_id = 'gisogm:edu.stanford.purl:be6ef8cd8ac5'
+ VCR.use_cassette('gis record elsewhere',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ get "/record/#{gis_record_id}"
+ assert_select 'a.access-button', text: 'View Stanford record', href: 'https://purl.stanford.edu/kv971cf1984'
+ end
+ end
+ end
+end
diff --git a/test/controllers/record_controller_test.rb b/test/controllers/record_controller_test.rb
index 6b9bbc7c..6e383396 100644
--- a/test/controllers/record_controller_test.rb
+++ b/test/controllers/record_controller_test.rb
@@ -36,54 +36,4 @@ class RecordControllerTest < ActionDispatch::IntegrationTest
assert_select 'main', /(.*)#{message}(.*)/
end
end
-
- class RecordControllerGeoTest < RecordControllerTest
- def setup
- @test_strategy = Flipflop::FeatureSet.current.test!
- @test_strategy.switch!(:gdt, true)
- end
-
- test 'no access button displays if GDT feature is disabled' do
- @test_strategy.switch!(:gdt, false)
- gis_record_id = 'gismit:CAMBRIDGEMEMPOLES09'
- VCR.use_cassette('gis record mit free',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- get "/record/#{gis_record_id}"
- assert_select 'a.access-button', count: 0
- end
- end
-
- test 'access button displays for freely accessible data' do
- gis_record_id = 'gismit:CAMBRIDGEMEMPOLES09'
- VCR.use_cassette('gis record mit free',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- get "/record/#{gis_record_id}"
- assert_select 'a.access-button', text: 'Download geodata files',
- href: 'https://cdn.dev1.mitlibrary.net/geo/public/CAMBRIDGEMEMPOLES09.zip'
- end
- end
-
- test 'access button displays for data requiring MIT auth' do
- gis_record_id = 'gismit:us_ma_boston_g47parcels_2018'
- VCR.use_cassette('gis record mit auth',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- get "/record/#{gis_record_id}"
- assert_select 'a.access-button', text: 'Download geodata files MIT authentication',
- href: 'https://cdn.dev1.mitlibrary.net/geo/restricted/us_ma_boston_g47parcels_2018.zip'
- end
- end
-
- test 'access button displays for non-MIT GIS records' do
- gis_record_id = 'gisogm:edu.stanford.purl:be6ef8cd8ac5'
- VCR.use_cassette('gis record elsewhere',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- get "/record/#{gis_record_id}"
- assert_select 'a.access-button', text: 'View Stanford record', href: 'https://purl.stanford.edu/kv971cf1984'
- end
- end
- end
end
diff --git a/test/controllers/search_controller_geo_test.rb b/test/controllers/search_controller_geo_test.rb
index 6e6908fa..0f607289 100644
--- a/test/controllers/search_controller_geo_test.rb
+++ b/test/controllers/search_controller_geo_test.rb
@@ -2,707 +2,791 @@
# Geospatial search behavior
class SearchControllerGeoTest < ActionDispatch::IntegrationTest
- def setup
- @test_strategy = Flipflop::FeatureSet.current.test!
- @test_strategy.switch!(:gdt, true)
- end
-
test 'GDT has specific advanced search fields' do
- get '/'
-
- # Please note that this test confirms fields in the DOM - but not whether
- # they are visible. Fields in a hidden details panel are still in the DOM,
- # but not visible or reachable via keyboard interaction.
- assert_select 'input#advanced-title', count: 1
- assert_select 'input#advanced-contributors', count: 1
- assert_select 'input#advanced-locations', count: 1
- assert_select 'input#advanced-subjects', count: 1
- assert_select 'input.source', count: 0
- assert_select 'input#advanced-citation', count: 0
- assert_select 'input#advanced-fundingInformation', count: 0
- assert_select 'input#advanced-identifiers', count: 0
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ get '/'
+
+ # Please note that this test confirms fields in the DOM - but not whether
+ # they are visible. Fields in a hidden details panel are still in the DOM,
+ # but not visible or reachable via keyboard interaction.
+ assert_select 'input#advanced-title', count: 1
+ assert_select 'input#advanced-contributors', count: 1
+ assert_select 'input#advanced-locations', count: 1
+ assert_select 'input#advanced-subjects', count: 1
+ assert_select 'input.source', count: 0
+ assert_select 'input#advanced-citation', count: 0
+ assert_select 'input#advanced-fundingInformation', count: 0
+ assert_select 'input#advanced-identifiers', count: 0
+ end
end
test 'index shows geo form when GDT is enabled' do
- get '/'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ get '/'
- # Should show geo form with all geo elements, no basic form in header
- assert_select 'form#search-form', { count: 0 } # No basic form in header when GDT enabled
- assert_select 'form#search-form-geo', { count: 1 } # Geo form in main content
- assert_select 'details#geobox-search-panel', { count: 1 }
- assert_select 'details#geodistance-search-panel', { count: 1 }
- assert_select 'details#advanced-search-panel', { count: 1 }
- end
-
- test 'results page shows geo form when GDT is enabled' do
- VCR.use_cassette('geobox and geodistance',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- query = {
- geobox: 'true',
- geodistance: 'true',
- geoboxMinLongitude: 40.5,
- geoboxMinLatitude: 60.0,
- geoboxMaxLongitude: 78.2,
- geoboxMaxLatitude: 80.0,
- geodistanceLatitude: 36.1,
- geodistanceLongitude: 62.6,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{query}"
- assert_response :success
+ # Should show geo form with all geo elements, no basic form in header
assert_select 'form#search-form', { count: 0 } # No basic form in header when GDT enabled
- assert_select 'form#search-form-geo', { count: 1 }
+ assert_select 'form#search-form-geo', { count: 1 } # Geo form in main content
assert_select 'details#geobox-search-panel', { count: 1 }
assert_select 'details#geodistance-search-panel', { count: 1 }
assert_select 'details#advanced-search-panel', { count: 1 }
end
end
+ test 'results page shows geo form when GDT is enabled' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox and geodistance',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ geobox: 'true',
+ geodistance: 'true',
+ geoboxMinLongitude: 40.5,
+ geoboxMinLatitude: 60.0,
+ geoboxMaxLongitude: 78.2,
+ geoboxMaxLatitude: 80.0,
+ geodistanceLatitude: 36.1,
+ geodistanceLongitude: 62.6,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+ assert_select 'form#search-form', { count: 0 } # No basic form in header when GDT enabled
+ assert_select 'form#search-form-geo', { count: 1 }
+ assert_select 'details#geobox-search-panel', { count: 1 }
+ assert_select 'details#geodistance-search-panel', { count: 1 }
+ assert_select 'details#advanced-search-panel', { count: 1 }
+ end
+ end
+ end
+
test 'contributors label is renamed to authors in GDT' do
- get '/'
- assert_select 'label', text: 'Authors'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ get '/'
+ assert_select 'label', text: 'Authors'
+ end
end
test 'index shows geobox form, closed by default' do
- get '/'
- assert_response :success
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ get '/'
+ assert_response :success
- details_div = assert_select('#geobox-search-panel')
- assert_nil details_div.attribute('open')
+ details_div = assert_select('#geobox-search-panel')
+ assert_nil details_div.attribute('open')
+ end
end
test 'index shows geodistance form, closed by default' do
- get '/'
- assert_response :success
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ get '/'
+ assert_response :success
- details_div = assert_select('#geobox-search-panel')
- assert_nil details_div.attribute('open')
+ details_div = assert_select('#geobox-search-panel')
+ assert_nil details_div.attribute('open')
+ end
end
test 'geobox form is open with URL parameter' do
- get '/?geobox=true'
- assert_response :success
- assert_select('#geobox-search-panel').attribute('open')
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ get '/?geobox=true'
+ assert_response :success
+ assert_select('#geobox-search-panel').attribute('open')
+ end
end
test 'geodistance form is open with URL parameter' do
- get '/?geodistance=true'
- assert_response :success
- assert_select('#geodistance-search-panel').attribute('open')
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ get '/?geodistance=true'
+ assert_response :success
+ assert_select('#geodistance-search-panel').attribute('open')
+ end
end
test 'all geobox fields are required when form is open' do
- get '/?geobox=true'
- assert_response :success
- assert_select('#geobox-search-panel').attribute('open')
- assert_select('#geobox-search-panel input') do |input|
- assert_select '[required]', count: 4
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ get '/?geobox=true'
+ assert_response :success
+ assert_select('#geobox-search-panel').attribute('open')
+ assert_select('#geobox-search-panel input') do |input|
+ assert_select '[required]', count: 4
+ end
end
end
test 'all geodistance fields are required when form is open' do
- get '/?geodistance=true'
- assert_response :success
- assert_select('#geodistance-search-panel').attribute('open')
- assert_select('#geodistance-search-panel input') do |input|
- assert_select '[required]', count: 3
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ get '/?geodistance=true'
+ assert_response :success
+ assert_select('#geodistance-search-panel').attribute('open')
+ assert_select('#geodistance-search-panel input') do |input|
+ assert_select '[required]', count: 3
+ end
end
end
test 'geobox and geodistance forms do not appear if GDT feature is disabled' do
- @test_strategy.switch!(:gdt, false)
- get '/'
- assert_response :success
- assert_select '#geobox-search-panel', count: 0
- assert_select '#geodistance-search-panel', count: 0
+ ClimateControl.modify FEATURE_GEODATA: 'false' do
+ get '/'
+ assert_response :success
+ assert_select '#geobox-search-panel', count: 0
+ assert_select '#geodistance-search-panel', count: 0
+ end
end
test 'GDT lists applied geospatial search terms' do
- VCR.use_cassette('geobox and geodistance',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- query = {
- geobox: 'true',
- geodistance: 'true',
- geoboxMinLongitude: 40.5,
- geoboxMinLatitude: 60.0,
- geoboxMaxLongitude: 78.2,
- geoboxMaxLatitude: 80.0,
- geodistanceLatitude: 36.1,
- geodistanceLongitude: 62.6,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{query}"
- assert_response :success
- assert_nil flash[:error]
-
- assert_select 'li', 'Min longitude: 40.5'
- assert_select 'li', 'Min latitude: 60.0'
- assert_select 'li', 'Max longitude: 78.2'
- assert_select 'li', 'Max latitude: 80.0'
- assert_select 'li', 'Latitude: 36.1'
- assert_select 'li', 'Longitude: 62.6'
- assert_select 'li', 'Distance: 50mi'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox and geodistance',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ geobox: 'true',
+ geodistance: 'true',
+ geoboxMinLongitude: 40.5,
+ geoboxMinLatitude: 60.0,
+ geoboxMaxLongitude: 78.2,
+ geoboxMaxLatitude: 80.0,
+ geodistanceLatitude: 36.1,
+ geodistanceLongitude: 62.6,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+ assert_nil flash[:error]
+
+ assert_select 'li', 'Min longitude: 40.5'
+ assert_select 'li', 'Min latitude: 60.0'
+ assert_select 'li', 'Max longitude: 78.2'
+ assert_select 'li', 'Max latitude: 80.0'
+ assert_select 'li', 'Latitude: 36.1'
+ assert_select 'li', 'Longitude: 62.6'
+ assert_select 'li', 'Distance: 50mi'
+ end
end
end
test 'can query geobox' do
- VCR.use_cassette('geobox',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- query = {
- geobox: 'true',
- geoboxMinLongitude: 40.5,
- geoboxMinLatitude: 60.0,
- geoboxMaxLongitude: 78.2,
- geoboxMaxLatitude: 80.0
- }.to_query
- get "/results?#{query}"
- assert_response :success
- assert_nil flash[:error]
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ geobox: 'true',
+ geoboxMinLongitude: 40.5,
+ geoboxMinLatitude: 60.0,
+ geoboxMaxLongitude: 78.2,
+ geoboxMaxLatitude: 80.0
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
end
end
test 'can query geodistance' do
- VCR.use_cassette('geodistance',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- query = {
- geodistance: 'true',
- geodistanceLatitude: 36.1,
- geodistanceLongitude: 62.6,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{query}"
- assert_response :success
- assert_nil flash[:error]
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geodistance',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ geodistance: 'true',
+ geodistanceLatitude: 36.1,
+ geodistanceLongitude: 62.6,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
end
end
test 'both geospatial fields can be queried at once' do
- VCR.use_cassette('geobox and geodistance',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- query = {
- geobox: 'true',
- geodistance: 'true',
- geoboxMinLongitude: 40.5,
- geoboxMinLatitude: 60.0,
- geoboxMaxLongitude: 78.2,
- geoboxMaxLatitude: 80.0,
- geodistanceLatitude: 36.1,
- geodistanceLongitude: 62.6,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{query}"
- assert_response :success
- assert_nil flash[:error]
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox and geodistance',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ geobox: 'true',
+ geodistance: 'true',
+ geoboxMinLongitude: 40.5,
+ geoboxMinLatitude: 60.0,
+ geoboxMaxLongitude: 78.2,
+ geoboxMaxLatitude: 80.0,
+ geodistanceLatitude: 36.1,
+ geodistanceLongitude: 62.6,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
end
end
test 'geo forms are open on results page with URL parameter' do
- VCR.use_cassette('geobox and geodistance',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- query = {
- geobox: 'true',
- geodistance: 'true',
- geoboxMinLongitude: 40.5,
- geoboxMinLatitude: 60.0,
- geoboxMaxLongitude: 78.2,
- geoboxMaxLatitude: 80.0,
- geodistanceLatitude: 36.1,
- geodistanceLongitude: 62.6,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{query}"
- assert_response :success
- assert_nil flash[:error]
-
- assert_select('#geobox-search-panel').attribute('open')
- assert_select('#geodistance-search-panel').attribute('open')
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox and geodistance',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ geobox: 'true',
+ geodistance: 'true',
+ geoboxMinLongitude: 40.5,
+ geoboxMinLatitude: 60.0,
+ geoboxMaxLongitude: 78.2,
+ geoboxMaxLatitude: 80.0,
+ geodistanceLatitude: 36.1,
+ geodistanceLongitude: 62.6,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+ assert_nil flash[:error]
+
+ assert_select('#geobox-search-panel').attribute('open')
+ assert_select('#geodistance-search-panel').attribute('open')
+ end
end
end
test 'coordinates can include decimals or not' do
- VCR.use_cassette('geobox and geodistance many decimals',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox and geodistance many decimals',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ geobox: 'true',
+ geodistance: 'true',
+ geoboxMinLongitude: 40.518235,
+ geoboxMinLatitude: 60.082199,
+ geoboxMaxLongitude: 78.224321,
+ geoboxMaxLatitude: 80.017501,
+ geodistanceLatitude: 36.100617,
+ geodistanceLongitude: 62.600002,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+ assert_nil flash[:error]
+
+ assert_select('#geobox-search-panel').attribute('open')
+ assert_select('#geodistance-search-panel').attribute('open')
+ end
+
+ VCR.use_cassette('geobox and geodistance no decimals',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ geobox: 'true',
+ geodistance: 'true',
+ geoboxMinLongitude: 40,
+ geoboxMinLatitude: 60,
+ geoboxMaxLongitude: 78,
+ geoboxMaxLatitude: 80,
+ geodistanceLatitude: 36,
+ geodistanceLongitude: 62,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+ assert_nil flash[:error]
+
+ assert_select('#geobox-search-panel').attribute('open')
+ assert_select('#geodistance-search-panel').attribute('open')
+ end
+ end
+ end
+
+ test 'geospatial arguments retain values in search form with correct data types' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox and geodistance',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ geobox: 'true',
+ geodistance: 'true',
+ geoboxMinLongitude: 40.5,
+ geoboxMinLatitude: 60.0,
+ geoboxMaxLongitude: 78.2,
+ geoboxMaxLatitude: 80.0,
+ geodistanceLatitude: 36.1,
+ geodistanceLongitude: 62.6,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+ assert_nil flash[:error]
+
+ assert_select 'input#geobox-minLongitude', value: 40.5
+ assert_select 'input#geobox-minLatitude', value: 60.0
+ assert_select 'input#geobox-maxLongitude', value: 78.2
+ assert_select 'input#geobox-maxLatitude', value: 80.0
+ assert_select 'input#geodistance-latitude', value: 36.1
+ assert_select 'input#geodistance-longitude', value: 62.6
+ assert_select 'input#geodistance-distance', value: '50mi'
+ end
+ end
+ end
+
+ test 'geospatial search can combine with basic and advanced inputs' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geo all',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ q: 'hi',
+ title: 'hey',
+ citation: 'hello',
+ geobox: 'true',
+ geodistance: 'true',
+ geoboxMinLongitude: 40.5,
+ geoboxMinLatitude: 60.0,
+ geoboxMaxLongitude: 78.2,
+ geoboxMaxLatitude: 80.0,
+ geodistanceLatitude: 36.1,
+ geodistanceLongitude: 62.6,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
+ end
+ end
+
+ test 'geobox arguments are non-nullable' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
query = {
- geobox: 'true',
- geodistance: 'true',
- geoboxMinLongitude: 40.518235,
- geoboxMinLatitude: 60.082199,
- geoboxMaxLongitude: 78.224321,
- geoboxMaxLatitude: 80.017501,
- geodistanceLatitude: 36.100617,
- geodistanceLongitude: 62.600002,
- geodistanceDistance: '50mi'
+ geobox: 'true'
}.to_query
get "/results?#{query}"
- assert_response :success
- assert_nil flash[:error]
-
- assert_select('#geobox-search-panel').attribute('open')
- assert_select('#geodistance-search-panel').attribute('open')
+ assert_response :redirect
+ assert_equal flash[:error], 'All bounding box fields are required.'
end
+ end
- VCR.use_cassette('geobox and geodistance no decimals',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
+ test 'geodistance arguments are non-nullable' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
query = {
- geobox: 'true',
- geodistance: 'true',
- geoboxMinLongitude: 40,
- geoboxMinLatitude: 60,
- geoboxMaxLongitude: 78,
- geoboxMaxLatitude: 80,
- geodistanceLatitude: 36,
- geodistanceLongitude: 62,
- geodistanceDistance: '50mi'
+ geodistance: 'true'
}.to_query
get "/results?#{query}"
- assert_response :success
- assert_nil flash[:error]
-
- assert_select('#geobox-search-panel').attribute('open')
- assert_select('#geodistance-search-panel').attribute('open')
+ assert_response :redirect
+ assert_equal flash[:error], 'All geospatial distance fields are required.'
end
end
- test 'geospatial arguments retain values in search form with correct data types' do
- VCR.use_cassette('geobox and geodistance',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
+ test 'geobox param is required for geobox search' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
query = {
- geobox: 'true',
- geodistance: 'true',
geoboxMinLongitude: 40.5,
geoboxMinLatitude: 60.0,
geoboxMaxLongitude: 78.2,
- geoboxMaxLatitude: 80.0,
- geodistanceLatitude: 36.1,
- geodistanceLongitude: 62.6,
- geodistanceDistance: '50mi'
+ geoboxMaxLatitude: 80.0
}.to_query
get "/results?#{query}"
- assert_response :success
- assert_nil flash[:error]
-
- assert_select 'input#geobox-minLongitude', value: 40.5
- assert_select 'input#geobox-minLatitude', value: 60.0
- assert_select 'input#geobox-maxLongitude', value: 78.2
- assert_select 'input#geobox-maxLatitude', value: 80.0
- assert_select 'input#geodistance-latitude', value: 36.1
- assert_select 'input#geodistance-longitude', value: 62.6
- assert_select 'input#geodistance-distance', value: '50mi'
+ assert_response :redirect
+ assert_equal flash[:error], 'A search term is required.'
end
end
- test 'geospatial search can combine with basic and advanced inputs' do
- VCR.use_cassette('geo all',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
+ test 'geodistance param is required for geobox search' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
query = {
- q: 'hi',
- title: 'hey',
- citation: 'hello',
- geobox: 'true',
- geodistance: 'true',
- geoboxMinLongitude: 40.5,
- geoboxMinLatitude: 60.0,
- geoboxMaxLongitude: 78.2,
- geoboxMaxLatitude: 80.0,
geodistanceLatitude: 36.1,
geodistanceLongitude: 62.6,
geodistanceDistance: '50mi'
}.to_query
get "/results?#{query}"
- assert_response :success
- assert_nil flash[:error]
+ assert_response :redirect
+ assert_equal flash[:error], 'A search term is required.'
end
end
- test 'geobox arguments are non-nullable' do
- query = {
- geobox: 'true'
- }.to_query
- get "/results?#{query}"
- assert_response :redirect
- assert_equal flash[:error], 'All bounding box fields are required.'
- end
-
- test 'geodistance arguments are non-nullable' do
- query = {
- geodistance: 'true'
- }.to_query
- get "/results?#{query}"
- assert_response :redirect
- assert_equal flash[:error], 'All geospatial distance fields are required.'
- end
-
- test 'geobox param is required for geobox search' do
- query = {
- geoboxMinLongitude: 40.5,
- geoboxMinLatitude: 60.0,
- geoboxMaxLongitude: 78.2,
- geoboxMaxLatitude: 80.0
- }.to_query
- get "/results?#{query}"
- assert_response :redirect
- assert_equal flash[:error], 'A search term is required.'
- end
-
- test 'geodistance param is required for geobox search' do
- query = {
- geodistanceLatitude: 36.1,
- geodistanceLongitude: 62.6,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{query}"
- assert_response :redirect
- assert_equal flash[:error], 'A search term is required.'
- end
-
test 'geobox lat cannot fall below lower limit' do
- low_query = {
- geobox: 'true',
- geoboxMinLongitude: -170.0,
- geoboxMinLatitude: -90.000001,
- geoboxMaxLongitude: -180.0,
- geoboxMaxLatitude: -42
- }.to_query
- get "/results?#{low_query}"
- assert_response :redirect
- assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ low_query = {
+ geobox: 'true',
+ geoboxMinLongitude: -170.0,
+ geoboxMinLatitude: -90.000001,
+ geoboxMaxLongitude: -180.0,
+ geoboxMaxLatitude: -42
+ }.to_query
+ get "/results?#{low_query}"
+ assert_response :redirect
+ assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
+ end
end
test 'geobox long cannot fall below lower limit' do
- low_query = {
- geobox: 'true',
- geoboxMinLongitude: -180.000001,
- geoboxMinLatitude: -90.0,
- geoboxMaxLongitude: -180.0,
- geoboxMaxLatitude: -42
- }.to_query
- get "/results?#{low_query}"
- assert_response :redirect
- assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ low_query = {
+ geobox: 'true',
+ geoboxMinLongitude: -180.000001,
+ geoboxMinLatitude: -90.0,
+ geoboxMaxLongitude: -180.0,
+ geoboxMaxLatitude: -42
+ }.to_query
+ get "/results?#{low_query}"
+ assert_response :redirect
+ assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
+ end
end
test 'geobox lat/long cannot exceed upper limit' do
- high_query = {
- geobox: 'true',
- geoboxMinLongitude: 180.000001,
- geoboxMinLatitude: 42,
- geoboxMaxLongitude: 180.0,
- geoboxMaxLatitude: 90.0
- }.to_query
- get "/results?#{high_query}"
- assert_response :redirect
- assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ high_query = {
+ geobox: 'true',
+ geoboxMinLongitude: 180.000001,
+ geoboxMinLatitude: 42,
+ geoboxMaxLongitude: 180.0,
+ geoboxMaxLatitude: 90.0
+ }.to_query
+ get "/results?#{high_query}"
+ assert_response :redirect
+ assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
+ end
end
test 'geobox does not error with minimum lat value' do
- VCR.use_cassette('geobox min lat range limit',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- acceptable_query = {
- geobox: 'true',
- geoboxMinLongitude: -45.0,
- geoboxMinLatitude: -90.0,
- geoboxMaxLongitude: -23.997,
- geoboxMaxLatitude: -40.024
- }.to_query
- get "/results?#{acceptable_query}"
- assert_response :success
- assert_nil flash[:error]
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox min lat range limit',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ acceptable_query = {
+ geobox: 'true',
+ geoboxMinLongitude: -45.0,
+ geoboxMinLatitude: -90.0,
+ geoboxMaxLongitude: -23.997,
+ geoboxMaxLatitude: -40.024
+ }.to_query
+ get "/results?#{acceptable_query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
end
end
test 'geobox does not error with minimum long value' do
- VCR.use_cassette('geobox min long range limit',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- acceptable_query = {
- geobox: 'true',
- geoboxMinLongitude: -180.0,
- geoboxMinLatitude: -45.23,
- geoboxMaxLongitude: -120.36,
- geoboxMaxLatitude: -40.024
- }.to_query
- get "/results?#{acceptable_query}"
- assert_response :success
- assert_nil flash[:error]
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox min long range limit',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ acceptable_query = {
+ geobox: 'true',
+ geoboxMinLongitude: -180.0,
+ geoboxMinLatitude: -45.23,
+ geoboxMaxLongitude: -120.36,
+ geoboxMaxLatitude: -40.024
+ }.to_query
+ get "/results?#{acceptable_query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
end
end
test 'geobox does not error with maximum lat value' do
- VCR.use_cassette('geobox max lat range limit',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- acceptable_query = {
- geobox: 'true',
- geoboxMinLongitude: 45.0,
- geoboxMinLatitude: 40.024,
- geoboxMaxLongitude: 23.997,
- geoboxMaxLatitude: 90.0
- }.to_query
- get "/results?#{acceptable_query}"
- assert_response :success
- assert_nil flash[:error]
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox max lat range limit',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ acceptable_query = {
+ geobox: 'true',
+ geoboxMinLongitude: 45.0,
+ geoboxMinLatitude: 40.024,
+ geoboxMaxLongitude: 23.997,
+ geoboxMaxLatitude: 90.0
+ }.to_query
+ get "/results?#{acceptable_query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
end
end
test 'geobox does not error with maximum long value' do
- VCR.use_cassette('geobox max long range limit',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- acceptable_query = {
- geobox: 'true',
- geoboxMinLongitude: 45.0,
- geoboxMinLatitude: 40.024,
- geoboxMaxLongitude: 180.0,
- geoboxMaxLatitude: 50.024
- }.to_query
- get "/results?#{acceptable_query}"
- assert_response :success
- assert_nil flash[:error]
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox max long range limit',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ acceptable_query = {
+ geobox: 'true',
+ geoboxMinLongitude: 45.0,
+ geoboxMinLatitude: 40.024,
+ geoboxMaxLongitude: 180.0,
+ geoboxMaxLatitude: 50.024
+ }.to_query
+ get "/results?#{acceptable_query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
end
end
test 'geobox minLat must be less than maxLat' do
- bad_values = {
- geobox: 'true',
- geoboxMinLongitude: 100.0,
- geoboxMinLatitude: 80.0,
- geoboxMaxLongitude: 29.6,
- geoboxMaxLatitude: 56.9
- }.to_query
- get "/results?#{bad_values}"
- assert_response :redirect
- assert_equal flash[:error], 'Maximum latitude cannot exceed minimum latitude.'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ bad_values = {
+ geobox: 'true',
+ geoboxMinLongitude: 100.0,
+ geoboxMinLatitude: 80.0,
+ geoboxMaxLongitude: 29.6,
+ geoboxMaxLatitude: 56.9
+ }.to_query
+ get "/results?#{bad_values}"
+ assert_response :redirect
+ assert_equal flash[:error], 'Maximum latitude cannot exceed minimum latitude.'
+ end
end
test 'geodistance lat cannot fall below lower limit' do
- low_query = {
- geodistance: 'true',
- geodistanceLatitude: -90.000001,
- geodistanceLongitude: -180.0,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{low_query}"
- assert_response :redirect
- assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ low_query = {
+ geodistance: 'true',
+ geodistanceLatitude: -90.000001,
+ geodistanceLongitude: -180.0,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{low_query}"
+ assert_response :redirect
+ assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
+ end
end
test 'geodistance long cannot fall below lower limit' do
- low_query = {
- geodistance: 'true',
- geodistanceLatitude: -90.0,
- geodistanceLongitude: -180.000001,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{low_query}"
- assert_response :redirect
- assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
- end
-
- test 'geodistance lat cannot exceed upper limit' do
- high_query = {
- geodistance: 'true',
- geodistanceLatitude: 90.000001,
- geodistanceLongitude: 180.0,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{high_query}"
- assert_response :redirect
- assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
- end
-
- test 'geodistance long cannot exceed upper limit' do
- high_query = {
- geodistance: 'true',
- geodistanceLatitude: 90.0,
- geodistanceLongitude: 180.000001,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{high_query}"
- assert_response :redirect
- assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
- end
-
- test 'geodistance does not error with minimum lat value' do
- VCR.use_cassette('geodistance min lat range limit',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- acceptable_query = {
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ low_query = {
geodistance: 'true',
geodistanceLatitude: -90.0,
- geodistanceLongitude: -43.33,
+ geodistanceLongitude: -180.000001,
geodistanceDistance: '50mi'
}.to_query
- get "/results?#{acceptable_query}"
- assert_response :success
- assert_nil flash[:error]
+ get "/results?#{low_query}"
+ assert_response :redirect
+ assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
end
end
- test 'geodistance does not error with minimum long value' do
- VCR.use_cassette('geodistance min long range limit',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- acceptable_query = {
+ test 'geodistance lat cannot exceed upper limit' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ high_query = {
geodistance: 'true',
- geodistanceLatitude: -21.1724,
- geodistanceLongitude: -180.0,
+ geodistanceLatitude: 90.000001,
+ geodistanceLongitude: 180.0,
geodistanceDistance: '50mi'
}.to_query
- get "/results?#{acceptable_query}"
- assert_response :success
- assert_nil flash[:error]
+ get "/results?#{high_query}"
+ assert_response :redirect
+ assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
end
end
- test 'geodistance does not error with maximum lat value' do
- VCR.use_cassette('geodistance max lat range limit',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- acceptable_query = {
+ test 'geodistance long cannot exceed upper limit' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ high_query = {
geodistance: 'true',
geodistanceLatitude: 90.0,
- geodistanceLongitude: -43.33,
+ geodistanceLongitude: 180.000001,
geodistanceDistance: '50mi'
}.to_query
- get "/results?#{acceptable_query}"
- assert_response :success
- assert_nil flash[:error]
+ get "/results?#{high_query}"
+ assert_response :redirect
+ assert_equal flash[:error], 'Latitude must be between -90.0 and 90.0, and longitude must be -180.0 and 180.0.'
+ end
+ end
+
+ test 'geodistance does not error with minimum lat value' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geodistance min lat range limit',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ acceptable_query = {
+ geodistance: 'true',
+ geodistanceLatitude: -90.0,
+ geodistanceLongitude: -43.33,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{acceptable_query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
+ end
+ end
+
+ test 'geodistance does not error with minimum long value' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geodistance min long range limit',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ acceptable_query = {
+ geodistance: 'true',
+ geodistanceLatitude: -21.1724,
+ geodistanceLongitude: -180.0,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{acceptable_query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
+ end
+ end
+
+ test 'geodistance does not error with maximum lat value' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geodistance max lat range limit',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ acceptable_query = {
+ geodistance: 'true',
+ geodistanceLatitude: 90.0,
+ geodistanceLongitude: -43.33,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{acceptable_query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
end
end
test 'geodistance does not error with maximum long value' do
- VCR.use_cassette('geodistance max long range limit',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- acceptable_query = {
- geodistance: 'true',
- geodistanceLatitude: -21.1724,
- geodistanceLongitude: 180.0,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{acceptable_query}"
- assert_response :success
- assert_nil flash[:error]
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geodistance max long range limit',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ acceptable_query = {
+ geodistance: 'true',
+ geodistanceLatitude: -21.1724,
+ geodistanceLongitude: 180.0,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{acceptable_query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
end
end
test 'geodistance cannot be negative' do
- zero_distance = {
- geodistance: 'true',
- geodistanceLatitude: 90.0,
- geodistanceLongitude: 180.0,
- geodistanceDistance: '-50mi'
- }.to_query
- get "/results?#{zero_distance}"
- assert_response :redirect
- assert_equal flash[:error], 'Distance must include an integer greater than 0.'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ zero_distance = {
+ geodistance: 'true',
+ geodistanceLatitude: 90.0,
+ geodistanceLongitude: 180.0,
+ geodistanceDistance: '-50mi'
+ }.to_query
+ get "/results?#{zero_distance}"
+ assert_response :redirect
+ assert_equal flash[:error], 'Distance must include an integer greater than 0.'
+ end
end
test 'geodistance cannot be 0' do
- negative_distance = {
- geodistance: 'true',
- geodistanceLatitude: 90.0,
- geodistanceLongitude: 180.0,
- geodistanceDistance: '0mi'
- }.to_query
- get "/results?#{negative_distance}"
- assert_response :redirect
- assert_equal flash[:error], 'Distance must include an integer greater than 0.'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ negative_distance = {
+ geodistance: 'true',
+ geodistanceLatitude: 90.0,
+ geodistanceLongitude: 180.0,
+ geodistanceDistance: '0mi'
+ }.to_query
+ get "/results?#{negative_distance}"
+ assert_response :redirect
+ assert_equal flash[:error], 'Distance must include an integer greater than 0.'
+ end
end
test 'geodistance can contain units or not (default is meters)' do
- VCR.use_cassette('geodistance units',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- acceptable_query = {
- geodistance: 'true',
- geodistanceLatitude: -21.1724,
- geodistanceLongitude: 76.021,
- geodistanceDistance: '50mi'
- }.to_query
- get "/results?#{acceptable_query}"
- assert_response :success
- assert_nil flash[:error]
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geodistance units',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ acceptable_query = {
+ geodistance: 'true',
+ geodistanceLatitude: -21.1724,
+ geodistanceLongitude: 76.021,
+ geodistanceDistance: '50mi'
+ }.to_query
+ get "/results?#{acceptable_query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
+
+ VCR.use_cassette('geodistance no units',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ another_acceptable_query = {
+ geodistance: 'true',
+ geodistanceLatitude: -21.1724,
+ geodistanceLongitude: 76.021,
+ geodistanceDistance: '50'
+ }.to_query
+ get "/results?#{another_acceptable_query}"
+ assert_response :success
+ assert_nil flash[:error]
+ end
end
+ end
- VCR.use_cassette('geodistance no units',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- another_acceptable_query = {
+ test 'geodistance units must be valid' do
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ bad_units = {
geodistance: 'true',
geodistanceLatitude: -21.1724,
geodistanceLongitude: 76.021,
- geodistanceDistance: '50'
+ geodistanceDistance: '50foo'
}.to_query
- get "/results?#{another_acceptable_query}"
- assert_response :success
- assert_nil flash[:error]
+ get "/results?#{bad_units}"
+ assert_response :redirect
+ assert_equal flash[:error], 'Distance units must be one of the following: mi, km, yd, ft, in, m, cm, mm, NM/nmi'
end
end
- test 'geodistance units must be valid' do
- bad_units = {
- geodistance: 'true',
- geodistanceLatitude: -21.1724,
- geodistanceLongitude: 76.021,
- geodistanceDistance: '50foo'
- }.to_query
- get "/results?#{bad_units}"
- assert_response :redirect
- assert_equal flash[:error], 'Distance units must be one of the following: mi, km, yd, ft, in, m, cm, mm, NM/nmi'
- end
-
test 'view full record link appears as expected for GDT records' do
- VCR.use_cassette('geobox',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- query = {
- geobox: 'true',
- geoboxMinLongitude: 40.5,
- geoboxMinLatitude: 60.0,
- geoboxMaxLongitude: 78.2,
- geoboxMaxLatitude: 80.0
- }.to_query
- get "/results?#{query}"
- assert_response :success
-
- record_id = controller.view_assigns['results'].first['timdexRecordId']
- assert_select '.result-record a', href: '/record/#{record_id}', text: 'View full record'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ geobox: 'true',
+ geoboxMinLongitude: 40.5,
+ geoboxMinLatitude: 60.0,
+ geoboxMaxLongitude: 78.2,
+ geoboxMaxLatitude: 80.0
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+
+ record_id = controller.view_assigns['results'].first['timdexRecordId']
+ assert_select '.result-record a', href: '/record/#{record_id}', text: 'View full record'
+ end
end
end
test 'geo sources are relabeled when GDT feature is enabled' do
- VCR.use_cassette('geobox',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- query = {
- geobox: 'true',
- geoboxMinLongitude: 40.5,
- geoboxMinLatitude: 60.0,
- geoboxMaxLongitude: 78.2,
- geoboxMaxLatitude: 80.0
- }.to_query
- get "/results?#{query}"
- assert_response :success
-
- # The original source names do not appear in the UI.
- assert_select 'span.name', text: 'mit gis resources', count: 0
- assert_select 'span.name', text: 'opengeometadata gis resources', count: 0
-
- # The friendly source names do appear instead.
- assert_select 'span.name', text: 'MIT'
- assert_select 'span.name', text: 'Non-MIT institutions'
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ VCR.use_cassette('geobox',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ query = {
+ geobox: 'true',
+ geoboxMinLongitude: 40.5,
+ geoboxMinLatitude: 60.0,
+ geoboxMaxLongitude: 78.2,
+ geoboxMaxLatitude: 80.0
+ }.to_query
+ get "/results?#{query}"
+ assert_response :success
+
+ # The original source names do not appear in the UI.
+ assert_select 'span.name', text: 'mit gis resources', count: 0
+ assert_select 'span.name', text: 'opengeometadata gis resources', count: 0
+
+ # The friendly source names do appear instead.
+ assert_select 'span.name', text: 'MIT'
+ assert_select 'span.name', text: 'Non-MIT institutions'
+ end
end
end
end
diff --git a/test/controllers/search_controller_test.rb b/test/controllers/search_controller_test.rb
index 3cbdc1ca..d3bb2658 100644
--- a/test/controllers/search_controller_test.rb
+++ b/test/controllers/search_controller_test.rb
@@ -1,11 +1,6 @@
require 'test_helper'
class SearchControllerTest < ActionDispatch::IntegrationTest
- def setup
- @test_strategy = Flipflop::FeatureSet.current.test!
- @test_strategy.switch!(:gdt, false)
- end
-
def mock_primo_search_success
# Mock the Primo search components to avoid external API calls
sample_doc = {
@@ -80,14 +75,12 @@ def mock_timdex_search_success
end
test 'index shows advanced search form with URL parameter' do
- if Flipflop.enabled?(:gdt)
- get '/?advanced=true'
- assert_response :success
- details_div = assert_select('details#advanced-search-panel')
- assert details_div.attribute('open')
- else
- skip('Advanced search functionality not implemented in USE UI')
- end
+ skip('Advanced search functionality not implemented in USE UI')
+
+ get '/?advanced=true'
+ assert_response :success
+ details_div = assert_select('details#advanced-search-panel')
+ assert details_div.attribute('open')
end
test 'index shows basic search form when GDT is disabled' do
@@ -104,17 +97,14 @@ def mock_timdex_search_success
end
test 'advanced search form appears on results page with URL parameter' do
- if Flipflop.enabled?(:gdt)
- VCR.use_cassette('advanced',
- allow_playback_repeats: true,
- match_requests_on: %i[method uri body]) do
- get '/results?advanced=true'
- assert_response :success
- details_div = assert_select('details#advanced-search-panel')
- assert details_div.attribute('open')
- end
- else
- skip('Advanced search functionality not implemented in USE UI')
+ skip('Advanced search functionality not implemented in USE UI')
+ VCR.use_cassette('advanced',
+ allow_playback_repeats: true,
+ match_requests_on: %i[method uri body]) do
+ get '/results?advanced=true'
+ assert_response :success
+ details_div = assert_select('details#advanced-search-panel')
+ assert details_div.attribute('open')
end
end
@@ -123,20 +113,6 @@ def mock_timdex_search_success
# Basic search field should always be present
assert_select 'input#basic-search-main', { count: 1 }
-
- if Flipflop.enabled?(:gdt)
- # Please note that this test confirms fields in the DOM - but not whether
- # they are visible. Fields in a hidden details panel are still in the DOM,
- # but not visible or reachable via keyboard interaction.
- assert_select 'input#advanced-citation', { count: 1 }
- assert_select 'input#advanced-contributors', { count: 1 }
- assert_select 'input#advanced-fundingInformation', { count: 1 }
- assert_select 'input#advanced-identifiers', { count: 1 }
- assert_select 'input#advanced-locations', { count: 1 }
- assert_select 'input#advanced-subjects', { count: 1 }
- assert_select 'input#advanced-title', { count: 1 }
- assert_select 'input.source', { minimum: 3 }
- end
end
test 'advanced search source checkboxes can be controlled by env' do
diff --git a/test/helpers/search_helper_test.rb b/test/helpers/search_helper_test.rb
index 9e79b2a5..7dba44dc 100644
--- a/test/helpers/search_helper_test.rb
+++ b/test/helpers/search_helper_test.rb
@@ -3,11 +3,6 @@
class SearchHelperTest < ActionView::TestCase
include SearchHelper
- def setup
- @test_strategy = Flipflop::FeatureSet.current.test!
- @test_strategy.switch!(:gdt, false)
- end
-
test 'removes displayed fields from highlights' do
result = { 'highlight' => [{ 'matchedField' => 'title', 'matchedPhrases' => 'Very important data' },
{ 'matchedField' => 'title.exact_value', 'matchedPhrases' => 'Very important data' },
@@ -164,12 +159,12 @@ def setup
end
test 'applied_advanced_terms translates contributors in GDT' do
- @test_strategy.switch!(:gdt, true)
-
- query = {
- contributors: 'person, sample'
- }
- assert_equal ['Authors: person, sample'], applied_advanced_terms(query)
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ query = {
+ contributors: 'person, sample'
+ }
+ assert_equal ['Authors: person, sample'], applied_advanced_terms(query)
+ end
end
test 'link_to_result returns link when source_link is present' do
diff --git a/test/models/enhancer_test.rb b/test/models/enhancer_test.rb
index 0758e7d0..a9a77056 100644
--- a/test/models/enhancer_test.rb
+++ b/test/models/enhancer_test.rb
@@ -1,13 +1,6 @@
require 'test_helper'
class EnhancerTest < ActiveSupport::TestCase
- def setup
- @test_strategy = Flipflop::FeatureSet.current.test!
- end
- def teardown
- @test_strategy = Flipflop::FeatureSet.current.test!
- end
-
test 'enhanced_query with no matched patterns returns raw query and q' do
params = {}
params[:q] = 'hallo'
@@ -100,34 +93,32 @@ def teardown
end
test 'enhanced_query extracts geospatial fields' do
- @test_strategy.switch!(:gdt, true)
-
- params = {
- geobox: 'true',
- geodistance: 'true',
- geoboxMinLongitude: '40.5',
- geoboxMinLatitude: '90.0',
- geoboxMaxLongitude: '78.2',
- geoboxMaxLatitude: '180.0',
- geodistanceLatitude: '36.1',
- geodistanceLongitude: '62.6',
- geodistanceDistance: '50mi'
- }
- eq = Enhancer.new(params)
- assert_equal 'true', eq.enhanced_query[:geobox]
- assert_equal 'true', eq.enhanced_query[:geodistance]
- assert_equal '40.5', eq.enhanced_query[:geoboxMinLongitude]
- assert_equal '90.0', eq.enhanced_query[:geoboxMinLatitude]
- assert_equal '78.2', eq.enhanced_query[:geoboxMaxLongitude]
- assert_equal '180.0', eq.enhanced_query[:geoboxMaxLatitude]
- assert_equal '36.1', eq.enhanced_query[:geodistanceLatitude]
- assert_equal '62.6', eq.enhanced_query[:geodistanceLongitude]
- assert_equal '50mi', eq.enhanced_query[:geodistanceDistance]
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ params = {
+ geobox: 'true',
+ geodistance: 'true',
+ geoboxMinLongitude: '40.5',
+ geoboxMinLatitude: '90.0',
+ geoboxMaxLongitude: '78.2',
+ geoboxMaxLatitude: '180.0',
+ geodistanceLatitude: '36.1',
+ geodistanceLongitude: '62.6',
+ geodistanceDistance: '50mi'
+ }
+ eq = Enhancer.new(params)
+ assert_equal 'true', eq.enhanced_query[:geobox]
+ assert_equal 'true', eq.enhanced_query[:geodistance]
+ assert_equal '40.5', eq.enhanced_query[:geoboxMinLongitude]
+ assert_equal '90.0', eq.enhanced_query[:geoboxMinLatitude]
+ assert_equal '78.2', eq.enhanced_query[:geoboxMaxLongitude]
+ assert_equal '180.0', eq.enhanced_query[:geoboxMaxLatitude]
+ assert_equal '36.1', eq.enhanced_query[:geodistanceLatitude]
+ assert_equal '62.6', eq.enhanced_query[:geodistanceLongitude]
+ assert_equal '50mi', eq.enhanced_query[:geodistanceDistance]
+ end
end
test 'enhanced_query does not extract geospatial fields if GDT feature flag is disabled' do
- @test_strategy.switch!(:gdt, false)
-
params = {
geobox: 'true',
geodistance: 'true',
@@ -137,17 +128,17 @@ def teardown
geoboxMaxLatitude: '180.0',
geodistanceLatitude: '36.1',
geodistanceLongitude: '62.6',
- geodistanceDistance: '50mi'
- }
- eq = Enhancer.new(params)
- assert_nil eq.enhanced_query[:geobox]
- assert_nil eq.enhanced_query[:geodistance]
- assert_nil eq.enhanced_query[:geoboxMinLongitude]
- assert_nil eq.enhanced_query[:geoboxMaxLatitude]
- assert_nil eq.enhanced_query[:geoboxMaxLongitude]
- assert_nil eq.enhanced_query[:geoboxMaxLatitude]
- assert_nil eq.enhanced_query[:geodistanceLatitude]
- assert_nil eq.enhanced_query[:geodistanceLongitude]
- assert_nil eq.enhanced_query[:geodistanceDistance]
+ geodistanceDistance: '50mi'
+ }
+ eq = Enhancer.new(params)
+ assert_nil eq.enhanced_query[:geobox]
+ assert_nil eq.enhanced_query[:geodistance]
+ assert_nil eq.enhanced_query[:geoboxMinLongitude]
+ assert_nil eq.enhanced_query[:geoboxMaxLatitude]
+ assert_nil eq.enhanced_query[:geoboxMaxLongitude]
+ assert_nil eq.enhanced_query[:geoboxMaxLatitude]
+ assert_nil eq.enhanced_query[:geodistanceLatitude]
+ assert_nil eq.enhanced_query[:geodistanceLongitude]
+ assert_nil eq.enhanced_query[:geodistanceDistance]
end
end
diff --git a/test/models/query_builder_test.rb b/test/models/query_builder_test.rb
index 630d4e48..0ae5201d 100644
--- a/test/models/query_builder_test.rb
+++ b/test/models/query_builder_test.rb
@@ -1,13 +1,6 @@
require 'test_helper'
class QueryBuilderTest < ActiveSupport::TestCase
- def setup
- @test_strategy = Flipflop::FeatureSet.current.test!
- end
- def teardown
- @test_strategy = Flipflop::FeatureSet.current.test!
- end
-
test 'query builder trims spaces' do
expected = { 'from' => '0', 'q' => 'blah', 'index' => 'FAKE_TIMDEX_INDEX' }
search = { q: ' blah ' }
@@ -82,51 +75,49 @@ def teardown
# Geospatial search behavior
test 'query builder handles supported geospatial fields and converts lat/long to float' do
- @test_strategy.switch!(:gdt, true)
-
- expected = {
- 'from' => '0',
- 'geobox' => 'true',
- 'geodistance' => 'true',
- 'geoboxMinLongitude' => 40.5,
- 'geoboxMinLatitude' => 90.0,
- 'geoboxMaxLongitude' => 78.2,
- 'geoboxMaxLatitude' => 180.0,
- 'geodistanceLatitude' => 36.1,
- 'geodistanceLongitude' => 62.6,
- 'geodistanceDistance' => '50mi',
- 'index' => 'FAKE_TIMDEX_INDEX'
- }
- search = {
- geobox: 'true',
- geodistance: 'true',
- geoboxMinLongitude: '40.5',
- geoboxMinLatitude: '90.0',
- geoboxMaxLongitude: '78.2',
- geoboxMaxLatitude: '180.0',
- geodistanceLatitude: '36.1',
- geodistanceLongitude: '62.6',
- geodistanceDistance: '50mi'
- }
- assert_equal expected, QueryBuilder.new(search).query
+ ClimateControl.modify FEATURE_GEODATA: 'true' do
+ expected = {
+ 'from' => '0',
+ 'geobox' => 'true',
+ 'geodistance' => 'true',
+ 'geoboxMinLongitude' => 40.5,
+ 'geoboxMinLatitude' => 90.0,
+ 'geoboxMaxLongitude' => 78.2,
+ 'geoboxMaxLatitude' => 180.0,
+ 'geodistanceLatitude' => 36.1,
+ 'geodistanceLongitude' => 62.6,
+ 'geodistanceDistance' => '50mi',
+ 'index' => 'FAKE_TIMDEX_INDEX'
+ }
+ search = {
+ geobox: 'true',
+ geodistance: 'true',
+ geoboxMinLongitude: '40.5',
+ geoboxMinLatitude: '90.0',
+ geoboxMaxLongitude: '78.2',
+ geoboxMaxLatitude: '180.0',
+ geodistanceLatitude: '36.1',
+ geodistanceLongitude: '62.6',
+ geodistanceDistance: '50mi'
+ }
+ assert_equal expected, QueryBuilder.new(search).query
+ end
end
test 'query builder ignores geospatial fields if feature flag is off' do
- @test_strategy.switch!(:gdt, false)
-
- expected = {
- 'from' => '0',
- 'index' => 'FAKE_TIMDEX_INDEX'
- }
+ expected = {
+ 'from' => '0',
+ 'index' => 'FAKE_TIMDEX_INDEX'
+ }
search = {
- geoboxMinLongitude: '40.5',
- geoboxMinLatitude: '90.0',
- geoboxMaxLongitude: '78.2',
- geoboxMaxLatitude: '180.0',
- geodistanceLatitude: '36.1',
- geodistanceLongitude: '62.6',
- geodistanceDistance: '50mi'
- }
+ geoboxMinLongitude: '40.5',
+ geoboxMinLatitude: '90.0',
+ geoboxMaxLongitude: '78.2',
+ geoboxMaxLatitude: '180.0',
+ geodistanceLatitude: '36.1',
+ geodistanceLongitude: '62.6',
+ geodistanceDistance: '50mi'
+ }
assert_equal expected, QueryBuilder.new(search).query
end
end