blacklight 4.3.0 → 4.4.0

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.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +0 -6
  4. data/Gemfile +5 -0
  5. data/README.md +1 -1
  6. data/Rakefile +0 -1
  7. data/VERSION +1 -1
  8. data/app/assets/javascripts/blacklight/autofocus.js +16 -0
  9. data/app/assets/javascripts/blacklight/blacklight.js +1 -0
  10. data/app/assets/javascripts/blacklight/bookmark_toggle.js +2 -5
  11. data/app/assets/javascripts/blacklight/checkbox_submit.js +3 -6
  12. data/app/assets/javascripts/blacklight/core.js +24 -1
  13. data/app/assets/javascripts/blacklight/css_dropdowns.js +2 -2
  14. data/app/assets/javascripts/blacklight/facet_expand_contract.js +4 -3
  15. data/app/assets/javascripts/blacklight/lightbox_dialog.js +7 -1
  16. data/app/assets/javascripts/blacklight/search_context.js +1 -1
  17. data/app/assets/javascripts/blacklight/select_submit.js +1 -1
  18. data/app/assets/javascripts/blacklight/zebra_stripe.js +1 -1
  19. data/app/assets/stylesheets/blacklight/_blacklight_base.css.scss +1 -0
  20. data/app/assets/stylesheets/blacklight/_catalog.css.scss +5 -0
  21. data/app/assets/stylesheets/blacklight/_facets.css.scss +6 -0
  22. data/app/assets/stylesheets/blacklight/_group.css.scss +14 -0
  23. data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +1 -0
  24. data/app/controllers/bookmarks_controller.rb +2 -2
  25. data/app/helpers/blacklight/blacklight_helper_behavior.rb +41 -24
  26. data/app/helpers/blacklight/catalog_helper_behavior.rb +48 -28
  27. data/app/helpers/blacklight/facets_helper_behavior.rb +9 -75
  28. data/app/models/record_mailer.rb +1 -16
  29. data/app/views/bookmarks/index.html.erb +2 -0
  30. data/app/views/catalog/_bookmark_control.html.erb +3 -4
  31. data/app/views/catalog/_document.html.erb +2 -1
  32. data/app/views/catalog/_document_header.html.erb +6 -3
  33. data/app/views/catalog/_email_form.html.erb +0 -7
  34. data/app/views/catalog/_facet_layout.html.erb +1 -1
  35. data/app/views/catalog/_group_default.html.erb +12 -0
  36. data/app/views/catalog/_index_default.html.erb +1 -1
  37. data/app/views/catalog/_opensearch_response_metadata.html.erb +2 -3
  38. data/app/views/catalog/_paginate_compact.html.erb +2 -2
  39. data/app/views/catalog/_results_pagination.html.erb +2 -2
  40. data/app/views/catalog/_search_form.html.erb +1 -1
  41. data/app/views/catalog/_sms_form.html.erb +1 -21
  42. data/app/views/catalog/_thumbnail_default.html.erb +5 -0
  43. data/app/views/catalog/email_sent.html.erb +9 -0
  44. data/app/views/catalog/index.atom.builder +7 -8
  45. data/app/views/catalog/index.html.erb +6 -3
  46. data/app/views/catalog/librarian_view.html.erb +1 -1
  47. data/app/views/catalog/sms_sent.html.erb +9 -0
  48. data/app/views/feedback/complete.html.erb +2 -0
  49. data/app/views/feedback/show.html.erb +7 -5
  50. data/app/views/kaminari/blacklight_compact/_paginator.html.erb +1 -1
  51. data/app/views/layouts/blacklight.html.erb +1 -2
  52. data/app/views/saved_searches/index.html.erb +2 -0
  53. data/app/views/search_history/index.html.erb +1 -1
  54. data/blacklight.gemspec +1 -1
  55. data/config/locales/blacklight.en.yml +11 -0
  56. data/config/locales/blacklight.fr.yml +15 -1
  57. data/gemfiles/rails3.gemfile +7 -0
  58. data/gemfiles/rails4.gemfile +7 -0
  59. data/lib/blacklight.rb +1 -0
  60. data/lib/blacklight/catalog.rb +101 -56
  61. data/lib/blacklight/configuration.rb +1 -1
  62. data/lib/blacklight/controller.rb +7 -4
  63. data/lib/blacklight/facet.rb +79 -0
  64. data/lib/blacklight/routes.rb +0 -1
  65. data/lib/blacklight/solr/document.rb +4 -0
  66. data/lib/blacklight/solr/document/marc_export.rb +1 -1
  67. data/lib/blacklight/solr_helper.rb +39 -8
  68. data/lib/blacklight/solr_response.rb +35 -3
  69. data/lib/blacklight/solr_response/facets.rb +4 -0
  70. data/lib/blacklight/solr_response/group.rb +33 -0
  71. data/lib/blacklight/solr_response/group_response.rb +49 -0
  72. data/lib/blacklight/solr_response/pagination_methods.rb +27 -0
  73. data/lib/blacklight/user.rb +30 -32
  74. data/lib/generators/blacklight/assets_generator.rb +3 -1
  75. data/lib/generators/blacklight/blacklight_generator.rb +28 -125
  76. data/lib/generators/blacklight/marc_generator.rb +66 -0
  77. data/lib/generators/blacklight/models_generator.rb +113 -0
  78. data/lib/generators/blacklight/templates/alternate_controller.rb +9 -0
  79. data/lib/generators/blacklight/templates/config/solr.yml +0 -2
  80. data/lib/generators/blacklight/templates/solr_document.rb +1 -13
  81. data/lib/railties/all_tests.rake +5 -8
  82. data/spec/controllers/catalog_controller_spec.rb +185 -113
  83. data/spec/features/alternate_controller_spec.rb +34 -0
  84. data/spec/features/bookmarks_spec.rb +58 -0
  85. data/spec/features/did_you_mean_spec.rb +135 -0
  86. data/spec/features/librarian_view_spec.rb +13 -0
  87. data/spec/features/record_view_spec.rb +37 -0
  88. data/spec/features/saved_searches_spec.rb +47 -0
  89. data/spec/features/search_filters_spec.rb +137 -0
  90. data/spec/features/search_history_spec.rb +75 -0
  91. data/spec/features/search_pagination_spec.rb +91 -0
  92. data/spec/features/search_results_spec.rb +68 -0
  93. data/spec/features/search_sort_spec.rb +20 -0
  94. data/spec/features/search_spec.rb +108 -0
  95. data/spec/helpers/blacklight_helper_spec.rb +45 -2
  96. data/spec/helpers/catalog_helper_spec.rb +134 -1
  97. data/spec/helpers/facets_helper_spec.rb +8 -0
  98. data/spec/lib/blacklight/solr_response/group_response_spec.rb +78 -0
  99. data/spec/lib/blacklight/solr_response/group_spec.rb +70 -0
  100. data/spec/lib/blacklight_solr_response_spec.rb +11 -5
  101. data/spec/lib/blacklight_user_spec.rb +22 -41
  102. data/spec/lib/solr_helper_spec.rb +73 -1
  103. data/spec/models/record_mailer_spec.rb +3 -3
  104. data/spec/models/{solr_docment_spec.rb → solr_document_spec.rb} +1 -1
  105. data/spec/spec_helper.rb +0 -1
  106. data/spec/support/features.rb +7 -0
  107. data/spec/support/features/session_helpers.rb +22 -0
  108. data/spec/test_app_templates/Gemfile.extra +0 -4
  109. data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -6
  110. data/spec/test_app_templates/lib/tasks/blacklight_test_app.rake +1 -9
  111. data/spec/views/catalog/_facets.html.erb_spec.rb +2 -1
  112. data/tasks/blacklight.rake +0 -10
  113. metadata +49 -58
  114. data/features/bookmarks.feature +0 -68
  115. data/features/did_you_mean.feature +0 -123
  116. data/features/librarian_view.feature +0 -18
  117. data/features/record_view.feature +0 -40
  118. data/features/saved_searches.feature +0 -49
  119. data/features/search.feature +0 -83
  120. data/features/search_filters.feature +0 -119
  121. data/features/search_history.feature +0 -85
  122. data/features/search_pagination.feature +0 -53
  123. data/features/search_results.feature +0 -61
  124. data/features/search_sort.feature +0 -27
  125. data/features/step_definitions/bookmarks_steps.rb +0 -6
  126. data/features/step_definitions/error_steps.rb +0 -5
  127. data/features/step_definitions/general_steps.rb +0 -50
  128. data/features/step_definitions/record_view_steps.rb +0 -12
  129. data/features/step_definitions/saved_searches_steps.rb +0 -19
  130. data/features/step_definitions/search_facets_steps.rb +0 -29
  131. data/features/step_definitions/search_history_steps.rb +0 -9
  132. data/features/step_definitions/search_pagination_steps.rb +0 -29
  133. data/features/step_definitions/search_result_steps.rb +0 -115
  134. data/features/step_definitions/search_steps.rb +0 -118
  135. data/features/step_definitions/user_steps.rb +0 -5
  136. data/features/step_definitions/web_steps.rb +0 -217
  137. data/features/support/env.rb +0 -65
  138. data/features/support/paths.rb +0 -48
  139. data/features/support/selectors.rb +0 -40
  140. data/lib/railties/blacklight_cucumber.rake +0 -126
  141. data/lib/solrmarc.log.1 +0 -854
@@ -21,121 +21,141 @@ describe CatalogController do
21
21
  @controller.instance_variable_get("@response")
22
22
  end
23
23
 
24
- it "should have no search history if no search criteria" do
25
- controller.should_receive(:get_search_results)
26
- session[:history] = []
27
- get :index
28
- session[:history].length.should == 0
29
- end
24
+ describe "with format :html" do
25
+ it "should have no search history if no search criteria" do
26
+ controller.should_receive(:get_search_results)
27
+ session[:history] = []
28
+ get :index
29
+ session[:history].length.should == 0
30
+ end
30
31
 
31
- # check each user manipulated parameter
32
- it "should have docs and facets for query with results", :integration => true do
33
- get :index, :q => @user_query
34
- assigns_response.docs.size.should > 1
35
- assert_facets_have_values(assigns_response.facets)
36
- end
37
- it "should have docs and facets for existing facet value", :integration => true do
38
- get :index, :f => @facet_query
39
- assigns_response.docs.size.should > 1
40
- assert_facets_have_values(assigns_response.facets)
41
- end
42
- it "should have docs and facets for non-default results per page", :integration => true do
43
- num_per_page = 7
44
- get :index, :per_page => num_per_page
45
- assigns_response.docs.size.should == num_per_page
46
- assert_facets_have_values(assigns_response.facets)
47
- end
32
+ # check each user manipulated parameter
33
+ it "should have docs and facets for query with results", :integration => true do
34
+ get :index, :q => @user_query
35
+ assigns_response.docs.size.should > 1
36
+ assert_facets_have_values(assigns_response.facets)
37
+ end
38
+ it "should have docs and facets for existing facet value", :integration => true do
39
+ get :index, :f => @facet_query
40
+ assigns_response.docs.size.should > 1
41
+ assert_facets_have_values(assigns_response.facets)
42
+ end
43
+ it "should have docs and facets for non-default results per page", :integration => true do
44
+ num_per_page = 7
45
+ get :index, :per_page => num_per_page
46
+ assigns_response.docs.size.should == num_per_page
47
+ assert_facets_have_values(assigns_response.facets)
48
+ end
48
49
 
49
- it "should have docs and facets for second page", :integration => true do
50
- page = 2
51
- get :index, :page => page
52
- assigns_response.docs.size.should > 1
53
- assigns_response.params[:start].to_i.should == (page-1) * @controller.blacklight_config[:default_solr_params][:rows]
54
- assert_facets_have_values(assigns_response.facets)
55
- end
50
+ it "should have docs and facets for second page", :integration => true do
51
+ page = 2
52
+ get :index, :page => page
53
+ assigns_response.docs.size.should > 1
54
+ assigns_response.params[:start].to_i.should == (page-1) * @controller.blacklight_config[:default_solr_params][:rows]
55
+ assert_facets_have_values(assigns_response.facets)
56
+ end
56
57
 
57
- it "should have no docs or facet values for query without results", :integration => true do
58
- get :index, :q => @no_docs_query
58
+ it "should have no docs or facet values for query without results", :integration => true do
59
+ get :index, :q => @no_docs_query
59
60
 
60
- assigns_response.docs.size.should == 0
61
- assigns_response.facets.each do |facet|
62
- facet.items.size.should == 0
61
+ assigns_response.docs.size.should == 0
62
+ assigns_response.facets.each do |facet|
63
+ facet.items.size.should == 0
64
+ end
63
65
  end
64
- end
65
66
 
66
- it "should have a spelling suggestion for an appropriately poor query", :integration => true do
67
- get :index, :q => 'boo'
68
- assigns_response.spelling.words.should_not be_nil
69
- end
70
-
71
- describe "session" do
72
- before do
73
- controller.stub(:get_search_results)
67
+ it "should have a spelling suggestion for an appropriately poor query", :integration => true do
68
+ get :index, :q => 'boo'
69
+ assigns_response.spelling.words.should_not be_nil
74
70
  end
75
- it "should include :search key with hash" do
76
- get :index
77
- session[:search].should_not be_nil
78
- session[:search].should be_kind_of(Hash)
71
+
72
+ describe "session" do
73
+ before do
74
+ controller.stub(:get_search_results)
75
+ end
76
+ it "should include :search key with hash" do
77
+ get :index
78
+ session[:search].should_not be_nil
79
+ session[:search].should be_kind_of(Hash)
80
+ end
81
+ it "should include search hash with key :q" do
82
+ get :index, :q => @user_query
83
+ session[:search].should_not be_nil
84
+ session[:search].keys.should include(:q)
85
+ session[:search][:q].should == @user_query
86
+ end
87
+ it "should include search hash with key :f" do
88
+ get :index, :f => @facet_query
89
+ session[:search].should_not be_nil
90
+ session[:search].keys.should include(:f)
91
+ session[:search][:f].should == @facet_query
92
+ end
93
+ it "should include search hash with key :per_page" do
94
+ get :index, :per_page => 10
95
+ session[:search].should_not be_nil
96
+ session[:search].keys.should include(:per_page)
97
+ session[:search][:per_page].should == "10"
98
+ end
99
+ it "should include search hash with key :page" do
100
+ get :index, :page => 2
101
+ session[:search].should_not be_nil
102
+ session[:search].keys.should include(:page)
103
+ session[:search][:page].should == "2"
104
+ end
105
+ it "should include search hash with random key" do
106
+ # cause a plugin might add an unpredictable one, we want to preserve it.
107
+ get :index, :some_weird_key => "value"
108
+ session[:search].should_not be_nil
109
+ session[:search].keys.should include(:some_weird_key)
110
+ session[:search][:some_weird_key].should == "value"
111
+ end
79
112
  end
80
- it "should include search hash with key :q" do
81
- get :index, :q => @user_query
82
- session[:search].should_not be_nil
83
- session[:search].keys.should include(:q)
84
- session[:search][:q].should == @user_query
113
+
114
+ # check with no user manipulation
115
+ describe "for default query" do
116
+ it "should get documents when no query", :integration => true do
117
+ get :index
118
+ assigns_response.docs.size.should > 1
119
+ end
120
+ it "should get facets when no query", :integration => true do
121
+ get :index
122
+ assert_facets_have_values(assigns_response.facets)
123
+ end
85
124
  end
86
- it "should include search hash with key :f" do
87
- get :index, :f => @facet_query
88
- session[:search].should_not be_nil
89
- session[:search].keys.should include(:f)
90
- session[:search][:f].should == @facet_query
91
- end
92
- it "should include search hash with key :per_page" do
93
- get :index, :per_page => 10
94
- session[:search].should_not be_nil
95
- session[:search].keys.should include(:per_page)
96
- session[:search][:per_page].should == "10"
97
- end
98
- it "should include search hash with key :page" do
99
- get :index, :page => 2
100
- session[:search].should_not be_nil
101
- session[:search].keys.should include(:page)
102
- session[:search][:page].should == "2"
103
- end
104
- it "should include search hash with random key" do
105
- # cause a plugin might add an unpredictable one, we want to preserve it.
106
- get :index, :some_weird_key => "value"
107
- session[:search].should_not be_nil
108
- session[:search].keys.should include(:some_weird_key)
109
- session[:search][:some_weird_key].should == "value"
110
- end
111
- end
112
-
113
- # check with no user manipulation
114
- describe "for default query" do
115
- it "should get documents when no query", :integration => true do
125
+
126
+ it "should render index.html.erb" do
127
+ controller.stub(:get_search_results)
116
128
  get :index
117
- assigns_response.docs.size.should > 1
129
+ response.should render_template(:index)
118
130
  end
119
- it "should get facets when no query", :integration => true do
131
+
132
+ # NOTE: status code is always 200 in isolation mode ...
133
+ it "HTTP status code for GET should be 200", :integration => true do
120
134
  get :index
121
- assert_facets_have_values(assigns_response.facets)
135
+ response.should be_success
122
136
  end
123
137
  end
124
138
 
125
- it "should get rss feed", :integration => true do
126
- get :index, :format => 'rss'
127
- response.should be_success
139
+ describe "with format :rss" do
140
+ it "should get the feed", :integration => true do
141
+ get :index, :format => 'rss'
142
+ response.should be_success
143
+ end
128
144
  end
129
145
 
130
- it "should render index.html.erb" do
131
- controller.stub(:get_search_results)
132
- get :index
133
- response.should render_template(:index)
134
- end
135
- # NOTE: status code is always 200 in isolation mode ...
136
- it "HTTP status code for GET should be 200", :integration => true do
137
- get :index
138
- response.should be_success
146
+ describe "with format :json" do
147
+ it "should get the feed" do
148
+ get :index, :format => 'json'
149
+ response.should be_success
150
+ json = JSON.parse response.body
151
+ json["response"]["pages"]["total_count"].should == 30
152
+ json["response"]["pages"]["current_page"].should == 1
153
+ json["response"]["pages"]["total_pages"].should == 3
154
+ json["response"]["docs"].size.should == 10
155
+ json["response"]["docs"].first.keys.should == ["published_display", "author_display", "lc_callnum_display", "pub_date", "subtitle_display", "format", "material_type_display", "title_display", "id", "subject_topic_facet", "language_facet", "score"]
156
+ json["response"]["facets"].length.should == 9
157
+ json["response"]["facets"].first.should == {"name"=>"format", "items"=>[{"value"=>"Book", "hits"=>30}]}
158
+ end
139
159
  end
140
160
 
141
161
  end # describe index action
@@ -159,9 +179,20 @@ describe CatalogController do
159
179
 
160
180
  doc_id = '2007020969'
161
181
 
162
- it "should get document", :integration => true do
163
- get :show, :id => doc_id
164
- assigns[:document].should_not be_nil
182
+ describe "with format :html" do
183
+ it "should get document", :integration => true do
184
+ get :show, :id => doc_id
185
+ assigns[:document].should_not be_nil
186
+ end
187
+ end
188
+
189
+ describe "with format :json" do
190
+ it "should get the feed" do
191
+ get :show, id: doc_id, format: 'json'
192
+ response.should be_success
193
+ json = JSON.parse response.body
194
+ json["response"]["document"].keys.should == ["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"]
195
+ end
165
196
  end
166
197
 
167
198
  describe "previous/next documents" do
@@ -278,21 +309,22 @@ describe CatalogController do
278
309
 
279
310
 
280
311
  after(:each) do
281
- SolrDocument.registered_extensions = nil
312
+ # remove the fake extension
313
+ SolrDocument.registered_extensions.pop
282
314
  end
283
315
  end # dynamic export formats
284
316
 
285
317
  end # describe show action
286
318
 
287
319
  describe "opensearch" do
288
- before do
289
- @mock_response = double()
290
- @mock_document = double()
291
- @mock_response.stub(:docs => [{ :id => 'my_fake_doc' }, { :id => 'my_other_doc'}])
292
- @mock_document = double()
293
- controller.stub(:find => @mock_response,
294
- :get_single_doc_via_search => @mock_document)
295
- end
320
+ before do
321
+ @mock_response = double()
322
+ @mock_document = double()
323
+ @mock_response.stub(:docs => [{ :id => 'my_fake_doc' }, { :id => 'my_other_doc'}])
324
+ @mock_document = double()
325
+ controller.stub(:find => @mock_response,
326
+ :get_single_doc_via_search => @mock_document)
327
+ end
296
328
  it "should return an opensearch description" do
297
329
  get :opensearch, :format => 'xml'
298
330
  response.should be_success
@@ -336,6 +368,12 @@ describe CatalogController do
336
368
  request.flash[:error].should be_nil
337
369
  request.should redirect_to(catalog_path(doc_id))
338
370
  end
371
+
372
+ it "should render email_sent for XHR requests" do
373
+ xhr :post, :email, :id => doc_id, :to => 'test_email@projectblacklight.org'
374
+ expect(request).to render_template 'email_sent'
375
+ expect(request.flash[:success]).to eq "Email Sent"
376
+ end
339
377
  end
340
378
  describe "sms" do
341
379
  it "should give error if no phone number is given" do
@@ -347,19 +385,29 @@ describe CatalogController do
347
385
  request.flash[:error].should == "You must select a carrier"
348
386
  end
349
387
  it "should give an error when the phone number is not 10 digits" do
350
- post :sms, :id => doc_id, :to => '555555555', :carrier => 'att'
388
+ post :sms, :id => doc_id, :to => '555555555', :carrier => 'txt.att.net'
351
389
  request.flash[:error].should == "You must enter a valid 10 digit phone number"
352
390
  end
391
+ it "should give an error when the carrier is not in our list of carriers" do
392
+ post :sms, :id => doc_id, :to => '5555555555', :carrier => 'no-such-carrier'
393
+ request.flash[:error].should == "You must enter a valid carrier"
394
+ end
353
395
  it "should allow punctuation in phone number" do
354
- post :sms, :id => doc_id, :to => '(555) 555-5555', :carrier => 'att'
396
+ post :sms, :id => doc_id, :to => '(555) 555-5555', :carrier => 'txt.att.net'
355
397
  request.flash[:error].should be_nil
356
398
  request.should redirect_to(catalog_path(doc_id))
357
399
  end
358
400
  it "should redirect back to the record upon success" do
359
- post :sms, :id => doc_id, :to => '5555555555', :carrier => 'att'
401
+ post :sms, :id => doc_id, :to => '5555555555', :carrier => 'txt.att.net'
360
402
  request.flash[:error].should be_nil
361
403
  request.should redirect_to(catalog_path(doc_id))
362
404
  end
405
+
406
+ it "should render sms_sent template for XHR requests" do
407
+ xhr :post, :sms, :id => doc_id, :to => '5555555555', :carrier => 'txt.att.net'
408
+ expect(request).to render_template 'sms_sent'
409
+ expect(request.flash[:success]).to eq "SMS Sent"
410
+ end
363
411
  end
364
412
  end
365
413
 
@@ -421,6 +469,30 @@ describe CatalogController do
421
469
  response.body.should_not =~ /Login/
422
470
  end
423
471
  end
472
+
473
+ describe "facet" do
474
+ describe "requesting js" do
475
+ it "should be successful" do
476
+ xhr :get, :facet, id: 'format'
477
+ response.should be_successful
478
+ end
479
+ end
480
+ describe "requesting html" do
481
+ it "should be successful" do
482
+ get :facet, id: 'format'
483
+ response.should be_successful
484
+ assigns[:pagination].should be_kind_of Blacklight::Solr::FacetPaginator
485
+ end
486
+ end
487
+ describe "requesting json" do
488
+ it "should be successful" do
489
+ get :facet, id: 'format', format: 'json'
490
+ response.should be_successful
491
+ json = JSON.parse(response.body)
492
+ json["response"]["facets"]["items"].first["value"].should == 'Book'
493
+ end
494
+ end
495
+ end
424
496
  end
425
497
 
426
498
 
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Alternate Controller Behaviors" do
4
+ it "should have the correct per-page form" do
5
+ visit alternate_index_path
6
+ page.should have_selector("form[action='#{alternate_index_path}']")
7
+ fill_in "q", :with=>"history"
8
+ click_button 'search'
9
+ expect(current_path).to match /#{alternate_index_path}/
10
+ click_on '10 per page'
11
+ expect(current_path).to match /#{alternate_index_path}/
12
+ end
13
+
14
+ it "should have the correct search field form" do
15
+ visit alternate_index_path
16
+ page.should have_selector("form[action='#{alternate_index_path}']")
17
+ fill_in "q", :with=>"history"
18
+ click_button 'search'
19
+ expect(current_path).to match /#{alternate_index_path}/
20
+ click_on 'relevance'
21
+ expect(current_path).to match /#{alternate_index_path}/
22
+ end
23
+
24
+ it "should display document thumbnails" do
25
+ visit alternate_index_path
26
+ page.should have_selector("form[action='#{alternate_index_path}']")
27
+ fill_in "q", :with=>"history"
28
+ click_button 'search'
29
+ expect(page).to have_selector ".document-thumbnail"
30
+ expect(page).to have_selector ".document-thumbnail a[data-counter]"
31
+ expect(page).to have_selector ".document-thumbnail a img"
32
+
33
+ end
34
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Bookmarks" do
4
+ describe "navigating from the homepage" do
5
+ it "should have a link to the history page" do
6
+ sign_in 'user1'
7
+ visit root_path
8
+ click_link 'Bookmarks'
9
+ expect(page).to have_content 'You have no bookmarks'
10
+ end
11
+ end
12
+
13
+ it "should clear bookmarks" do
14
+ visit catalog_path('2007020969')
15
+ click_button 'Bookmark'
16
+ click_link 'Bookmarks'
17
+ click_link 'Clear Bookmarks'
18
+ expect(page).to have_content 'Cleared your bookmarks.'
19
+ expect(page).to have_content 'You have no bookmarks'
20
+ end
21
+ it "add and remove bookmarks from search results" do
22
+ sign_in 'user1'
23
+ visit root_path
24
+ fill_in "q", with: 'book'
25
+ click_button 'search'
26
+ click_button 'Bookmark'
27
+ expect(page).to have_content 'Successfully added bookmark.'
28
+ fill_in "q", with: 'book'
29
+ click_button 'search'
30
+ click_button 'Remove bookmark'
31
+ expect(page).to have_content 'Successfully removed bookmark.'
32
+ end
33
+
34
+ it "should add and delete bookmarks from the show page" do
35
+ sign_in 'user1'
36
+ visit catalog_path('2007020969')
37
+ click_button 'Bookmark'
38
+ click_button 'Remove bookmark'
39
+ expect(page).to have_content 'Successfully removed bookmark.'
40
+ end
41
+
42
+ it "should add bookmarks after a user logs in" do
43
+ visit catalog_path('2007020969')
44
+ click_button 'Bookmark'
45
+ sign_in 'user1'
46
+ visit bookmarks_path
47
+ expect(page).to have_button("Remove bookmark")
48
+ expect(page).to have_content("Strong Medicine speaks")
49
+ end
50
+
51
+ it "should cite items in bookmarks" do
52
+ visit catalog_path('2007020969')
53
+ click_button 'Bookmark'
54
+ click_link 'Bookmarks'
55
+ click_link 'Cite'
56
+ expect(page).to have_content 'Strong Medicine speaks'
57
+ end
58
+ end