blacklight 4.7.0 → 4.8.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +13 -12
- data/Gemfile +37 -2
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/{_blacklight_base.css.scss → _blacklight_base.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_bookmark.css.scss → _bookmark.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_catalog.css.scss → _catalog.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_dropdown.css.scss → _dropdown.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_facets.css.scss → _facets.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_footer.css.scss → _footer.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_group.css.scss → _group.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_header.css.scss → _header.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_layout.css.scss → _layout.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_mixins.css.scss → _mixins.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_modal.css.scss → _modal.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_print.css.scss → _print.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_responsive.css.scss → _responsive.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_search_history.css.scss → _search_history.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{blacklight.css.scss → blacklight.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{blacklight_defaults.css.scss → blacklight_defaults.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_catalog.css.scss → _catalog.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_facets.css.scss → _facets.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_header.css.scss → _header.scss} +0 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +2 -2
- data/blacklight.gemspec +5 -6
- data/lib/blacklight/catalog.rb +1 -1
- data/lib/blacklight/catalog/search_context.rb +6 -6
- data/lib/blacklight/solr/document.rb +29 -21
- data/lib/blacklight/solr_helper.rb +6 -4
- data/lib/generators/blacklight/templates/{blacklight.css.scss → blacklight.scss} +0 -0
- data/spec/controllers/application_controller_spec.rb +3 -3
- data/spec/controllers/bookmarks_controller_spec.rb +11 -11
- data/spec/controllers/catalog_controller_spec.rb +117 -117
- data/spec/controllers/search_history_controller_spec.rb +8 -8
- data/spec/features/alternate_controller_spec.rb +7 -5
- data/spec/features/record_view_spec.rb +4 -1
- data/spec/features/search_filters_spec.rb +37 -24
- data/spec/features/search_pagination_spec.rb +11 -7
- data/spec/features/search_results_spec.rb +22 -14
- data/spec/features/search_sort_spec.rb +3 -1
- data/spec/features/search_spec.rb +6 -0
- data/spec/helpers/blacklight_helper_spec.rb +175 -166
- data/spec/helpers/catalog_helper_spec.rb +59 -59
- data/spec/helpers/facets_helper_spec.rb +118 -118
- data/spec/helpers/hash_as_hidden_fields_spec.rb +14 -8
- data/spec/helpers/html_head_helper_spec.rb +51 -45
- data/spec/helpers/render_constraints_helper_spec.rb +5 -6
- data/spec/helpers/search_history_constraints_helper_spec.rb +21 -21
- data/spec/lib/blacklight/solr_response/group_response_spec.rb +2 -2
- data/spec/lib/blacklight_configurable_spec.rb +16 -16
- data/spec/lib/blacklight_configuration_spec.rb +132 -132
- data/spec/lib/blacklight_email_spec.rb +4 -4
- data/spec/lib/blacklight_sms_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_dublin_core_spec.rb +6 -6
- data/spec/lib/blacklight_solr_document_marc_spec.rb +3 -3
- data/spec/lib/blacklight_solr_document_more_like_this_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_spec.rb +36 -36
- data/spec/lib/blacklight_solr_response_spec.rb +42 -42
- data/spec/lib/blacklight_spec.rb +5 -5
- data/spec/lib/blacklight_user_spec.rb +5 -5
- data/spec/lib/facet_paginator_spec.rb +12 -12
- data/spec/lib/marc_export_spec.rb +746 -746
- data/spec/lib/search_fields_spec.rb +13 -13
- data/spec/lib/solr_helper_spec.rb +255 -250
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
- data/spec/lib/tasks/solr_marc_task_spec.rb +6 -6
- data/spec/lib/utils_spec.rb +11 -11
- data/spec/models/bookmark_spec.rb +7 -6
- data/spec/models/record_mailer_spec.rb +16 -16
- data/spec/models/search_spec.rb +8 -8
- data/spec/models/solr_document_spec.rb +7 -7
- data/spec/requests/alternate_controller_spec.rb +3 -3
- data/spec/routing/catalog_routing_spec.rb +10 -15
- data/spec/spec_helper.rb +6 -4
- data/spec/support/assert_difference.rb +2 -2
- data/spec/support/features.rb +11 -0
- data/spec/support/features/session_helpers.rb +3 -3
- data/spec/support/include_text.rb +2 -2
- data/spec/test_app_templates/Gemfile.extra +2 -15
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +17 -6
- data/spec/views/catalog/_constraints.html.erb_spec.rb +7 -7
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +12 -12
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +13 -13
- data/spec/views/catalog/_index_default.erb_spec.rb +20 -20
- data/spec/views/catalog/_show_default.erb_spec.rb +20 -20
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +6 -6
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +28 -28
- data/spec/views/catalog/index.html.erb_spec.rb +6 -6
- metadata +35 -57
- data/gemfiles/rails3.gemfile +0 -25
- data/gemfiles/rails4.gemfile +0 -24
|
@@ -15,7 +15,7 @@ describe "blacklight:delete_old_searches" do
|
|
|
15
15
|
|
|
16
16
|
it "should call Search.delete_old_searches" do
|
|
17
17
|
days_old = 7
|
|
18
|
-
Search.
|
|
18
|
+
expect(Search).to receive(:delete_old_searches).with(days_old)
|
|
19
19
|
@rake[@task_name].invoke(days_old)
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -32,7 +32,7 @@ describe "solr:marc:*" do
|
|
|
32
32
|
@rake['solr:marc:index_test_data'].invoke
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
o.
|
|
35
|
+
expect(o).to match(Regexp.escape("SolrMarc command that will be run:"))
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -48,11 +48,11 @@ describe "solr:marc:*" do
|
|
|
48
48
|
output =~ /SolrMarc command that will be run:\n\s*\n\s*(.*)\n/
|
|
49
49
|
java_cmd = $1
|
|
50
50
|
|
|
51
|
-
java_cmd.
|
|
52
|
-
java_cmd.
|
|
53
|
-
java_cmd.
|
|
54
|
-
java_cmd.
|
|
55
|
-
java_cmd.
|
|
51
|
+
expect(java_cmd).not_to be_nil
|
|
52
|
+
expect(java_cmd).to match "java -Xmx512m"
|
|
53
|
+
expect(java_cmd).to match /-jar .*\/SolrMarc\.jar/
|
|
54
|
+
expect(java_cmd).to match "#{Rails.root}/config/SolrMarc/config-test.properties dummy.mrc"
|
|
55
|
+
expect(java_cmd).to match "-Dsolr.hosturl=http://127.0.0.1:[0-9]{2,5}/solr"
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
end
|
data/spec/lib/utils_spec.rb
CHANGED
|
@@ -6,16 +6,16 @@ describe 'Blacklight::Utils' do
|
|
|
6
6
|
it "should provide hash-like accessors for OpenStruct data" do
|
|
7
7
|
a = Blacklight::OpenStructWithHashAccess.new :foo => :bar, :baz => 1
|
|
8
8
|
|
|
9
|
-
a[:foo].
|
|
10
|
-
a[:baz].
|
|
11
|
-
a[:asdf].
|
|
9
|
+
expect(a[:foo]).to eq(:bar)
|
|
10
|
+
expect(a[:baz]).to eq(1)
|
|
11
|
+
expect(a[:asdf]).to be_nil
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it "should provide hash-like writers for OpenStruct data" do
|
|
15
15
|
a = Blacklight::OpenStructWithHashAccess.new :foo => :bar, :baz => 1
|
|
16
16
|
|
|
17
17
|
a[:asdf] = 'qwerty'
|
|
18
|
-
a.asdf.
|
|
18
|
+
expect(a.asdf).to eq('qwerty')
|
|
19
19
|
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -23,12 +23,12 @@ describe 'Blacklight::Utils' do
|
|
|
23
23
|
h = Blacklight::OpenStructWithHashAccess.new
|
|
24
24
|
|
|
25
25
|
h["string"] = "value"
|
|
26
|
-
h[:string].
|
|
27
|
-
h.string.
|
|
26
|
+
expect(h[:string]).to eq("value")
|
|
27
|
+
expect(h.string).to eq("value")
|
|
28
28
|
|
|
29
29
|
h[:symbol] = "value"
|
|
30
|
-
h["symbol"].
|
|
31
|
-
h.symbol.
|
|
30
|
+
expect(h["symbol"]).to eq("value")
|
|
31
|
+
expect(h.symbol).to eq("value")
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
describe "internal hash table" do
|
|
@@ -39,12 +39,12 @@ describe 'Blacklight::Utils' do
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "should expose the internal hash table" do
|
|
42
|
-
@h.to_h.
|
|
43
|
-
@h.to_h[:a].
|
|
42
|
+
expect(@h.to_h).to be_a_kind_of(Hash)
|
|
43
|
+
expect(@h.to_h[:a]).to eq(1)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "should expose keys" do
|
|
47
|
-
@h.keys.
|
|
47
|
+
expect(@h.keys).to include(:a, :b)
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
@@ -5,20 +5,21 @@ describe Bookmark do
|
|
|
5
5
|
before(:each) do
|
|
6
6
|
@bookmark = Bookmark.new
|
|
7
7
|
end
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
it "should be valid" do
|
|
10
10
|
@bookmark.id = 1
|
|
11
11
|
@bookmark.user_id = 1
|
|
12
12
|
@bookmark.document_id = 'u001'
|
|
13
|
-
@bookmark.
|
|
13
|
+
expect(@bookmark).to be_valid
|
|
14
14
|
end
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
it "should require user_id" do
|
|
17
|
-
@bookmark.
|
|
17
|
+
expect(@bookmark).not_to be_valid
|
|
18
|
+
expect(@bookmark.errors[:user_id].length).to eq 1
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
it "should belong to user" do
|
|
21
|
-
Bookmark.reflect_on_association(:user).
|
|
22
|
+
expect(Bookmark.reflect_on_association(:user)).not_to be_nil
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
it "should be valid after saving" do
|
|
@@ -26,6 +27,6 @@ describe Bookmark do
|
|
|
26
27
|
@bookmark.user_id = 1
|
|
27
28
|
@bookmark.document_id = 'u001'
|
|
28
29
|
@bookmark.save
|
|
29
|
-
@bookmark.
|
|
30
|
+
expect(@bookmark).to be_valid
|
|
30
31
|
end
|
|
31
32
|
end
|
|
@@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
|
4
4
|
|
|
5
5
|
describe RecordMailer do
|
|
6
6
|
before(:each) do
|
|
7
|
-
RecordMailer.
|
|
7
|
+
allow(RecordMailer).to receive(:default) { { :from => 'no-reply@projectblacklight.org' } }
|
|
8
8
|
SolrDocument.use_extension( Blacklight::Solr::Document::Email )
|
|
9
9
|
SolrDocument.use_extension( Blacklight::Solr::Document::Sms )
|
|
10
10
|
document = SolrDocument.new({:id=>"123456", :format=>["book"], :title_display => "The horn", :language_facet => "English", :author_display => "Janetzky, Kurt"})
|
|
@@ -16,26 +16,26 @@ describe RecordMailer do
|
|
|
16
16
|
@email = RecordMailer.email_record(@documents,details,{:host =>'projectblacklight.org', :protocol => 'https'})
|
|
17
17
|
end
|
|
18
18
|
it "should receive the TO paramater and send the email to that address" do
|
|
19
|
-
@email.to.
|
|
19
|
+
expect(@email.to).to eq(['test@test.com'])
|
|
20
20
|
end
|
|
21
21
|
it "should start the subject w/ Item Record:" do
|
|
22
|
-
@email.subject.
|
|
22
|
+
expect(@email.subject).to match(/^Item Record:/)
|
|
23
23
|
end
|
|
24
24
|
it "should put the title of the item in the subject" do
|
|
25
|
-
@email.subject.
|
|
25
|
+
expect(@email.subject).to match(/The horn/)
|
|
26
26
|
end
|
|
27
27
|
it "should have the correct from address (w/o the port number)" do
|
|
28
|
-
@email.from.
|
|
28
|
+
expect(@email.from).to eq(["no-reply@projectblacklight.org"])
|
|
29
29
|
end
|
|
30
30
|
it "should print out the correct body" do
|
|
31
|
-
@email.body.
|
|
32
|
-
@email.body.
|
|
33
|
-
@email.body.
|
|
31
|
+
expect(@email.body).to match(/Title: The horn/)
|
|
32
|
+
expect(@email.body).to match(/Author: Janetzky, Kurt/)
|
|
33
|
+
expect(@email.body).to match(/projectblacklight.org/)
|
|
34
34
|
end
|
|
35
35
|
it "should use https URLs when protocol is set" do
|
|
36
36
|
details = {:to => 'test@test.com', :message => "This is my message"}
|
|
37
37
|
@https_email = RecordMailer.email_record(@documents,details,{:host =>'projectblacklight.org', :protocol => 'https'})
|
|
38
|
-
@https_email.body.
|
|
38
|
+
expect(@https_email.body).to match(%r|https://projectblacklight.org/|)
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -45,23 +45,23 @@ describe RecordMailer do
|
|
|
45
45
|
@sms = RecordMailer.sms_record(@documents,details,{:host =>'projectblacklight.org:3000'})
|
|
46
46
|
end
|
|
47
47
|
it "should create the correct TO address for the SMS email" do
|
|
48
|
-
@sms.to.
|
|
48
|
+
expect(@sms.to).to eq(['5555555555@txt.att.net'])
|
|
49
49
|
end
|
|
50
50
|
it "should not have a subject" do
|
|
51
|
-
@sms.subject.
|
|
51
|
+
expect(@sms.subject).to eq("") unless @sms.subject.nil?
|
|
52
52
|
end
|
|
53
53
|
it "should have the correct from address (w/o the port number)" do
|
|
54
|
-
@sms.from.
|
|
54
|
+
expect(@sms.from).to eq(["no-reply@projectblacklight.org"])
|
|
55
55
|
end
|
|
56
56
|
it "should print out the correct body" do
|
|
57
|
-
@sms.body.
|
|
58
|
-
@sms.body.
|
|
59
|
-
@sms.body.
|
|
57
|
+
expect(@sms.body).to match(/The horn/)
|
|
58
|
+
expect(@sms.body).to match(/by Janetzky, Kurt/)
|
|
59
|
+
expect(@sms.body).to match(/projectblacklight.org:3000/)
|
|
60
60
|
end
|
|
61
61
|
it "should use https URL when protocol is set" do
|
|
62
62
|
details = {:to => '5555555555@txt.att.net'}
|
|
63
63
|
@https_sms = RecordMailer.sms_record(@documents,details,{:host =>'projectblacklight.org', :protocol => 'https'})
|
|
64
|
-
@https_sms.body.
|
|
64
|
+
expect(@https_sms.body).to match(%r|https://projectblacklight.org/|)
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
|
data/spec/models/search_spec.rb
CHANGED
|
@@ -14,7 +14,7 @@ describe Search do
|
|
|
14
14
|
it "should return a Hash as the value" do
|
|
15
15
|
@search.query_params = @query_params
|
|
16
16
|
assert @search.save
|
|
17
|
-
Search.find(@search.id).query_params.
|
|
17
|
+
expect(Search.find(@search.id).query_params).to eq(@query_params)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -24,23 +24,23 @@ describe Search do
|
|
|
24
24
|
@search.user_id = 1
|
|
25
25
|
@search.save
|
|
26
26
|
|
|
27
|
-
@search.saved
|
|
27
|
+
expect(@search.saved?).to be_truthy
|
|
28
28
|
end
|
|
29
29
|
it "should be false when user_id is NULL or less than 1" do
|
|
30
30
|
@search = Search.create
|
|
31
|
-
@search.saved
|
|
31
|
+
expect(@search.saved?).not_to be_truthy
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
describe "delete_old_searches" do
|
|
36
36
|
it "should throw an ArgumentError if days_old is not a number" do
|
|
37
|
-
|
|
37
|
+
expect { Search.delete_old_searches("blah") }.to raise_error(ArgumentError)
|
|
38
38
|
end
|
|
39
39
|
it "should throw an ArgumentError if days_old is equal to 0" do
|
|
40
|
-
|
|
40
|
+
expect { Search.delete_old_searches(0) }.to raise_error(ArgumentError)
|
|
41
41
|
end
|
|
42
42
|
it "should throw an ArgumentError if days_old is less than 0" do
|
|
43
|
-
|
|
43
|
+
expect { Search.delete_old_searches(-1) }.to raise_error(ArgumentError)
|
|
44
44
|
end
|
|
45
45
|
it "should destroy searches with no user_id that are older than X days" do
|
|
46
46
|
Search.destroy_all
|
|
@@ -65,9 +65,9 @@ describe Search do
|
|
|
65
65
|
saved_search_past.created_at = Date.today - (days_old + 1).days
|
|
66
66
|
saved_search_past.save
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
expect do
|
|
69
69
|
Search.delete_old_searches(days_old)
|
|
70
|
-
end.
|
|
70
|
+
end.to change(Search, :count).by(-1)
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
end
|
|
@@ -52,22 +52,22 @@ end
|
|
|
52
52
|
|
|
53
53
|
describe "new" do
|
|
54
54
|
it "should take a Hash as the argument" do
|
|
55
|
-
|
|
55
|
+
expect { SolrDocument.new(@hash_with_marcxml) }.not_to raise_error
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
describe "access methods" do
|
|
60
60
|
|
|
61
61
|
it "should have the right value for title_display" do
|
|
62
|
-
@solrdoc[:title_display].
|
|
62
|
+
expect(@solrdoc[:title_display]).not_to be_nil
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
it "should have the right value for format" do
|
|
66
|
-
@solrdoc[:format][0].
|
|
66
|
+
expect(@solrdoc[:format][0]).to eq('Book')
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it "should provide the item's solr id" do
|
|
70
|
-
@solrdoc.id.
|
|
70
|
+
expect(@solrdoc.id).to eq('00282214')
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
@@ -76,8 +76,8 @@ end
|
|
|
76
76
|
it "should have a valid to_marc" do
|
|
77
77
|
@solrdoc = SolrDocument.new(@hash_with_marcxml)
|
|
78
78
|
|
|
79
|
-
@solrdoc.
|
|
80
|
-
@solrdoc.to_marc.
|
|
79
|
+
expect(@solrdoc).to respond_to(:to_marc)
|
|
80
|
+
expect(@solrdoc.to_marc).to be_kind_of(MARC::Record)
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
it "should not try to create marc for objects w/out stored marc (marcxml test only at this time)" do
|
|
@@ -85,7 +85,7 @@ end
|
|
|
85
85
|
# sure everything fails gracefully
|
|
86
86
|
@hash_without_marcxml = get_hash_without_marcxml['response']['docs'][0]
|
|
87
87
|
@solrdoc_without_marc = SolrDocument.new(@hash_without_marcxml)
|
|
88
|
-
@solrdoc_without_marc.
|
|
88
|
+
expect(@solrdoc_without_marc).not_to respond_to(:to_marc)
|
|
89
89
|
# legacy check
|
|
90
90
|
# @solrdoc_without_marc.should respond_to(:marc)
|
|
91
91
|
# @solrdoc_without_marc.marc.should == nil
|
|
@@ -6,11 +6,11 @@ describe "controllers that are not catalog controller" do
|
|
|
6
6
|
it "should have the correct search form" do
|
|
7
7
|
pending
|
|
8
8
|
visit alternate_index_path
|
|
9
|
-
page.
|
|
9
|
+
expect(page).to have_selector("form[action='#{alternate_index_path}']")
|
|
10
10
|
fill_in "q", :with=>"history"
|
|
11
11
|
click_button 'search'
|
|
12
12
|
# page.should have_link("startOverLink", :href=>alternate_index_path)
|
|
13
|
-
page.
|
|
14
|
-
page.
|
|
13
|
+
expect(page).to have_selector("form.per_page[action='#{alternate_index_path}']")
|
|
14
|
+
expect(page).to have_selector("form.sort[action='#{alternate_index_path}']")
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -4,50 +4,45 @@ describe "Routing" do
|
|
|
4
4
|
describe "Paths Generated by Custom Routes:" do
|
|
5
5
|
# paths generated by custom routes
|
|
6
6
|
it "should have a path for showing the email form" do
|
|
7
|
-
{ :get => "/catalog/email" }.
|
|
7
|
+
expect({ :get => "/catalog/email" }).to route_to(:controller => 'catalog', :action => 'email')
|
|
8
8
|
end
|
|
9
9
|
it "should have a path for sending the email" do
|
|
10
|
-
{ :post => "/catalog/email" }.
|
|
10
|
+
expect({ :post => "/catalog/email" }).to route_to(:controller => 'catalog', :action => 'email')
|
|
11
11
|
end
|
|
12
12
|
it "should map {:controller => 'catalog', :action => 'sms'} to /catalog/sms" do
|
|
13
|
-
{ :get => "/catalog/sms" }.
|
|
13
|
+
expect({ :get => "/catalog/sms" }).to route_to(:controller => 'catalog', :action => 'sms')
|
|
14
14
|
end
|
|
15
15
|
it "should map { :controller => 'catalog', :action => 'show', :id => 666 } to /catalog/666" do
|
|
16
|
-
{ :get => "/catalog/666" }.
|
|
16
|
+
expect({ :get => "/catalog/666" }).to route_to(:controller => 'catalog', :action => 'show', :id => "666")
|
|
17
17
|
end
|
|
18
18
|
it "should map {:controller => 'catalog', :id => '111', :action => 'librarian_view'} to /catalog/111/librarian_view" do
|
|
19
|
-
{ :get => "/catalog/111/librarian_view" }.
|
|
19
|
+
expect({ :get => "/catalog/111/librarian_view" }).to route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
describe "catalog_path for SolrDocument", :test => true do
|
|
25
25
|
it "should route correctly" do
|
|
26
|
-
{ :get => catalog_path(SolrDocument.new(:id => 'asdf')) }.
|
|
26
|
+
expect({ :get => catalog_path(SolrDocument.new(:id => 'asdf')) }).to route_to(:controller => 'catalog', :action => 'show', :id => 'asdf')
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
context "should escape solr document ids" do
|
|
30
30
|
|
|
31
31
|
it "should pass-through url-valid ids" do
|
|
32
|
-
{ :get => catalog_path(SolrDocument.new(:id => 'qwerty'))}.
|
|
32
|
+
expect({ :get => catalog_path(SolrDocument.new(:id => 'qwerty'))}).to route_to(:controller => 'catalog', :action => 'show', :id => 'qwerty')
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "should route url-like ids" do
|
|
36
36
|
pending "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
|
|
37
|
-
{ :get => catalog_path(SolrDocument.new(:id => 'http://example.com'))}.
|
|
37
|
+
expect({ :get => catalog_path(SolrDocument.new(:id => 'http://example.com'))}).to route_to(:controller => 'catalog', :action => 'show', :id => 'http://example.com')
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "should route ids with whitespace" do
|
|
41
|
-
{ :get => catalog_path(SolrDocument.new(:id => 'mm 123')) }.
|
|
41
|
+
expect({ :get => catalog_path(SolrDocument.new(:id => 'mm 123')) }).to route_to(:controller => 'catalog', :action => 'show', :id => 'mm 123')
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "should route ids with a literal '+'" do
|
|
45
|
-
{ :get => catalog_path(SolrDocument.new(:id => 'this+that')) }.
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "should route ids with a literal '/" do
|
|
49
|
-
pending "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
|
|
50
|
-
{ :get => catalog_path(SolrDocument.new(:id => 'and/or')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'and/or')
|
|
45
|
+
expect({ :get => catalog_path(SolrDocument.new(:id => 'this+that')) }).to route_to(:controller => 'catalog', :action => 'show', :id => 'this+that')
|
|
51
46
|
end
|
|
52
47
|
end
|
|
53
48
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
|
2
2
|
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
3
3
|
# Has been customized by Blacklight to work when application is in one place,
|
|
4
|
-
# and actual spec/ stuff is in another (the blacklight gem checkout).
|
|
4
|
+
# and actual spec/ stuff is in another (the blacklight gem checkout).
|
|
5
5
|
|
|
6
6
|
ENV["RAILS_ENV"] ||= 'test'
|
|
7
7
|
|
|
@@ -23,7 +23,7 @@ require 'rspec/rails'
|
|
|
23
23
|
require 'capybara/rspec'
|
|
24
24
|
require 'capybara/poltergeist'
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Capybara.server = :webrick
|
|
27
27
|
Capybara.javascript_driver = :poltergeist
|
|
28
28
|
|
|
29
29
|
Capybara.register_driver :poltergeist do |app|
|
|
@@ -36,8 +36,8 @@ end
|
|
|
36
36
|
|
|
37
37
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
38
38
|
# in spec/support/ and its subdirectories.
|
|
39
|
-
# Blacklight, again, make sure we're looking in the right place for em.
|
|
40
|
-
# Relative to HERE, NOT to Rails.root, which is off somewhere else.
|
|
39
|
+
# Blacklight, again, make sure we're looking in the right place for em.
|
|
40
|
+
# Relative to HERE, NOT to Rails.root, which is off somewhere else.
|
|
41
41
|
Dir[Pathname.new(File.expand_path("../support/**/*.rb", __FILE__))].each {|f| require f}
|
|
42
42
|
|
|
43
43
|
RSpec.configure do |config|
|
|
@@ -57,4 +57,6 @@ RSpec.configure do |config|
|
|
|
57
57
|
# examples within a transaction, remove the following line or assign false
|
|
58
58
|
# instead of true.
|
|
59
59
|
config.use_transactional_fixtures = true
|
|
60
|
+
|
|
61
|
+
config.infer_spec_type_from_file_location!
|
|
60
62
|
end
|
|
@@ -5,13 +5,13 @@ def assert_difference(executable, how_many = 1, &block)
|
|
|
5
5
|
before = eval(executable)
|
|
6
6
|
yield
|
|
7
7
|
after = eval(executable)
|
|
8
|
-
after.
|
|
8
|
+
expect(after).to eq(before + how_many)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def assert_no_difference(executable, &block)
|
|
12
12
|
before = eval(executable)
|
|
13
13
|
yield
|
|
14
14
|
after = eval(executable)
|
|
15
|
-
after.
|
|
15
|
+
expect(after).to eq(before)
|
|
16
16
|
end
|
|
17
17
|
|
data/spec/support/features.rb
CHANGED
|
@@ -4,4 +4,15 @@ require File.expand_path("../features/session_helpers.rb", __FILE__)
|
|
|
4
4
|
|
|
5
5
|
RSpec.configure do |config|
|
|
6
6
|
config.include Features::SessionHelpers, type: :feature
|
|
7
|
+
|
|
8
|
+
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
|
9
|
+
# from the file location. You can explicitly opt-in to the feature using this
|
|
10
|
+
# config option.
|
|
11
|
+
# To explicitly tag specs without using automatic inference, set the `:type`
|
|
12
|
+
# metadata manually:
|
|
13
|
+
#
|
|
14
|
+
# describe ThingsController, :type => :controller do
|
|
15
|
+
# # Equivalent to being in spec/controllers
|
|
16
|
+
# end
|
|
17
|
+
config.infer_spec_type_from_file_location!
|
|
7
18
|
end
|
|
@@ -14,9 +14,9 @@ module Features
|
|
|
14
14
|
email = "#{login}@#{login}.com"
|
|
15
15
|
user = User.create(:email => email, :password => "password", :password_confirmation => "password")
|
|
16
16
|
visit new_user_session_path
|
|
17
|
-
fill_in("user_email", :with => email)
|
|
18
|
-
fill_in("user_password", :with => "password")
|
|
19
|
-
click_button("
|
|
17
|
+
fill_in("user_email", :with => email)
|
|
18
|
+
fill_in("user_password", :with => "password")
|
|
19
|
+
click_button("Log in")
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
end
|