diff --git a/lib/blacklight_range_limit/range_limit_builder.rb b/lib/blacklight_range_limit/range_limit_builder.rb index 802efa3..8c3c00e 100644 --- a/lib/blacklight_range_limit/range_limit_builder.rb +++ b/lib/blacklight_range_limit/range_limit_builder.rb @@ -100,7 +100,9 @@ def bl_create_selected_range_value(selected_value, field_config) range = if selected_value.is_a? Range selected_value - elsif range_config[:assumed_boundaries] + elsif range_config[:assumed_boundaries].is_a?(Range) + range_config[:assumed_boundaries] + elsif range_config[:assumed_boundaries] # Array of two things please Range.new(*range_config[:assumed_boundaries]) else nil diff --git a/spec/features/run_through_spec.rb b/spec/features/run_through_spec.rb index 9d0523b..9aa9cf0 100644 --- a/spec/features/run_through_spec.rb +++ b/spec/features/run_through_spec.rb @@ -136,14 +136,15 @@ end context 'when assumed boundaries configured' do - before do - CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config = { - assumed_boundaries: start_range.to_i...end_range.to_i - } - end + around do |example| + original = CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config + CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config = original.merge({ + :assumed_boundaries=>1900...2100, + }) + + example.run - after do - CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config = {} + CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config = original end it 'should show the range limit with set boundaries' do @@ -156,14 +157,15 @@ end context 'when missing facet item is configured not to show' do - before do - CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config = { + around do |example| + original = CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config + CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config = original.merge({ show_missing_link: false - } - end + }) + + example.run - after do - CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config = {} + CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config = original end it 'should not show the missing facet item' do