blacklight_range_limit 5.0.2 → 5.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34d5e12f33dab6b85a0a6124a1debc14c3ee422f
4
- data.tar.gz: 696ebe4c0d178bfc0b6d1923be6863d2a6694a1f
3
+ metadata.gz: bfbd60cfa11906f880033d02aa35b34cda312d3a
4
+ data.tar.gz: 658444bdfca712dec061edb48cd0ddf9066b12a9
5
5
  SHA512:
6
- metadata.gz: 7343e933270b6409e504b5d1dcb3476018c888f63539a0f9fe8c4720503aa6abdc9744d418cb8f1c4cb00115c86b16e395ac4d5285352c2cb708fab04fc2515c
7
- data.tar.gz: 894027d5d73feb173af418b104e2b81810c4146acd119508d4e54282e011b1e5091e751800c56e9003e8f0fff9f83206d6edd3e39f07321222cea50b18fe09e9
6
+ metadata.gz: 8fe6f9b7a91a2f2e6395f47d10e032f09f9026bfdfee2d4135a17523c317ec69b7e172ed338ed5d6a4cceeb36d3339ae02e9783f6ccf96756748e5f622aa7581
7
+ data.tar.gz: 930d57f88f318fa4273580b80f1771deec6a44540a628ef1e7d2e1e3757f5c628052aec86f48c5b540d3c8a251babadf4822caa58f8b9e7da0b1cb825f31ebf0
data/.travis.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  notifications:
2
2
  email: false
3
3
 
4
+ language: ruby
5
+ cache: bundler
6
+ sudo: false
4
7
  rvm:
5
8
  - 1.9.3
6
9
  - 2.0.0
data/Rakefile CHANGED
@@ -40,6 +40,7 @@ namespace :test do
40
40
  within_test_app do
41
41
  ENV['RAILS_ENV'] ||= 'test'
42
42
  system "rake blacklight:solr:seed"
43
+ system "rake blacklight_range_limit:seed"
43
44
  end
44
45
  end
45
46
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.2
1
+ 5.0.3
@@ -10,7 +10,7 @@ $(".range_limit .profile .range.slider_js").each(function() {
10
10
  var min = boundaries[0];
11
11
  var max = boundaries[1];
12
12
 
13
- if (min && max) {
13
+ if (isInt(min) && isInt(max)) {
14
14
  $(this).contents().wrapAll('<div style="display:none" />');
15
15
 
16
16
  var range_element = $(this);
@@ -46,7 +46,6 @@ $(".range_limit .profile .range.slider_js").each(function() {
46
46
  }
47
47
  }
48
48
 
49
-
50
49
  begin_el.val(min);
51
50
  end_el.val(max);
52
51
 
@@ -112,4 +111,11 @@ function min_max(range_element) {
112
111
  return [min, max]
113
112
  }
114
113
 
114
+
115
+ // Check to see if a value is an Integer
116
+ // see: http://stackoverflow.com/questions/3885817/how-to-check-if-a-number-is-float-or-integer
117
+ function isInt(n) {
118
+ return n % 1 === 0;
119
+ }
120
+
115
121
  });
@@ -17,9 +17,9 @@
17
17
  <li class="selected">
18
18
  <span class="facet-label">
19
19
  <span class="selected"><%= range_display(solr_field) %></span>
20
- <%= link_to remove_range_param(solr_field), :class=>"remove", :title => "remove" do %>
20
+ <%= link_to remove_range_param(solr_field), :class=>"remove", :title => t('blacklight.range_limit.remove_limit') do %>
21
21
  <span class="glyphicon glyphicon-remove"></span>
22
- <span class="sr-only">[remove]</span>
22
+ <span class="sr-only">[<%= t('blacklight.range_limit.remove_limit') %>]</span>
23
23
  <% end %>
24
24
  </span>
25
25
  <span class="selected facet-count"><%= number_with_delimiter(@response.total) %></span>
@@ -40,7 +40,7 @@
40
40
  <% end %>
41
41
 
42
42
  <%= render_range_input(solr_field, :begin, input_label_range_begin) %> – <%= render_range_input(solr_field, :end, input_label_range_end) %>
43
- <%= submit_tag 'Limit', :class=>'submit btn btn-default' %>
43
+ <%= submit_tag t('blacklight.range_limit.submit_limit'), :class=>'submit btn btn-default' %>
44
44
 
45
45
  <% end %>
46
46
  <% end %>
@@ -3,3 +3,5 @@ en:
3
3
  range_limit:
4
4
  range_begin: "%{field_label} range begin"
5
5
  range_end: "%{field_label} range end"
6
+ submit_limit: 'Limit'
7
+ remove_limit: 'remove'
@@ -7,5 +7,4 @@ class BlacklightRangeLimitGenerator < Rails::Generators::Base
7
7
  def copy_public_assets
8
8
  BlacklightRangeLimit::AssetsGenerator.start
9
9
  end
10
-
11
10
  end
@@ -0,0 +1,10 @@
1
+ require 'rails/generators'
2
+
3
+ namespace :blacklight_range_limit do
4
+ desc 'Add in additional Solr docs'
5
+ task seed: :environment do
6
+ docs = Dir['spec/fixtures/solr_documents/*.yml'].map { |f| YAML.load File.read(f) }.flatten
7
+ Blacklight.solr.add docs
8
+ Blacklight.solr.commit
9
+ end
10
+ end
@@ -1,36 +1,30 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Blacklight Range Limit" do
4
- before do
5
- CatalogController.blacklight_config = Blacklight::Configuration.new
6
- CatalogController.configure_blacklight do |config|
7
- config.add_facet_field 'pub_date_sort', :label => 'Publication Date Sort', :range => true
8
- config.default_solr_params[:'facet.field'] = config.facet_fields.keys
9
- end
10
- end
11
4
 
12
5
  it "should show the range limit facet" do
13
- visit '/catalog'
6
+ visit catalog_index_path
14
7
  page.should have_selector 'input.range_begin'
15
8
  page.should have_selector 'input.range_end'
16
9
  page.should have_selector 'label.sr-only[for="range_pub_date_sort_begin"]', :text => 'Publication Date Sort range begin'
17
10
  page.should have_selector 'label.sr-only[for="range_pub_date_sort_end"]', :text => 'Publication Date Sort range end'
11
+ expect(page).to have_css 'input.submit', value: 'Limit'
18
12
  end
19
13
 
20
14
  it "should provide distribution information" do
21
- visit '/catalog'
15
+ visit catalog_index_path
22
16
  click_link 'View distribution'
23
17
 
24
- page.should have_content("1941 to 1944 1")
25
- page.should have_content("2005 to 2008 7")
18
+ page.should have_content("1500 to 1599 0")
19
+ page.should have_content("2000 to 2008 12")
26
20
  end
27
21
 
28
22
  it "should limit appropriately" do
29
- visit '/catalog'
23
+ visit catalog_index_path
30
24
  click_link 'View distribution'
31
- click_link '1941 to 1944'
25
+ click_link '2000 to 2008'
32
26
 
33
- page.should have_content "1941 to 1944 [remove] 1"
27
+ page.should have_content "2000 to 2008 [remove] 12"
34
28
  end
35
29
  end
36
30
 
@@ -0,0 +1,3 @@
1
+ id: 'zero_doc_id'
2
+ title_display: 'Zero year doc'
3
+ pub_date: 1000
@@ -2,9 +2,11 @@ require "spec_helper"
2
2
 
3
3
  describe "Blacklight Range Limit Helper" do
4
4
 
5
- it "should render range text fields with/without labels" do
6
- expect(helper.render_range_input('pub_date', 'begin')).to match /^<input class=\"form-control range_begin\" id=\"range_pub_date_begin\" maxlength=\"4\"/
7
- expect(helper.render_range_input('pub_date', 'begin', 'from pub date')).to match /^<label class=\"sr-only\" for=\"range_pub_date_begin\">from pub date<\/label>/
5
+ it "should render range text fields with/without labels" do
6
+ begin_html = Capybara.string(helper.render_range_input('pub_date', 'begin'))
7
+ begin_from_pub_html = Capybara.string(helper.render_range_input('pub_date', 'begin', 'from pub date'))
8
+ expect(begin_html).to have_css 'input.form-control.range_begin#range_pub_date_begin'
9
+ expect(begin_from_pub_html).to have_css 'label.sr-only[for="range_pub_date_begin"]'
8
10
  end
9
11
 
10
12
  end
@@ -19,4 +19,15 @@ class TestAppGenerator < Rails::Generators::Base
19
19
 
20
20
  generate 'blacklight_range_limit'
21
21
  end
22
+
23
+ def fixtures
24
+ FileUtils.mkdir_p 'spec/fixtures/solr_documents'
25
+ directory 'solr_documents', 'spec/fixtures/solr_documents'
26
+ end
27
+
28
+ def inject_into_catalog_controller
29
+ inject_into_file 'app/controllers/catalog_controller.rb', after: "config.add_facet_field 'example_pivot_field', :label => 'Pivot Field', :pivot => ['format', 'language_facet']" do
30
+ "\n config.add_facet_field 'pub_date_sort', :label => 'Publication Date Sort', :range => true"
31
+ end
32
+ end
22
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight_range_limit
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-13 00:00:00.000000000 Z
12
+ date: 2015-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -193,7 +193,9 @@ files:
193
193
  - lib/blacklight_range_limit/view_helper_override.rb
194
194
  - lib/generators/blacklight_range_limit/assets_generator.rb
195
195
  - lib/generators/blacklight_range_limit/blacklight_range_limit_generator.rb
196
+ - lib/tasks/blacklight_range_limit.rake
196
197
  - spec/features/blacklight_range_limit_spec.rb
198
+ - spec/fixtures/solr_documents/zero_year.yml
197
199
  - spec/helpers/blacklight_range_limit_helper_spec.rb
198
200
  - spec/spec_helper.rb
199
201
  - spec/test_app_templates/Gemfile.extra
@@ -229,6 +231,7 @@ specification_version: 4
229
231
  summary: Blacklight Range Limit plugin
230
232
  test_files:
231
233
  - spec/features/blacklight_range_limit_spec.rb
234
+ - spec/fixtures/solr_documents/zero_year.yml
232
235
  - spec/helpers/blacklight_range_limit_helper_spec.rb
233
236
  - spec/spec_helper.rb
234
237
  - spec/test_app_templates/Gemfile.extra