blacklight 4.0.1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -6
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/.gitignore +1 -0
- data/.travis.yml +14 -6
- data/Gemfile +2 -3
- data/README.md +3 -1
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_blacklight_base.css.scss +1 -0
- data/app/assets/stylesheets/blacklight/_dropdown.css.scss +2 -1
- data/app/assets/stylesheets/blacklight/_search_history.css.scss +1 -1
- data/app/assets/stylesheets/blacklight/blacklight.css.scss +2 -0
- data/app/assets/stylesheets/improved-modal/bootstrap-modal.css +2 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +199 -48
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -1
- data/app/views/catalog/_document_header.html.erb +1 -1
- data/app/views/catalog/_index_default.html.erb +3 -3
- data/app/views/catalog/_per_page_widget.html.erb +1 -1
- data/app/views/catalog/_show_default.html.erb +3 -3
- data/app/views/catalog/_sort_widget.html.erb +1 -1
- data/app/views/catalog/show.html.erb +29 -32
- data/app/views/layouts/blacklight.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.fr.yml +236 -0
- data/gemfiles/rails3.gemfile +9 -0
- data/gemfiles/rails4.gemfile +10 -0
- data/lib/blacklight/catalog.rb +22 -10
- data/lib/blacklight/configurable.rb +2 -3
- data/lib/blacklight/configuration/fields.rb +5 -4
- data/lib/blacklight/mash.rb +7 -139
- data/lib/blacklight/routes.rb +19 -18
- data/lib/blacklight/solr_helper.rb +14 -11
- data/lib/blacklight/solr_response.rb +1 -1
- data/lib/generators/blacklight/blacklight_generator.rb +9 -1
- data/lib/generators/blacklight/test_support_generator.rb +15 -0
- data/test_support/bin/setup-test-app.sh +8 -12
- data/test_support/bin/test.sh +20 -24
- data/test_support/features/search.feature +0 -3
- data/test_support/features/search_pagination.feature +53 -0
- data/test_support/features/step_definitions/search_pagination_steps.rb +29 -0
- data/test_support/features/step_definitions/search_steps.rb +0 -11
- data/test_support/spec/controllers/catalog_controller_spec.rb +15 -80
- data/test_support/spec/helpers/blacklight_helper_spec.rb +75 -22
- data/test_support/spec/helpers/catalog_helper_spec.rb +8 -1
- data/test_support/spec/helpers/html_head_helper_spec.rb +21 -7
- data/test_support/spec/lib/blacklight_configurable_spec.rb +18 -4
- data/test_support/spec/lib/blacklight_configuration_spec.rb +28 -0
- data/test_support/spec/lib/solr_helper_spec.rb +14 -4
- data/test_support/spec/routing/catalog_routing_spec.rb +67 -0
- data/test_support/spec/views/catalog/index.atom.builder_spec.rb +3 -7
- metadata +42 -15
- metadata.gz.sig +0 -0
@@ -30,13 +30,10 @@ Feature: Search
|
|
30
30
|
And I should see "All Fields"
|
31
31
|
And I should see "history"
|
32
32
|
And I should see select list "select#search_field" with "All Fields" selected
|
33
|
-
And I should see "per page"
|
34
|
-
And I should see a selectable list with per page choices
|
35
33
|
And I should see "1."
|
36
34
|
And I should see "2."
|
37
35
|
And I should see "3."
|
38
36
|
And I should see "Sort by"
|
39
|
-
|
40
37
|
|
41
38
|
Scenario: Submitting a Search with specific field selected
|
42
39
|
When I am on the home page
|
@@ -0,0 +1,53 @@
|
|
1
|
+
@search_pagination
|
2
|
+
Feature: Search Pagination
|
3
|
+
In order to find lower ranked documents
|
4
|
+
As a user
|
5
|
+
I want to be able to page through search results and be able to choose how
|
6
|
+
many documents to display per page
|
7
|
+
|
8
|
+
Background:
|
9
|
+
Given the application is configured to have per page with values "10, 20, 50"
|
10
|
+
|
11
|
+
Scenario: Results Page Supports Paging
|
12
|
+
Given I am on the home page
|
13
|
+
When I fill in "q" with ""
|
14
|
+
And I press "search"
|
15
|
+
Then I should see "1 - 10 of"
|
16
|
+
When I follow "Next »"
|
17
|
+
Then I should see "11 - 20 of"
|
18
|
+
When I follow "« Previous"
|
19
|
+
Then I should see "1 - 10 of"
|
20
|
+
|
21
|
+
Scenario: Results Page Has Per Page Available
|
22
|
+
Given I am on the home page
|
23
|
+
When I fill in "q" with ""
|
24
|
+
And I press "search"
|
25
|
+
Then I should see "per page"
|
26
|
+
And I should see the per_page dropdown with values "10, 20, 50"
|
27
|
+
|
28
|
+
Scenario: Results Page Can Display 20 Items Per Page
|
29
|
+
Given I am on the home page
|
30
|
+
And I fill in "q" with ""
|
31
|
+
When I press "search"
|
32
|
+
Then I should see "1 - 10 of"
|
33
|
+
When I show 20 per page
|
34
|
+
Then I should see "1 - 20 of"
|
35
|
+
|
36
|
+
Scenario: Application Can Be Configured for Other Per Page Values
|
37
|
+
Given the application is configured to have per page with values "15, 30"
|
38
|
+
And I am on the home page
|
39
|
+
When I fill in "q" with ""
|
40
|
+
And I press "search"
|
41
|
+
Then I should see the per_page dropdown with values "15, 30"
|
42
|
+
And I should see "1 - 15 of"
|
43
|
+
When I show 30 per page
|
44
|
+
Then I should see "1 - 30 of"
|
45
|
+
|
46
|
+
Scenario: Page Offset Resets to 1 When Changing Per Page
|
47
|
+
Given I am on the home page
|
48
|
+
And I fill in "q" with ""
|
49
|
+
When I press "search"
|
50
|
+
And I follow "Next »"
|
51
|
+
Then I should see "11 - 20 of"
|
52
|
+
When I show 20 per page
|
53
|
+
Then I should see "1 - 20 of"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
Given /^the application is configured to have per page with values "([^\"]*)"$/ do |values|
|
3
|
+
values = values.split(", ")
|
4
|
+
CatalogController.blacklight_config[:per_page] = []
|
5
|
+
values.each do |value|
|
6
|
+
CatalogController.blacklight_config[:per_page] << value
|
7
|
+
end
|
8
|
+
CatalogController.blacklight_config[:default_solr_params][:rows] = values[0]
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
Then /^I should see a selectable list with per page choices$/ do
|
13
|
+
page.should have_selector("#per_page-dropdown")
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^I should see the per_page dropdown with values "(.*?)"$/ do |arg1|
|
17
|
+
page.should have_selector('#per_page-dropdown') do
|
18
|
+
labels = values.split(", ")
|
19
|
+
labels.each do |label|
|
20
|
+
with_tag('li', label)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
When /^I show (\d+) per page$/ do |value|
|
26
|
+
within('#per_page-dropdown .css-dropdown ul') do
|
27
|
+
click_link("#{value} per page")
|
28
|
+
end
|
29
|
+
end
|
@@ -8,17 +8,6 @@ Then /^I should see a selectable list with field choices$/ do
|
|
8
8
|
page.should have_selector("select#search_field")
|
9
9
|
end
|
10
10
|
|
11
|
-
Then /^I should see a selectable list with per page choices$/ do
|
12
|
-
page.should have_selector("#per_page-dropdown")
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
When /^I show (\d+) per page$/ do |value|
|
17
|
-
page.should have_selector('#per_page-dropdown') do
|
18
|
-
click_link(value)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
11
|
Then /^I should see the sort dropdown$/ do
|
23
12
|
page.should have_selector("#sort-dropdown")
|
24
13
|
end
|
@@ -5,83 +5,6 @@ require 'marc'
|
|
5
5
|
|
6
6
|
describe CatalogController do
|
7
7
|
include Devise::TestHelpers
|
8
|
-
#=begin
|
9
|
-
# ROUTES and MAPPING
|
10
|
-
describe "Paths Generated by Custom Routes:" do
|
11
|
-
# paths generated by custom routes
|
12
|
-
it "should map {:controller => 'catalog', :action => 'email'} to /catalog/email" do
|
13
|
-
# RSpec <1.2.9: route_for(:controller => 'catalog', :action => 'email').should == '/catalog/email'
|
14
|
-
{ :get => "/catalog/email" }.should route_to(:controller => 'catalog', :action => 'email')
|
15
|
-
|
16
|
-
end
|
17
|
-
it "should map {:controller => 'catalog', :action => 'sms'} to /catalog/sms" do
|
18
|
-
# RSpec <1.2.9: route_for(:controller => 'catalog', :action => 'sms').should == '/catalog/sms'
|
19
|
-
{ :get => "/catalog/sms" }.should route_to(:controller => 'catalog', :action => 'sms')
|
20
|
-
end
|
21
|
-
it "should map { :controller => 'catalog', :action => 'show', :id => 666 } to /catalog/666" do
|
22
|
-
# RSpec <1.2.9: route_for(:controller => 'catalog', :action => 'show', :id => '666').should == '/catalog/666'
|
23
|
-
{ :get => "/catalog/666" }.should route_to(:controller => 'catalog', :action => 'show', :id => "666")
|
24
|
-
end
|
25
|
-
it "should map {:controller => 'catalog', :id => '111', :action => 'librarian_view'} to /catalog/111/librarian_view" do
|
26
|
-
# RSpec <1.2.9: route_for(:controller => 'catalog', :action => 'librarian_view', :id => '111').should == '/catalog/111/librarian_view'
|
27
|
-
{ :get => "/catalog/111/librarian_view" }.should route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# parameters generated from routes
|
32
|
-
describe "Parameters Generated from Routes:" do
|
33
|
-
it "should map /catalog/email to {:controller => 'catalog', :action => 'email'}" do
|
34
|
-
# RSpec <1.2.9: params_from(:get, '/catalog/email').should == {:controller => 'catalog', :action => 'email'}
|
35
|
-
{ :get => "/catalog/email" }.should route_to(:controller => 'catalog', :action => 'email')
|
36
|
-
end
|
37
|
-
it "should map /catalog/sms to {:controller => 'catalog', :action => 'sms'}" do
|
38
|
-
#RSpec <1.2.9 :params_from(:get, '/catalog/sms').should == {:controller => 'catalog', :action => 'sms'}
|
39
|
-
{ :get => "/catalog/sms" }.should route_to(:controller => 'catalog', :action => 'sms')
|
40
|
-
end
|
41
|
-
it "should map /catalog/666 to {:controller => 'catalog', :action => 'show', :id => 666}" do
|
42
|
-
#RSPEC <1.2.9 params_from(:get, '/catalog/666').should == {:controller => 'catalog', :action => 'show', :id => '666'}
|
43
|
-
{ :get => "/catalog/666" }.should route_to(:controller => 'catalog', :action => 'show', :id => "666")
|
44
|
-
end
|
45
|
-
it "should map /catalog/111/librarian_view to {:controller => 'catalog', :action => 'librarian_view', :id => 111}" do
|
46
|
-
# params_from(:get, '/catalog/111/librarian_view').should == {:controller => 'catalog', :action => 'librarian_view', :id => '111'}
|
47
|
-
{ :get => "/catalog/111/librarian_view" }.should route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "catalog_url for SolrDocument", :test => true do
|
52
|
-
it "should route correctly" do
|
53
|
-
{ :get => catalog_url(SolrDocument.new(:id => 'asdf')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'asdf')
|
54
|
-
end
|
55
|
-
|
56
|
-
context "should escape solr document ids" do
|
57
|
-
|
58
|
-
it "should pass-through url-valid ids" do
|
59
|
-
{ :get => catalog_url(SolrDocument.new(:id => 'qwerty'))}.should route_to(:controller => 'catalog', :action => 'show', :id => 'qwerty')
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should route url-like ids" do
|
63
|
-
pending "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
|
64
|
-
{ :get => catalog_url(SolrDocument.new(:id => 'http://example.com'))}.should route_to(:controller => 'catalog', :action => 'show', :id => 'http://example.com')
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should route ids with whitespace" do
|
68
|
-
{ :get => catalog_url(SolrDocument.new(:id => 'mm 123')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'mm 123')
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should route ids with a literal '+'" do
|
72
|
-
{ :get => catalog_url(SolrDocument.new(:id => 'this+that')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'this+that')
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should route ids with a literal '/" do
|
76
|
-
pending "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
|
77
|
-
{ :get => catalog_url(SolrDocument.new(:id => 'and/or')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'and/or')
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
8
|
# INDEX ACTION
|
86
9
|
describe "index action" do
|
87
10
|
before(:each) do
|
@@ -452,18 +375,30 @@ describe CatalogController do
|
|
452
375
|
response.should_not be_success
|
453
376
|
response.status.should == 404
|
454
377
|
end
|
455
|
-
it "should
|
378
|
+
it "should redirect the user to the root url for a bad search" do
|
456
379
|
req = {}
|
457
380
|
res = {}
|
458
381
|
fake_error = RSolr::Error::Http.new(req, res)
|
459
382
|
controller.stub(:get_search_results) { |*args| raise fake_error }
|
460
383
|
controller.logger.should_receive(:error).with(fake_error)
|
461
384
|
get :index, :q=>"+"
|
385
|
+
|
462
386
|
response.redirect_url.should == root_url
|
463
387
|
request.flash[:notice].should == "Sorry, I don't understand your search."
|
464
388
|
response.should_not be_success
|
465
|
-
response.status.should ==
|
466
|
-
|
389
|
+
response.status.should == 302
|
390
|
+
end
|
391
|
+
it "should return status 500 if the catalog path is raising an exception" do
|
392
|
+
|
393
|
+
req = {}
|
394
|
+
res = {}
|
395
|
+
fake_error = RSolr::Error::Http.new(req, res)
|
396
|
+
controller.stub(:get_search_results) { |*args| raise fake_error }
|
397
|
+
controller.flash.stub!(:sweep)
|
398
|
+
controller.stub(:flash).and_return(:notice => I18n.t('blacklight.search.errors.request_error'))
|
399
|
+
expect {
|
400
|
+
get :index, :q=>"+"
|
401
|
+
}.to raise_error
|
467
402
|
end
|
468
403
|
|
469
404
|
end
|
@@ -146,35 +146,88 @@ describe BlacklightHelper do
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
-
describe "
|
149
|
+
describe "params_for_search" do
|
150
150
|
def params
|
151
|
-
{
|
151
|
+
{ 'default' => 'params'}
|
152
152
|
end
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
153
|
+
|
154
|
+
it "should default to using the controller's params" do
|
155
|
+
result = params_for_search
|
156
|
+
result.should == params
|
157
|
+
params.object_id.should_not == result.object_id
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should let you pass in params to use" do
|
161
|
+
source_params = { :q => 'query'}
|
162
|
+
result = params_for_search(:params => source_params )
|
163
|
+
source_params.should == result
|
164
|
+
source_params.object_id.should_not == result.object_id
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should not return blacklisted elements" do
|
168
|
+
source_params = { :action => 'action', :controller => 'controller', :commit => 'commit'}
|
169
|
+
result = params_for_search(:params => source_params )
|
170
|
+
result.keys.should_not include(:action, :controller, :commit)
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should adjust the current page if the per_page changes" do
|
175
|
+
source_params = { :per_page => 20, :page => 5}
|
176
|
+
result = params_for_search(:params => source_params, :per_page => 100)
|
177
|
+
result[:page].should == 1
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should not adjust the current page if the per_page is the same as it always was" do
|
181
|
+
source_params = { :per_page => 20, :page => 5}
|
182
|
+
result = params_for_search(:params => source_params, :per_page => 20)
|
183
|
+
result[:page].should == 5
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should adjust the current page if the sort changes" do
|
187
|
+
source_params = { :sort => 'field_a', :page => 5}
|
188
|
+
result = params_for_search(:params => source_params, :sort => 'field_b')
|
189
|
+
result[:page].should == 1
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should not adjust the current page if the sort is the same as it always was" do
|
193
|
+
source_params = { :sort => 'field_a', :page => 5}
|
194
|
+
result = params_for_search(:params => source_params, :sort => 'field_a')
|
195
|
+
result[:page].should == 5
|
196
|
+
end
|
197
|
+
|
198
|
+
describe "omit keys parameter" do
|
199
|
+
it "should omit keys by key name" do
|
200
|
+
source_params = { :a => 1, :b => 2, :c => 3}
|
201
|
+
result = params_for_search(:params => source_params, :omit_keys => [:a, :b] )
|
202
|
+
|
203
|
+
result.keys.should_not include(:a, :b)
|
204
|
+
result[:c].should == 3
|
157
205
|
end
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
206
|
+
|
207
|
+
it "should remove keys if a key/value pair was passed and no values are left for that key" do
|
208
|
+
source_params = { :f => ['a']}
|
209
|
+
result = params_for_search(:params => source_params, :omit_keys => [{:f => 'a' }])
|
210
|
+
result.keys.should_not include(:f)
|
162
211
|
end
|
163
|
-
describe "for omit_keys parameter" do
|
164
|
-
it "should not include those keys" do
|
165
|
-
generated = search_as_hidden_fields(:omit_keys => [:per_page, :sort])
|
166
212
|
|
167
|
-
|
168
|
-
generated.should_not have_selector("input[name=per_page]")
|
213
|
+
it "should only remove keys when a key/value pair is based that are in that pair" do
|
169
214
|
|
170
|
-
|
171
|
-
|
215
|
+
source_params = { :f => ['a', 'b']}
|
216
|
+
result = params_for_search(:params => source_params, :omit_keys => [{:f => 'a' }])
|
217
|
+
result[:f].should_not include('a')
|
218
|
+
result[:f].should include('b')
|
219
|
+
end
|
220
|
+
end
|
172
221
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
222
|
+
end
|
223
|
+
|
224
|
+
describe "search_as_hidden_fields" do
|
225
|
+
def params
|
226
|
+
{:q => "query", :sort => "sort", :per_page => "20", :search_field => "search_field", :page => 100, :arbitrary_key => "arbitrary_value", :f => {"field" => ["value1", "value2"], "other_field" => ['asdf']}, :controller => "catalog", :action => "index", :commit => "search"}
|
227
|
+
end
|
228
|
+
describe "for default arguments" do
|
229
|
+
it "should default to omitting :page" do
|
230
|
+
search_as_hidden_fields.should_not have_selector("input[name='page']")
|
178
231
|
end
|
179
232
|
end
|
180
233
|
end
|
@@ -6,7 +6,7 @@ describe CatalogHelper do
|
|
6
6
|
|
7
7
|
def mock_response args
|
8
8
|
current_page = args[:current_page] || 1
|
9
|
-
per_page = args[:per_page] || 10
|
9
|
+
per_page = args[:rows] || args[:per_page] || 10
|
10
10
|
total = args[:total]
|
11
11
|
start = (current_page - 1) * per_page
|
12
12
|
|
@@ -78,6 +78,13 @@ describe CatalogHelper do
|
|
78
78
|
html.should == "<strong>41</strong> - <strong>47</strong> of <strong>47</strong>"
|
79
79
|
html.html_safe?.should == true
|
80
80
|
end
|
81
|
+
it "should work with rows the same as per_page" do
|
82
|
+
@response = mock_response :total => 47, :rows => 20, :current_page => 2
|
83
|
+
|
84
|
+
html = render_pagination_info(@response, { :entry_name => 'entry_name' })
|
85
|
+
html.should == "<strong>21</strong> - <strong>40</strong> of <strong>47</strong>"
|
86
|
+
html.html_safe?.should == true
|
87
|
+
end
|
81
88
|
|
82
89
|
end
|
83
90
|
end
|
@@ -13,10 +13,15 @@ describe HtmlHeadHelper do
|
|
13
13
|
it "should include script tags specified in controller#javascript_includes" do
|
14
14
|
html = helper.render_js_includes
|
15
15
|
|
16
|
-
if
|
16
|
+
if Rails::VERSION::MAJOR == 4
|
17
|
+
html.should have_selector("script[src='/javascripts/some_js.js']")
|
18
|
+
html.should have_selector("script[src='/javascripts/other_js.js']")
|
19
|
+
elsif use_asset_pipeline?
|
20
|
+
# only for rails 3 with asset pipeline enabled
|
17
21
|
html.should have_selector("script[src='/assets/some_js.js'][type='text/javascript']")
|
18
22
|
html.should have_selector("script[src='/assets/other_js.js'][type='text/javascript']")
|
19
23
|
else
|
24
|
+
# rails 3 with asset pipeline disabled
|
20
25
|
html.should have_selector("script[src='/javascripts/some_js.js'][type='text/javascript']")
|
21
26
|
html.should have_selector("script[src='/javascripts/other_js.js'][type='text/javascript']")
|
22
27
|
end
|
@@ -37,7 +42,10 @@ describe HtmlHeadHelper do
|
|
37
42
|
it "should render stylesheets specified in controller #stylesheet_links" do
|
38
43
|
html = helper.render_stylesheet_includes
|
39
44
|
|
40
|
-
if
|
45
|
+
if Rails::VERSION::MAJOR == 4
|
46
|
+
html.should have_selector("link[href='/stylesheets/my_stylesheet.css'][rel='stylesheet']")
|
47
|
+
html.should have_selector("link[href='/stylesheets/other_stylesheet.css'][rel='stylesheet']")
|
48
|
+
elsif use_asset_pipeline?
|
41
49
|
html.should have_selector("link[href='/assets/my_stylesheet.css'][rel='stylesheet'][type='text/css']")
|
42
50
|
html.should have_selector("link[href='/assets/other_stylesheet.css'][rel='stylesheet'][type='text/css']")
|
43
51
|
else
|
@@ -98,12 +106,18 @@ describe HtmlHeadHelper do
|
|
98
106
|
@output.should have_selector("link[rel=rel][type=type][href=href]")
|
99
107
|
end
|
100
108
|
it "should include render_javascript_includes" do
|
101
|
-
|
102
|
-
|
109
|
+
if Rails::VERSION::MAJOR == 4
|
110
|
+
@output.should have_selector("script[src='/javascripts/my_js.js']")
|
111
|
+
else
|
112
|
+
@output.should have_selector("script[src='/assets/my_js.js'][type='text/javascript']")
|
113
|
+
end
|
103
114
|
end
|
104
115
|
it "should include render_stylesheet_links" do
|
105
|
-
|
106
|
-
|
116
|
+
if Rails::VERSION::MAJOR == 4
|
117
|
+
@output.should have_selector("link[href='/stylesheets/my_css.css']")
|
118
|
+
else
|
119
|
+
@output.should have_selector("link[href='/assets/my_css.css'][type='text/css']")
|
120
|
+
end
|
107
121
|
end
|
108
122
|
it "should include content_for :head" do
|
109
123
|
@output.should have_selector("meta[keywords]")
|
@@ -121,7 +135,7 @@ describe HtmlHeadHelper do
|
|
121
135
|
|
122
136
|
private
|
123
137
|
def use_asset_pipeline?
|
124
|
-
(Rails::VERSION::MAJOR
|
138
|
+
Rails::VERSION::MAJOR == 4 || ((Rails::VERSION::MAJOR == 3 and Rails::VERSION::MINOR >= 1) and Rails.application.config.assets.enabled)
|
125
139
|
end
|
126
140
|
|
127
141
|
end
|
@@ -69,6 +69,18 @@ describe "Blacklight::Configurable" do
|
|
69
69
|
|
70
70
|
klass.blacklight_config.my_key.should == 'value'
|
71
71
|
end
|
72
|
+
|
73
|
+
it "allows the instance to set a radically different config from the class" do
|
74
|
+
klass = Class.new
|
75
|
+
klass.send(:include, Blacklight::Configurable)
|
76
|
+
klass.blacklight_config.foo = "bar"
|
77
|
+
|
78
|
+
instance = klass.new
|
79
|
+
instance.blacklight_config = Blacklight::Configuration.new
|
80
|
+
|
81
|
+
instance.blacklight_config.should_not == klass.blacklight_config
|
82
|
+
instance.blacklight_config.foo.should be_nil
|
83
|
+
end
|
72
84
|
|
73
85
|
it "allows instance to set it's own config seperate from class" do
|
74
86
|
# this is built into class_attribute; we spec it both to document it,
|
@@ -77,14 +89,16 @@ describe "Blacklight::Configurable" do
|
|
77
89
|
klass = Class.new
|
78
90
|
klass.send(:include, Blacklight::Configurable)
|
79
91
|
klass.blacklight_config.foo = "bar"
|
92
|
+
klass.blacklight_config.bar = []
|
93
|
+
klass.blacklight_config.bar << "asd"
|
80
94
|
|
81
95
|
instance = klass.new
|
82
|
-
|
83
|
-
instance.blacklight_config = Blacklight::Configuration.new
|
84
|
-
|
96
|
+
instance.blacklight_config.bar << "123"
|
85
97
|
instance.blacklight_config.should_not == klass.blacklight_config
|
86
|
-
instance.blacklight_config.foo.should be_nil
|
87
98
|
klass.blacklight_config.foo.should == "bar"
|
99
|
+
instance.blacklight_config.foo.should == "bar"
|
100
|
+
klass.blacklight_config.bar.should_not include("123")
|
101
|
+
instance.blacklight_config.bar.should include("asd", "123")
|
88
102
|
end
|
89
103
|
|
90
104
|
it "configurable classes should not mutate the default configuration object" do
|