blacklight 5.0.0.pre1 → 5.0.0.pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -4
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_bookmark.css.scss +4 -0
- data/app/assets/stylesheets/blacklight/_catalog.css.scss +9 -13
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +15 -9
- data/app/helpers/blacklight/catalog_helper_behavior.rb +8 -25
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -1
- data/app/views/bookmarks/index.html.erb +1 -1
- data/app/views/catalog/_did_you_mean.html.erb +1 -1
- data/app/views/catalog/_document.html.erb +4 -10
- data/app/views/catalog/{_document_header.html.erb → _index_header_default.html.erb} +6 -3
- data/app/views/catalog/_paginate_compact.html.erb +5 -0
- data/app/views/catalog/_show_header_default.html.erb +2 -0
- data/app/views/catalog/index.html.erb +1 -1
- data/app/views/catalog/show.html.erb +4 -10
- data/lib/blacklight.rb +0 -1
- data/lib/blacklight/configuration.rb +2 -2
- data/lib/blacklight/controller.rb +0 -1
- data/lib/blacklight/solr/document.rb +2 -0
- data/lib/blacklight/solr/document/schema_org.rb +7 -0
- data/lib/blacklight/solr_response.rb +4 -0
- data/lib/blacklight/user.rb +0 -6
- data/spec/controllers/application_controller_spec.rb +1 -2
- data/spec/controllers/bookmarks_controller_spec.rb +8 -9
- data/spec/controllers/catalog_controller_spec.rb +72 -73
- data/spec/controllers/saved_searches_controller_spec.rb +1 -2
- data/spec/controllers/search_history_controller_spec.rb +9 -10
- data/spec/features/search_pagination_spec.rb +1 -0
- data/spec/features/search_results_spec.rb +1 -0
- data/spec/features/search_spec.rb +1 -0
- data/spec/helpers/blacklight_helper_spec.rb +103 -93
- data/spec/helpers/catalog_helper_spec.rb +34 -21
- data/spec/helpers/facets_helper_spec.rb +41 -41
- data/spec/helpers/hash_as_hidden_fields_spec.rb +8 -9
- data/spec/helpers/render_constraints_helper_spec.rb +3 -3
- data/spec/helpers/search_history_constraints_helper_spec.rb +13 -14
- data/spec/lib/{blacklight_configurable_spec.rb → blacklight/configurable_spec.rb} +12 -14
- data/spec/lib/{blacklight_configuration_spec.rb → blacklight/configuration_spec.rb} +67 -69
- data/spec/lib/{facet_paginator_spec.rb → blacklight/facet_paginator_spec.rb} +13 -16
- data/spec/lib/{search_fields_spec.rb → blacklight/search_fields_spec.rb} +14 -15
- data/spec/lib/{blacklight_solr_document_dublin_core_spec.rb → blacklight/solr/document/dublin_core_spec.rb} +7 -8
- data/spec/lib/{blacklight_email_spec.rb → blacklight/solr/document/email_spec.rb} +5 -6
- data/spec/lib/{blacklight_solr_document_more_like_this_spec.rb → blacklight/solr/document/more_like_this_spec.rb} +5 -5
- data/spec/lib/{blacklight_sms_spec.rb → blacklight/solr/document/sms_spec.rb} +5 -6
- data/spec/lib/{blacklight_solr_document_spec.rb → blacklight/solr/document_spec.rb} +37 -39
- data/spec/lib/{solr_helper_spec.rb → blacklight/solr_helper_spec.rb} +183 -183
- data/spec/lib/{blacklight_solr_response_spec.rb → blacklight/solr_response_spec.rb} +20 -16
- data/spec/lib/{blacklight_user_spec.rb → blacklight/user_spec.rb} +3 -4
- data/spec/lib/blacklight_spec.rb +6 -7
- data/spec/lib/tasks/blacklight_task_spec.rb +2 -3
- data/spec/lib/utils_spec.rb +13 -14
- data/spec/models/bookmark_spec.rb +4 -4
- data/spec/models/record_mailer_spec.rb +15 -15
- data/spec/models/search_spec.rb +7 -7
- data/spec/models/solr_document_spec.rb +4 -4
- data/spec/routing/catalog_routing_spec.rb +12 -12
- data/spec/spec_helper.rb +1 -3
- data/spec/test_app_templates/Gemfile.extra +1 -2
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +12 -13
- data/spec/views/catalog/_document.html.erb_spec.rb +19 -2
- data/spec/views/catalog/_document_list.html.erb_spec.rb +0 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +5 -5
- data/spec/views/catalog/_index_default.erb_spec.rb +10 -11
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +45 -0
- data/spec/views/catalog/_search_header.erb_spec.rb +0 -1
- data/spec/views/catalog/_show_default.erb_spec.rb +10 -11
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +2 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +26 -27
- data/spec/views/catalog/index.html.erb_spec.rb +1 -1
- data/spec/views/catalog/show.html.erb_spec.rb +56 -0
- data/tasks/blacklight.rake +1 -1
- metadata +65 -64
- data/lib/blacklight/legacy_controller_methods.rb +0 -26
- data/spec/rcov.opts +0 -3
- data/spec/support/assert_difference.rb +0 -17
data/lib/blacklight/user.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
3
|
describe ApplicationController do
|
@@ -7,7 +6,7 @@ describe ApplicationController do
|
|
7
6
|
describe "#blacklight_config" do
|
8
7
|
|
9
8
|
it "should provide a default blacklight_config everywhere" do
|
10
|
-
controller.blacklight_config.
|
9
|
+
expect(controller.blacklight_config).to eq CatalogController.blacklight_config
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe BookmarksController do
|
5
4
|
include Devise::TestHelpers
|
@@ -8,8 +7,8 @@ describe BookmarksController do
|
|
8
7
|
describe "update" do
|
9
8
|
it "has a 204 status code when creating a new one" do
|
10
9
|
xhr :put, :update, :id => '2007020969', :format => :js
|
11
|
-
response.
|
12
|
-
response.code.
|
10
|
+
expect(response).to be_success
|
11
|
+
expect(response.code).to eq "204"
|
13
12
|
end
|
14
13
|
|
15
14
|
it "has a 500 status code when fails is success" do
|
@@ -17,15 +16,15 @@ describe BookmarksController do
|
|
17
16
|
@controller.stub_chain(:current_or_guest_user, :persisted?).and_return(true)
|
18
17
|
@controller.stub_chain(:current_or_guest_user, :bookmarks, :create).and_return(false)
|
19
18
|
xhr :put, :update, :id => 'iamabooboo', :format => :js
|
20
|
-
response.code.
|
19
|
+
expect(response.code).to eq "500"
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
24
23
|
describe "delete" do
|
25
24
|
it "has a 204 status code when delete is success" do
|
26
25
|
xhr :delete, :destroy, :id => '2007020969', :format => :js
|
27
|
-
response.
|
28
|
-
response.code.
|
26
|
+
expect(response).to be_success
|
27
|
+
expect(response.code).to eq "204"
|
29
28
|
end
|
30
29
|
|
31
30
|
it "has a 500 status code when delete is not success" do
|
@@ -34,8 +33,8 @@ describe BookmarksController do
|
|
34
33
|
@controller.stub_chain(:current_or_guest_user, :bookmarks, :delete).and_return(false)
|
35
34
|
|
36
35
|
xhr :delete, :destroy, :id => 'pleasekillme', :format => :js
|
37
|
-
|
38
|
-
response.code.
|
36
|
+
|
37
|
+
expect(response.code).to eq "500"
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe CatalogController do
|
5
4
|
include Devise::TestHelpers
|
@@ -24,47 +23,47 @@ describe CatalogController do
|
|
24
23
|
controller.should_receive(:get_search_results)
|
25
24
|
session[:history] = []
|
26
25
|
get :index
|
27
|
-
session[:history].
|
26
|
+
expect(session[:history]).to be_empty
|
28
27
|
end
|
29
28
|
|
30
29
|
# check each user manipulated parameter
|
31
30
|
it "should have docs and facets for query with results", :integration => true do
|
32
31
|
get :index, :q => @user_query
|
33
|
-
assigns_response.docs.
|
32
|
+
expect(assigns_response.docs).to_not be_empty
|
34
33
|
assert_facets_have_values(assigns_response.facets)
|
35
34
|
end
|
36
35
|
it "should have docs and facets for existing facet value", :integration => true do
|
37
36
|
get :index, :f => @facet_query
|
38
|
-
assigns_response.docs.
|
37
|
+
expect(assigns_response.docs).to_not be_empty
|
39
38
|
assert_facets_have_values(assigns_response.facets)
|
40
39
|
end
|
41
40
|
it "should have docs and facets for non-default results per page", :integration => true do
|
42
41
|
num_per_page = 7
|
43
42
|
get :index, :per_page => num_per_page
|
44
|
-
assigns_response.docs.
|
43
|
+
expect(assigns_response.docs).to have(num_per_page).items
|
45
44
|
assert_facets_have_values(assigns_response.facets)
|
46
45
|
end
|
47
46
|
|
48
47
|
it "should have docs and facets for second page", :integration => true do
|
49
48
|
page = 2
|
50
49
|
get :index, :page => page
|
51
|
-
assigns_response.docs.
|
52
|
-
assigns_response.params[:start].to_i.
|
50
|
+
expect(assigns_response.docs).to_not be_empty
|
51
|
+
expect(assigns_response.params[:start].to_i).to eq (page-1) * @controller.blacklight_config[:default_solr_params][:rows]
|
53
52
|
assert_facets_have_values(assigns_response.facets)
|
54
53
|
end
|
55
54
|
|
56
55
|
it "should have no docs or facet values for query without results", :integration => true do
|
57
56
|
get :index, :q => @no_docs_query
|
58
57
|
|
59
|
-
assigns_response.docs.
|
58
|
+
expect(assigns_response.docs).to be_empty
|
60
59
|
assigns_response.facets.each do |facet|
|
61
|
-
facet.items.
|
60
|
+
expect(facet.items).to be_empty
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
65
64
|
it "should have a spelling suggestion for an appropriately poor query", :integration => true do
|
66
65
|
get :index, :q => 'boo'
|
67
|
-
assigns_response.spelling.words.
|
66
|
+
expect(assigns_response.spelling.words).to_not be_nil
|
68
67
|
end
|
69
68
|
|
70
69
|
describe "session" do
|
@@ -73,13 +72,13 @@ describe CatalogController do
|
|
73
72
|
end
|
74
73
|
it "should include :search key with hash" do
|
75
74
|
get :index
|
76
|
-
session[:search].
|
77
|
-
session[:search].
|
75
|
+
expect(session[:search]).to_not be_nil
|
76
|
+
expect(session[:search]).to be_kind_of(Hash)
|
78
77
|
end
|
79
78
|
it "should include search hash with key :q" do
|
80
79
|
get :index, :q => @user_query
|
81
|
-
session[:search].
|
82
|
-
session[:search].keys.
|
80
|
+
expect(session[:search]).to_not be_nil
|
81
|
+
expect(session[:search].keys).to include :id
|
83
82
|
|
84
83
|
search = Search.find(session[:search][:id])
|
85
84
|
expect(search.query_params[:q]).to eq @user_query
|
@@ -90,7 +89,7 @@ describe CatalogController do
|
|
90
89
|
describe "for default query" do
|
91
90
|
it "should get documents when no query", :integration => true do
|
92
91
|
get :index
|
93
|
-
assigns_response.docs.
|
92
|
+
expect(assigns_response.docs).to_not be_empty
|
94
93
|
end
|
95
94
|
it "should get facets when no query", :integration => true do
|
96
95
|
get :index
|
@@ -101,27 +100,27 @@ describe CatalogController do
|
|
101
100
|
it "should render index.html.erb" do
|
102
101
|
controller.stub(:get_search_results)
|
103
102
|
get :index
|
104
|
-
response.
|
103
|
+
expect(response).to render_template(:index)
|
105
104
|
end
|
106
105
|
|
107
106
|
# NOTE: status code is always 200 in isolation mode ...
|
108
107
|
it "HTTP status code for GET should be 200", :integration => true do
|
109
108
|
get :index
|
110
|
-
response.
|
109
|
+
expect(response).to be_success
|
111
110
|
end
|
112
111
|
end
|
113
112
|
|
114
113
|
describe "with format :rss" do
|
115
114
|
it "should get the feed", :integration => true do
|
116
115
|
get :index, :format => 'rss'
|
117
|
-
response.
|
116
|
+
expect(response).to be_success
|
118
117
|
end
|
119
118
|
end
|
120
119
|
|
121
120
|
describe "with format :json" do
|
122
121
|
before do
|
123
122
|
get :index, :format => 'json'
|
124
|
-
response.
|
123
|
+
expect(response).to be_success
|
125
124
|
end
|
126
125
|
let(:json) { JSON.parse(response.body)['response'] }
|
127
126
|
let(:pages) { json["pages"] }
|
@@ -129,29 +128,29 @@ describe CatalogController do
|
|
129
128
|
let(:facets) { json["facets"] }
|
130
129
|
|
131
130
|
it "should get the pages" do
|
132
|
-
pages["total_count"].
|
133
|
-
pages["current_page"].
|
134
|
-
pages["total_pages"].
|
131
|
+
expect(pages["total_count"]).to eq 30
|
132
|
+
expect(pages["current_page"]).to eq 1
|
133
|
+
expect(pages["total_pages"]).to eq 3
|
135
134
|
end
|
136
135
|
|
137
136
|
it "should get the documents" do
|
138
|
-
docs.
|
137
|
+
expect(docs).to have(10).documents
|
139
138
|
expect(docs.first.keys).to match_array(["published_display", "author_display", "lc_callnum_display", "pub_date", "subtitle_display", "format", "material_type_display", "title_display", "id", "subject_topic_facet", "language_facet", "score"])
|
140
139
|
end
|
141
140
|
|
142
141
|
it "should get the facets" do
|
143
|
-
facets.
|
144
|
-
facets.first.
|
142
|
+
expect(facets).to have(9).facets
|
143
|
+
expect(facets.first).to eq({"name"=>"format", "label" => "Format", "items"=>[{"value"=>"Book", "hits"=>30, "label"=>"Book"}]})
|
145
144
|
end
|
146
145
|
|
147
146
|
describe "facets" do
|
148
147
|
let(:query_facet_items) { facets.last['items'] }
|
149
148
|
let(:regular_facet_items) { facets.first['items'] }
|
150
149
|
it "should have items with labels and values" do
|
151
|
-
query_facet_items.first['label'].
|
152
|
-
query_facet_items.first['value'].
|
153
|
-
regular_facet_items.first['label'].
|
154
|
-
regular_facet_items.first['value'].
|
150
|
+
expect(query_facet_items.first['label']).to eq 'within 10 Years'
|
151
|
+
expect(query_facet_items.first['value']).to eq 'years_10'
|
152
|
+
expect(regular_facet_items.first['label']).to eq "Book"
|
153
|
+
expect(regular_facet_items.first['value']).to eq "Book"
|
155
154
|
end
|
156
155
|
end
|
157
156
|
end
|
@@ -163,7 +162,7 @@ describe CatalogController do
|
|
163
162
|
|
164
163
|
it "should set counter value into session[:search]" do
|
165
164
|
put :update, :id => doc_id, :counter => 3
|
166
|
-
session[:search][:counter].
|
165
|
+
expect(session[:search][:counter]).to eq "3"
|
167
166
|
end
|
168
167
|
|
169
168
|
it "should redirect to show action for doc id" do
|
@@ -173,7 +172,7 @@ describe CatalogController do
|
|
173
172
|
|
174
173
|
it "HTTP status code for redirect should be 303" do
|
175
174
|
put :update, :id => doc_id, :counter => 3
|
176
|
-
response.status.
|
175
|
+
expect(response.status).to eq 303
|
177
176
|
end
|
178
177
|
end
|
179
178
|
|
@@ -185,14 +184,14 @@ describe CatalogController do
|
|
185
184
|
describe "with format :html" do
|
186
185
|
it "should get document", :integration => true do
|
187
186
|
get :show, :id => doc_id
|
188
|
-
assigns[:document].
|
187
|
+
expect(assigns[:document]).to_not be_nil
|
189
188
|
end
|
190
189
|
end
|
191
190
|
|
192
191
|
describe "with format :json" do
|
193
192
|
it "should get the feed" do
|
194
193
|
get :show, id: doc_id, format: 'json'
|
195
|
-
response.
|
194
|
+
expect(response).to be_success
|
196
195
|
json = JSON.parse response.body
|
197
196
|
expect(json["response"]["document"].keys).to match_array(["author_t", "opensearch_display", "marc_display", "published_display", "author_display", "lc_callnum_display", "title_t", "pub_date", "pub_date_sort", "subtitle_display", "format", "url_suppl_display", "material_type_display", "title_display", "subject_addl_t", "subject_t", "isbn_t", "id", "title_addl_t", "subject_geo_facet", "subject_topic_facet", "author_addl_t", "language_facet", "subtitle_t", "timestamp"])
|
198
197
|
end
|
@@ -214,30 +213,30 @@ describe CatalogController do
|
|
214
213
|
it "should set previous document if counter present in session" do
|
215
214
|
session[:search] = @search_session.merge(:counter => 2)
|
216
215
|
get :show, :id => doc_id
|
217
|
-
assigns[:previous_document].
|
216
|
+
expect(assigns[:previous_document]).to_not be_nil
|
218
217
|
end
|
219
218
|
it "should not set previous or next document if session is blank" do
|
220
219
|
get :show, :id => doc_id
|
221
|
-
assigns[:previous_document].
|
222
|
-
assigns[:next_document].
|
220
|
+
expect(assigns[:previous_document]).to be_nil
|
221
|
+
expect(assigns[:next_document]).to be_nil
|
223
222
|
end
|
224
223
|
it "should not set previous or next document if session[:search][:counter] is nil" do
|
225
224
|
session[:search] = {}
|
226
225
|
get :show, :id => doc_id
|
227
|
-
assigns[:previous_document].
|
228
|
-
assigns[:next_document].
|
226
|
+
expect(assigns[:previous_document]).to be_nil
|
227
|
+
expect(assigns[:next_document]).to be_nil
|
229
228
|
end
|
230
229
|
it "should set next document if counter present in session" do
|
231
230
|
session[:search] = @search_session.merge(:counter => 2)
|
232
231
|
get :show, :id => doc_id
|
233
|
-
assigns[:next_document].
|
232
|
+
expect(assigns[:next_document]).to_not be_nil
|
234
233
|
end
|
235
234
|
end
|
236
235
|
|
237
236
|
# NOTE: status code is always 200 in isolation mode ...
|
238
237
|
it "HTTP status code for GET should be 200", :integration => true do
|
239
238
|
get :show, :id => doc_id
|
240
|
-
response.
|
239
|
+
expect(response).to be_success
|
241
240
|
end
|
242
241
|
it "should render show.html.erb" do
|
243
242
|
@mock_response = double()
|
@@ -262,7 +261,7 @@ describe CatalogController do
|
|
262
261
|
@document = assigns[:document]
|
263
262
|
end
|
264
263
|
it "should be a SolrDocument" do
|
265
|
-
@document.
|
264
|
+
expect(@document).to be_instance_of(SolrDocument)
|
266
265
|
end
|
267
266
|
end
|
268
267
|
|
@@ -302,8 +301,8 @@ describe CatalogController do
|
|
302
301
|
|
303
302
|
it "should respond to an extension-registered format properly" do
|
304
303
|
get :show, :id => doc_id, :format => "mock" # This no longer works: :format => "mock"
|
305
|
-
response.
|
306
|
-
response.body.
|
304
|
+
expect(response).to be_success
|
305
|
+
expect(response.body).to match /mock_export/
|
307
306
|
end
|
308
307
|
|
309
308
|
|
@@ -326,14 +325,14 @@ describe CatalogController do
|
|
326
325
|
end
|
327
326
|
it "should return an opensearch description" do
|
328
327
|
get :opensearch, :format => 'xml'
|
329
|
-
response.
|
328
|
+
expect(response).to be_success
|
330
329
|
end
|
331
330
|
it "should return valid JSON" do
|
332
331
|
get :opensearch,:format => 'json', :q => "a"
|
333
|
-
response.
|
332
|
+
expect(response).to be_success
|
334
333
|
end
|
335
334
|
end
|
336
|
-
|
335
|
+
|
337
336
|
describe "email/sms" do
|
338
337
|
doc_id = '2007020969'
|
339
338
|
before do
|
@@ -352,15 +351,15 @@ describe CatalogController do
|
|
352
351
|
describe "email" do
|
353
352
|
it "should give error if no TO paramater" do
|
354
353
|
post :email, :id => doc_id
|
355
|
-
request.flash[:error].
|
354
|
+
expect(request.flash[:error]).to eq "You must enter a recipient in order to send this message"
|
356
355
|
end
|
357
356
|
it "should give an error if the email address is not valid" do
|
358
357
|
post :email, :id => doc_id, :to => 'test_bad_email'
|
359
|
-
request.flash[:error].
|
358
|
+
expect(request.flash[:error]).to eq "You must enter a valid email address"
|
360
359
|
end
|
361
360
|
it "should not give error if no Message paramater is set" do
|
362
361
|
post :email, :id => doc_id, :to => 'test_email@projectblacklight.org'
|
363
|
-
request.flash[:error].
|
362
|
+
expect(request.flash[:error]).to be_nil
|
364
363
|
end
|
365
364
|
it "should redirect back to the record upon success" do
|
366
365
|
mock_mailer = double
|
@@ -368,8 +367,8 @@ describe CatalogController do
|
|
368
367
|
RecordMailer.should_receive(:email_record).with(anything, { :to => 'test_email@projectblacklight.org', :message => 'xyz' }, hash_including(:host => 'test.host')).and_return mock_mailer
|
369
368
|
|
370
369
|
post :email, :id => doc_id, :to => 'test_email@projectblacklight.org', :message => 'xyz'
|
371
|
-
request.flash[:error].
|
372
|
-
request.
|
370
|
+
expect(request.flash[:error]).to be_nil
|
371
|
+
expect(request).to redirect_to(catalog_path(doc_id))
|
373
372
|
end
|
374
373
|
|
375
374
|
it "should render email_sent for XHR requests" do
|
@@ -381,24 +380,24 @@ describe CatalogController do
|
|
381
380
|
describe "sms" do
|
382
381
|
it "should give error if no phone number is given" do
|
383
382
|
post :sms, :id => doc_id, :carrier => 'att'
|
384
|
-
request.flash[:error].
|
383
|
+
expect(request.flash[:error]).to eq "You must enter a recipient's phone number in order to send this message"
|
385
384
|
end
|
386
385
|
it "should give an error when a carrier is not provided" do
|
387
386
|
post :sms, :id => doc_id, :to => '5555555555', :carrier => ''
|
388
|
-
request.flash[:error].
|
387
|
+
expect(request.flash[:error]).to eq "You must select a carrier"
|
389
388
|
end
|
390
389
|
it "should give an error when the phone number is not 10 digits" do
|
391
390
|
post :sms, :id => doc_id, :to => '555555555', :carrier => 'txt.att.net'
|
392
|
-
request.flash[:error].
|
391
|
+
expect(request.flash[:error]).to eq "You must enter a valid 10 digit phone number"
|
393
392
|
end
|
394
393
|
it "should give an error when the carrier is not in our list of carriers" do
|
395
394
|
post :sms, :id => doc_id, :to => '5555555555', :carrier => 'no-such-carrier'
|
396
|
-
request.flash[:error].
|
395
|
+
expect(request.flash[:error]).to eq "You must enter a valid carrier"
|
397
396
|
end
|
398
397
|
it "should allow punctuation in phone number" do
|
399
398
|
post :sms, :id => doc_id, :to => '(555) 555-5555', :carrier => 'txt.att.net'
|
400
|
-
request.flash[:error].
|
401
|
-
request.
|
399
|
+
expect(request.flash[:error]).to be_nil
|
400
|
+
expect(request).to redirect_to(catalog_path(doc_id))
|
402
401
|
end
|
403
402
|
it "should redirect back to the record upon success" do
|
404
403
|
post :sms, :id => doc_id, :to => '5555555555', :carrier => 'txt.att.net'
|
@@ -422,9 +421,9 @@ describe CatalogController do
|
|
422
421
|
controller.stub(:find => @mock_response,
|
423
422
|
:get_single_doc_via_search => @mock_document)
|
424
423
|
get :show, :id=>"987654321"
|
425
|
-
request.flash[:notice].
|
426
|
-
response.
|
427
|
-
response.status.
|
424
|
+
expect(request.flash[:notice]).to eq "Sorry, you have requested a record that doesn't exist."
|
425
|
+
expect(response).to render_template('index')
|
426
|
+
expect(response.status).to eq 404
|
428
427
|
end
|
429
428
|
it "should redirect the user to the root url for a bad search" do
|
430
429
|
req = {}
|
@@ -434,10 +433,10 @@ describe CatalogController do
|
|
434
433
|
controller.logger.should_receive(:error).with(fake_error)
|
435
434
|
get :index, :q=>"+"
|
436
435
|
|
437
|
-
response.redirect_url.
|
438
|
-
request.flash[:notice].
|
439
|
-
response.
|
440
|
-
response.status.
|
436
|
+
expect(response.redirect_url).to eq root_url
|
437
|
+
expect(request.flash[:notice]).to eq "Sorry, I don't understand your search."
|
438
|
+
expect(response).to_not be_success
|
439
|
+
expect(response.status).to eq 302
|
441
440
|
end
|
442
441
|
it "should return status 500 if the catalog path is raising an exception" do
|
443
442
|
|
@@ -469,7 +468,7 @@ describe CatalogController do
|
|
469
468
|
|
470
469
|
it "should not show user util links" do
|
471
470
|
get :index
|
472
|
-
response.body.
|
471
|
+
expect(response.body).to_not match /Login/
|
473
472
|
end
|
474
473
|
end
|
475
474
|
|
@@ -477,22 +476,22 @@ describe CatalogController do
|
|
477
476
|
describe "requesting js" do
|
478
477
|
it "should be successful" do
|
479
478
|
xhr :get, :facet, id: 'format'
|
480
|
-
response.
|
479
|
+
expect(response).to be_successful
|
481
480
|
end
|
482
481
|
end
|
483
482
|
describe "requesting html" do
|
484
483
|
it "should be successful" do
|
485
484
|
get :facet, id: 'format'
|
486
|
-
response.
|
487
|
-
assigns[:pagination].
|
485
|
+
expect(response).to be_successful
|
486
|
+
expect(assigns[:pagination]).to be_kind_of Blacklight::Solr::FacetPaginator
|
488
487
|
end
|
489
488
|
end
|
490
489
|
describe "requesting json" do
|
491
490
|
it "should be successful" do
|
492
491
|
get :facet, id: 'format', format: 'json'
|
493
|
-
response.
|
492
|
+
expect(response).to be_successful
|
494
493
|
json = JSON.parse(response.body)
|
495
|
-
json["response"]["facets"]["items"].first["value"].
|
494
|
+
expect(json["response"]["facets"]["items"].first["value"]).to eq 'Book'
|
496
495
|
end
|
497
496
|
end
|
498
497
|
end
|
@@ -591,10 +590,10 @@ end
|
|
591
590
|
|
592
591
|
# there must be at least one facet, and each facet must have at least one value
|
593
592
|
def assert_facets_have_values(facets)
|
594
|
-
facets.
|
593
|
+
expect(facets).to_not be_empty
|
595
594
|
# should have at least one value for each facet
|
596
595
|
facets.each do |facet|
|
597
|
-
facet.items.
|
596
|
+
expect(facet.items).to have_at_least(1).item
|
598
597
|
end
|
599
598
|
end
|
600
599
|
|