hydra-head 3.1.0.pre5 → 3.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.textile +14 -1
- data/app/helpers/application_helper.rb +1 -166
- data/app/helpers/article_metadata_helper.rb +2 -78
- data/app/helpers/blacklight_helper.rb +2 -195
- data/app/helpers/downloads_helper.rb +3 -18
- data/app/helpers/generic_content_objects_helper.rb +2 -14
- data/app/helpers/hydra/application_helper_behavior.rb +10 -0
- data/app/helpers/hydra/article_metadata_helper_behavior.rb +82 -0
- data/app/helpers/hydra/blacklight_helper_behavior.rb +203 -0
- data/app/helpers/hydra/downloads_helper_behavior.rb +21 -0
- data/app/helpers/hydra/generic_content_objects_helper_behavior.rb +16 -0
- data/app/helpers/hydra/hydra_assets_helper_behavior.rb +66 -0
- data/app/helpers/hydra/hydra_djatoka_helper_behavior.rb +23 -0
- data/app/helpers/hydra/hydra_fedora_metadata_helper_behavior.rb +349 -0
- data/app/helpers/hydra/hydra_helper_behavior.rb +184 -0
- data/app/helpers/hydra/hydra_uploader_helper_behavior.rb +18 -0
- data/app/helpers/hydra/inline_editable_metadata_helper_behavior.rb +15 -0
- data/app/helpers/hydra/javascript_includes_helper_behavior.rb +91 -0
- data/app/helpers/hydra/personalization_helper_behavior.rb +44 -0
- data/app/helpers/hydra/release_process_helper_behavior.rb +32 -0
- data/app/helpers/hydra_assets_helper.rb +2 -64
- data/app/helpers/hydra_djatoka_helper.rb +3 -22
- data/app/helpers/hydra_fedora_metadata_helper.rb +2 -347
- data/app/helpers/hydra_helper.rb +2 -182
- data/app/helpers/hydra_uploader_helper.rb +2 -16
- data/app/helpers/inline_editable_metadata_helper.rb +3 -14
- data/app/helpers/javascript_includes_helper.rb +2 -89
- data/app/helpers/personalization_helper.rb +2 -42
- data/app/helpers/release_process_helper.rb +2 -30
- data/lib/blacklight/blacklight_helper_behavior.rb +612 -0
- data/lib/hydra-head/version.rb +1 -1
- data/lib/railties/hydra-fixtures.rake +0 -1
- data/tasks/hydra-head.rake +1 -2
- data/test_support/features/step_definitions/edit_metadata_steps.rb +0 -1
- data/{spec → test_support/spec}/controllers/catalog_valid_html_spec.rb +1 -11
- data/test_support/spec/helpers/blacklight_helper_spec.rb +6 -2
- data/test_support/spec/spec_helper.rb +5 -3
- metadata +23 -14
- data/lib/hydra/fixture_loader.rb +0 -48
- data/lib/stanford/searchworks_helper.rb +0 -1338
- data/lib/stanford/solr_helper.rb +0 -108
- data/lib/stanford_blacklight_extensions.rb +0 -6
- data/spec-rails2/helpers/hydra_fedora_metadata_helper_spec.rb +0 -219
- data/spec-rails2/spec_helper.rb +0 -88
data/lib/stanford/solr_helper.rb
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
# Stanford SolrHelper is a controller layer mixin. It is in the controller scope: request params, session etc.
|
2
|
-
#
|
3
|
-
# NOTE: Be careful when creating variables here as they may be overriding something that already exists.
|
4
|
-
# The ActionController docs: http://api.rubyonrails.org/classes/ActionController/Base.html
|
5
|
-
#
|
6
|
-
# Override these methods in your own controller for customizations:
|
7
|
-
#
|
8
|
-
# class HomeController < ActionController::Base
|
9
|
-
#
|
10
|
-
# include Stanford::SolrHelper
|
11
|
-
#
|
12
|
-
# def solr_search_params
|
13
|
-
# super.merge :per_page=>10
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
module Stanford::SolrHelper
|
19
|
-
|
20
|
-
# returns a params hash for a home facet field solr query.
|
21
|
-
# used primary by the get_facet_pagination method
|
22
|
-
def home_facet_params(extra_controller_params={})
|
23
|
-
input = params.deep_merge(extra_controller_params)
|
24
|
-
{
|
25
|
-
:qt => Blacklight.config[:default_qt],
|
26
|
-
:per_page => 0,
|
27
|
-
:phrase_filters => input[:f],
|
28
|
-
"f.callnum_top_facet.facet.sort" => "false"
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
# returns a params hash for the advanced search facet field solr query.
|
33
|
-
# used primary by the get_facet_pagination method
|
34
|
-
def advanced_search_facet_params(extra_controller_params={})
|
35
|
-
input = params.deep_merge(extra_controller_params)
|
36
|
-
{
|
37
|
-
:qt => Blacklight.config[:default_qt],
|
38
|
-
:per_page => 0,
|
39
|
-
:phrase_filters => input[:f],
|
40
|
-
"f.callnum_top_facet.facet.sort" => "false",
|
41
|
-
"f.format.facet.sort" => "false",
|
42
|
-
"f.building_facet.facet.sort" => "false",
|
43
|
-
"f.access_facet.facet.sort" => "false",
|
44
|
-
"f.language.facet.limit" => 100
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
# a solr query method
|
49
|
-
# given a user query, return a solr response containing both result docs and facets
|
50
|
-
# - mixes in the Blacklight::Solr::SpellingSuggestions module
|
51
|
-
# - the response will have a spelling_suggestions method
|
52
|
-
def get_advanced_search_facets(extra_controller_params={})
|
53
|
-
Blacklight.solr.find self.advanced_search_facet_params(extra_controller_params)
|
54
|
-
end
|
55
|
-
|
56
|
-
# a solr query method
|
57
|
-
# given a user query, return a solr response containing both result docs and facets
|
58
|
-
# - mixes in the Blacklight::Solr::SpellingSuggestions module
|
59
|
-
# - the response will have a spelling_suggestions method
|
60
|
-
def get_home_facets(extra_controller_params={})
|
61
|
-
Blacklight.solr.find self.home_facet_params(extra_controller_params)
|
62
|
-
end
|
63
|
-
|
64
|
-
# given a field name and a field value, get the next "alphabetic" N
|
65
|
-
# terms for the field
|
66
|
-
# returns array of one element hashes with key=term and value=count
|
67
|
-
# NOTE: terms in index are case sensitive! Okay for shelfkey ...
|
68
|
-
def get_next_terms(curr_value, field, how_many)
|
69
|
-
# TermsComponent Query to get the terms
|
70
|
-
solr_params = {
|
71
|
-
'terms.fl' => field,
|
72
|
-
'terms.lower' => curr_value,
|
73
|
-
:per_page => how_many
|
74
|
-
}
|
75
|
-
solr_response = Blacklight.solr.send_request('/alphaTerms', solr_params)
|
76
|
-
|
77
|
-
# create array of one element hashes with key=term and value=count
|
78
|
-
result = []
|
79
|
-
terms ||= solr_response['terms'] || []
|
80
|
-
field_terms ||= terms[1] || []
|
81
|
-
# field_terms is an array of value, then num hits, then next value, then hits ...
|
82
|
-
i = 0
|
83
|
-
until result.length == how_many || i >= field_terms.length do
|
84
|
-
term_hash = {field_terms[i] => field_terms[i+1]}
|
85
|
-
result << term_hash
|
86
|
-
i = i + 2
|
87
|
-
end
|
88
|
-
|
89
|
-
result
|
90
|
-
end
|
91
|
-
|
92
|
-
# given a field name and array of values, get the matching SOLR documents
|
93
|
-
def get_docs_for_field_values(values, field)
|
94
|
-
value_str = "(\"" + values.join("\" OR \"") + "\")"
|
95
|
-
solr_params = {
|
96
|
-
:qt => "standard", # need boolean for OR
|
97
|
-
:q => "#{field}:#{value_str}",
|
98
|
-
'fl' => "*",
|
99
|
-
'facet' => 'false',
|
100
|
-
'spellcheck' => 'false'
|
101
|
-
}
|
102
|
-
|
103
|
-
solr_response = Blacklight.solr.find solr_params
|
104
|
-
solr_response.docs
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
end
|
@@ -1,219 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe HydraFedoraMetadataHelper do
|
4
|
-
|
5
|
-
before(:all) do
|
6
|
-
# @mock_ng_ds = mock("nokogiri datastream")
|
7
|
-
# @mock_ng_ds.stubs(:kind_of?).with(ActiveFedora::NokogiriDatastream).returns(true)
|
8
|
-
# @mock_ng_ds.stubs(:class).returns(ActiveFedora::NokogiriDatastream)
|
9
|
-
# @mock_md_ds = stub(:stream_values=>"value")
|
10
|
-
# datastreams = {"ng_ds"=>@mock_ng_ds,"simple_ds"=>@mock_md_ds}
|
11
|
-
@resource = mock("fedora object")
|
12
|
-
# @resource.stubs(:datastreams).returns(datastreams)
|
13
|
-
# @resource.stubs(:datastreams_in_memory).returns(datastreams)
|
14
|
-
|
15
|
-
@resource.stubs(:get_values_from_datastream).with("simple_ds", "subject", "").returns( ["topic1","topic2"] )
|
16
|
-
|
17
|
-
@resource.stubs(:get_values_from_datastream).with("ng_ds", [:title, :main_title], "").returns( ["My Title"] )
|
18
|
-
@resource.stubs(:get_values_from_datastream).with("ng_ds", [{:person=>1}, :given_name], "").returns( ["Bob"] )
|
19
|
-
|
20
|
-
@resource.stubs(:get_values_from_datastream).with("empty_ds", "something", "").returns( [""] )
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "fedora_text_field" do
|
24
|
-
it "should generate a text field input with values from the given datastream" do
|
25
|
-
generated_html = helper.fedora_text_field(@resource,"ng_ds",[:title, :main_title])
|
26
|
-
generated_html.should have_tag "#title_main_title_0-container.editable-container"do
|
27
|
-
with_tag "span#title_main_title_0-text.editable-text.text", "My Title"
|
28
|
-
with_tag "input#title_main_title_0.editable-edit.edit" do
|
29
|
-
with_tag "[value=?]", "My Title"
|
30
|
-
with_tag "[name=?]","asset[ng_ds][title_main_title][0]"
|
31
|
-
with_tag "[data-datastream-name=?]", "ng_ds"
|
32
|
-
with_tag "[rel=?]", "title_main_title"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
it "should generate an ordered list of text field inputs" do
|
37
|
-
generated_html = helper.fedora_text_field(@resource,"simple_ds","subject")
|
38
|
-
generated_html.should have_tag "ol[rel=subject]" do
|
39
|
-
with_tag "li#subject_0-container.editable-container.field" do
|
40
|
-
with_tag "a.destructive.field"
|
41
|
-
with_tag "span#subject_0-text.editable-text.text", "topic1"
|
42
|
-
with_tag "input#subject_0.editable-edit.edit" do
|
43
|
-
with_tag "[value=?]", "topic1"
|
44
|
-
with_tag "[name=?]", "asset[simple_ds][subject][0]"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
with_tag "li#subject_1-container.editable-container.field" do
|
48
|
-
with_tag "a.destructive.field"
|
49
|
-
with_tag "span#subject_1-text.editable-text.text", "topic2"
|
50
|
-
with_tag "input#subject_1.editable-edit.edit" do
|
51
|
-
with_tag "[value=?]", "topic2"
|
52
|
-
with_tag "[name=?]", "asset[simple_ds][subject][1]"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
generated_html.should have_tag "input", :class=>"editable-edit", :id=>"subject_1", :name=>"asset[simple_ds][subject_1]", :value=>"topic9"
|
57
|
-
end
|
58
|
-
it "should render an empty control if the field has no values" do
|
59
|
-
helper.fedora_text_field(@resource,"empty_ds","something").should have_tag "li#something_0-container.editable-container" do
|
60
|
-
with_tag "#something_0-text.editable-text.text", ""
|
61
|
-
end
|
62
|
-
end
|
63
|
-
it "should limit to single-value output with no ordered list if :multiple=>false" do
|
64
|
-
generated_html = helper.fedora_text_field(@resource,"simple_ds","subject", :multiple=>false)
|
65
|
-
generated_html.should_not have_tag "ol"
|
66
|
-
generated_html.should_not have_tag "li"
|
67
|
-
|
68
|
-
generated_html.should have_tag "span#subject-container.editable-container.field" do
|
69
|
-
with_tag "span#subject-text.editable-text.text", "topic1"
|
70
|
-
with_tag "input#subject.editable-edit.edit[value=topic1]" do
|
71
|
-
with_tag "[name=?]", "asset[simple_ds][subject][0]"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "fedora_text_area" do
|
78
|
-
it "should generate an ordered list of textile-enabled text area with values from the given datastream" do
|
79
|
-
helper.fedora_text_area(@resource,"simple_ds","subject").should have_tag "ol[rel=subject]" do
|
80
|
-
with_tag "li#subject_0-container.field" do
|
81
|
-
without_tag "a.destructive.field"
|
82
|
-
with_tag "span#subject_0-text.editable-text.text[style=display:none;]", "topic1"
|
83
|
-
with_tag "textarea#subject_0.editable-edit.edit", "topic1"
|
84
|
-
end
|
85
|
-
with_tag "li#subject_1-container.field" do
|
86
|
-
with_tag "span#subject_1-text.editable-text.text[style=display:none;]","topic2"
|
87
|
-
with_tag "textarea#subject_1.editable-edit.edit", "topic2"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
it "should render an empty control if the field has no values" do
|
92
|
-
helper.fedora_text_area(@resource,"empty_ds","something").should have_tag "li#something_0-container.field" do
|
93
|
-
with_tag "span#something_0-text.editable-text.text[style=display:none;]", ""
|
94
|
-
with_tag "textarea#something_0.editable-edit.edit", ""
|
95
|
-
end
|
96
|
-
end
|
97
|
-
it "should limit to single-value output if :multiple=>false" do
|
98
|
-
generated_html = helper.fedora_text_area(@resource,"simple_ds","subject", :multiple=>false)
|
99
|
-
generated_html.should_not have_tag "ol"
|
100
|
-
generated_html.should_not have_tag "li"
|
101
|
-
generated_html.should have_tag "span#subject-container.field" do
|
102
|
-
with_tag "span#subject-text.editable-text.text[style=display:none;]", "topic1"
|
103
|
-
with_tag "textarea#subject.editable-edit.edit", "topic1"
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "fedora_select" do
|
109
|
-
it "should generate a select with values from the given datastream" do
|
110
|
-
generated_html = helper.fedora_select(@resource,"simple_ds","subject", :choices=>["topic1","topic2", "topic3"])
|
111
|
-
generated_html.should have_tag "select.metadata-dd[name=?]", "asset[simple_ds][subject][0]" do
|
112
|
-
with_tag "[rel=?]", "subject"
|
113
|
-
with_tag "option[value=topic1][selected=selected]"
|
114
|
-
with_tag "option[value=topic2][selected=selected]"
|
115
|
-
with_tag "option[value=topic3]"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
it "should return the product of fedora_text_field if :choices is not set" do
|
119
|
-
helper.expects(:fedora_text_field).returns("fake response")
|
120
|
-
generated_html = helper.fedora_select(@resource,"simple_ds","subject")
|
121
|
-
generated_html.should == "fake response"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe "fedora_date_select" do
|
126
|
-
it "should generate a date picker with values from the given datastream" do
|
127
|
-
generated_html = helper.fedora_date_select(@resource,"simple_ds","subject")
|
128
|
-
generated_html.should have_tag ".date-select[name=?]", "asset[simple_ds][subject]" do
|
129
|
-
with_tag "[rel=?]", "subject"
|
130
|
-
with_tag "input#subject-sel-y.controlled-date-part.w4em"
|
131
|
-
with_tag "select#subject-sel-mm.controlled-date-part" do
|
132
|
-
with_tag "option[value=01]", "January"
|
133
|
-
with_tag "option[value=12]", "December"
|
134
|
-
end
|
135
|
-
with_tag "select#subject-sel-dd.controlled-date-part" do
|
136
|
-
with_tag "option[value=01]", "01"
|
137
|
-
with_tag "option[value=31]", "31"
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
describe "fedora_checkbox" do
|
145
|
-
it "should generate a set of checkboxes with values from the given datastream"
|
146
|
-
end
|
147
|
-
|
148
|
-
describe "all field generators" do
|
149
|
-
it "should include any necessary field_selector info" do
|
150
|
-
field_selectors_regexp = helper.field_selectors_for("ng_ds",[:title, :main_title]).gsub('/','\/').gsub(']','\]').gsub('[','\[')
|
151
|
-
["fedora_text_field", "fedora_text_area", "fedora_select", "fedora_date_select"].each do |method|
|
152
|
-
generated_html = eval("helper.#{method}(@resource,\"ng_ds\",[:title, :main_title])")
|
153
|
-
generated_html.should match( field_selectors_regexp )
|
154
|
-
end
|
155
|
-
generated_html = helper.fedora_select(@resource,"ng_ds",[:title, :main_title], :choices=>["choice1"])
|
156
|
-
generated_html.should match( field_selectors_regexp )
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe "fedora_text_field_insert_link" do
|
161
|
-
it "should generate a link for inserting a fedora_text_field into the page" do
|
162
|
-
helper.fedora_text_field_insert_link("ng_ds",[:title, :main_title]).should have_tag "a.addval.textfield[href=\#]"
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
describe "fedora_text_area_insert_link" do
|
167
|
-
it "should generate a link for inserting a fedora_text_area into the page" do
|
168
|
-
helper.fedora_text_area_insert_link("ng_ds",[:title, :main_title]).should have_tag "a.addval.textarea[href=\#]"
|
169
|
-
end
|
170
|
-
|
171
|
-
end
|
172
|
-
|
173
|
-
describe "fedora_field_label" do
|
174
|
-
it "should generate a label with appropriate @for attribute" do
|
175
|
-
params[:action] = "edit"
|
176
|
-
helper.fedora_field_label("ng_ds",[:title, :main_title], "Title:").should have_tag "label[for=title_main_title]", "Title:"
|
177
|
-
end
|
178
|
-
it "should display the field name if no label is provided" do
|
179
|
-
params[:action] = "edit"
|
180
|
-
helper.fedora_field_label("ng_ds",[:title, :main_title]).should have_tag "label[for=title_main_title]", "title_main_title"
|
181
|
-
end
|
182
|
-
it "should return a span and not a label when we are not editing the object" do
|
183
|
-
params[:action] = "show"
|
184
|
-
helper.fedora_field_label("ng_ds",[:title, :main_title]).should have_tag "span","title_main_title"
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe "field_selectors_for" do
|
189
|
-
it "should generate any necessary field_selector values for the given field" do
|
190
|
-
generated_html = helper.field_selectors_for("myDsName", [{:name => 3}, :name_part])
|
191
|
-
generated_html.should have_tag "input.fieldselector[type=hidden][name=?]", "field_selectors[myDsName][name_3_name_part][][name]" do
|
192
|
-
with_tag "[rel=name_3_name_part]"
|
193
|
-
with_tag "[value=3]"
|
194
|
-
end
|
195
|
-
generated_html.should have_tag "input.fieldselector[type=hidden][name=?]", "field_selectors[myDsName][name_3_name_part][]" do
|
196
|
-
with_tag "[rel=name_3_name_part]"
|
197
|
-
with_tag "[value=name_part]"
|
198
|
-
end
|
199
|
-
# ordering is important. this next line makes sure that the inputs are in the correct order
|
200
|
-
# (tried using CSS3 nth-of-type selectors in have_tag but it didn't work)
|
201
|
-
generated_html.should match(/<input.*name="field_selectors\[myDsName\]\[name_3_name_part\]\[\]\[name\]".*\/><input.*name="field_selectors\[myDsName\]\[name_3_name_part\]\[\].*value="name_part" .*\/>/)
|
202
|
-
end
|
203
|
-
it "should not generate any field selectors if the field key is not an array" do
|
204
|
-
helper.field_selectors_for("myDsName", :description).should == ""
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
describe "hydra_form_for" do
|
209
|
-
it "should generate an entire form" do
|
210
|
-
pending
|
211
|
-
eval_erb(%(
|
212
|
-
<% hydra_form_for @resource do |h| %>
|
213
|
-
<h2>Hello</h2>
|
214
|
-
<%= h.fedora_text_field %>
|
215
|
-
<% end %>
|
216
|
-
)).should match_html("<h2>Hello</h2> blah blah blah ")
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
data/spec-rails2/spec_helper.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
2
|
-
# from the project root directory.
|
3
|
-
ENV["RAILS_ENV"] ||= 'test'
|
4
|
-
|
5
|
-
# Overrides require_plugin_dependency, pointing to plugins within dummy app
|
6
|
-
# Original require_plugin_dependency method defined in init.rb
|
7
|
-
def require_plugin_dependency(dependency_path)
|
8
|
-
modified_path = File.join(File.dirname(__FILE__), "..","hydra-plugin_test_host", dependency_path)
|
9
|
-
p "(spec_helper) Re-routing require path to: #{modified_path}"
|
10
|
-
require_dependency modified_path
|
11
|
-
end
|
12
|
-
|
13
|
-
require File.dirname(__FILE__) + "/../hydra-plugin_test_host/config/environment" unless defined?(RAILS_ROOT)
|
14
|
-
|
15
|
-
# This ensures that the current plugin's models, helpers and controllers are loaded last
|
16
|
-
# Dir["app/helpers/*.rb"].each {|f| require f }
|
17
|
-
# Dir["app/models/*.rb"].each {|f| require f}
|
18
|
-
# Dir["app/controllers/*.rb"].each {|f| require f} # Loading the controllers a second time messes up the method aliasing for CatalogController.show
|
19
|
-
|
20
|
-
require 'spec/autorun'
|
21
|
-
require 'spec/rails'
|
22
|
-
|
23
|
-
# Requires supporting files with custom matchers and macros, etc,
|
24
|
-
# in ./support/ and its subdirectories.
|
25
|
-
# Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
26
|
-
Dir[File.join(File.dirname(__FILE__), "support", "**", "*.rb")].each {|f| require f}
|
27
|
-
|
28
|
-
Spec::Runner.configure do |config|
|
29
|
-
# If you're not using ActiveRecord you should remove these
|
30
|
-
# lines, delete config/database.yml and disable :active_record
|
31
|
-
# in your config/boot.rb
|
32
|
-
# config.use_transactional_fixtures = true
|
33
|
-
# config.use_instantiated_fixtures = false
|
34
|
-
# config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
35
|
-
|
36
|
-
# == Fixtures
|
37
|
-
#
|
38
|
-
# You can declare fixtures for each example_group like this:
|
39
|
-
# describe "...." do
|
40
|
-
# fixtures :table_a, :table_b
|
41
|
-
#
|
42
|
-
# Alternatively, if you prefer to declare them only once, you can
|
43
|
-
# do so right here. Just uncomment the next line and replace the fixture
|
44
|
-
# names with your fixtures.
|
45
|
-
#
|
46
|
-
# config.global_fixtures = :table_a, :table_b
|
47
|
-
#
|
48
|
-
# If you declare global fixtures, be aware that they will be declared
|
49
|
-
# for all of your examples, even those that don't use them.
|
50
|
-
#
|
51
|
-
# You can also declare which fixtures to use (for example fixtures for test/fixtures):
|
52
|
-
#
|
53
|
-
# config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
54
|
-
#
|
55
|
-
# == Mock Framework
|
56
|
-
#
|
57
|
-
# RSpec uses it's own mocking framework by default. If you prefer to
|
58
|
-
# use mocha, flexmock or RR, uncomment the appropriate line:
|
59
|
-
#
|
60
|
-
config.mock_with :mocha
|
61
|
-
# config.mock_with :flexmock
|
62
|
-
# config.mock_with :rr
|
63
|
-
#
|
64
|
-
# == Notes
|
65
|
-
#
|
66
|
-
# For more information take a look at Spec::Runner::Configuration and Spec::Runner
|
67
|
-
|
68
|
-
def fixture(file)
|
69
|
-
File.new(File.join(File.dirname(__FILE__), 'fixtures', file))
|
70
|
-
end
|
71
|
-
|
72
|
-
def match_html(html)
|
73
|
-
# Match two strings, but don't care about whitespace
|
74
|
-
simple_matcher("should match #{html}"){|given| given.strip.gsub(/\s+/,' ').gsub('> <','><') == html.strip.gsub(/\s+/,' ').gsub('> <','><') }
|
75
|
-
end
|
76
|
-
|
77
|
-
def connect_bl_solr
|
78
|
-
# @connection = Solr::Connection.new( SHELVER_SOLR_URL, :autocommit => :on )
|
79
|
-
if defined?(@index_full_text) && @index_full_text
|
80
|
-
url = Blacklight.solr_config['fulltext']['url']
|
81
|
-
else
|
82
|
-
url = Blacklight.solr_config[:url]
|
83
|
-
end
|
84
|
-
|
85
|
-
@bl_solr = Solr::Connection.new(url, :autocommit => :on )
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|