blacklight 4.7.0 → 4.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +13 -12
- data/Gemfile +37 -2
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/{_blacklight_base.css.scss → _blacklight_base.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_bookmark.css.scss → _bookmark.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_catalog.css.scss → _catalog.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_dropdown.css.scss → _dropdown.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_facets.css.scss → _facets.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_footer.css.scss → _footer.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_group.css.scss → _group.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_header.css.scss → _header.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_layout.css.scss → _layout.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_mixins.css.scss → _mixins.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_modal.css.scss → _modal.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_print.css.scss → _print.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_responsive.css.scss → _responsive.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_search_history.css.scss → _search_history.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{blacklight.css.scss → blacklight.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{blacklight_defaults.css.scss → blacklight_defaults.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_catalog.css.scss → _catalog.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_facets.css.scss → _facets.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_header.css.scss → _header.scss} +0 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +2 -2
- data/blacklight.gemspec +5 -6
- data/lib/blacklight/catalog.rb +1 -1
- data/lib/blacklight/catalog/search_context.rb +6 -6
- data/lib/blacklight/solr/document.rb +29 -21
- data/lib/blacklight/solr_helper.rb +6 -4
- data/lib/generators/blacklight/templates/{blacklight.css.scss → blacklight.scss} +0 -0
- data/spec/controllers/application_controller_spec.rb +3 -3
- data/spec/controllers/bookmarks_controller_spec.rb +11 -11
- data/spec/controllers/catalog_controller_spec.rb +117 -117
- data/spec/controllers/search_history_controller_spec.rb +8 -8
- data/spec/features/alternate_controller_spec.rb +7 -5
- data/spec/features/record_view_spec.rb +4 -1
- data/spec/features/search_filters_spec.rb +37 -24
- data/spec/features/search_pagination_spec.rb +11 -7
- data/spec/features/search_results_spec.rb +22 -14
- data/spec/features/search_sort_spec.rb +3 -1
- data/spec/features/search_spec.rb +6 -0
- data/spec/helpers/blacklight_helper_spec.rb +175 -166
- data/spec/helpers/catalog_helper_spec.rb +59 -59
- data/spec/helpers/facets_helper_spec.rb +118 -118
- data/spec/helpers/hash_as_hidden_fields_spec.rb +14 -8
- data/spec/helpers/html_head_helper_spec.rb +51 -45
- data/spec/helpers/render_constraints_helper_spec.rb +5 -6
- data/spec/helpers/search_history_constraints_helper_spec.rb +21 -21
- data/spec/lib/blacklight/solr_response/group_response_spec.rb +2 -2
- data/spec/lib/blacklight_configurable_spec.rb +16 -16
- data/spec/lib/blacklight_configuration_spec.rb +132 -132
- data/spec/lib/blacklight_email_spec.rb +4 -4
- data/spec/lib/blacklight_sms_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_dublin_core_spec.rb +6 -6
- data/spec/lib/blacklight_solr_document_marc_spec.rb +3 -3
- data/spec/lib/blacklight_solr_document_more_like_this_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_spec.rb +36 -36
- data/spec/lib/blacklight_solr_response_spec.rb +42 -42
- data/spec/lib/blacklight_spec.rb +5 -5
- data/spec/lib/blacklight_user_spec.rb +5 -5
- data/spec/lib/facet_paginator_spec.rb +12 -12
- data/spec/lib/marc_export_spec.rb +746 -746
- data/spec/lib/search_fields_spec.rb +13 -13
- data/spec/lib/solr_helper_spec.rb +255 -250
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
- data/spec/lib/tasks/solr_marc_task_spec.rb +6 -6
- data/spec/lib/utils_spec.rb +11 -11
- data/spec/models/bookmark_spec.rb +7 -6
- data/spec/models/record_mailer_spec.rb +16 -16
- data/spec/models/search_spec.rb +8 -8
- data/spec/models/solr_document_spec.rb +7 -7
- data/spec/requests/alternate_controller_spec.rb +3 -3
- data/spec/routing/catalog_routing_spec.rb +10 -15
- data/spec/spec_helper.rb +6 -4
- data/spec/support/assert_difference.rb +2 -2
- data/spec/support/features.rb +11 -0
- data/spec/support/features/session_helpers.rb +3 -3
- data/spec/support/include_text.rb +2 -2
- data/spec/test_app_templates/Gemfile.extra +2 -15
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +17 -6
- data/spec/views/catalog/_constraints.html.erb_spec.rb +7 -7
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +12 -12
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +13 -13
- data/spec/views/catalog/_index_default.erb_spec.rb +20 -20
- data/spec/views/catalog/_show_default.erb_spec.rb +20 -20
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +6 -6
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +28 -28
- data/spec/views/catalog/index.html.erb_spec.rb +6 -6
- metadata +35 -57
- data/gemfiles/rails3.gemfile +0 -25
- data/gemfiles/rails4.gemfile +0 -24
@@ -15,26 +15,26 @@ describe SearchHistoryController do
|
|
15
15
|
session[:history] = [@one.id, @three.id]
|
16
16
|
get :index
|
17
17
|
@searches = assigns(:searches)
|
18
|
-
@searches.length.
|
19
|
-
@searches.
|
20
|
-
@searches.
|
21
|
-
@searches.
|
18
|
+
expect(@searches.length).to eq(2)
|
19
|
+
expect(@searches).to include(@one)
|
20
|
+
expect(@searches).to include(@three)
|
21
|
+
expect(@searches).not_to include(@two)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should tolerate bad ids in session" do
|
25
25
|
session[:history] = [@one.id, @three.id, "NOT_IN_DB"]
|
26
26
|
get :index
|
27
27
|
@searches = assigns(:searches)
|
28
|
-
@searches.length.
|
29
|
-
@searches.
|
30
|
-
@searches.
|
28
|
+
expect(@searches.length).to eq(2)
|
29
|
+
expect(@searches).to include(@one)
|
30
|
+
expect(@searches).to include(@three)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should not fetch any searches if there is no history" do
|
34
34
|
session[:history] = []
|
35
35
|
get :index
|
36
36
|
@searches = assigns(:searches)
|
37
|
-
@searches.length.
|
37
|
+
expect(@searches.length).to eq(0)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -3,17 +3,19 @@ require 'spec_helper'
|
|
3
3
|
describe "Alternate Controller Behaviors" do
|
4
4
|
it "should have the correct per-page form" do
|
5
5
|
visit alternate_index_path
|
6
|
-
page.
|
6
|
+
expect(page).to have_selector("form[action='#{alternate_index_path}']")
|
7
7
|
fill_in "q", :with=>"history"
|
8
8
|
click_button 'search'
|
9
9
|
expect(current_path).to match /#{alternate_index_path}/
|
10
|
-
|
10
|
+
within ("#per_page-dropdown") do
|
11
|
+
click_link '20 per page'
|
12
|
+
end
|
11
13
|
expect(current_path).to match /#{alternate_index_path}/
|
12
14
|
end
|
13
15
|
|
14
16
|
it "should have the correct search field form" do
|
15
17
|
visit alternate_index_path
|
16
|
-
page.
|
18
|
+
expect(page).to have_selector("form[action='#{alternate_index_path}']")
|
17
19
|
fill_in "q", :with=>"history"
|
18
20
|
click_button 'search'
|
19
21
|
expect(current_path).to match /#{alternate_index_path}/
|
@@ -23,7 +25,7 @@ describe "Alternate Controller Behaviors" do
|
|
23
25
|
|
24
26
|
it "should display document thumbnails" do
|
25
27
|
visit alternate_index_path
|
26
|
-
page.
|
28
|
+
expect(page).to have_selector("form[action='#{alternate_index_path}']")
|
27
29
|
fill_in "q", :with=>"history"
|
28
30
|
click_button 'search'
|
29
31
|
expect(page).to have_selector ".document-thumbnail"
|
@@ -31,4 +33,4 @@ describe "Alternate Controller Behaviors" do
|
|
31
33
|
expect(page).to have_selector ".document-thumbnail a img"
|
32
34
|
|
33
35
|
end
|
34
|
-
end
|
36
|
+
end
|
@@ -14,7 +14,10 @@ describe "Record View" do
|
|
14
14
|
expect(page).to have_content "Book"
|
15
15
|
expect(page).to have_content "Call number:"
|
16
16
|
expect(page).to have_content "E99.D2 H437 2008"
|
17
|
+
tmp_value = Capybara.ignore_hidden_elements
|
18
|
+
Capybara.ignore_hidden_elements = false
|
17
19
|
expect(page).to have_selector("link[rel=alternate]")
|
20
|
+
Capybara.ignore_hidden_elements = tmp_value
|
18
21
|
|
19
22
|
end
|
20
23
|
|
@@ -31,7 +34,7 @@ describe "Record View" do
|
|
31
34
|
end
|
32
35
|
it "should not display 404" do
|
33
36
|
visit catalog_path('this_id_does_not_exist')
|
34
|
-
page.driver.status_code.
|
37
|
+
expect(page.driver.status_code).to eq(404)
|
35
38
|
expect(page).to have_content "Sorry, you have requested a record that doesn't exist."
|
36
39
|
end
|
37
40
|
end
|
@@ -3,11 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe "Facets" do
|
4
4
|
it "should work without a search term" do
|
5
5
|
visit root_path
|
6
|
-
|
7
|
-
|
6
|
+
within 'div.blacklight-language_facet' do
|
7
|
+
click_link "Tibetan"
|
8
|
+
end
|
9
|
+
within "#sortAndPerPage" do
|
8
10
|
expect(page).to have_content "1 - 6 of 6"
|
9
11
|
end
|
10
|
-
within(".blacklight-language_facet") do
|
12
|
+
within("div.blacklight-language_facet") do
|
11
13
|
expect(page).to have_selector("span.selected", :text => "Tibetan 6")
|
12
14
|
end
|
13
15
|
|
@@ -15,10 +17,10 @@ describe "Facets" do
|
|
15
17
|
within ("#sortAndPerPage") do
|
16
18
|
expect(page).to have_content "1 - 2 of 2"
|
17
19
|
end
|
18
|
-
within(".blacklight-language_facet") do
|
20
|
+
within("div.blacklight-language_facet") do
|
19
21
|
expect(page).to have_selector("span.selected", :text => "Tibetan 2")
|
20
22
|
end
|
21
|
-
within(".blacklight-subject_geo_facet") do
|
23
|
+
within(".blacklight-subject_geo_facet") do
|
22
24
|
expect(page).to have_selector("span.selected", :text => "India 2")
|
23
25
|
end
|
24
26
|
end
|
@@ -31,11 +33,13 @@ describe "Facets" do
|
|
31
33
|
expect(page).to have_content "1 - 9 of 9"
|
32
34
|
end
|
33
35
|
|
34
|
-
|
36
|
+
within "div.blacklight-language_facet" do
|
37
|
+
click_link "Tibetan"
|
38
|
+
end
|
35
39
|
within ("#sortAndPerPage") do
|
36
40
|
expect(page).to have_content "1 - 2 of 2"
|
37
41
|
end
|
38
|
-
within(".blacklight-language_facet") do
|
42
|
+
within("div.blacklight-language_facet") do
|
39
43
|
expect(page).to have_selector("span.selected", :text => "Tibetan 2")
|
40
44
|
end
|
41
45
|
within "#appliedParams" do
|
@@ -48,21 +52,23 @@ describe "Facets" do
|
|
48
52
|
within ("#sortAndPerPage") do
|
49
53
|
expect(page).to have_content "1 entry found"
|
50
54
|
end
|
51
|
-
within(".blacklight-language_facet") do
|
55
|
+
within("div.blacklight-language_facet") do
|
52
56
|
expect(page).to have_selector("span.selected", :text => "Tibetan 1")
|
53
57
|
end
|
54
|
-
within(".blacklight-pub_date") do
|
58
|
+
within(".blacklight-pub_date") do
|
55
59
|
expect(page).to have_selector("span.selected", :text => "2004 1")
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
59
63
|
it "should allow removing filters" do
|
60
64
|
visit root_path
|
61
|
-
|
62
|
-
|
65
|
+
within "div.blacklight-language_facet" do
|
66
|
+
click_link "Tibetan"
|
67
|
+
end
|
68
|
+
within("div.blacklight-language_facet") do
|
63
69
|
expect(page).to have_selector("span.selected", :text => "Tibetan 6")
|
64
70
|
end
|
65
|
-
within(".blacklight-language_facet") do
|
71
|
+
within("div.blacklight-language_facet") do
|
66
72
|
click_link 'remove'
|
67
73
|
end
|
68
74
|
expect(page).to_not have_link 'remove'
|
@@ -73,26 +79,28 @@ describe "Facets" do
|
|
73
79
|
visit root_path
|
74
80
|
fill_in "q", with: 'history'
|
75
81
|
click_button 'search'
|
76
|
-
|
77
|
-
|
82
|
+
within "div.blacklight-language_facet" do
|
83
|
+
click_link "Tibetan"
|
84
|
+
end
|
85
|
+
within("div.blacklight-language_facet") do
|
78
86
|
expect(page).to have_selector("span.selected", :text => "Tibetan 2")
|
79
87
|
end
|
80
88
|
|
81
89
|
click_link '2004'
|
82
90
|
|
83
|
-
within(".blacklight-language_facet") do
|
91
|
+
within("div.blacklight-language_facet") do
|
84
92
|
expect(page).to have_selector("span.selected", :text => "Tibetan 1")
|
85
93
|
end
|
86
|
-
within(".blacklight-pub_date") do
|
94
|
+
within(".blacklight-pub_date") do
|
87
95
|
expect(page).to have_selector("span.selected", :text => "2004 1")
|
88
96
|
end
|
89
97
|
fill_in "q", with: 'china'
|
90
98
|
click_button 'search'
|
91
99
|
|
92
|
-
within(".blacklight-language_facet") do
|
100
|
+
within("div.blacklight-language_facet") do
|
93
101
|
expect(page).to have_selector("span.selected", :text => "Tibetan 1")
|
94
102
|
end
|
95
|
-
within(".blacklight-pub_date") do
|
103
|
+
within(".blacklight-pub_date") do
|
96
104
|
expect(page).to have_selector("span.selected", :text => "2004 1")
|
97
105
|
end
|
98
106
|
end
|
@@ -101,12 +109,14 @@ describe "Facets" do
|
|
101
109
|
visit root_path
|
102
110
|
fill_in "q", with: 'history'
|
103
111
|
click_button 'search'
|
104
|
-
|
105
|
-
|
112
|
+
within("div.blacklight-language_facet") do
|
113
|
+
click_link 'Tibetan'
|
114
|
+
end
|
115
|
+
within("div.blacklight-language_facet") do
|
106
116
|
expect(page).to have_selector("span.selected", :text => "Tibetan 2")
|
107
117
|
end
|
108
118
|
click_link 'title'
|
109
|
-
within(".blacklight-language_facet") do
|
119
|
+
within("div.blacklight-language_facet") do
|
110
120
|
expect(page).to have_selector("span.selected", :text => "Tibetan 2")
|
111
121
|
end
|
112
122
|
within "#appliedParams" do
|
@@ -119,14 +129,17 @@ describe "Facets" do
|
|
119
129
|
visit root_path
|
120
130
|
fill_in "q", with: 'history'
|
121
131
|
click_button 'search'
|
122
|
-
|
123
|
-
within(".blacklight-language_facet") do
|
132
|
+
|
133
|
+
within("div.blacklight-language_facet") do
|
134
|
+
click_link 'Tibetan'
|
135
|
+
end
|
136
|
+
within("div.blacklight-language_facet") do
|
124
137
|
expect(page).to have_selector("span.selected", :text => "Tibetan 2")
|
125
138
|
end
|
126
139
|
within '#per_page-dropdown' do
|
127
140
|
click_link '20'
|
128
141
|
end
|
129
|
-
within(".blacklight-language_facet") do
|
142
|
+
within("div.blacklight-language_facet") do
|
130
143
|
expect(page).to have_selector("span.selected", :text => "Tibetan 2")
|
131
144
|
end
|
132
145
|
within "#appliedParams" do
|
@@ -16,12 +16,14 @@ describe "Search Pagination" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
19
|
-
|
20
|
-
|
19
|
+
within '#sortAndPerPage' do
|
20
|
+
click_link "Next »"
|
21
|
+
end
|
22
|
+
within "#sortAndPerPage" do
|
21
23
|
expect(page).to have_content "11 - 20 of "
|
24
|
+
click_link "« Previous"
|
22
25
|
end
|
23
|
-
|
24
|
-
within ("#sortAndPerPage") do
|
26
|
+
within "#sortAndPerPage" do
|
25
27
|
expect(page).to have_content "1 - 10 of "
|
26
28
|
end
|
27
29
|
end
|
@@ -77,14 +79,16 @@ describe "Search Pagination" do
|
|
77
79
|
visit root_path
|
78
80
|
fill_in "q", with: ''
|
79
81
|
click_button 'search'
|
80
|
-
|
81
|
-
|
82
|
+
within "#sortAndPerPage" do
|
83
|
+
click_link "Next »"
|
84
|
+
end
|
85
|
+
within "#sortAndPerPage" do
|
82
86
|
expect(page).to have_content "11 - 20 of "
|
83
87
|
end
|
84
88
|
within ("#per_page-dropdown") do
|
85
89
|
click_link '20'
|
86
90
|
end
|
87
|
-
within
|
91
|
+
within "#sortAndPerPage" do
|
88
92
|
expect(page).to have_content "1 - 20 of "
|
89
93
|
end
|
90
94
|
end
|
@@ -4,40 +4,43 @@ require 'spec_helper'
|
|
4
4
|
describe "Search Results" do
|
5
5
|
it "should have for an empty query" do
|
6
6
|
search_for ''
|
7
|
-
number_of_results_from_page(page).
|
8
|
-
page.
|
7
|
+
expect(number_of_results_from_page(page)).to eq(30)
|
8
|
+
expect(page).to have_xpath("//a[contains(@href, #{2007020969})]")
|
9
9
|
search_for 'korea'
|
10
|
-
number_of_results_from_page(page).
|
10
|
+
expect(number_of_results_from_page(page)).to eq(4)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should find same result set with or without diacritcs" do
|
14
14
|
search_for 'inmul'
|
15
|
-
number_of_results_from_page(page).
|
16
|
-
page.
|
15
|
+
expect(number_of_results_from_page(page)).to eq(1)
|
16
|
+
expect(page).to have_xpath("//a[contains(@href, #{77826928})]")
|
17
17
|
|
18
18
|
search_for 'inmül'
|
19
|
-
number_of_results_from_page(page).
|
19
|
+
expect(number_of_results_from_page(page)).to eq(1)
|
20
20
|
end
|
21
21
|
it "should find same result set for a case-insensitive query " do
|
22
22
|
search_for 'inmul'
|
23
|
-
number_of_results_from_page(page).
|
24
|
-
page.
|
23
|
+
expect(number_of_results_from_page(page)).to eq(1)
|
24
|
+
expect(page).to have_xpath("//a[contains(@href, #{77826928})]")
|
25
25
|
|
26
26
|
search_for 'INMUL'
|
27
|
-
number_of_results_from_page(page).
|
27
|
+
expect(number_of_results_from_page(page)).to eq(1)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should order by relevancy" do
|
31
31
|
search_for "Korea"
|
32
|
-
position_in_result_page(page, '77826928').
|
33
|
-
position_in_result_page(page, '94120425').
|
34
|
-
|
32
|
+
expect(position_in_result_page(page, '77826928')).to eq(1)
|
33
|
+
expect(position_in_result_page(page, '94120425')).to eq(2)
|
34
|
+
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should have an opensearch description document" do
|
38
38
|
visit root_path
|
39
|
+
tmp_value = Capybara.ignore_hidden_elements
|
40
|
+
Capybara.ignore_hidden_elements = false
|
39
41
|
page.should have_xpath("//link[contains(@rel, 'search')]")
|
40
42
|
expect(page.find(:xpath, "//link[contains(@rel, 'search')]")[:href]).to eq "http://www.example.com/catalog/opensearch.xml"
|
43
|
+
Capybara.ignore_hidden_elements = tmp_value
|
41
44
|
end
|
42
45
|
|
43
46
|
it "should provide search hints if there are no results" do
|
@@ -46,6 +49,7 @@ describe "Search Results" do
|
|
46
49
|
end
|
47
50
|
|
48
51
|
it "should pass the current search id through", :js => true do
|
52
|
+
pending
|
49
53
|
visit root_path
|
50
54
|
fill_in "q", with: ''
|
51
55
|
click_button 'search'
|
@@ -79,7 +83,7 @@ def position_in_result_page(page, id)
|
|
79
83
|
end
|
80
84
|
i.to_i
|
81
85
|
end
|
82
|
-
|
86
|
+
|
83
87
|
def number_of_results_for_query(query)
|
84
88
|
visit root_path
|
85
89
|
fill_in "q", :with => query
|
@@ -88,5 +92,9 @@ def number_of_results_for_query(query)
|
|
88
92
|
end
|
89
93
|
|
90
94
|
def number_of_results_from_page(page)
|
91
|
-
|
95
|
+
tmp_value = Capybara.ignore_hidden_elements
|
96
|
+
Capybara.ignore_hidden_elements = false
|
97
|
+
val = page.find("meta[name=totalResults]")['content'].to_i rescue 0
|
98
|
+
Capybara.ignore_hidden_elements = tmp_value
|
99
|
+
val
|
92
100
|
end
|
@@ -3,7 +3,9 @@ require 'spec_helper'
|
|
3
3
|
describe "Search Sort" do
|
4
4
|
it "should sort on facet results with no search terms" do
|
5
5
|
visit root_path
|
6
|
-
|
6
|
+
within("div.blacklight-language_facet") do
|
7
|
+
click_link 'English'
|
8
|
+
end
|
7
9
|
expect(page).to have_content 'Sort by relevance'
|
8
10
|
click_link 'title'
|
9
11
|
expect(page).to have_content 'Sort by title'
|
@@ -15,7 +15,10 @@ describe "Search Page" do
|
|
15
15
|
expect(page).to_not have_selector("#startOverLink")
|
16
16
|
|
17
17
|
expect(page).to have_content "Welcome!"
|
18
|
+
tmp_value = Capybara.ignore_hidden_elements
|
19
|
+
Capybara.ignore_hidden_elements = false
|
18
20
|
expect(page).to have_selector("link[rel=stylesheet]")
|
21
|
+
Capybara.ignore_hidden_elements = tmp_value
|
19
22
|
end
|
20
23
|
|
21
24
|
it "should do searches across all fields" do
|
@@ -24,6 +27,8 @@ describe "Search Page" do
|
|
24
27
|
select 'All Fields', from: 'search_field'
|
25
28
|
click_button 'search'
|
26
29
|
|
30
|
+
tmp_value = Capybara.ignore_hidden_elements
|
31
|
+
Capybara.ignore_hidden_elements = false
|
27
32
|
expect(page).to have_selector("link[rel=alternate][type='application/rss+xml']")
|
28
33
|
expect(page).to have_selector("link[rel=alternate][type='application/atom+xml']")
|
29
34
|
|
@@ -31,6 +36,7 @@ describe "Search Page" do
|
|
31
36
|
expect(page).to have_selector("meta[name=totalResults]")
|
32
37
|
expect(page).to have_selector("meta[name=startIndex]")
|
33
38
|
expect(page).to have_selector("meta[name=itemsPerPage]")
|
39
|
+
Capybara.ignore_hidden_elements = tmp_value
|
34
40
|
|
35
41
|
within "#appliedParams" do
|
36
42
|
expect(page).to have_content "You searched for:"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#ste -*- encoding : utf-8 -*-
|
2
2
|
# -*- coding: UTF-8 -*-
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
5
|
def exportable_record
|
6
6
|
"<record>
|
7
7
|
<leader>01828cjm a2200409 a 4500</leader>
|
@@ -82,7 +82,7 @@ describe BlacklightHelper do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
before(:each) do
|
85
|
-
helper.
|
85
|
+
allow(helper).to receive(:search_action_url) do |*args|
|
86
86
|
catalog_index_url *args
|
87
87
|
end
|
88
88
|
end
|
@@ -95,21 +95,21 @@ describe BlacklightHelper do
|
|
95
95
|
describe "#index_field_names" do
|
96
96
|
it "should warn" do
|
97
97
|
expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
|
98
|
-
helper.
|
98
|
+
allow(helper).to receive_messages(:index_fields => {})
|
99
99
|
helper.index_field_names
|
100
100
|
end
|
101
101
|
end
|
102
102
|
describe "#index_field_labels" do
|
103
103
|
it "should warn" do
|
104
104
|
expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
|
105
|
-
helper.
|
105
|
+
allow(helper).to receive_messages(:index_fields => {})
|
106
106
|
helper.index_field_labels
|
107
107
|
end
|
108
108
|
end
|
109
109
|
describe "#document_show_field_labels" do
|
110
110
|
it "should warn" do
|
111
111
|
expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
|
112
|
-
helper.
|
112
|
+
allow(helper).to receive_messages(:document_show_fields => {})
|
113
113
|
helper.document_show_field_labels
|
114
114
|
end
|
115
115
|
end
|
@@ -117,7 +117,7 @@ describe BlacklightHelper do
|
|
117
117
|
describe "#render_document_list_partial" do
|
118
118
|
it "should warn" do
|
119
119
|
expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
|
120
|
-
helper.
|
120
|
+
allow(helper).to receive(:render)
|
121
121
|
helper.render_document_list_partial
|
122
122
|
end
|
123
123
|
end
|
@@ -125,12 +125,12 @@ describe BlacklightHelper do
|
|
125
125
|
|
126
126
|
describe "#application_name", :test => true do
|
127
127
|
it "should use the Rails application config application_name if available" do
|
128
|
-
Rails.application.config.
|
129
|
-
Rails.application.config.
|
130
|
-
application_name.
|
128
|
+
allow(Rails.application.config).to receive_messages(:application_name => 'asdf')
|
129
|
+
expect(Rails.application.config).to receive(:respond_to?).with(:application_name).and_return(true)
|
130
|
+
expect(application_name).to eq('asdf')
|
131
131
|
end
|
132
132
|
it "should default to 'Blacklight'" do
|
133
|
-
application_name.
|
133
|
+
expect(application_name).to eq("Blacklight")
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -141,50 +141,50 @@ describe BlacklightHelper do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
it "should build a link tag to catalog using session[:search] for query params" do
|
144
|
-
helper.
|
144
|
+
allow(helper).to receive(:current_search_session).and_return double(:query_params => @query_params)
|
145
145
|
tag = helper.link_back_to_catalog
|
146
|
-
tag.
|
147
|
-
tag.
|
148
|
-
tag.
|
149
|
-
tag.
|
146
|
+
expect(tag).to match(/q=query/)
|
147
|
+
expect(tag).to match(/f=facets/)
|
148
|
+
expect(tag).to match(/per_page=10/)
|
149
|
+
expect(tag).to match(/page=2/)
|
150
150
|
end
|
151
151
|
|
152
152
|
it "should build a link tag to bookmarks using session[:search] for query params" do
|
153
|
-
helper.
|
153
|
+
allow(helper).to receive(:current_search_session).and_return double(:query_params => @bookmarks_query_params)
|
154
154
|
tag = helper.link_back_to_catalog
|
155
|
-
tag.
|
156
|
-
tag.
|
157
|
-
tag.
|
155
|
+
expect(tag).to match(/Back to Bookmarks/)
|
156
|
+
expect(tag).to match(/\/bookmarks/)
|
157
|
+
expect(tag).to match(/page=2/)
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
161
|
describe "link_to_query" do
|
162
162
|
it "should build a link tag to catalog using query string (no other params)" do
|
163
163
|
query = "brilliant"
|
164
|
-
self.
|
164
|
+
expect(self).to receive(:params).and_return({})
|
165
165
|
tag = link_to_query(query)
|
166
|
-
tag.
|
167
|
-
tag.
|
166
|
+
expect(tag).to match(/q=#{query}/)
|
167
|
+
expect(tag).to match(/>#{query}<\/a>/)
|
168
168
|
end
|
169
169
|
it "should build a link tag to catalog using query string and other existing params" do
|
170
170
|
query = "wonderful"
|
171
|
-
self.
|
171
|
+
expect(self).to receive(:params).and_return({:qt => "title_search", :per_page => "50"})
|
172
172
|
tag = link_to_query(query)
|
173
|
-
tag.
|
174
|
-
tag.
|
173
|
+
expect(tag).to match(/qt=title_search/)
|
174
|
+
expect(tag).to match(/per_page=50/)
|
175
175
|
end
|
176
176
|
it "should ignore existing :page param" do
|
177
177
|
query = "yes"
|
178
|
-
self.
|
178
|
+
expect(self).to receive(:params).and_return({:page => "2", :qt => "author_search"})
|
179
179
|
tag = link_to_query(query)
|
180
|
-
tag.
|
181
|
-
tag.
|
180
|
+
expect(tag).to match(/qt=author_search/)
|
181
|
+
expect(tag).not_to match(/page/)
|
182
182
|
end
|
183
183
|
it "should be html_safe" do
|
184
184
|
query = "brilliant"
|
185
|
-
self.
|
185
|
+
expect(self).to receive(:params).and_return({:page => "2", :qt => "author_search"})
|
186
186
|
tag = link_to_query(query)
|
187
|
-
tag.html_safe
|
187
|
+
expect(tag.html_safe?).to eq(true)
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
@@ -212,24 +212,24 @@ describe BlacklightHelper do
|
|
212
212
|
|
213
213
|
it "should default to using the controller's params" do
|
214
214
|
result = params_for_search
|
215
|
-
result.
|
216
|
-
params.object_id.
|
215
|
+
expect(result).to eq(params)
|
216
|
+
expect(params.object_id).not_to eq(result.object_id)
|
217
217
|
end
|
218
218
|
|
219
219
|
it "should let you pass in params to use" do
|
220
220
|
source_params = { :q => 'query'}
|
221
221
|
result = params_for_search(source_params, {})
|
222
|
-
source_params.
|
223
|
-
source_params.object_id.
|
222
|
+
expect(source_params).to eq(result)
|
223
|
+
expect(source_params.object_id).not_to eq(result.object_id)
|
224
224
|
end
|
225
225
|
|
226
226
|
it "should let you pass in params to use (the deprecated way)" do
|
227
227
|
source_params = { :q => 'query'}
|
228
228
|
result = params_for_search(:params => source_params )
|
229
|
-
source_params.
|
230
|
-
source_params.object_id.
|
229
|
+
expect(source_params).to eq(result)
|
230
|
+
expect(source_params.object_id).not_to eq(result.object_id)
|
231
231
|
end
|
232
|
-
|
232
|
+
|
233
233
|
|
234
234
|
it "should let you pass in params to merge into the controller's params" do
|
235
235
|
source_params = { :q => 'query'}
|
@@ -240,32 +240,32 @@ describe BlacklightHelper do
|
|
240
240
|
it "should not return blacklisted elements" do
|
241
241
|
source_params = { :action => 'action', :controller => 'controller', :id => "id", :commit => 'commit'}
|
242
242
|
result = params_for_search(source_params, {} )
|
243
|
-
result.keys.
|
243
|
+
expect(result.keys).not_to include(:action, :controller, :commit, :id)
|
244
244
|
|
245
245
|
end
|
246
246
|
|
247
247
|
it "should adjust the current page if the per_page changes" do
|
248
248
|
source_params = { :per_page => 20, :page => 5}
|
249
249
|
result = params_for_search(source_params, :per_page => 100)
|
250
|
-
result[:page].
|
250
|
+
expect(result[:page]).to eq(1)
|
251
251
|
end
|
252
252
|
|
253
253
|
it "should not adjust the current page if the per_page is the same as it always was" do
|
254
254
|
source_params = { :per_page => 20, :page => 5}
|
255
255
|
result = params_for_search(source_params, :per_page => 20)
|
256
|
-
result[:page].
|
256
|
+
expect(result[:page]).to eq(5)
|
257
257
|
end
|
258
258
|
|
259
259
|
it "should adjust the current page if the sort changes" do
|
260
260
|
source_params = { :sort => 'field_a', :page => 5}
|
261
261
|
result = params_for_search(source_params, :sort => 'field_b')
|
262
|
-
result[:page].
|
262
|
+
expect(result[:page]).to eq(1)
|
263
263
|
end
|
264
264
|
|
265
265
|
it "should not adjust the current page if the sort is the same as it always was" do
|
266
266
|
source_params = { :sort => 'field_a', :page => 5}
|
267
267
|
result = params_for_search(source_params, :sort => 'field_a')
|
268
|
-
result[:page].
|
268
|
+
expect(result[:page]).to eq(5)
|
269
269
|
end
|
270
270
|
|
271
271
|
describe "omit keys parameter" do
|
@@ -273,33 +273,33 @@ describe BlacklightHelper do
|
|
273
273
|
source_params = { :a => 1, :b => 2, :c => 3}
|
274
274
|
result = params_for_search(source_params, :omit_keys => [:a, :b] )
|
275
275
|
|
276
|
-
result.keys.
|
277
|
-
result[:c].
|
276
|
+
expect(result.keys).not_to include(:a, :b)
|
277
|
+
expect(result[:c]).to eq(3)
|
278
278
|
end
|
279
279
|
|
280
280
|
it "should remove keys if a key/value pair was passed and no values are left for that key" do
|
281
281
|
source_params = { :f => ['a']}
|
282
282
|
result = params_for_search(source_params, :omit_keys => [{:f => 'a' }])
|
283
|
-
result.keys.
|
283
|
+
expect(result.keys).not_to include(:f)
|
284
284
|
end
|
285
285
|
|
286
286
|
it "should only remove keys when a key/value pair is based that are in that pair" do
|
287
287
|
|
288
288
|
source_params = { :f => ['a', 'b']}
|
289
289
|
result = params_for_search(source_params, :omit_keys => [{:f => 'a' }])
|
290
|
-
result[:f].
|
291
|
-
result[:f].
|
290
|
+
expect(result[:f]).not_to include('a')
|
291
|
+
expect(result[:f]).to include('b')
|
292
292
|
end
|
293
293
|
end
|
294
294
|
|
295
295
|
describe "params_for_search with a block" do
|
296
296
|
it "should evalute the block and allow it to add or remove keys" do
|
297
297
|
result = params_for_search({:a => 1, :b => 2}, :c => 3) do |params|
|
298
|
-
params.except! :a, :b
|
298
|
+
params.except! :a, :b
|
299
299
|
params[:d] = 'd'
|
300
300
|
end
|
301
301
|
|
302
|
-
result.keys.
|
302
|
+
expect(result.keys).not_to include(:a, :b)
|
303
303
|
expect(result[:c]).to eq 3
|
304
304
|
expect(result[:d]).to eq 'd'
|
305
305
|
end
|
@@ -315,7 +315,7 @@ describe BlacklightHelper do
|
|
315
315
|
describe "for default arguments" do
|
316
316
|
it "should default to omitting :page" do
|
317
317
|
Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
|
318
|
-
search_as_hidden_fields.
|
318
|
+
expect(search_as_hidden_fields).not_to have_selector("input[name='page']")
|
319
319
|
end
|
320
320
|
end
|
321
321
|
end
|
@@ -325,18 +325,18 @@ describe BlacklightHelper do
|
|
325
325
|
describe "render body class" do
|
326
326
|
it "should include a serialization of the current controller name" do
|
327
327
|
@controller = double("controller")
|
328
|
-
@controller.
|
329
|
-
@controller.
|
328
|
+
allow(@controller).to receive(:controller_name).and_return("123456")
|
329
|
+
allow(@controller).to receive(:action_name).and_return("abcdef")
|
330
330
|
|
331
|
-
render_body_class.split(' ').
|
331
|
+
expect(render_body_class.split(' ')).to include('blacklight-123456')
|
332
332
|
end
|
333
333
|
|
334
334
|
it "should include a serialization of the current action name" do
|
335
335
|
@controller = double("controller")
|
336
|
-
@controller.
|
337
|
-
@controller.
|
336
|
+
allow(@controller).to receive(:controller_name).and_return("123456")
|
337
|
+
allow(@controller).to receive(:action_name).and_return("abcdef")
|
338
338
|
|
339
|
-
render_body_class.split(' ').
|
339
|
+
expect(render_body_class.split(' ')).to include('blacklight-123456-abcdef')
|
340
340
|
end
|
341
341
|
end
|
342
342
|
|
@@ -345,12 +345,12 @@ describe BlacklightHelper do
|
|
345
345
|
it "should consist of the show heading field when available" do
|
346
346
|
@document = SolrDocument.new('title_display' => "A Fake Document")
|
347
347
|
|
348
|
-
document_heading.
|
348
|
+
expect(document_heading).to eq("A Fake Document")
|
349
349
|
end
|
350
350
|
|
351
351
|
it "should fallback on the document id if no title is available" do
|
352
352
|
@document = SolrDocument.new(:id => '123456')
|
353
|
-
document_heading.
|
353
|
+
expect(document_heading).to eq('123456')
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
@@ -358,40 +358,40 @@ describe BlacklightHelper do
|
|
358
358
|
it "should consist of #document_heading wrapped in a <h1>" do
|
359
359
|
@document = SolrDocument.new('title_display' => "A Fake Document")
|
360
360
|
|
361
|
-
render_document_heading.
|
362
|
-
render_document_heading.html_safe
|
361
|
+
expect(render_document_heading).to have_selector("h4", :text => "A Fake Document", :count => 1)
|
362
|
+
expect(render_document_heading.html_safe?).to eq(true)
|
363
363
|
end
|
364
364
|
it "should join the values if it is an array" do
|
365
365
|
@document = SolrDocument.new('title_display' => ["A Fake Document", 'Something Else'])
|
366
366
|
|
367
|
-
render_document_heading.
|
368
|
-
render_document_heading.html_safe
|
367
|
+
expect(render_document_heading).to have_selector("h4", :text => "A Fake Document, Something Else", :count => 1)
|
368
|
+
expect(render_document_heading.html_safe?).to eq(true)
|
369
369
|
end
|
370
370
|
end
|
371
371
|
|
372
372
|
describe "document_show_html_title" do
|
373
373
|
it "should join the values if it is an array" do
|
374
374
|
@document = SolrDocument.new('title_display' => ["A Fake Document", 'Something Else'])
|
375
|
-
document_show_html_title.
|
375
|
+
expect(document_show_html_title).to eq("A Fake Document, Something Else")
|
376
376
|
end
|
377
377
|
end
|
378
378
|
|
379
379
|
describe "document_index_view_type" do
|
380
380
|
it "should default to 'list'" do
|
381
|
-
document_index_view_type.
|
381
|
+
expect(document_index_view_type).to eq('list')
|
382
382
|
end
|
383
383
|
|
384
384
|
it "should pluck values out of params" do
|
385
|
-
blacklight_config.
|
385
|
+
allow(blacklight_config).to receive(:document_index_view_types) { ['list', 'asdf'] }
|
386
386
|
params[:view] = 'asdf'
|
387
|
-
document_index_view_type.
|
387
|
+
expect(document_index_view_type).to eq('asdf')
|
388
388
|
|
389
389
|
params[:view] = 'not_in_list'
|
390
|
-
document_index_view_type.
|
390
|
+
expect(document_index_view_type).to eq('list')
|
391
391
|
end
|
392
392
|
|
393
393
|
it "should pluck values from supplied params" do
|
394
|
-
blacklight_config.
|
394
|
+
allow(blacklight_config).to receive(:document_index_view_types) { ['list', 'asdf'] }
|
395
395
|
params[:view] = 'asdf'
|
396
396
|
expect(document_index_view_type(:view => 'list')).to eq 'list'
|
397
397
|
end
|
@@ -399,14 +399,14 @@ describe BlacklightHelper do
|
|
399
399
|
|
400
400
|
describe "start_over_path" do
|
401
401
|
it 'should be the catalog path with the current view type' do
|
402
|
-
blacklight_config.
|
403
|
-
helper.
|
402
|
+
allow(blacklight_config).to receive(:document_index_view_types) { ['list', 'abc'] }
|
403
|
+
allow(helper).to receive_messages(:blacklight_config => blacklight_config)
|
404
404
|
expect(helper.start_over_path(:view => 'abc')).to eq catalog_index_url(:view => 'abc')
|
405
405
|
end
|
406
406
|
|
407
407
|
it 'should not include the current view type if it is the default' do
|
408
|
-
blacklight_config.
|
409
|
-
helper.
|
408
|
+
allow(blacklight_config).to receive(:document_index_view_types) { ['list', 'abc'] }
|
409
|
+
allow(helper).to receive_messages(:blacklight_config => blacklight_config)
|
410
410
|
expect(helper.start_over_path(:view => 'list')).to eq catalog_index_url
|
411
411
|
end
|
412
412
|
end
|
@@ -414,41 +414,41 @@ describe BlacklightHelper do
|
|
414
414
|
describe "render_document_index" do
|
415
415
|
it "should render the document_list" do
|
416
416
|
@document_list = ['a', 'b']
|
417
|
-
self.
|
417
|
+
expect(self).to receive(:render).with(hash_including(:partial => 'document_gallery'))
|
418
418
|
render_document_index_with_view 'gallery', @document_list
|
419
419
|
end
|
420
420
|
|
421
421
|
it "should fall back on more specific templates" do
|
422
422
|
ex = ActionView::MissingTemplate.new [], '', '', '',''
|
423
|
-
self.
|
424
|
-
self.
|
425
|
-
self.
|
423
|
+
expect(self).to receive(:render).with(hash_including(:partial => 'document_gallery')).and_raise(ex)
|
424
|
+
expect(self).to receive(:render).with(hash_including(:partial => 'catalog/document_gallery')).and_raise(ex)
|
425
|
+
expect(self).to receive(:render).with(hash_including(:partial => 'catalog/document_list'))
|
426
426
|
render_document_index_with_view 'gallery', @document_list
|
427
427
|
end
|
428
428
|
end
|
429
429
|
|
430
430
|
describe "document_partial_name" do
|
431
431
|
it "should default to 'default' when a format blank" do
|
432
|
-
document_partial_name({}).
|
432
|
+
expect(document_partial_name({})).to eq("default")
|
433
433
|
end
|
434
434
|
it "should handle normal formats correctly" do
|
435
|
-
document_partial_name({"format" => "myformat"}).
|
435
|
+
expect(document_partial_name({"format" => "myformat"})).to eq("myformat")
|
436
436
|
end
|
437
437
|
it "should handle spaces correctly" do
|
438
|
-
document_partial_name({"format" => "my format"}).
|
438
|
+
expect(document_partial_name({"format" => "my format"})).to eq("my_format")
|
439
439
|
end
|
440
440
|
it "should handle capitalization correctly" do
|
441
|
-
document_partial_name({"format" => "MyFormat"}).
|
441
|
+
expect(document_partial_name({"format" => "MyFormat"})).to eq("myformat")
|
442
442
|
end
|
443
443
|
it "should handle puncuation correctly" do
|
444
|
-
document_partial_name({"format" => "My.Format"}).
|
444
|
+
expect(document_partial_name({"format" => "My.Format"})).to eq("my_format")
|
445
445
|
end
|
446
446
|
it "should handle multi-valued fields correctly" do
|
447
|
-
document_partial_name({"format" => ["My Format", "My OtherFormat"]}).
|
447
|
+
expect(document_partial_name({"format" => ["My Format", "My OtherFormat"]})).to eq("my_format_my_otherformat")
|
448
448
|
end
|
449
449
|
it "should remove - characters because they will throw errors" do
|
450
|
-
document_partial_name({"format" => "My-Format"}).
|
451
|
-
document_partial_name({"format" => ["My-Format",["My Other-Format"]]}).
|
450
|
+
expect(document_partial_name({"format" => "My-Format"})).to eq("my_format")
|
451
|
+
expect(document_partial_name({"format" => ["My-Format",["My Other-Format"]]})).to eq("my_format_my_other_format")
|
452
452
|
end
|
453
453
|
end
|
454
454
|
|
@@ -456,45 +456,45 @@ describe BlacklightHelper do
|
|
456
456
|
it "should consist of the document title wrapped in a <a>" do
|
457
457
|
data = {'id'=>'123456','title_display'=>['654321'] }
|
458
458
|
@document = SolrDocument.new(data)
|
459
|
-
link_to_document(@document, { :label => :title_display }).
|
459
|
+
expect(link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '654321', :count => 1)
|
460
460
|
end
|
461
461
|
it "should accept and return a string label" do
|
462
462
|
data = {'id'=>'123456','title_display'=>['654321'] }
|
463
463
|
@document = SolrDocument.new(data)
|
464
|
-
link_to_document(@document, { :label => "title_display" }).
|
464
|
+
expect(link_to_document(@document, { :label => "title_display" })).to have_selector("a", :text => 'title_display', :count => 1)
|
465
465
|
end
|
466
466
|
|
467
467
|
it "should accept and return a Proc" do
|
468
468
|
data = {'id'=>'123456','title_display'=>['654321'] }
|
469
469
|
@document = SolrDocument.new(data)
|
470
|
-
link_to_document(@document, { :label => Proc.new { |doc, opts| doc.get(:id) + ": " + doc.get(:title_display) } }).
|
470
|
+
expect(link_to_document(@document, { :label => Proc.new { |doc, opts| doc.get(:id) + ": " + doc.get(:title_display) } })).to have_selector("a", :text => '123456: 654321', :count => 1)
|
471
471
|
end
|
472
472
|
it "should return id when label is missing" do
|
473
473
|
data = {'id'=>'123456'}
|
474
474
|
@document = SolrDocument.new(data)
|
475
|
-
link_to_document(@document, { :label => :title_display }).
|
475
|
+
expect(link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '123456', :count => 1)
|
476
476
|
end
|
477
477
|
|
478
478
|
it "should be html safe" do
|
479
479
|
data = {'id'=>'123456'}
|
480
480
|
@document = SolrDocument.new(data)
|
481
|
-
link_to_document(@document, { :label => :title_display }).html_safe
|
481
|
+
expect(link_to_document(@document, { :label => :title_display }).html_safe?).to eq(true)
|
482
482
|
end
|
483
483
|
|
484
484
|
it "should convert the counter parameter into a data- attribute" do
|
485
485
|
data = {'id'=>'123456','title_display'=>['654321']}
|
486
486
|
@document = SolrDocument.new(data)
|
487
|
-
link_to_document(@document, { :label => :title_display, :counter => 5 }).
|
487
|
+
expect(link_to_document(@document, { :label => :title_display, :counter => 5 })).to match(/data-counter="5"/)
|
488
488
|
end
|
489
489
|
|
490
490
|
it "passes on the title attribute to the link_to_with_data method" do
|
491
491
|
@document = SolrDocument.new('id'=>'123456')
|
492
|
-
link_to_document(@document,:label=>"Some crazy long label...",:title=>"Some crazy longer label").
|
492
|
+
expect(link_to_document(@document,:label=>"Some crazy long label...",:title=>"Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
|
493
493
|
end
|
494
494
|
|
495
495
|
it "doesn't add an erroneous title attribute if one isn't provided" do
|
496
496
|
@document = SolrDocument.new('id'=>'123456')
|
497
|
-
link_to_document(@document,:label=>"Some crazy long label...").
|
497
|
+
expect(link_to_document(@document,:label=>"Some crazy long label...")).not_to match(/title=/)
|
498
498
|
end
|
499
499
|
end
|
500
500
|
|
@@ -521,35 +521,44 @@ describe BlacklightHelper do
|
|
521
521
|
@doc_id = "MOCK_ID1"
|
522
522
|
@document = MockDocumentAppHelper.new(:id => @doc_id)
|
523
523
|
render_params = {:controller => "controller", :action => "action"}
|
524
|
-
helper.
|
524
|
+
allow(helper).to receive(:params).and_return(render_params)
|
525
525
|
end
|
526
526
|
it "generates <link rel=alternate> tags" do
|
527
527
|
|
528
528
|
response = render_link_rel_alternates(@document)
|
529
529
|
|
530
|
+
tmp_value = Capybara.ignore_hidden_elements
|
531
|
+
Capybara.ignore_hidden_elements = false
|
530
532
|
@document.export_formats.each_pair do |format, spec|
|
531
|
-
response.
|
532
|
-
matches.length.
|
533
|
+
expect(response).to have_selector("link[href$='.#{ format }']") do |matches|
|
534
|
+
expect(matches.length).to eq(1)
|
533
535
|
tag = matches[0]
|
534
|
-
tag.attributes["rel"].value.
|
535
|
-
tag.attributes["title"].value.
|
536
|
-
tag.attributes["href"].value.
|
536
|
+
expect(tag.attributes["rel"].value).to eq("alternate")
|
537
|
+
expect(tag.attributes["title"].value).to eq(format.to_s)
|
538
|
+
expect(tag.attributes["href"].value).to be === mock_document_app_helper_url(@document, :format =>format)
|
537
539
|
end
|
538
540
|
end
|
541
|
+
Capybara.ignore_hidden_elements = tmp_value
|
539
542
|
end
|
540
543
|
it "respects :unique=>true" do
|
541
544
|
response = render_link_rel_alternates(@document, :unique => true)
|
545
|
+
tmp_value = Capybara.ignore_hidden_elements
|
546
|
+
Capybara.ignore_hidden_elements = false
|
542
547
|
response.should have_selector("link[type='application/weird']", :count => 1)
|
548
|
+
Capybara.ignore_hidden_elements = tmp_value
|
543
549
|
end
|
544
550
|
it "excludes formats from :exclude" do
|
545
551
|
response = render_link_rel_alternates(@document, :exclude => [:weird_dup])
|
546
552
|
|
553
|
+
tmp_value = Capybara.ignore_hidden_elements
|
554
|
+
Capybara.ignore_hidden_elements = false
|
547
555
|
response.should_not have_selector("link[href$='.weird_dup']")
|
556
|
+
Capybara.ignore_hidden_elements = tmp_value
|
548
557
|
end
|
549
558
|
|
550
559
|
it "should be html safe" do
|
551
560
|
response = render_link_rel_alternates(@document)
|
552
|
-
response.html_safe
|
561
|
+
expect(response.html_safe?).to eq(true)
|
553
562
|
end
|
554
563
|
end
|
555
564
|
|
@@ -565,20 +574,20 @@ describe BlacklightHelper do
|
|
565
574
|
end
|
566
575
|
|
567
576
|
@document = SolrDocument.new('title_display' => "A Fake Document", 'id'=>'8')
|
568
|
-
helper.
|
569
|
-
helper.
|
570
|
-
helper.
|
577
|
+
allow(helper).to receive(:blacklight_config).and_return(@config)
|
578
|
+
allow(helper).to receive(:has_user_authentication_provider?).and_return(true)
|
579
|
+
allow(helper).to receive(:current_or_guest_user).and_return(User.new)
|
571
580
|
end
|
572
581
|
describe "render_index_doc_actions" do
|
573
582
|
it "should render partials" do
|
574
583
|
response = helper.render_index_doc_actions(@document)
|
575
|
-
response.
|
584
|
+
expect(response).to have_selector(".bookmark_toggle")
|
576
585
|
end
|
577
586
|
end
|
578
587
|
describe "render_show_doc_actions" do
|
579
588
|
it "should render partials" do
|
580
589
|
response = helper.render_show_doc_actions(@document)
|
581
|
-
response.
|
590
|
+
expect(response).to have_selector(".bookmark_toggle")
|
582
591
|
end
|
583
592
|
end
|
584
593
|
end
|
@@ -592,67 +601,67 @@ describe BlacklightHelper do
|
|
592
601
|
config.add_index_field 'link_to_search_named', :link_to_search => :some_field
|
593
602
|
config.add_index_field 'highlight', :highlight => true
|
594
603
|
end
|
595
|
-
helper.
|
604
|
+
allow(helper).to receive(:blacklight_config).and_return(@config)
|
596
605
|
end
|
597
606
|
|
598
607
|
it "should check for an explicit value" do
|
599
608
|
doc = double()
|
600
|
-
doc.
|
609
|
+
expect(doc).not_to receive(:get).with('asdf', :sep => nil)
|
601
610
|
value = helper.render_index_field_value :value => 'asdf', :document => doc, :field => 'asdf'
|
602
|
-
value.
|
611
|
+
expect(value).to eq('asdf')
|
603
612
|
end
|
604
613
|
|
605
614
|
it "should check for a helper method to call" do
|
606
615
|
doc = double()
|
607
|
-
doc.
|
608
|
-
helper.
|
616
|
+
expect(doc).not_to receive(:get).with('asdf', :sep => nil)
|
617
|
+
allow(helper).to receive(:render_asdf_index_field).and_return('custom asdf value')
|
609
618
|
value = helper.render_index_field_value :document => doc, :field => 'asdf'
|
610
|
-
value.
|
619
|
+
expect(value).to eq('custom asdf value')
|
611
620
|
end
|
612
621
|
|
613
622
|
it "should check for a link_to_search" do
|
614
623
|
doc = double()
|
615
|
-
doc.
|
624
|
+
expect(doc).to receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
|
616
625
|
value = helper.render_index_field_value :document => doc, :field => 'link_to_search_true'
|
617
|
-
value.
|
626
|
+
expect(value).to eq(helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] })))
|
618
627
|
end
|
619
628
|
|
620
629
|
it "should check for a link_to_search with a field name" do
|
621
630
|
doc = double()
|
622
|
-
doc.
|
631
|
+
expect(doc).to receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
|
623
632
|
value = helper.render_index_field_value :document => doc, :field => 'link_to_search_named'
|
624
|
-
value.
|
633
|
+
expect(value).to eq(helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] })))
|
625
634
|
end
|
626
635
|
|
627
636
|
it "should gracefully handle when no highlight field is available" do
|
628
637
|
doc = double()
|
629
|
-
doc.
|
630
|
-
doc.
|
638
|
+
expect(doc).not_to receive(:get)
|
639
|
+
expect(doc).to receive(:has_highlight_field?).and_return(false)
|
631
640
|
value = helper.render_index_field_value :document => doc, :field => 'highlight'
|
632
|
-
value.
|
641
|
+
expect(value).to be_blank
|
633
642
|
end
|
634
643
|
|
635
644
|
it "should check for a highlighted field" do
|
636
645
|
doc = double()
|
637
|
-
doc.
|
638
|
-
doc.
|
639
|
-
doc.
|
646
|
+
expect(doc).not_to receive(:get)
|
647
|
+
expect(doc).to receive(:has_highlight_field?).and_return(true)
|
648
|
+
expect(doc).to receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
|
640
649
|
value = helper.render_index_field_value :document => doc, :field => 'highlight'
|
641
|
-
value.
|
650
|
+
expect(value).to eq('<em>highlight</em>')
|
642
651
|
end
|
643
652
|
|
644
653
|
it "should check the document field value" do
|
645
654
|
doc = double()
|
646
|
-
doc.
|
655
|
+
expect(doc).to receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
|
647
656
|
value = helper.render_index_field_value :document => doc, :field => 'qwer'
|
648
|
-
value.
|
657
|
+
expect(value).to eq('document qwer value')
|
649
658
|
end
|
650
659
|
|
651
660
|
it "should work with index fields that aren't explicitly defined" do
|
652
661
|
doc = double()
|
653
|
-
doc.
|
662
|
+
expect(doc).to receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
|
654
663
|
value = helper.render_index_field_value :document => doc, :field => 'mnbv'
|
655
|
-
value.
|
664
|
+
expect(value).to eq('document mnbv value')
|
656
665
|
end
|
657
666
|
end
|
658
667
|
|
@@ -666,86 +675,86 @@ describe BlacklightHelper do
|
|
666
675
|
config.add_show_field 'link_to_search_named', :link_to_search => :some_field
|
667
676
|
config.add_show_field 'highlight', :highlight => true
|
668
677
|
end
|
669
|
-
helper.
|
678
|
+
allow(helper).to receive(:blacklight_config).and_return(@config)
|
670
679
|
end
|
671
680
|
|
672
681
|
it "should check for an explicit value" do
|
673
682
|
doc = double()
|
674
|
-
doc.
|
675
|
-
helper.
|
683
|
+
expect(doc).not_to receive(:get).with('asdf', :sep => nil)
|
684
|
+
expect(helper).not_to receive(:render_asdf_document_show_field)
|
676
685
|
value = helper.render_document_show_field_value :value => 'asdf', :document => doc, :field => 'asdf'
|
677
|
-
value.
|
686
|
+
expect(value).to eq('asdf')
|
678
687
|
end
|
679
688
|
|
680
689
|
it "should check for a helper method to call" do
|
681
690
|
doc = double()
|
682
|
-
doc.
|
683
|
-
helper.
|
691
|
+
expect(doc).not_to receive(:get).with('asdf', :sep => nil)
|
692
|
+
allow(helper).to receive(:render_asdf_document_show_field).and_return('custom asdf value')
|
684
693
|
value = helper.render_document_show_field_value :document => doc, :field => 'asdf'
|
685
|
-
value.
|
694
|
+
expect(value).to eq('custom asdf value')
|
686
695
|
end
|
687
696
|
|
688
697
|
it "should check for a link_to_search" do
|
689
698
|
doc = double()
|
690
|
-
doc.
|
699
|
+
expect(doc).to receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
|
691
700
|
value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_true'
|
692
|
-
value.
|
701
|
+
expect(value).to eq(helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] })))
|
693
702
|
end
|
694
703
|
|
695
704
|
it "should check for a link_to_search with a field name" do
|
696
705
|
doc = double()
|
697
|
-
doc.
|
706
|
+
expect(doc).to receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
|
698
707
|
value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_named'
|
699
|
-
value.
|
708
|
+
expect(value).to eq(helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] })))
|
700
709
|
end
|
701
710
|
|
702
711
|
it "should gracefully handle when no highlight field is available" do
|
703
712
|
doc = double()
|
704
|
-
doc.
|
705
|
-
doc.
|
713
|
+
expect(doc).not_to receive(:get)
|
714
|
+
expect(doc).to receive(:has_highlight_field?).and_return(false)
|
706
715
|
value = helper.render_document_show_field_value :document => doc, :field => 'highlight'
|
707
|
-
value.
|
716
|
+
expect(value).to be_blank
|
708
717
|
end
|
709
718
|
|
710
719
|
it "should check for a highlighted field" do
|
711
720
|
doc = double()
|
712
|
-
doc.
|
713
|
-
doc.
|
714
|
-
doc.
|
721
|
+
expect(doc).not_to receive(:get)
|
722
|
+
expect(doc).to receive(:has_highlight_field?).and_return(true)
|
723
|
+
expect(doc).to receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
|
715
724
|
value = helper.render_document_show_field_value :document => doc, :field => 'highlight'
|
716
|
-
value.
|
725
|
+
expect(value).to eq('<em>highlight</em>')
|
717
726
|
end
|
718
727
|
|
719
728
|
|
720
729
|
it "should check the document field value" do
|
721
730
|
doc = double()
|
722
|
-
doc.
|
731
|
+
expect(doc).to receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
|
723
732
|
value = helper.render_document_show_field_value :document => doc, :field => 'qwer'
|
724
|
-
value.
|
733
|
+
expect(value).to eq('document qwer value')
|
725
734
|
end
|
726
735
|
|
727
736
|
it "should work with show fields that aren't explicitly defined" do
|
728
737
|
doc = double()
|
729
|
-
doc.
|
738
|
+
expect(doc).to receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
|
730
739
|
value = helper.render_document_show_field_value :document => doc, :field => 'mnbv'
|
731
|
-
value.
|
740
|
+
expect(value).to eq('document mnbv value')
|
732
741
|
end
|
733
742
|
end
|
734
743
|
|
735
744
|
describe "#should_render_index_field?" do
|
736
745
|
it "should if the document has the field value" do
|
737
746
|
doc = double()
|
738
|
-
doc.
|
747
|
+
allow(doc).to receive(:has?).with('asdf').and_return(true)
|
739
748
|
field_config = double(:field => 'asdf')
|
740
|
-
helper.should_render_index_field?(doc, field_config).
|
749
|
+
expect(helper.should_render_index_field?(doc, field_config)).to eq(true)
|
741
750
|
end
|
742
751
|
|
743
752
|
it "should if the document has a highlight field value" do
|
744
753
|
doc = double()
|
745
|
-
doc.
|
746
|
-
doc.
|
754
|
+
allow(doc).to receive(:has?).with('asdf').and_return(false)
|
755
|
+
allow(doc).to receive(:has_highlight_field?).with('asdf').and_return(true)
|
747
756
|
field_config = double(:field => 'asdf', :highlight => true)
|
748
|
-
helper.should_render_index_field?(doc, field_config).
|
757
|
+
expect(helper.should_render_index_field?(doc, field_config)).to eq(true)
|
749
758
|
end
|
750
759
|
end
|
751
760
|
|
@@ -753,17 +762,17 @@ describe BlacklightHelper do
|
|
753
762
|
describe "#should_render_show_field?" do
|
754
763
|
it "should if the document has the field value" do
|
755
764
|
doc = double()
|
756
|
-
doc.
|
765
|
+
allow(doc).to receive(:has?).with('asdf').and_return(true)
|
757
766
|
field_config = double(:field => 'asdf')
|
758
|
-
helper.should_render_show_field?(doc, field_config).
|
767
|
+
expect(helper.should_render_show_field?(doc, field_config)).to eq(true)
|
759
768
|
end
|
760
769
|
|
761
770
|
it "should if the document has a highlight field value" do
|
762
771
|
doc = double()
|
763
|
-
doc.
|
764
|
-
doc.
|
772
|
+
allow(doc).to receive(:has?).with('asdf').and_return(false)
|
773
|
+
allow(doc).to receive(:has_highlight_field?).with('asdf').and_return(true)
|
765
774
|
field_config = double(:field => 'asdf', :highlight => true)
|
766
|
-
helper.should_render_show_field?(doc, field_config).
|
775
|
+
expect(helper.should_render_show_field?(doc, field_config)).to eq(true)
|
767
776
|
end
|
768
777
|
end
|
769
778
|
|
@@ -771,13 +780,13 @@ describe BlacklightHelper do
|
|
771
780
|
describe "render_grouped_response?" do
|
772
781
|
it "should check if the response ivar contains grouped data" do
|
773
782
|
assign(:response, double("SolrResponse", :grouped? => true))
|
774
|
-
expect(helper.render_grouped_response?).to
|
783
|
+
expect(helper.render_grouped_response?).to eq true
|
775
784
|
end
|
776
785
|
|
777
786
|
|
778
787
|
it "should check if the response param contains grouped data" do
|
779
788
|
response = double("SolrResponse", :grouped? => true)
|
780
|
-
expect(helper.render_grouped_response?(response)).to
|
789
|
+
expect(helper.render_grouped_response?(response)).to eq true
|
781
790
|
end
|
782
791
|
end
|
783
792
|
|
@@ -791,7 +800,7 @@ describe BlacklightHelper do
|
|
791
800
|
end
|
792
801
|
|
793
802
|
it "should join values using the field_value_separator" do
|
794
|
-
helper.
|
803
|
+
allow(helper).to receive(:field_value_separator).and_return(" -- ")
|
795
804
|
expect(helper.render_field_value(['a', 'b'])).to eq "a -- b"
|
796
805
|
end
|
797
806
|
|
@@ -803,28 +812,28 @@ describe BlacklightHelper do
|
|
803
812
|
describe "link_to_previous_search" do
|
804
813
|
it "should link to the given search parameters" do
|
805
814
|
params = {}
|
806
|
-
helper.
|
815
|
+
expect(helper).to receive(:render_search_to_s).with(params).and_return "link text"
|
807
816
|
expect(helper.link_to_previous_search({})).to eq helper.link_to("link text", catalog_index_path)
|
808
817
|
end
|
809
818
|
end
|
810
819
|
|
811
820
|
describe "should_show_spellcheck_suggestions?" do
|
812
821
|
before :each do
|
813
|
-
helper.
|
822
|
+
allow(helper).to receive_messages spell_check_max: 5
|
814
823
|
end
|
815
824
|
it "should not show suggestions if there are enough results" do
|
816
825
|
response = double(total: 10)
|
817
|
-
expect(helper.should_show_spellcheck_suggestions? response).to
|
826
|
+
expect(helper.should_show_spellcheck_suggestions? response).to eq false
|
818
827
|
end
|
819
828
|
|
820
829
|
it "should only show suggestions if there are very few results" do
|
821
830
|
response = double(total: 4, spelling: double(words: [1]))
|
822
|
-
expect(helper.should_show_spellcheck_suggestions? response).to
|
831
|
+
expect(helper.should_show_spellcheck_suggestions? response).to eq true
|
823
832
|
end
|
824
833
|
|
825
834
|
it "should show suggestions only if there are spelling suggestions available" do
|
826
835
|
response = double(total: 4, spelling: double(words: []))
|
827
|
-
expect(helper.should_show_spellcheck_suggestions? response).to
|
836
|
+
expect(helper.should_show_spellcheck_suggestions? response).to eq false
|
828
837
|
end
|
829
838
|
end
|
830
839
|
end
|