hydra-collections 7.0.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Changelog.md +5 -4
  4. data/Gemfile +2 -1
  5. data/README.md +2 -11
  6. data/app/controllers/concerns/hydra/collections_controller_behavior.rb +18 -8
  7. data/app/helpers/collections_helper.rb +6 -2
  8. data/app/models/concerns/hydra/collections/metadata.rb +2 -2
  9. data/app/views/collections/_button_remove_from_collection.html.erb +4 -6
  10. data/app/views/collections/_document_header.html.erb +1 -4
  11. data/app/views/collections/_form.html.erb +7 -7
  12. data/app/views/collections/_search_form.html.erb +4 -4
  13. data/app/views/collections/show.html.erb +29 -5
  14. data/app/views/layouts/collections.html.erb +0 -1
  15. data/hydra-collections.gemspec +1 -0
  16. data/lib/hydra-collections.rb +0 -1
  17. data/lib/hydra/collections/version.rb +1 -1
  18. data/solr/config/_rest_managed.json +3 -0
  19. data/solr/config/admin-extra.html +31 -0
  20. data/solr/config/elevate.xml +36 -0
  21. data/solr/config/mapping-ISOLatin1Accent.txt +246 -0
  22. data/solr/config/protwords.txt +21 -0
  23. data/solr/config/schema.xml +372 -0
  24. data/solr/config/scripts.conf +24 -0
  25. data/solr/config/solrconfig.xml +300 -0
  26. data/solr/config/spellings.txt +2 -0
  27. data/solr/config/stopwords.txt +58 -0
  28. data/solr/config/stopwords_en.txt +58 -0
  29. data/solr/config/synonyms.txt +31 -0
  30. data/solr/config/xslt/example.xsl +132 -0
  31. data/solr/config/xslt/example_atom.xsl +67 -0
  32. data/solr/config/xslt/example_rss.xsl +66 -0
  33. data/solr/config/xslt/luke.xsl +337 -0
  34. data/spec/controllers/catalog_controller_spec.rb +6 -14
  35. data/spec/controllers/collections_controller_spec.rb +67 -61
  36. data/spec/controllers/other_collections_controller_spec.rb +1 -1
  37. data/spec/controllers/selects_collections_spec.rb +33 -33
  38. data/spec/factories.rb +10 -1
  39. data/spec/factories/users.rb +1 -11
  40. data/spec/features/create_collection_spec.rb +17 -0
  41. data/spec/helpers/collections_helper_spec.rb +44 -35
  42. data/spec/models/collection_spec.rb +8 -10
  43. data/spec/spec_helper.rb +9 -0
  44. data/spec/test_app_templates/app/views/catalog/_sort_and_per_page.html.erb +2 -3
  45. data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -4
  46. data/spec/views/collections/_form.html.erb_spec.rb +15 -0
  47. data/spec/views/collections/show.html.erb_spec.rb +1 -1
  48. data/tasks/hydra-collections-dev.rake +6 -6
  49. metadata +37 -14
  50. data/app/helpers/collections_search_helper.rb +0 -11
  51. data/app/models/concerns/hydra/collections/actions.rb +0 -22
  52. data/config/jetty.yml +0 -6
  53. data/lib/hydra/collections/collectible.rb +0 -25
  54. data/spec/helpers/collections_search_helper_spec.rb +0 -16
  55. data/spec/lib/collectible_spec.rb +0 -39
  56. data/spec/test_app_templates/config/blacklight.yml +0 -22
  57. data/tasks/jetty.rake +0 -40
@@ -1,16 +1,6 @@
1
1
  FactoryGirl.define do
2
2
  factory :user, :class => User do |u|
3
- email 'jilluser@example.com'
4
- password 'password'
5
- end
6
-
7
- factory :archivist, :class => User do |u|
8
- email 'archivist1@example.com'
9
- password 'password'
10
- end
11
-
12
- factory :curator, :class => User do |u|
13
- email 'curator1@example.com'
3
+ sequence(:email) { |n| "user#{n}@example.com" }
14
4
  password 'password'
15
5
  end
16
6
  end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Creating collection" do
4
+ let(:user) { FactoryGirl.create(:user) }
5
+ before do
6
+ login_as(user, scope: :user)
7
+ visit '/collections'
8
+ end
9
+
10
+ specify do
11
+ click_button 'Create Collection'
12
+ fill_in 'Title', with: 'Test title'
13
+ fill_in 'Description', with: 'Test description'
14
+ click_button 'Create Collection'
15
+ expect(page).to have_content 'Test title'
16
+ end
17
+ end
@@ -3,8 +3,21 @@ require 'spec_helper'
3
3
  include Hydra::Collections::Engine.routes.url_helpers
4
4
 
5
5
  describe CollectionsHelper, :type => :helper do
6
+ describe "has_collection_search_parameters?" do
7
+ subject { helper }
8
+ context "when cq is set" do
9
+ before { allow(helper).to receive(:params).and_return(cq: 'foo') }
10
+ it { is_expected.to have_collection_search_parameters }
11
+ end
12
+
13
+ context "when cq is not set" do
14
+ before { allow(helper).to receive(:params).and_return(cq: '') }
15
+ it { is_expected.not_to have_collection_search_parameters }
16
+ end
17
+ end
18
+
6
19
  describe "button_for_create_collection" do
7
- it " should create a button to the collections new path" do
20
+ it "creates a button to the collections new path" do
8
21
  str = String.new(helper.button_for_create_collection)
9
22
  doc = Nokogiri::HTML(str)
10
23
  form = doc.xpath('//form').first
@@ -12,7 +25,8 @@ describe CollectionsHelper, :type => :helper do
12
25
  i = form.xpath('.//input').first
13
26
  expect(i.attr('type')).to eq('submit')
14
27
  end
15
- it "should create a button with my text" do
28
+
29
+ it "creates a button with my text" do
16
30
  str = String.new(helper.button_for_create_collection "Create My Button")
17
31
  doc = Nokogiri::HTML(str)
18
32
  form = doc.xpath('//form').first
@@ -21,39 +35,37 @@ describe CollectionsHelper, :type => :helper do
21
35
  expect(i.attr('value')).to eq('Create My Button')
22
36
  end
23
37
  end
38
+
24
39
  describe "button_for_delete_collection" do
25
- before do
26
- @collection = Collection.create(title: "Test Public")
27
- end
40
+ let(:collection) { FactoryGirl.create(:collection) }
28
41
 
29
- it " should create a button to the collections delete path" do
30
- str = button_for_delete_collection @collection
42
+ it "creates a button to the collections delete path" do
43
+ str = button_for_delete_collection collection
31
44
  doc = Nokogiri::HTML(str)
32
45
  form = doc.xpath('//form').first
33
- expect(form.attr('action')).to eq collections.collection_path(@collection)
46
+ expect(form.attr('action')).to eq collections.collection_path(collection)
34
47
  i = form.xpath('.//input')[1]
35
48
  expect(i.attr('type')).to eq('submit')
36
49
  end
37
- it "should create a button with my text" do
38
- str = button_for_delete_collection @collection, "Delete My Button"
50
+ it "creates a button with my text" do
51
+ str = button_for_delete_collection collection, "Delete My Button"
39
52
  doc = Nokogiri::HTML(str)
40
53
  form = doc.xpath('//form').first
41
- expect(form.attr('action')).to eq collections.collection_path(@collection)
54
+ expect(form.attr('action')).to eq collections.collection_path(collection)
42
55
  i = form.xpath('.//input')[1]
43
56
  expect(i.attr('value')).to eq("Delete My Button")
44
57
  end
45
58
  end
59
+
46
60
  describe "button_for_remove_from_collection" do
47
- let(:item) { double(id: 'changeme:123') }
48
- before do
49
- @collection = Collection.create
50
- end
61
+ let(:item) { double(id: 'changeme:123') }
62
+ let(:collection) { FactoryGirl.create(:collection) }
51
63
 
52
- it "should generate a form that can remove the item" do
53
- str = button_for_remove_from_collection item
64
+ it "generates a form that can remove the item" do
65
+ str = button_for_remove_from_collection collection, item
54
66
  doc = Nokogiri::HTML(str)
55
67
  form = doc.xpath('//form').first
56
- expect(form.attr('action')).to eq collections.collection_path(@collection)
68
+ expect(form.attr('action')).to eq collections.collection_path(collection)
57
69
  expect(form.css('input#collection_members[type="hidden"][value="remove"]')).not_to be_empty
58
70
  expect(form.css('input[type="hidden"][name="batch_document_ids[]"][value="changeme:123"]')).not_to be_empty
59
71
  end
@@ -64,52 +76,50 @@ describe CollectionsHelper, :type => :helper do
64
76
  include Hydra::Collection
65
77
  include Hydra::Works::WorkBehavior
66
78
  end
67
-
68
- @collection = OtherCollection.create
69
79
  end
80
+
81
+ let!(:collection) { OtherCollection.create! }
82
+
70
83
  after(:all) do
71
84
  Object.send(:remove_const, :OtherCollection)
72
85
  end
73
86
 
74
- it "should generate a form that can remove the item" do
75
- str = button_for_remove_from_collection item
87
+ it "generates a form that can remove the item" do
88
+ str = button_for_remove_from_collection collection, item
76
89
  doc = Nokogiri::HTML(str)
77
90
  form = doc.xpath('//form').first
78
- expect(form.attr('action')).to eq collections.collection_path(@collection)
91
+ expect(form.attr('action')).to eq collections.collection_path(collection)
79
92
  expect(form.css('input#collection_members[type="hidden"][value="remove"]')).not_to be_empty
80
93
  expect(form.css('input[type="hidden"][name="batch_document_ids[]"][value="changeme:123"]')).not_to be_empty
81
94
  end
82
-
83
95
  end
84
96
  end
85
97
 
86
98
  describe "button_for_remove_selected_from_collection" do
87
- before do
88
- @collection = Collection.create title: "Test Public"
89
- end
99
+ let(:collection) { FactoryGirl.create(:collection) }
90
100
 
91
- it " should create a button to the collections delete path" do
92
- str = button_for_remove_selected_from_collection @collection
101
+ it "creates a button to the collections delete path" do
102
+ str = button_for_remove_selected_from_collection collection
93
103
  doc = Nokogiri::HTML(str)
94
104
  form = doc.xpath('//form').first
95
- expect(form.attr('action')).to eq collections.collection_path(@collection)
105
+ expect(form.attr('action')).to eq collections.collection_path(collection)
96
106
  i = form.xpath('.//input')[2]
97
107
  expect(i.attr('value')).to eq("remove")
98
108
  expect(i.attr('name')).to eq("collection[members]")
99
109
  end
100
110
 
101
- it "should create a button with my text" do
102
- str = button_for_remove_selected_from_collection @collection, "Remove My Button"
111
+ it "creates a button with my text" do
112
+ str = button_for_remove_selected_from_collection collection, "Remove My Button"
103
113
  doc = Nokogiri::HTML(str)
104
114
  form = doc.css('form').first
105
- expect(form.attr('action')).to eq collections.collection_path(@collection)
115
+ expect(form.attr('action')).to eq collections.collection_path(collection)
106
116
  expect(form.css('input[type="submit"]').attr('value').value).to eq "Remove My Button"
107
117
  end
108
118
  end
109
119
 
110
120
  describe "hidden_collection_members" do
111
121
  before { helper.params[:batch_document_ids] = ['foo:12', 'foo:23'] }
112
- it "should make hidden fields" do
122
+ it "makes hidden fields" do
113
123
  doc = Nokogiri::HTML(hidden_collection_members)
114
124
  inputs = doc.xpath('//input[@type="hidden"][@name="batch_document_ids[]"]')
115
125
  expect(inputs.length).to eq(2)
@@ -117,5 +127,4 @@ describe CollectionsHelper, :type => :helper do
117
127
  expect(inputs[1].attr('value')).to eq('foo:23')
118
128
  end
119
129
  end
120
-
121
130
  end
@@ -2,13 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe Collection, :type => :model do
4
4
  before(:all) do
5
- @user = FactoryGirl.find_or_create(:user)
6
5
  class GenericFile < ActiveFedora::Base
7
6
  include Hydra::Works::WorkBehavior
8
7
  end
9
8
  end
10
9
  after(:all) do
11
- @user.destroy
12
10
  Object.send(:remove_const, :GenericFile)
13
11
  end
14
12
 
@@ -16,10 +14,10 @@ describe Collection, :type => :model do
16
14
  let(:gf2) { GenericFile.create }
17
15
  let(:gf3) { GenericFile.create }
18
16
 
19
- let(:user) { @user }
17
+ let(:user) { FactoryGirl.create(:user) }
20
18
 
21
19
  describe "#to_solr" do
22
- let(:collection) { Collection.new(title: "A good title", depositor: user.user_key) }
20
+ let(:collection) { FactoryGirl.build(:collection, user: user, title: ['A good title']) }
23
21
 
24
22
  subject { collection.to_solr }
25
23
 
@@ -113,16 +111,16 @@ describe Collection, :type => :model do
113
111
  end
114
112
  end
115
113
 
116
- it "should have a title" do
117
- subject.title = "title"
114
+ it "has a title" do
115
+ subject.title = ["title"]
118
116
  subject.save
119
- expect(subject.title).to eq "title"
117
+ expect(subject.reload.title).to eq ["title"]
120
118
  end
121
119
 
122
- it "should have a description" do
123
- subject.description = "description"
120
+ it "has a description" do
121
+ subject.description = ["description"]
124
122
  subject.save
125
- expect(subject.reload.description).to eq "description"
123
+ expect(subject.reload.description).to eq ["description"]
126
124
  end
127
125
 
128
126
  describe "#destroy" do
@@ -29,6 +29,15 @@ RSpec.configure do |config|
29
29
  config.before(:each) do
30
30
  ActiveFedora::Cleaner.clean!
31
31
  end
32
+
33
+ config.include Warden::Test::Helpers
34
+ config.before :suite do
35
+ Warden.test_mode!
36
+ end
37
+
38
+ config.after :each do
39
+ Warden.test_reset!
40
+ end
32
41
  end
33
42
 
34
43
  module FactoryGirl
@@ -1,8 +1,7 @@
1
1
  <div id="sortAndPerPage">
2
2
  <div id="sortAndPerPage" class="clearfix">
3
- <%= render "paginate_compact", object: @response if show_pagination? %>
3
+ <%= render partial: "paginate_compact", object: @response if show_pagination? %>
4
4
  <%= button_for_create_collection %>
5
- <%= render partial: 'collections/form_for_select_collection', locals: {user_collections: @user_collections} %>
5
+ <%= render 'collections/form_for_select_collection', user_collections: @user_collections %>
6
6
  </div>
7
-
8
7
  </div>
@@ -51,10 +51,6 @@ class TestAppGenerator < Rails::Generators::Base
51
51
  copy_file "app/controllers/other_collections_controller.rb"
52
52
  end
53
53
 
54
- def overwrite_blacklight_config
55
- copy_file 'config/blacklight.yml', force: true
56
- end
57
-
58
54
  # Inject javascript into application.js
59
55
  def inject_javascript
60
56
  insert_into_file "app/assets/javascripts/application.js", :after => '//= require_tree .' do
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'collections/_form.html.erb' do
4
+ before do
5
+ assign(:collection, stub_model(Collection))
6
+ render
7
+ end
8
+
9
+ it "draws the fields" do
10
+ expect(rendered).to have_css 'input#collection_title'
11
+ expect(rendered).to have_css 'label[for="collection_title"]'
12
+ expect(rendered).to have_css 'textarea#collection_description'
13
+ expect(rendered).to have_css 'label[for="collection_description"]'
14
+ end
15
+ end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe 'collections/show.html.erb' do
4
4
  let(:response) { Blacklight::Solr::Response.new(sample_response, {}) }
5
- let(:collection) { mock_model(Collection, id: '123', title: "My Collection", description: "Just a collection") }
5
+ let(:collection) { mock_model(Collection, id: '123', title: ["My Collection"], description: ["Just a collection"]) }
6
6
 
7
7
  let(:blacklight_config) { CatalogController.blacklight_config }
8
8
  let(:member_docs) { [ SolrDocument.new(id: '234'), SolrDocument.new(id: '456') ] }
@@ -1,18 +1,18 @@
1
1
  require 'rspec/core'
2
2
  require 'rspec/core/rake_task'
3
- require 'jettywrapper'
3
+ require 'solr_wrapper'
4
+ require 'fcrepo_wrapper'
4
5
  require 'engine_cart/rake_task'
6
+ require 'active_fedora/rake_support'
5
7
 
6
8
  RSpec::Core::RakeTask.new(:spec) do |spec|
7
9
  spec.rspec_opts = ['--backtrace'] if ENV['CI']
8
10
  end
9
11
 
10
- desc 'Spin up hydra-jetty and run specs'
11
- task ci: ['engine_cart:clean', 'engine_cart:generate', 'jetty:clean'] do
12
+ desc 'Start solr, fcrepo, and run specs'
13
+ task ci: ['engine_cart:generate'] do
12
14
  puts 'running continuous integration'
13
- jetty_params = Jettywrapper.load_config
14
- error = Jettywrapper.wrap(jetty_params) do
15
+ with_test_server do
15
16
  Rake::Task['spec'].invoke
16
17
  end
17
- raise "test failures: #{error}" if error
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-collections
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carolyn Cole
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-22 00:00:00.000000000 Z
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hydra-head
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '9.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: active-fedora
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '9.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '9.9'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: deprecation
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -147,10 +161,8 @@ files:
147
161
  - app/controllers/concerns/hydra/collections_controller_behavior.rb
148
162
  - app/helpers/batch_select_helper.rb
149
163
  - app/helpers/collections_helper.rb
150
- - app/helpers/collections_search_helper.rb
151
164
  - app/models/collection.rb
152
165
  - app/models/concerns/hydra/collection.rb
153
- - app/models/concerns/hydra/collections/actions.rb
154
166
  - app/models/concerns/hydra/collections/metadata.rb
155
167
  - app/models/concerns/hydra/collections/solr_document_behavior.rb
156
168
  - app/models/solr_document.rb
@@ -183,16 +195,30 @@ files:
183
195
  - app/views/collections/new.html.erb
184
196
  - app/views/collections/show.html.erb
185
197
  - app/views/layouts/collections.html.erb
186
- - config/jetty.yml
187
198
  - config/routes.rb
188
199
  - gemfiles/rails3.gemfile
189
200
  - gemfiles/rails4.gemfile
190
201
  - hydra-collections.gemspec
191
202
  - lib/hydra-collections.rb
192
203
  - lib/hydra/collections/accepts_batches.rb
193
- - lib/hydra/collections/collectible.rb
194
204
  - lib/hydra/collections/search_service.rb
195
205
  - lib/hydra/collections/version.rb
206
+ - solr/config/_rest_managed.json
207
+ - solr/config/admin-extra.html
208
+ - solr/config/elevate.xml
209
+ - solr/config/mapping-ISOLatin1Accent.txt
210
+ - solr/config/protwords.txt
211
+ - solr/config/schema.xml
212
+ - solr/config/scripts.conf
213
+ - solr/config/solrconfig.xml
214
+ - solr/config/spellings.txt
215
+ - solr/config/stopwords.txt
216
+ - solr/config/stopwords_en.txt
217
+ - solr/config/synonyms.txt
218
+ - solr/config/xslt/example.xsl
219
+ - solr/config/xslt/example_atom.xsl
220
+ - solr/config/xslt/example_rss.xsl
221
+ - solr/config/xslt/luke.xsl
196
222
  - solr_conf/conf/schema.xml
197
223
  - solr_conf/conf/solrconfig.xml
198
224
  - solr_conf/solr.xml
@@ -203,9 +229,8 @@ files:
203
229
  - spec/controllers/selects_collections_spec.rb
204
230
  - spec/factories.rb
205
231
  - spec/factories/users.rb
232
+ - spec/features/create_collection_spec.rb
206
233
  - spec/helpers/collections_helper_spec.rb
207
- - spec/helpers/collections_search_helper_spec.rb
208
- - spec/lib/collectible_spec.rb
209
234
  - spec/lib/search_service_spec.rb
210
235
  - spec/models/collection_spec.rb
211
236
  - spec/spec_helper.rb
@@ -216,14 +241,13 @@ files:
216
241
  - spec/test_app_templates/app/views/catalog/_document_header.html.erb
217
242
  - spec/test_app_templates/app/views/catalog/_index_collection.html.erb
218
243
  - spec/test_app_templates/app/views/catalog/_sort_and_per_page.html.erb
219
- - spec/test_app_templates/config/blacklight.yml
220
244
  - spec/test_app_templates/db/migrate/20111101221803_create_searches.rb
221
245
  - spec/test_app_templates/lib/generators/test_app_generator.rb
222
246
  - spec/test_app_templates/lib/tasks/rspec.rake
247
+ - spec/views/collections/_form.html.erb_spec.rb
223
248
  - spec/views/collections/_thumbnail_default.html.erb_spec.rb
224
249
  - spec/views/collections/show.html.erb_spec.rb
225
250
  - tasks/hydra-collections-dev.rake
226
- - tasks/jetty.rake
227
251
  homepage: https://github.com/projecthydra/hydra-collections
228
252
  licenses:
229
253
  - APACHE2
@@ -244,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
268
  version: '0'
245
269
  requirements: []
246
270
  rubyforge_project:
247
- rubygems_version: 2.4.5.1
271
+ rubygems_version: 2.5.1
248
272
  signing_key:
249
273
  specification_version: 4
250
274
  summary: A rails engine for managing Hydra Collections
@@ -256,9 +280,8 @@ test_files:
256
280
  - spec/controllers/selects_collections_spec.rb
257
281
  - spec/factories.rb
258
282
  - spec/factories/users.rb
283
+ - spec/features/create_collection_spec.rb
259
284
  - spec/helpers/collections_helper_spec.rb
260
- - spec/helpers/collections_search_helper_spec.rb
261
- - spec/lib/collectible_spec.rb
262
285
  - spec/lib/search_service_spec.rb
263
286
  - spec/models/collection_spec.rb
264
287
  - spec/spec_helper.rb
@@ -269,9 +292,9 @@ test_files:
269
292
  - spec/test_app_templates/app/views/catalog/_document_header.html.erb
270
293
  - spec/test_app_templates/app/views/catalog/_index_collection.html.erb
271
294
  - spec/test_app_templates/app/views/catalog/_sort_and_per_page.html.erb
272
- - spec/test_app_templates/config/blacklight.yml
273
295
  - spec/test_app_templates/db/migrate/20111101221803_create_searches.rb
274
296
  - spec/test_app_templates/lib/generators/test_app_generator.rb
275
297
  - spec/test_app_templates/lib/tasks/rspec.rake
298
+ - spec/views/collections/_form.html.erb_spec.rb
276
299
  - spec/views/collections/_thumbnail_default.html.erb_spec.rb
277
300
  - spec/views/collections/show.html.erb_spec.rb