blacklight 5.0.0.pre1 → 5.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -4
  3. data/VERSION +1 -1
  4. data/app/assets/stylesheets/blacklight/_bookmark.css.scss +4 -0
  5. data/app/assets/stylesheets/blacklight/_catalog.css.scss +9 -13
  6. data/app/helpers/blacklight/blacklight_helper_behavior.rb +15 -9
  7. data/app/helpers/blacklight/catalog_helper_behavior.rb +8 -25
  8. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
  9. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -1
  10. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -2
  11. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -1
  12. data/app/views/bookmarks/index.html.erb +1 -1
  13. data/app/views/catalog/_did_you_mean.html.erb +1 -1
  14. data/app/views/catalog/_document.html.erb +4 -10
  15. data/app/views/catalog/{_document_header.html.erb → _index_header_default.html.erb} +6 -3
  16. data/app/views/catalog/_paginate_compact.html.erb +5 -0
  17. data/app/views/catalog/_show_header_default.html.erb +2 -0
  18. data/app/views/catalog/index.html.erb +1 -1
  19. data/app/views/catalog/show.html.erb +4 -10
  20. data/lib/blacklight.rb +0 -1
  21. data/lib/blacklight/configuration.rb +2 -2
  22. data/lib/blacklight/controller.rb +0 -1
  23. data/lib/blacklight/solr/document.rb +2 -0
  24. data/lib/blacklight/solr/document/schema_org.rb +7 -0
  25. data/lib/blacklight/solr_response.rb +4 -0
  26. data/lib/blacklight/user.rb +0 -6
  27. data/spec/controllers/application_controller_spec.rb +1 -2
  28. data/spec/controllers/bookmarks_controller_spec.rb +8 -9
  29. data/spec/controllers/catalog_controller_spec.rb +72 -73
  30. data/spec/controllers/saved_searches_controller_spec.rb +1 -2
  31. data/spec/controllers/search_history_controller_spec.rb +9 -10
  32. data/spec/features/search_pagination_spec.rb +1 -0
  33. data/spec/features/search_results_spec.rb +1 -0
  34. data/spec/features/search_spec.rb +1 -0
  35. data/spec/helpers/blacklight_helper_spec.rb +103 -93
  36. data/spec/helpers/catalog_helper_spec.rb +34 -21
  37. data/spec/helpers/facets_helper_spec.rb +41 -41
  38. data/spec/helpers/hash_as_hidden_fields_spec.rb +8 -9
  39. data/spec/helpers/render_constraints_helper_spec.rb +3 -3
  40. data/spec/helpers/search_history_constraints_helper_spec.rb +13 -14
  41. data/spec/lib/{blacklight_configurable_spec.rb → blacklight/configurable_spec.rb} +12 -14
  42. data/spec/lib/{blacklight_configuration_spec.rb → blacklight/configuration_spec.rb} +67 -69
  43. data/spec/lib/{facet_paginator_spec.rb → blacklight/facet_paginator_spec.rb} +13 -16
  44. data/spec/lib/{search_fields_spec.rb → blacklight/search_fields_spec.rb} +14 -15
  45. data/spec/lib/{blacklight_solr_document_dublin_core_spec.rb → blacklight/solr/document/dublin_core_spec.rb} +7 -8
  46. data/spec/lib/{blacklight_email_spec.rb → blacklight/solr/document/email_spec.rb} +5 -6
  47. data/spec/lib/{blacklight_solr_document_more_like_this_spec.rb → blacklight/solr/document/more_like_this_spec.rb} +5 -5
  48. data/spec/lib/{blacklight_sms_spec.rb → blacklight/solr/document/sms_spec.rb} +5 -6
  49. data/spec/lib/{blacklight_solr_document_spec.rb → blacklight/solr/document_spec.rb} +37 -39
  50. data/spec/lib/{solr_helper_spec.rb → blacklight/solr_helper_spec.rb} +183 -183
  51. data/spec/lib/{blacklight_solr_response_spec.rb → blacklight/solr_response_spec.rb} +20 -16
  52. data/spec/lib/{blacklight_user_spec.rb → blacklight/user_spec.rb} +3 -4
  53. data/spec/lib/blacklight_spec.rb +6 -7
  54. data/spec/lib/tasks/blacklight_task_spec.rb +2 -3
  55. data/spec/lib/utils_spec.rb +13 -14
  56. data/spec/models/bookmark_spec.rb +4 -4
  57. data/spec/models/record_mailer_spec.rb +15 -15
  58. data/spec/models/search_spec.rb +7 -7
  59. data/spec/models/solr_document_spec.rb +4 -4
  60. data/spec/routing/catalog_routing_spec.rb +12 -12
  61. data/spec/spec_helper.rb +1 -3
  62. data/spec/test_app_templates/Gemfile.extra +1 -2
  63. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +12 -13
  64. data/spec/views/catalog/_document.html.erb_spec.rb +19 -2
  65. data/spec/views/catalog/_document_list.html.erb_spec.rb +0 -1
  66. data/spec/views/catalog/_facets.html.erb_spec.rb +5 -5
  67. data/spec/views/catalog/_index_default.erb_spec.rb +10 -11
  68. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +45 -0
  69. data/spec/views/catalog/_search_header.erb_spec.rb +0 -1
  70. data/spec/views/catalog/_show_default.erb_spec.rb +10 -11
  71. data/spec/views/catalog/_show_sidebar.erb_spec.rb +2 -3
  72. data/spec/views/catalog/index.atom.builder_spec.rb +26 -27
  73. data/spec/views/catalog/index.html.erb_spec.rb +1 -1
  74. data/spec/views/catalog/show.html.erb_spec.rb +56 -0
  75. data/tasks/blacklight.rake +1 -1
  76. metadata +65 -64
  77. data/lib/blacklight/legacy_controller_methods.rb +0 -26
  78. data/spec/rcov.opts +0 -3
  79. data/spec/support/assert_difference.rb +0 -17
@@ -14,8 +14,7 @@ group :test do
14
14
  gem 'rspec-rails', '~> 2.13'
15
15
  gem 'generator_spec'
16
16
  gem 'poltergeist'
17
- gem 'simplecov', :platform => :mri_19
18
- gem 'simplecov-rcov', :platform => :mri_19
17
+ gem 'simplecov'
19
18
  end
20
19
 
21
20
  gem 'jettywrapper', '>= 1.2.0'
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  describe "catalog/_constraints_element.html.erb" do
@@ -7,9 +6,9 @@ describe "catalog/_constraints_element.html.erb" do
7
6
  render :partial => "catalog/constraints_element", :locals => {:label => "my label", :value => "my value"}
8
7
  end
9
8
  it "should render label and value" do
10
- rendered.should have_selector("span.appliedFilter.constraint") do |s|
11
- s.should have_selector "span.filterName", :content => "my label"
12
- s.should have_selector "span.filterValue", :content => "my value"
9
+ expect(rendered).to have_selector("span.appliedFilter.constraint") do |s|
10
+ expect(s).to have_selector "span.filterName", :content => "my label"
11
+ expect(s).to have_selector "span.filterValue", :content => "my value"
13
12
  end
14
13
  end
15
14
  end
@@ -19,14 +18,14 @@ describe "catalog/_constraints_element.html.erb" do
19
18
  render :partial => "catalog/constraints_element", :locals => {:label => "my label", :value => "my value", :options => {:remove => "http://remove"}}
20
19
  end
21
20
  it "should include remove link" do
22
- rendered.should have_selector("span.appliedFilter") do |s|
23
- s.should have_selector(".remove[href='http://remove']")
21
+ expect(rendered).to have_selector("span.appliedFilter") do |s|
22
+ expect(s).to have_selector(".remove[href='http://remove']")
24
23
  end
25
24
  end
26
25
 
27
26
  it "should have an accessible remove label" do
28
- rendered.should have_selector(".remove") do |s|
29
- s.should have_content("Remove constraint my label: my value")
27
+ expect(rendered).to have_selector(".remove") do |s|
28
+ expect(s).to have_content("Remove constraint my label: my value")
30
29
  end
31
30
  end
32
31
  end
@@ -36,8 +35,8 @@ describe "catalog/_constraints_element.html.erb" do
36
35
  render :partial => "catalog/constraints_element", :locals => {:label => "my label", :value => "my value", :options => {:check => false}}
37
36
  end
38
37
  it "should not include checkmark" do
39
- rendered.should have_selector("span.appliedFilter") do |s|
40
- s.should_not have_selector("img[src$='checkmark.gif']")
38
+ expect(rendered).to have_selector("span.appliedFilter") do |s|
39
+ expect(s).to_not have_selector("img[src$='checkmark.gif']")
41
40
  end
42
41
  end
43
42
  end
@@ -47,7 +46,7 @@ describe "catalog/_constraints_element.html.erb" do
47
46
  render :partial => "catalog/constraints_element", :locals => {:label => "my label", :value => "my value", :options => {:classes => ["class1", "class2"]}}
48
47
  end
49
48
  it "should include them" do
50
- rendered.should have_selector("span.appliedFilter.constraint.class1.class2")
49
+ expect(rendered).to have_selector("span.appliedFilter.constraint.class1.class2")
51
50
  end
52
51
  end
53
52
 
@@ -56,8 +55,8 @@ describe "catalog/_constraints_element.html.erb" do
56
55
  render( :partial => "catalog/constraints_element", :locals => {:label => "<span class='custom_label'>my label</span>", :value => "<span class='custom_value'>my value</span>", :options => {:escape_label => false, :escape_value => false}} )
57
56
  end
58
57
  it "should not escape key and value" do
59
- rendered.should have_selector("span.appliedFilter.constraint span.filterName span.custom_label")
60
- rendered.should have_selector("span.appliedFilter.constraint span.filterValue span.custom_value")
58
+ expect(rendered).to have_selector("span.appliedFilter.constraint span.filterName span.custom_label")
59
+ expect(rendered).to have_selector("span.appliedFilter.constraint span.filterValue span.custom_value")
61
60
  end
62
61
 
63
62
  end
@@ -9,14 +9,31 @@ describe "catalog/_document" do
9
9
  Blacklight::Configuration.new
10
10
  end
11
11
 
12
- it "should render the header, thumbnail and index" do
12
+ it "should render the header, thumbnail and index by default" do
13
+ view.stub(:render_grouped_response?).and_return(false)
13
14
  view.stub(:blacklight_config).and_return(blacklight_config)
14
- stub_template "catalog/_document_header.html.erb" => "document_header"
15
+ stub_template "catalog/_index_header_default.html.erb" => "document_header"
15
16
  stub_template "catalog/_thumbnail_default.html.erb" => "thumbnail_default"
16
17
  stub_template "catalog/_index_default.html.erb" => "index_default"
17
18
  render :partial => "catalog/document", :locals => {:document => document, :document_counter => 1}
18
19
  expect(rendered).to match /document_header/
19
20
  expect(rendered).to match /thumbnail_default/
20
21
  expect(rendered).to match /index_default/
22
+ expect(rendered).to have_selector('div.document[@itemscope]')
23
+ expect(rendered).to have_selector('div.document[@itemtype="http://schema.org/Thing"]')
24
+ end
25
+
26
+
27
+ it "should use the index.partials parameter to determine the partials to render" do
28
+ view.stub(:render_grouped_response?).and_return(false)
29
+ view.stub(:blacklight_config).and_return(blacklight_config)
30
+ blacklight_config.index.partials = ['a', 'b', 'c']
31
+ stub_template "catalog/_a_default.html.erb" => "a_partial"
32
+ stub_template "catalog/_b_default.html.erb" => "b_partial"
33
+ stub_template "catalog/_c_default.html.erb" => "c_partial"
34
+ render :partial => "catalog/document", :locals => {:document => document, :document_counter => 1}
35
+ expect(rendered).to match /a_partial/
36
+ expect(rendered).to match /b_partial/
37
+ expect(rendered).to match /c_partial/
21
38
  end
22
39
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  describe "/catalog/_document_list.html.erb" do
@@ -8,7 +8,7 @@ describe "catalog/_facets" do
8
8
  it "should not have a header if no facets are displayed" do
9
9
  view.stub(:render_facet_partials => '')
10
10
  render
11
- rendered.should_not have_selector('h4')
11
+ expect(rendered).to_not have_selector('h4')
12
12
  end
13
13
 
14
14
  it "should have a header" do
@@ -24,7 +24,7 @@ describe "catalog/_facets" do
24
24
 
25
25
  view.stub(:render_facet_partials => '')
26
26
  render
27
- rendered.should have_selector('h4')
27
+ expect(rendered).to have_selector('h4')
28
28
  end
29
29
 
30
30
  describe "facet display" do
@@ -42,13 +42,13 @@ describe "catalog/_facets" do
42
42
 
43
43
  it "should have a(n accessible) header" do
44
44
  render
45
- rendered.should have_selector('h5')
45
+ expect(rendered).to have_selector('h5')
46
46
  end
47
47
 
48
48
  it "should list values" do
49
49
  render
50
- rendered.should have_selector('a.facet_select')
51
- rendered.should have_selector('.facet-count')
50
+ expect(rendered).to have_selector('a.facet_select')
51
+ expect(rendered).to have_selector('.facet-count')
52
52
  end
53
53
 
54
54
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  # spec for default partial to display solr document fields
@@ -45,21 +44,21 @@ describe "/catalog/_index_default.erb" do
45
44
  end
46
45
 
47
46
  it "should only display fields listed in the initializer" do
48
- @rendered.should_not include_text("val_2")
49
- @rendered.should_not include_text(@fname_2)
47
+ expect(@rendered).to_not include_text("val_2")
48
+ expect(@rendered).to_not include_text(@fname_2)
50
49
  end
51
50
 
52
51
  it "should skip over fields listed in initializer that are not in solr response" do
53
- @rendered.should_not include_text(@fname_3)
52
+ expect(@rendered).to_not include_text(@fname_3)
54
53
  end
55
54
 
56
55
  it "should display field labels from initializer and raw solr field names in the class" do
57
56
  # labels
58
- @rendered.should include_text(@flabel_1)
59
- @rendered.should include_text(@flabel_4)
57
+ expect(@rendered).to include_text(@flabel_1)
58
+ expect(@rendered).to include_text(@flabel_4)
60
59
  # classes
61
- @rendered.should include_text("blacklight-#{@fname_1}")
62
- @rendered.should include_text("blacklight-#{@fname_4}")
60
+ expect(@rendered).to include_text("blacklight-#{@fname_1}")
61
+ expect(@rendered).to include_text("blacklight-#{@fname_4}")
63
62
  end
64
63
 
65
64
  # this test probably belongs in a Cucumber feature
@@ -68,9 +67,9 @@ describe "/catalog/_index_default.erb" do
68
67
  # end
69
68
 
70
69
  it "should have values for displayed fields" do
71
- @rendered.should include_text("val_1")
72
- @rendered.should include_text("val_4")
73
- @rendered.should_not include_text("val_2")
70
+ expect(@rendered).to include_text("val_1")
71
+ expect(@rendered).to include_text("val_4")
72
+ expect(@rendered).to_not include_text("val_2")
74
73
  end
75
74
 
76
75
  end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe "catalog/_paginate_compact.html.erb" do
4
+
5
+ describe "with a real solr response", :integration => true do
6
+ def blacklight_config
7
+ @config ||= CatalogController.blacklight_config
8
+ end
9
+
10
+ def blacklight_config=(config)
11
+ @config = config
12
+ end
13
+
14
+ def blacklight_solr
15
+ Blacklight.solr
16
+ end
17
+
18
+ def facet_limit_for *args
19
+ 0
20
+ end
21
+
22
+ include Blacklight::SolrHelper
23
+
24
+ it "should render solr responses" do
25
+ solr_response, document_list = get_search_results(:q => '')
26
+
27
+ render :partial => 'catalog/paginate_compact', :object => solr_response
28
+ expect(rendered).to have_selector ".page_entries"
29
+ expect(rendered).to have_selector "a[@rel=next]"
30
+ end
31
+ end
32
+
33
+ it "should render paginatable arrays" do
34
+ render :partial => 'catalog/paginate_compact', :object => (Kaminari.paginate_array([], total_count: 145).page(1).per(10))
35
+ expect(rendered).to have_selector ".page_entries"
36
+ expect(rendered).to have_selector "a[@rel=next]"
37
+ end
38
+
39
+ it "should render ActiveRecord collections" do
40
+ 50.times { b = Bookmark.new; b.user_id = 1; b.save! }
41
+ render :partial => 'catalog/paginate_compact', :object => Bookmark.page(1).per(25)
42
+ expect(rendered).to have_selector ".page_entries"
43
+ expect(rendered).to have_selector "a[@rel=next]"
44
+ end
45
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  # spec for sidebar partial in catalog show view
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  # spec for default partial to display solr document fields
@@ -47,21 +46,21 @@ describe "/catalog/_show_default.html.erb" do
47
46
  end
48
47
 
49
48
  it "should only display fields listed in the initializer" do
50
- @rendered.should_not include_text("val_2")
51
- @rendered.should_not include_text(@fname_2)
49
+ expect(@rendered).to_not include_text("val_2")
50
+ expect(@rendered).to_not include_text(@fname_2)
52
51
  end
53
52
 
54
53
  it "should skip over fields listed in initializer that are not in solr response" do
55
- @rendered.should_not include_text(@fname_3)
54
+ expect(@rendered).to_not include_text(@fname_3)
56
55
  end
57
56
 
58
57
  it "should display field labels from initializer and raw solr field names in the class" do
59
58
  # labels
60
- @rendered.should include_text(@flabel_1)
61
- @rendered.should include_text(@flabel_4)
59
+ expect(@rendered).to include_text(@flabel_1)
60
+ expect(@rendered).to include_text(@flabel_4)
62
61
  # classes
63
- @rendered.should include_text("blacklight-#{@fname_1}")
64
- @rendered.should include_text("blacklight-#{@fname_4}")
62
+ expect(@rendered).to include_text("blacklight-#{@fname_1}")
63
+ expect(@rendered).to include_text("blacklight-#{@fname_4}")
65
64
  end
66
65
 
67
66
  # this test probably belongs in a Cucumber feature
@@ -70,9 +69,9 @@ describe "/catalog/_show_default.html.erb" do
70
69
  # end
71
70
 
72
71
  it "should have values for displayed fields" do
73
- @rendered.should include_text("val_1")
74
- @rendered.should include_text("val_4")
75
- @rendered.should_not include_text("val_2")
72
+ expect(@rendered).to include_text("val_1")
73
+ expect(@rendered).to include_text("val_4")
74
+ expect(@rendered).to_not include_text("val_2")
76
75
  end
77
76
 
78
77
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  # spec for sidebar partial in catalog show view
@@ -20,7 +19,7 @@ describe "/catalog/_show_sidebar.html.erb" do
20
19
  @document = SolrDocument.new :id => 1, :title_s => 'abc', :format => 'default'
21
20
  @document.stub(:more_like_this).and_return([SolrDocument.new({ 'id' => '2', 'title_display' => 'Title of MLT Document' })])
22
21
  render
23
- rendered.should include_text("More Like This")
24
- rendered.should include_text("Title of MLT Document")
22
+ expect(rendered).to include_text("More Like This")
23
+ expect(rendered).to include_text("Title of MLT Document")
25
24
  end
26
25
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  describe "catalog/index" do
@@ -41,51 +40,51 @@ describe "catalog/index" do
41
40
  end
42
41
 
43
42
  it "should have contextual information" do
44
- rendered.should have_selector("link[rel=self]")
45
- rendered.should have_selector("link[rel=next]")
46
- rendered.should have_selector("link[rel=previous]")
47
- rendered.should have_selector("link[rel=first]")
48
- rendered.should have_selector("link[rel=last]")
49
- rendered.should have_selector("link[rel='alternate'][type='text/html']")
50
- rendered.should have_selector("link[rel=search][type='application/opensearchdescription+xml']")
43
+ expect(rendered).to have_selector("link[rel=self]")
44
+ expect(rendered).to have_selector("link[rel=next]")
45
+ expect(rendered).to have_selector("link[rel=previous]")
46
+ expect(rendered).to have_selector("link[rel=first]")
47
+ expect(rendered).to have_selector("link[rel=last]")
48
+ expect(rendered).to have_selector("link[rel='alternate'][type='text/html']")
49
+ expect(rendered).to have_selector("link[rel=search][type='application/opensearchdescription+xml']")
51
50
  end
52
51
 
53
52
  it "should get paging data correctly from response" do
54
53
  # Can't use have_tag for namespaced elements, sorry.
55
- @response_xml.elements["/feed/opensearch:totalResults"].text.should == "30"
56
- @response_xml.elements["/feed/opensearch:startIndex"].text.should == "10"
57
- @response_xml.elements["/feed/opensearch:itemsPerPage"].text.should == "10"
54
+ expect(@response_xml.elements["/feed/opensearch:totalResults"].text).to eq "30"
55
+ expect(@response_xml.elements["/feed/opensearch:startIndex"].text).to eq "10"
56
+ expect(@response_xml.elements["/feed/opensearch:itemsPerPage"].text).to eq "10"
58
57
  end
59
58
 
60
59
  it "should include an opensearch Query role=request" do
61
60
 
62
- @response_xml.elements.to_a("/feed/opensearch:itemsPerPage").length.should == 1
61
+ expect(@response_xml.elements.to_a("/feed/opensearch:itemsPerPage")).to have(1).item
63
62
  query_el = @response_xml.elements["/feed/opensearch:Query"]
64
- query_el.should_not be_nil
65
- query_el.attributes["role"].should == "request"
66
- query_el.attributes["searchTerms"].should == ""
67
- query_el.attributes["startPage"].should == "2"
63
+ expect(query_el).to_not be_nil
64
+ expect(query_el.attributes["role"]).to eq "request"
65
+ expect(query_el.attributes["searchTerms"]).to eq ""
66
+ expect(query_el.attributes["startPage"]).to eq "2"
68
67
  end
69
68
 
70
69
  it "should have ten entries" do
71
- rendered.should have_selector("entry", :count => 10)
70
+ expect(rendered).to have_selector("entry", :count => 10)
72
71
  end
73
72
 
74
73
  describe "entries" do
75
74
  it "should have a title" do
76
- rendered.should have_selector("entry > title")
75
+ expect(rendered).to have_selector("entry > title")
77
76
  end
78
77
  it "should have an updated" do
79
- rendered.should have_selector("entry > updated")
78
+ expect(rendered).to have_selector("entry > updated")
80
79
  end
81
80
  it "should have html link" do
82
- rendered.should have_selector("entry > link[rel=alternate][type='text/html']")
81
+ expect(rendered).to have_selector("entry > link[rel=alternate][type='text/html']")
83
82
  end
84
83
  it "should have an id" do
85
- rendered.should have_selector("entry > id")
84
+ expect(rendered).to have_selector("entry > id")
86
85
  end
87
86
  it "should have a summary" do
88
- rendered.should have_selector("entry > summary")
87
+ expect(rendered).to have_selector("entry > summary")
89
88
  end
90
89
 
91
90
  describe "with an author" do
@@ -93,7 +92,7 @@ describe "catalog/index" do
93
92
  @entry = @response_xml.elements.to_a("/feed/entry")[0]
94
93
  end
95
94
  it "should have author tag" do
96
- @entry.elements["author/name"].should_not be_nil
95
+ expect(@entry.elements["author/name"]).not_to be_nil
97
96
  end
98
97
  end
99
98
 
@@ -102,7 +101,7 @@ describe "catalog/index" do
102
101
  @entry = @response_xml.elements.to_a("/feed/entry")[1]
103
102
  end
104
103
  it "should not have an author tag" do
105
- @entry.elements["author/name"].should be_nil
104
+ expect(@entry.elements["author/name"]).to be_nil
106
105
  end
107
106
  end
108
107
  end
@@ -113,10 +112,10 @@ describe "catalog/index" do
113
112
  @entry = @response_xml.elements.to_a("/feed/entry")[0]
114
113
  end
115
114
  it "should include a link rel tag" do
116
- @entry.to_s.should have_selector("link[rel=alternate][type='application/marc']")
115
+ expect(@entry.to_s).to have_selector("link[rel=alternate][type='application/marc']")
117
116
  end
118
117
  it "should have content embedded" do
119
- @entry.to_s.should have_selector("content")
118
+ expect(@entry.to_s).to have_selector("content")
120
119
  end
121
120
  end
122
121
  describe "for an entry with NO content available" do
@@ -124,7 +123,7 @@ describe "catalog/index" do
124
123
  @entry = @response_xml.elements.to_a("/feed/entry")[5]
125
124
  end
126
125
  it "should include content" do
127
- @entry.to_s.should_not have_selector("content[type='application/marc']")
126
+ expect(@entry.to_s).to_not have_selector("content[type='application/marc']")
128
127
  end
129
128
  end
130
129
  end
@@ -23,7 +23,7 @@ describe "catalog/index.html.erb" do
23
23
  view.stub(:blacklight_config).and_return(Blacklight::Configuration.new)
24
24
  view.stub(:has_search_parameters?).and_return(true)
25
25
  view.stub(:render_opensearch_response_metadata).and_return("")
26
- view.stub(:response_has_no_search_results?).and_return(true)
26
+ assign(:response, double(:empty? => true))
27
27
  render
28
28
  expect(rendered).to match /header_content/
29
29
  end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe "catalog/show.html.erb" do
4
+
5
+ let :document do
6
+ SolrDocument.new :id => 'xyz', :format => 'a'
7
+ end
8
+
9
+ let :blacklight_config do
10
+ Blacklight::Configuration.new
11
+ end
12
+
13
+ before :each do
14
+ view.stub(:has_user_authentication_provider? => false)
15
+ view.stub(:render_document_sidebar_partial => "Sidebar")
16
+ end
17
+
18
+ it "should include schema.org itemscope/type properties" do
19
+ view.stub(:document_show_html_title).and_return("Heading")
20
+ document.stub(:itemtype => 'some-item-type-uri')
21
+ assign :document, document
22
+ view.stub(:blacklight_config).and_return(blacklight_config)
23
+ render
24
+
25
+ expect(rendered).to have_selector('div#document[@itemscope]')
26
+ expect(rendered).to have_selector('div#document[@itemtype="some-item-type-uri"]')
27
+ end
28
+
29
+ it "should render the show_header and show partials by default" do
30
+ view.stub(:render_grouped_response?).and_return(false)
31
+ view.stub(:blacklight_config).and_return(blacklight_config)
32
+ stub_template "catalog/_show_header_default.html.erb" => "document_header"
33
+ stub_template "catalog/_show_default.html.erb" => "show_default"
34
+
35
+ assign :document, document
36
+ render
37
+
38
+ expect(rendered).to match /document_header/
39
+ expect(rendered).to match /show_default/
40
+ end
41
+
42
+
43
+ it "should use the show.partials parameter to determine the partials to render" do
44
+ view.stub(:render_grouped_response?).and_return(false)
45
+ view.stub(:blacklight_config).and_return(blacklight_config)
46
+ blacklight_config.show.partials = ['a', 'b', 'c']
47
+ stub_template "catalog/_a_default.html.erb" => "a_partial"
48
+ stub_template "catalog/_b_default.html.erb" => "b_partial"
49
+ stub_template "catalog/_c_default.html.erb" => "c_partial"
50
+ assign :document, document
51
+ render
52
+ expect(rendered).to match /a_partial/
53
+ expect(rendered).to match /b_partial/
54
+ expect(rendered).to match /c_partial/
55
+ end
56
+ end