blacklight 3.1.2 → 3.2.0pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/.gitignore +5 -2
  2. data/README.md +7 -2
  3. data/VERSION +1 -1
  4. data/app/assets/images/favicon.ico +0 -0
  5. data/app/assets/javascripts/blacklight/blacklight.js +23 -1
  6. data/app/assets/stylesheets/blacklight/_catalog.css.scss +369 -0
  7. data/app/assets/stylesheets/blacklight/_facets.css.scss +117 -0
  8. data/app/assets/stylesheets/blacklight/_folder.css.scss +38 -0
  9. data/app/assets/stylesheets/blacklight/_formatting.css.scss +164 -0
  10. data/app/assets/stylesheets/blacklight/_header.css.scss +36 -0
  11. data/app/assets/stylesheets/blacklight/_layout.css.scss +79 -0
  12. data/app/assets/stylesheets/blacklight/_print.css.scss +54 -0
  13. data/app/assets/stylesheets/blacklight/_search_history.css.scss +44 -0
  14. data/app/assets/stylesheets/blacklight/_susy_framework.css.scss +228 -0
  15. data/app/assets/stylesheets/blacklight/blacklight.css.scss +27 -0
  16. data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +48 -0
  17. data/app/controllers/bookmarks_controller.rb +2 -1
  18. data/app/controllers/folder_controller.rb +4 -0
  19. data/app/controllers/saved_searches_controller.rb +4 -0
  20. data/app/controllers/search_history_controller.rb +4 -0
  21. data/app/helpers/blacklight/blacklight_helper_behavior.rb +64 -104
  22. data/app/helpers/blacklight/catalog_helper_behavior.rb +4 -4
  23. data/app/helpers/blacklight/facets_helper_behavior.rb +52 -5
  24. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +14 -59
  25. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +56 -0
  26. data/app/helpers/search_history_constraints_helper.rb +3 -0
  27. data/app/models/record_mailer.rb +1 -2
  28. data/app/views/_flash_msg.html.erb +4 -5
  29. data/app/views/_user_util_links.html.erb +3 -1
  30. data/app/views/bookmarks/index.html.erb +2 -2
  31. data/app/views/catalog/_bookmark_control.html.erb +6 -6
  32. data/app/views/catalog/_facet_layout.html.erb +4 -0
  33. data/app/views/catalog/_facet_limit.html.erb +20 -33
  34. data/app/views/catalog/_facets.html.erb +1 -5
  35. data/app/views/catalog/_folder_control.html.erb +5 -5
  36. data/app/views/catalog/_index_default.html.erb +1 -1
  37. data/app/views/catalog/_search_form.html.erb +4 -3
  38. data/app/views/catalog/_show_default.html.erb +1 -1
  39. data/app/views/catalog/_show_tools.html.erb +6 -6
  40. data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
  41. data/app/views/catalog/index.atom.builder +2 -2
  42. data/app/views/catalog/index.rss.builder +1 -1
  43. data/app/views/catalog/opensearch.xml.builder +10 -0
  44. data/app/views/catalog/show.html.erb +1 -1
  45. data/app/views/folder/_tools.html.erb +4 -4
  46. data/app/views/layouts/blacklight.html.erb +25 -37
  47. data/app/views/record_mailer/email_record.text.erb +1 -1
  48. data/app/views/record_mailer/sms_record.text.erb +2 -2
  49. data/app/views/search_history/index.html.erb +1 -1
  50. data/blacklight.gemspec +11 -9
  51. data/lib/{generators/blacklight/templates/SolrMarc.jar → SolrMarc.jar} +0 -0
  52. data/lib/blacklight.rb +5 -3
  53. data/lib/blacklight/catalog.rb +3 -4
  54. data/lib/blacklight/configurable.rb +54 -39
  55. data/lib/blacklight/configuration.rb +126 -0
  56. data/lib/blacklight/configuration/fields.rb +142 -0
  57. data/lib/blacklight/configuration/search_field.rb +12 -0
  58. data/lib/blacklight/configuration/solr_field.rb +12 -0
  59. data/lib/blacklight/configuration/sort_field.rb +17 -0
  60. data/lib/blacklight/controller.rb +16 -14
  61. data/lib/blacklight/engine.rb +1 -1
  62. data/lib/blacklight/global_configurable.rb +46 -0
  63. data/lib/blacklight/search_fields.rb +21 -54
  64. data/lib/blacklight/solr/document.rb +13 -3
  65. data/lib/blacklight/solr_helper.rb +88 -52
  66. data/lib/blacklight/utils.rb +18 -0
  67. data/lib/generators/blacklight/assets_generator.rb +14 -20
  68. data/lib/generators/blacklight/blacklight_generator.rb +14 -6
  69. data/lib/generators/blacklight/jetty_generator.rb +1 -1
  70. data/lib/generators/blacklight/templates/assets/standard.css.scss +51 -0
  71. data/lib/generators/blacklight/templates/catalog_controller.rb +148 -0
  72. data/lib/generators/blacklight/templates/config/blacklight_config.rb +2 -239
  73. data/lib/generators/blacklight/templates/config/sass.rb +5 -0
  74. data/lib/generators/blacklight/templates/solr_conf/schema.xml +514 -164
  75. data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +1591 -323
  76. data/lib/generators/blacklight/templates/solr_document.rb +2 -0
  77. data/lib/railties/all_tests.rake +36 -3
  78. data/lib/railties/blacklight_cucumber.rake +6 -4
  79. data/lib/railties/blacklight_rspec.rake +5 -4
  80. data/test_support/bin/run-tests.sh +2 -13
  81. data/test_support/bin/test.sh +30 -23
  82. data/test_support/features/did_you_mean.feature +14 -13
  83. data/test_support/features/step_definitions/saved_searches_steps.rb +1 -1
  84. data/test_support/features/step_definitions/search_steps.rb +4 -4
  85. data/test_support/spec/controllers/application_controller_spec.rb +3 -13
  86. data/test_support/spec/controllers/catalog_controller_spec.rb +102 -24
  87. data/test_support/spec/controllers/folder_controller_spec.rb +7 -1
  88. data/test_support/spec/helpers/blacklight_helper_spec.rb +45 -34
  89. data/test_support/spec/helpers/facets_helper_spec.rb +68 -0
  90. data/test_support/spec/helpers/html_head_helper_spec.rb +37 -0
  91. data/test_support/spec/helpers/{render_constraints_helper_spec.rb → search_history_constraints_helper_spec.rb} +26 -7
  92. data/test_support/spec/lib/blacklight_configurable_spec.rb +92 -0
  93. data/test_support/spec/lib/blacklight_configuration_spec.rb +295 -0
  94. data/test_support/spec/lib/{configurable_spec.rb → global_configurable_spec.rb} +2 -2
  95. data/test_support/spec/lib/search_fields_spec.rb +26 -29
  96. data/test_support/spec/{helpers → lib}/solr_helper_spec.rb +268 -287
  97. data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +1 -1
  98. data/test_support/spec/lib/utils_spec.rb +58 -0
  99. data/test_support/spec/models/solr_docment_spec.rb +4 -8
  100. data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +27 -170
  101. data/test_support/spec/views/catalog/_index_default.erb_spec.rb +38 -20
  102. data/test_support/spec/views/catalog/_show_default.erb_spec.rb +38 -19
  103. data/test_support/spec/views/catalog/index.atom.builder_spec.rb +19 -1
  104. metadata +148 -145
  105. data/app/assets/stylesheets/blacklight/blacklight.css +0 -493
  106. data/app/assets/stylesheets/yui.css +0 -31
  107. data/app/views/catalog/opensearch.xml.erb +0 -11
  108. data/doc/Atom-Responses.md +0 -90
  109. data/doc/CUSTOMIZING.md +0 -121
  110. data/doc/Extending-blacklight-with-the-document-extension-framework.md +0 -1
  111. data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -131
  112. data/doc/Features.md +0 -147
  113. data/doc/Integration-with-Rails-Footnotes.md +0 -20
  114. data/doc/Pagination.md +0 -38
  115. data/doc/Quickstart.md +0 -97
  116. data/doc/Upgrading-Guide.md +0 -98
  117. data/doc/User-Authentication.md +0 -54
  118. data/doc/Using-a-custom-solr-uniquekey-field.md +0 -36
  119. data/lib/blacklight/comma_link_renderer.rb +0 -28
  120. data/lib/railties/jetty_solr_server.rb +0 -108
  121. data/test_support/spec/views/catalog/show.html.erb_spec.rb +0 -101
@@ -50,7 +50,7 @@ describe "solr:marc:*" do
50
50
 
51
51
  java_cmd.should_not be_nil
52
52
  java_cmd.should match "java -Xmx512m"
53
- java_cmd.should match "-jar #{Rails.root}/lib/SolrMarc.jar"
53
+ java_cmd.should match /-jar .*\/SolrMarc\.jar/
54
54
  java_cmd.should match "#{Rails.root}/config/SolrMarc/config-test.properties dummy.mrc"
55
55
  java_cmd.should match "-Dsolr.hosturl=http://127.0.0.1:[0-9]{4}/solr"
56
56
  end
@@ -0,0 +1,58 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+
4
+ describe 'Blacklight::Utils' do
5
+ describe Blacklight::OpenStructWithHashAccess do
6
+ it "should provide hash-like accessors for OpenStruct data" do
7
+ a = Blacklight::OpenStructWithHashAccess.new :foo => :bar, :baz => 1
8
+
9
+ a[:foo].should == :bar
10
+ a[:baz].should == 1
11
+ a[:asdf].should be_nil
12
+ end
13
+
14
+ it "should provide hash-like writers for OpenStruct data" do
15
+ a = Blacklight::OpenStructWithHashAccess.new :foo => :bar, :baz => 1
16
+
17
+ a[:asdf] = 'qwerty'
18
+ a.asdf.should == 'qwerty'
19
+
20
+ end
21
+
22
+ it "should treat symbols and strings interchangeably in hash access" do
23
+ h = Blacklight::OpenStructWithHashAccess.new
24
+
25
+ h["string"] = "value"
26
+ h[:string].should == "value"
27
+ h.string.should == "value"
28
+
29
+ h[:symbol] = "value"
30
+ h["symbol"].should == "value"
31
+ h.symbol.should == "value"
32
+ end
33
+
34
+ describe "internal hash table" do
35
+ before do
36
+ @h = Blacklight::OpenStructWithHashAccess.new
37
+
38
+ @h[:a] = 1
39
+ @h[:b] = 2
40
+
41
+
42
+ end
43
+ it "should expose the internal hash table" do
44
+ @h.to_h.should be_a_kind_of(Hash)
45
+ @h.to_h[:a].should == 1
46
+ end
47
+
48
+ it "should expose keys" do
49
+ @h.keys.should include(:a, :b)
50
+ end
51
+
52
+ it "should expose merge" do
53
+ @h.merge(:a => 'a')[:a].should == 'a'
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -60,6 +60,10 @@ end
60
60
  end
61
61
 
62
62
  describe "access methods" do
63
+
64
+ it "should have the right value for title_display" do
65
+ @solrdoc[:title_display].should_not be_nil
66
+ end
63
67
 
64
68
  it "should have the right value for format" do
65
69
  @solrdoc[:format][0].should == 'Book'
@@ -68,14 +72,6 @@ end
68
72
  it "should provide the item's solr id" do
69
73
  @solrdoc.id.should == '00282214'
70
74
  end
71
-
72
- it "should have access methods for all special function fields named in initializer" do
73
- # the fields specified in Blacklight.config[:show] that
74
- Blacklight.config[:show].each_key do |function|
75
- @solrdoc[Blacklight.config[:show][function]].should_not be_nil
76
- end
77
- end
78
-
79
75
  end
80
76
 
81
77
  describe "ruby marc creation" do
@@ -1,183 +1,40 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
3
2
 
4
- describe "/catalog/_facets.html.erb" do
5
-
6
- before(:each) do
7
-
8
- # create mock facets to be retrieved from the response
9
- @solr_item00 = stub("solr_item00")
10
- @solr_item00.stub!(:value).and_return("val_0_0")
11
- @solr_item00.stub!(:hits).and_return("90")
12
- @solr_item01 = stub("solr_item01")
13
- @solr_item01.stub!(:value).and_return("val_0_1")
14
- @solr_item01.stub!(:hits).and_return("91")
15
- @facet0 = stub("facet0")
16
- @solr_fname0 = Blacklight.config[:facet][:field_names].last
17
- @facet0.stub!(:name).and_return(@solr_fname0);
18
- @solr_items0 = [@solr_item00, @solr_item01]
19
- @facet0.stub!(:items).and_return(@solr_items0);
20
-
21
- @solr_item10 = stub("solr_item10")
22
- @solr_item10.stub!(:value).and_return("val_1_0")
23
- @solr_item10.stub!(:hits).and_return("10")
24
- @solr_item11 = stub("solr_item11")
25
- @solr_item11.stub!(:value).and_return("val_1_1")
26
- @solr_item11.stub!(:hits).and_return("11")
27
- @facet1 = stub("facet1")
28
- @solr_fname1 = Blacklight.config[:facet][:field_names][1]
29
- @facet1.stub!(:name).and_return(@solr_fname1);
30
- @solr_items1 = [@solr_item10, @solr_item11]
31
- @facet1.stub!(:items).and_return(@solr_items1);
32
-
33
- @solr_item20 = stub("solr_item20")
34
- @solr_item20.stub!(:value).and_return("val_2_0")
35
- @solr_item20.stub!(:hits).and_return("20")
36
- @solr_item21 = stub("solr_item21")
37
- @solr_item21.stub!(:value).and_return("val_2_1")
38
- @solr_item21.stub!(:hits).and_return("21")
39
- @facet2 = stub("facet2")
40
- @solr_fname2 = Blacklight.config[:facet][:field_names][0]
41
- @facet2.stub!(:name).and_return(@solr_fname2);
42
- @solr_items2 = [@solr_item20, @solr_item21]
43
- @facet2.stub!(:items).and_return(@solr_items2);
44
-
45
- @solr_item30 = stub("solr_item30")
46
- @solr_item30.stub!(:value).and_return("val_3_0")
47
- @solr_item30.stub!(:hits).and_return("30")
48
- @solr_item31 = stub("solr_item31")
49
- @solr_item31.stub!(:value).and_return("val_3_1")
50
- @solr_item31.stub!(:hits).and_return("31")
51
- @facet3 = stub("facet3")
52
- @solr_fname3 = "solr_field_not_in_initializer_facet"
53
- @facet3.stub!(:name).and_return(@solr_fname3);
54
- @solr_items3 = [@solr_item30, @solr_item31]
55
- @facet3.stub!(:items).and_return(@solr_items3);
56
-
57
- @facets = [@facet0, @facet1, @facet2, @facet3]
58
- @response.stub!(:facets).and_return(@facets)
59
-
60
- # one facet is selected
61
- selected_facet = {@solr_fname1 => [@solr_item10.value]}
62
- params[:f] = selected_facet
63
-
64
- assigns[:response] = @response
65
-
66
- render :partial => 'catalog/facets'
67
- end
68
-
69
- # There is a problem with link_to and rspec-rails. See:
70
- # http://www.nabble.com/Rails:-View-specs-and-implicit-parameters-in-link_to()-td20011051.html
71
- # This spec will run cleanly if the implicit routes are added to the plugin
72
- # level routes.rb file: (at the bottom of the file)
73
- #
74
- # map.connect ':controller/:action/:id'
75
- # map.connect ':controller/:action/:id.:format'
76
-
77
- # If someone can find a better workaround, that would be mega-spiffy.
78
- #
79
- # For now, I am commenting out this spec because I'm not sure if adding those
80
- # routes will affect anything else. Similar comments are in routes.rb
81
- # - Naomi 2009-04-19
82
-
83
- =begin
84
-
85
- it "should have div tag with id=facets" do
86
- response.should have_selector('div[id=facets]')
87
- end
88
-
89
- it "should not have facets that aren't specified in initializer" do
90
- response.should_not include_text(@solr_fname3)
3
+ describe "catalog/_facets.html.erb" do
4
+ before do
5
+ @mock_config = Blacklight::Configuration.new
6
+ view.stub(:blacklight_config => @mock_config)
91
7
  end
92
-
93
- it "should skip over facets specified in the initializer that aren't in the response" do
94
- solr_field = Blacklight.config[:facet][:field_names][2]
95
- label = Blacklight.config[:facet][:labels][solr_field]
96
- response.should_not include_text(label)
8
+ it "should have a header" do
9
+ view.stub(:render_facet_partials => '')
10
+ render
11
+ rendered.should have_selector('h2')
97
12
  end
98
13
 
99
- it "should have all facets specified in initializer that are included in solr response" do
100
- solr_field1 = Blacklight.config[:facet][:field_names].last
101
- response.should include_text(solr_field1)
102
-
103
- solr_field2 = Blacklight.config[:facet][:field_names][1]
104
- response.should include_text(solr_field2)
14
+ describe "facet display" do
15
+ before do
16
+ @mock_field_1 = mock(:field => 'facet_field_1',
17
+ :label => 'label')
18
+ @mock_display_facet_1 = mock(:name => 'facet_field_1', :items => [mock(:value => 'Value', :hits => 1234)])
19
+ view.stub(:facet_field_names => [:facet_field_1],
20
+ :facet_limit_for => 10 )
105
21
 
106
- solr_field3 = Blacklight.config[:facet][:field_names][0]
107
- response.should include_text(solr_field3)
108
- end
22
+ @response = mock()
23
+ @response.should_receive(:facet_by_field_name).with(:facet_field_1) { @mock_display_facet_1 }
109
24
 
110
- it "should use the labels specified in initializer" do
111
- label1 = Blacklight.config[:facet][:labels][@solr_fname0]
112
- response.should include_text(label1)
113
-
114
- label2 = Blacklight.config[:facet][:labels][@solr_fname1]
115
- response.should include_text(label2)
116
-
117
- label3 = Blacklight.config[:facet][:labels][@solr_fname2]
118
- response.should include_text(label3)
119
- end
120
-
121
- # TODO: check the display order of the facets. Naomi can't figure this out
122
- # it "should display the facets in the order specified in the initializer" do
123
- # pending
124
- # end
125
- #
126
- # output is:
127
- # <div id="facets">
128
- # <div>
129
- # <h3>Format</h3>
130
- # <ul>
131
- # <li>Book</li>
132
- # <li>Online</li>
133
- # </ul>
134
- # </div>
135
- # <div>
136
- # <h3>Language</h3>
137
- # <ul>
138
- # <li>English</li>
139
- # <li>Urdu/li>
140
- # </ul>
141
- # </div>
142
- # </div>
143
- #
144
- # can't test for ordering of h3 contents:
145
- # they are not immediate children of <div id="facets">
146
- #
147
- # perhaps use Cucumber?
25
+ end
148
26
 
149
-
150
- it "should have values for displayed facets" do
151
- response.should have_selector("li") do
152
- with_tag("a", @solr_item00.value)
153
- with_tag("a", @solr_item01.value)
154
- # with_tag("a", @solr_item10.value) # this facet is selected
155
- with_tag("a", @solr_item11.value)
156
- with_tag("a", @solr_item20.value)
157
- with_tag("a", @solr_item21.value)
27
+ it "should have a header" do
28
+ render
29
+ rendered.should have_selector('h3')
158
30
  end
159
- end
160
31
 
161
- it "should have numbers of hits for displayed facets" do
162
- response.should include_text(@solr_item00.hits)
163
- response.should include_text(@solr_item01.hits)
164
- response.should include_text(@solr_item10.hits)
165
- response.should include_text(@solr_item11.hits)
166
- response.should include_text(@solr_item20.hits)
167
- response.should include_text(@solr_item21.hits)
168
- end
169
-
170
- it "should have links to include facet values in solr query" do
171
- response.should have_selector("a", :text => @solr_item00.value)
172
- response.should include_text("f%5B"+@solr_fname0 + "%5D%5B%5D=" + @solr_item00.value)
173
- response.should have_selector("a", :text => @solr_item11.value)
174
- response.should include_text("f%5B"+@solr_fname1 + "%5D%5B%5D=" + @solr_item11.value)
175
- end
32
+ it "should list values" do
33
+ render
34
+ rendered.should have_selector('a.label')
35
+ rendered.should have_selector('.count')
36
+ end
176
37
 
177
- it "should display selected facets properly" do
178
- response.should have_selector("span[class=selected]", :text => /#{@solr_item10.value}/)
179
38
  end
180
-
181
- =end
182
-
183
39
  end
40
+
@@ -5,15 +5,32 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
5
5
  # in catalog INDEX view
6
6
 
7
7
  describe "/catalog/_index_default.erb" do
8
-
9
8
  include BlacklightHelper
10
9
  include CatalogHelper
11
-
10
+
12
11
  before(:each) do
13
- @fname_1 = Blacklight.config[:index_fields][:field_names].last
14
- @fname_2 = "solr_field_not_in_initializer"
15
- @fname_3 = Blacklight.config[:index_fields][:field_names][1]
16
- @fname_4 = Blacklight.config[:index_fields][:field_names][0]
12
+ @config = Blacklight::Configuration.from_legacy_configuration({
13
+ :show => {
14
+ :display_type => 'asdf'
15
+ },
16
+ :index_fields => {
17
+ :field_names => [
18
+ 'one_field',
19
+ 'empty_field',
20
+ 'four_field'
21
+ ],
22
+ :labels => {
23
+ 'one_field' => 'One:',
24
+ 'empty_field' => 'Three:',
25
+ 'four_field' => 'Four:'
26
+ }
27
+ }
28
+ })
29
+
30
+ @fname_1 = "one_field"
31
+ @fname_2 = "solr_field_not_in_config"
32
+ @fname_3 = "empty_field"
33
+ @fname_4 = "four_field"
17
34
 
18
35
  @document = mock("solr_doc")
19
36
  @document.should_receive(:get).with(@fname_1, hash_including(:sep => nil)).any_number_of_times.and_return("val_1")
@@ -31,30 +48,31 @@ describe "/catalog/_index_default.erb" do
31
48
  @document.should_receive(:get).with(anything(), hash_including(:sep => nil)).any_number_of_times.and_return("bleah")
32
49
  @document.should_receive(:[]).any_number_of_times
33
50
 
34
- @flabel_1 = Blacklight.config[:index_fields][:labels][@fname_1]
35
- @flabel_3 = Blacklight.config[:index_fields][:labels][@fname_3]
36
- @flabel_4 = Blacklight.config[:index_fields][:labels][@fname_4]
51
+ @flabel_1 = "One:"
52
+ @flabel_3 = "Three:"
53
+ @flabel_4 = "Four:"
37
54
 
55
+ view.stub!(:blacklight_config).and_return(@config)
38
56
  assigns[:document] = @document
39
- render_document_partial @document, :index
57
+ @rendered = view.render_document_partial @document, :index
40
58
  end
41
59
 
42
60
  it "should only display fields listed in the initializer" do
43
- rendered.should_not include_text("val_2")
44
- rendered.should_not include_text(@fname_2)
61
+ @rendered.should_not include_text("val_2")
62
+ @rendered.should_not include_text(@fname_2)
45
63
  end
46
64
 
47
65
  it "should skip over fields listed in initializer that are not in solr response" do
48
- rendered.should_not include_text(@fname_3)
66
+ @rendered.should_not include_text(@fname_3)
49
67
  end
50
68
 
51
69
  it "should display field labels from initializer and raw solr field names in the class" do
52
70
  # labels
53
- rendered.should include_text(@flabel_1)
54
- rendered.should include_text(@flabel_4)
71
+ @rendered.should include_text(@flabel_1)
72
+ @rendered.should include_text(@flabel_4)
55
73
  # classes
56
- rendered.should include_text("blacklight-#{@fname_1}")
57
- rendered.should include_text("blacklight-#{@fname_4}")
74
+ @rendered.should include_text("blacklight-#{@fname_1}")
75
+ @rendered.should include_text("blacklight-#{@fname_4}")
58
76
  end
59
77
 
60
78
  # this test probably belongs in a Cucumber feature
@@ -63,9 +81,9 @@ describe "/catalog/_index_default.erb" do
63
81
  # end
64
82
 
65
83
  it "should have values for displayed fields" do
66
- rendered.should include_text("val_1")
67
- rendered.should include_text("val_4")
68
- rendered.should_not include_text("val_2")
84
+ @rendered.should include_text("val_1")
85
+ @rendered.should include_text("val_4")
86
+ @rendered.should_not include_text("val_2")
69
87
  end
70
88
 
71
89
  end
@@ -8,12 +8,30 @@ describe "/catalog/_show_default.html.erb" do
8
8
 
9
9
  include BlacklightHelper
10
10
  include CatalogHelper
11
-
11
+
12
+
12
13
  before(:each) do
13
- @fname_1 = Blacklight.config[:show_fields][:field_names].last
14
- @fname_2 = "solr_field_not_in_initializer"
15
- @fname_3 = Blacklight.config[:show_fields][:field_names][2]
16
- @fname_4 = Blacklight.config[:show_fields][:field_names][0]
14
+ @config = Blacklight::Configuration.from_legacy_configuration({
15
+ :show => {
16
+ :display_type => 'asdf'
17
+ },
18
+ :show_fields => {
19
+ :field_names => [
20
+ 'one_field',
21
+ 'empty_field',
22
+ 'four_field'
23
+ ],
24
+ :labels => {
25
+ 'one_field' => 'One:',
26
+ 'empty_field' => 'Three:',
27
+ 'four_field' => 'Four:'
28
+ }
29
+ }
30
+ })
31
+ @fname_1 = "one_field"
32
+ @fname_2 = "solr_field_not_in_config"
33
+ @fname_3 = "empty_field"
34
+ @fname_4 = "four_field"
17
35
 
18
36
  @document = mock("solr_doc")
19
37
  @document.should_receive(:get).with(@fname_1, hash_including(:sep => nil)).any_number_of_times.and_return("val_1")
@@ -31,30 +49,31 @@ describe "/catalog/_show_default.html.erb" do
31
49
  @document.should_receive(:get).with(any_args()).any_number_of_times.and_return("bleah")
32
50
  @document.should_receive(:[]).any_number_of_times
33
51
 
34
- @flabel_1 = Blacklight.config[:show_fields][:labels][@fname_1]
35
- @flabel_3 = Blacklight.config[:show_fields][:labels][@fname_3]
36
- @flabel_4 = Blacklight.config[:show_fields][:labels][@fname_4]
52
+ @flabel_1 = "One:"
53
+ @flabel_3 = "Two:"
54
+ @flabel_4 = "Four:"
37
55
 
56
+ view.stub!(:blacklight_config).and_return(@config)
38
57
  assigns[:document] = @document
39
- render_document_partial @document, :show
58
+ @rendered = view.render_document_partial @document, :show
40
59
  end
41
60
 
42
61
  it "should only display fields listed in the initializer" do
43
- rendered.should_not include_text("val_2")
44
- rendered.should_not include_text(@fname_2)
62
+ @rendered.should_not include_text("val_2")
63
+ @rendered.should_not include_text(@fname_2)
45
64
  end
46
65
 
47
66
  it "should skip over fields listed in initializer that are not in solr response" do
48
- rendered.should_not include_text(@fname_3)
67
+ @rendered.should_not include_text(@fname_3)
49
68
  end
50
69
 
51
70
  it "should display field labels from initializer and raw solr field names in the class" do
52
71
  # labels
53
- rendered.should include_text(@flabel_1)
54
- rendered.should include_text(@flabel_4)
72
+ @rendered.should include_text(@flabel_1)
73
+ @rendered.should include_text(@flabel_4)
55
74
  # classes
56
- rendered.should include_text("blacklight-#{@fname_1}")
57
- rendered.should include_text("blacklight-#{@fname_4}")
75
+ @rendered.should include_text("blacklight-#{@fname_1}")
76
+ @rendered.should include_text("blacklight-#{@fname_4}")
58
77
  end
59
78
 
60
79
  # this test probably belongs in a Cucumber feature
@@ -63,9 +82,9 @@ describe "/catalog/_show_default.html.erb" do
63
82
  # end
64
83
 
65
84
  it "should have values for displayed fields" do
66
- rendered.should include_text("val_1")
67
- rendered.should include_text("val_4")
68
- rendered.should_not include_text("val_2")
85
+ @rendered.should include_text("val_1")
86
+ @rendered.should include_text("val_4")
87
+ @rendered.should_not include_text("val_2")
69
88
  end
70
89
 
71
90
  end