worthwhile 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -3
  3. data/README.md +2 -0
  4. data/app/assets/stylesheets/worthwhile/_worthwhile.css.scss +2 -0
  5. data/app/helpers/curate/collections_helper.rb +17 -117
  6. data/app/helpers/worthwhile/collections_helper.rb +15 -4
  7. data/app/views/catalog/_action_menu_partials/_default.html.erb +1 -1
  8. data/app/views/catalog/index.html.erb +5 -6
  9. data/app/views/collections/_form.html.erb +1 -1
  10. data/app/views/collections/_form_representative_image.html.erb +13 -0
  11. data/app/views/collections/edit.html.erb +7 -12
  12. data/app/views/collections/new.html.erb +9 -11
  13. data/app/views/curate/collections/_add_to_collection_modal.html.erb +2 -2
  14. data/app/views/curation_concern/base/_form_descriptive_fields.erb +1 -13
  15. data/app/views/curation_concern/base/_form_editors.html.erb +15 -0
  16. data/app/views/curation_concern/base/edit.html.erb +10 -12
  17. data/app/views/curation_concern/base/new.html.erb +9 -11
  18. data/app/views/curation_concern/base/show.html.erb +15 -19
  19. data/app/views/curation_concern/generic_files/edit.html.erb +2 -2
  20. data/app/views/curation_concern/generic_files/show.html.erb +3 -3
  21. data/app/views/curation_concern/linked_resources/edit.html.erb +2 -2
  22. data/app/views/curation_concern/linked_resources/new.html.erb +2 -2
  23. data/app/views/embargoes/edit.html.erb +1 -1
  24. data/app/views/layouts/curate_nd/1_column.html.erb +1 -12
  25. data/app/views/layouts/curate_nd/catalog.html.erb +1 -2
  26. data/app/views/layouts/curate_nd.html.erb +2 -13
  27. data/app/views/leases/edit.html.erb +1 -1
  28. data/app/views/worthwhile/classify_concerns/new.html.erb +3 -5
  29. data/config/locales/sufia.en.yml +2 -2
  30. data/lib/generators/worthwhile/install_generator.rb +6 -1
  31. data/lib/generators/worthwhile/templates/worthwhile.css.scss +0 -2
  32. data/lib/worthwhile/rails/routes.rb +4 -5
  33. data/lib/worthwhile/version.rb +1 -1
  34. data/spec/controllers/collections_controller_spec.rb +1 -1
  35. data/spec/controllers/curation_concern/permissions_controller_spec.rb +3 -3
  36. data/spec/controllers/downloads_controller_spec.rb +2 -2
  37. data/spec/controllers/worthwhile/classify_concerns_controller_spec.rb +19 -11
  38. data/spec/features/collection_spec.rb +48 -48
  39. data/spec/helpers/worthwhile/collections_helper_spec.rb +19 -0
  40. data/spec/matchers/metadata_field_matchers.rb +3 -3
  41. data/spec/models/collection_spec.rb +23 -23
  42. data/spec/models/curation_concern/collection_model_spec.rb +2 -2
  43. data/spec/models/worthwhile/content_version_spec.rb +2 -2
  44. data/spec/models/worthwhile/linked_resource_spec.rb +8 -8
  45. data/spec/routing/worthwhile/routes_spec.rb +2 -3
  46. data/spec/spec_helper.rb +5 -11
  47. data/spec/views/collections/_form_representative_image.html.erb_spec.rb +20 -0
  48. data/spec/views/curation_concern/base/_attributes.html.erb_spec.rb +3 -3
  49. data/spec/views/curation_concern/base/show.html.erb_spec.rb +13 -9
  50. metadata +8 -7
  51. data/app/assets/stylesheets/worthwhile.css.scss +0 -23
  52. data/app/views/curate/collections/add_member_form.html.erb +0 -6
  53. data/app/views/layouts/common_objects.html.erb +0 -36
  54. data/app/views/layouts/curate_nd/2_column.html.erb +0 -26
  55. data/app/views/layouts/curate_nd/dashboard.html.erb +0 -22
@@ -1,6 +1,6 @@
1
1
  en:
2
2
  sufia:
3
- product_name: "Curate"
3
+ product_name: "Repository"
4
4
  institution_name: "Your Institution"
5
5
  institution_homepage_url: "#"
6
6
  division_name: "Your Division at Institution"
@@ -8,7 +8,7 @@ en:
8
8
  search:
9
9
  form:
10
10
  q:
11
- label: "Search Curate"
11
+ label: "Search Repository"
12
12
  placeholder: "Type keywords in here"
13
13
  search_facets:
14
14
  label: "View:"
@@ -20,13 +20,18 @@ module Worthwhile
20
20
  say_status("warning", "Removing Blacklight's generated CatalogController...", :yellow)
21
21
  remove_file('app/controllers/catalog_controller.rb')
22
22
  end
23
-
23
+
24
24
  def inject_application_controller_behavior
25
25
  inject_into_file 'app/controllers/application_controller.rb', :after => /Blacklight::Controller\s*\n/ do
26
26
  " include Worthwhile::ApplicationControllerBehavior\n"
27
27
  end
28
28
  end
29
29
 
30
+ def replace_blacklight_layout
31
+ gsub_file 'app/controllers/application_controller.rb', /layout 'blacklight'/,
32
+ "include Worthwhile::ThemedLayoutController\n with_themed_layout '1_column'\n"
33
+ end
34
+
30
35
  def inject_routes
31
36
  inject_into_file 'config/routes.rb', :after => /devise_for :users\s*\n/ do
32
37
  " mount Hydra::Collections::Engine => '/'\n"\
@@ -1,3 +1 @@
1
- @import 'worthwhile/variables_bootstrap';
2
- @import 'bootstrap';
3
1
  @import 'worthwhile/worthwhile';
@@ -1,7 +1,7 @@
1
1
  module ActionDispatch::Routing
2
2
  class Mapper
3
-
4
- def worthwhile_curation_concerns
3
+
4
+ def worthwhile_curation_concerns
5
5
  resources :downloads, only: :show
6
6
  namespace :curation_concern, path: :concern do
7
7
  Worthwhile.configuration.registered_curation_concern_types.map(&:tableize).each do |curation_concern_name|
@@ -37,7 +37,6 @@ module ActionDispatch::Routing
37
37
  get 'facet/:id', action: :facet, as: :dashboard_facet
38
38
  end
39
39
  collection do
40
- get :add_member_form
41
40
  put '', action: :update
42
41
  put :remove_member
43
42
  end
@@ -56,7 +55,7 @@ module ActionDispatch::Routing
56
55
  end
57
56
  end
58
57
  end
59
-
58
+
60
59
  private
61
60
  # Namespaces routes appropriately
62
61
  # @example route_namespaced_target("worthwhile/generic_work") is equivalent to
@@ -67,7 +66,7 @@ module ActionDispatch::Routing
67
66
  if target.include?("/")
68
67
  the_namespace = target[0..target.index("/")-1]
69
68
  new_target = target[target.index("/")+1..-1]
70
- namespace the_namespace do
69
+ namespace the_namespace do
71
70
  namespaced_resources(new_target, opts)
72
71
  end
73
72
  else
@@ -1,3 +1,3 @@
1
1
  module Worthwhile
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -119,7 +119,7 @@ describe CollectionsController do
119
119
  end
120
120
  it "should remove members and update all of the relevant solr documents" do
121
121
  # BUG: This is returning inaccurate information
122
- # collection.reload.members.should include public_asset_not_mine
122
+ # expect(collection.reload.members).to include public_asset_not_mine
123
123
  solr_doc_before_remove = ActiveFedora::SolrInstanceLoader.new(ActiveFedora::Base, public_asset_not_mine.pid).send(:solr_doc)
124
124
  expect(solr_doc_before_remove[Solrizer.solr_name(:collection)]).to eq [collection.pid]
125
125
  put :update, id: collection.id, collection: {members:"remove"}, batch_document_ids:[public_asset_not_mine.pid]
@@ -15,11 +15,11 @@ describe CurationConcern::PermissionsController do
15
15
 
16
16
  describe "#copy" do
17
17
  let(:generic_work) { FactoryGirl.create(:generic_work, user: user) }
18
+ let(:worker) { double }
18
19
 
19
20
  it "should add a worker to the queue" do
20
- worker = double
21
- VisibilityCopyWorker.should_receive(:new).with(generic_work.pid).and_return(worker)
22
- Sufia.queue.should_receive(:push).with(worker)
21
+ expect(VisibilityCopyWorker).to receive(:new).with(generic_work.pid).and_return(worker)
22
+ expect(Sufia.queue).to receive(:push).with(worker)
23
23
  post :copy, id: generic_work
24
24
  expect(response).to redirect_to controller.polymorphic_path([:curation_concern, generic_work])
25
25
  expect(flash[:notice]).to eq 'Updating file permissions. This may take a few minutes. You may want to refresh your browser or return to this record later to see the updated file permissions.'
@@ -39,7 +39,7 @@ describe DownloadsController do
39
39
  generic_file
40
40
  sign_in user
41
41
  get :show, id: generic_file.to_param
42
- response.body.should == generic_file.content.content
42
+ expect(response.body).to eq generic_file.content.content
43
43
  end
44
44
 
45
45
  it 'sends requested datastream content' do
@@ -47,7 +47,7 @@ describe DownloadsController do
47
47
  generic_file.save!
48
48
  sign_in user
49
49
  get :show, id: generic_file.to_param, datastream_id: 'thumbnail'
50
- response.body.should == generic_file.thumbnail.content
50
+ expect(response.body).to eq generic_file.thumbnail.content
51
51
  end
52
52
  end
53
53
  end
@@ -17,19 +17,27 @@ describe Worthwhile::ClassifyConcernsController do
17
17
  end
18
18
 
19
19
  describe '#create' do
20
- it 'redirect to login page if user is not logged in' do
21
- post :create, classify: { curation_concern_type: 'GenericWork' }
22
- expect(response).to redirect_to(main_app.user_session_path)
20
+ context 'without logging in' do
21
+ it 'redirect to login page if user is not logged in' do
22
+ post :create, classify: { curation_concern_type: 'GenericWork' }
23
+ expect(response).to redirect_to(main_app.user_session_path)
24
+ end
23
25
  end
24
26
 
25
- it 'requires authentication' do
26
- sign_in(user)
27
- # Had to stub the actual handling of curation_concern paths since those paths live outside the engine while the path to this controller lives inside the engine.
28
- new_curation_concern_generic_work_path = "/stub/path"
29
- subject.should_receive(:new_polymorphic_path).with([:curation_concern, GenericWork]).and_return(new_curation_concern_generic_work_path)
30
- post :create, classify_concern: { curation_concern_type: 'GenericWork' }
31
- expect(response).to redirect_to(new_curation_concern_generic_work_path)
32
- end
27
+ context 'when logged in' do
28
+ before do
29
+ sign_in(user)
30
+ # Had to stub the actual handling of curation_concern paths since those paths live outside the engine while the path to this controller lives inside the engine.
31
+ expect(subject).to receive(:new_polymorphic_path).with([:curation_concern, GenericWork]).and_return(new_curation_concern_generic_work_path)
32
+ end
33
+
34
+ let(:new_curation_concern_generic_work_path) { "/stub/path" }
35
+
36
+ it 'requires authentication' do
37
+ post :create, classify_concern: { curation_concern_type: 'GenericWork' }
38
+ expect(response).to redirect_to(new_curation_concern_generic_work_path)
39
+ end
40
+ end
33
41
 
34
42
  end
35
43
  end
@@ -84,12 +84,12 @@ describe 'collection' do
84
84
  end
85
85
 
86
86
  it "should delete a collection" do
87
- page.should have_content(@collection.title)
87
+ expect(page).to have_content(@collection.title)
88
88
  within("#document_#{@collection.noid}") do
89
89
  first(".itemtrash").click
90
90
  end
91
- page.should_not have_content(@collection.title)
92
- page.should have_content("Collection was successfully deleted.")
91
+ expect(page).to_not have_content(@collection.title)
92
+ expect(page).to have_content("Collection was successfully deleted.")
93
93
  end
94
94
  end
95
95
 
@@ -105,16 +105,16 @@ describe 'collection' do
105
105
  end
106
106
 
107
107
  it "should show a collection with a listing of Descriptive Metadata and catalog-style search results" do
108
- page.should have_content(@collection.title)
108
+ expect(page).to have_content(@collection.title)
109
109
  within('#document_'+@collection.noid) do
110
110
  click_link("collection title")
111
111
  end
112
- page.should have_content(@collection.title)
113
- page.should have_content(@collection.description)
112
+ expect(page).to have_content(@collection.title)
113
+ expect(page).to have_content(@collection.description)
114
114
  # Should have search results / contents listing
115
- page.should have_content(@gw1.title.first)
116
- page.should have_content(@gw2.title.first)
117
- page.should_not have_css(".pager")
115
+ expect(page).to have_content(@gw1.title.first)
116
+ expect(page).to have_content(@gw2.title.first)
117
+ expect(page).to_not have_css(".pager")
118
118
 
119
119
  #click_link "Gallery"
120
120
  #expect(page).to have_content(@gw1.title)
@@ -122,25 +122,25 @@ describe 'collection' do
122
122
  end
123
123
 
124
124
  it "should hide collection descriptive metadata when searching a collection" do
125
- page.should have_content(@collection.title)
125
+ expect(page).to have_content(@collection.title)
126
126
  within("#document_#{@collection.noid}") do
127
127
  click_link("collection title")
128
128
  end
129
- page.should have_content(@collection.title)
130
- page.should have_content(@collection.description)
131
- page.should have_content(@gw1.title.first)
132
- page.should have_content(@gw2.title.first)
129
+ expect(page).to have_content(@collection.title)
130
+ expect(page).to have_content(@collection.description)
131
+ expect(page).to have_content(@gw1.title.first)
132
+ expect(page).to have_content(@gw2.title.first)
133
133
  fill_in('collection_search', with: @gw1.title.first)
134
134
  click_button('collection_submit')
135
135
  # Should not have Collection Descriptive metadata table
136
- page.should_not have_content("Descriptions")
137
- page.should have_content(@collection.title)
138
- page.should have_content(@collection.description)
136
+ expect(page).to_not have_content("Descriptions")
137
+ expect(page).to have_content(@collection.title)
138
+ expect(page).to have_content(@collection.description)
139
139
  # Should have search results / contents listing
140
- page.should have_content(@gw1.title.first)
141
- page.should_not have_content(@gw2.title.first)
140
+ expect(page).to have_content(@gw1.title.first)
141
+ expect(page).to_not have_content(@gw2.title.first)
142
142
  # Should not have Dashboard content in contents listing
143
- page.should_not have_content("Visibility")
143
+ expect(page).to_not have_content("Visibility")
144
144
  end
145
145
  end
146
146
 
@@ -156,12 +156,12 @@ describe 'collection' do
156
156
  end
157
157
 
158
158
  it "should edit and update collection metadata" do
159
- page.should have_content(@collection.title)
159
+ expect(page).to have_content(@collection.title)
160
160
  within("#document_#{@collection.noid}") do
161
161
  click_link('Edit Collection')
162
162
  end
163
- page.should have_field('collection_title', with: @collection.title)
164
- page.should have_field('collection_description', with: @collection.description)
163
+ expect(page).to have_field('collection_title', with: @collection.title)
164
+ expect(page).to have_field('collection_description', with: @collection.description)
165
165
  new_title = "Altered Title"
166
166
  new_description = "Completely new Description text."
167
167
  creators = ["Dorje Trollo", "Vajrayogini"]
@@ -171,48 +171,48 @@ describe 'collection' do
171
171
  #within('.form-actions') do
172
172
  click_button('Update Collection')
173
173
  #end
174
- page.should_not have_content(@collection.title)
175
- page.should_not have_content(@collection.description)
176
- page.should have_content(new_title)
177
- page.should have_content(new_description)
178
- page.should have_content(creators.first)
174
+ expect(page).to_not have_content(@collection.title)
175
+ expect(page).to_not have_content(@collection.description)
176
+ expect(page).to have_content(new_title)
177
+ expect(page).to have_content(new_description)
178
+ expect(page).to have_content(creators.first)
179
179
  end
180
180
 
181
181
  it "should remove a work from a collection" do
182
182
  skip "BUG removing works from a collection"
183
- page.should have_content(@collection.title)
183
+ expect(page).to have_content(@collection.title)
184
184
  within("#document_#{@collection.noid}") do
185
185
  click_link('Edit Collection')
186
186
  end
187
- page.should have_field('collection_title', with: @collection.title)
188
- page.should have_field('collection_description', with: @collection.description)
189
- page.should have_content(@gw1.title)
190
- page.should have_content(@gw2.title)
187
+ expect(page).to have_field('collection_title', with: @collection.title)
188
+ expect(page).to have_field('collection_description', with: @collection.description)
189
+ expect(page).to have_content(@gw1.title)
190
+ expect(page).to have_content(@gw2.title)
191
191
  within("#document_#{@gw1.noid}") do
192
192
  click_button('Remove From Collection')
193
193
  end
194
- page.should have_content(@collection.title)
195
- page.should have_content(@collection.description)
196
- page.should_not have_content(@gw1.title)
197
- page.should have_content(@gw2.title)
194
+ expect(page).to have_content(@collection.title)
195
+ expect(page).to have_content(@collection.description)
196
+ expect(page).to_not have_content(@gw1.title)
197
+ expect(page).to have_content(@gw2.title)
198
198
  end
199
199
 
200
200
  it "should remove all works from a collection" do
201
201
  skip "batch collection operations (add/remove)"
202
- page.should have_content(@collection.title)
202
+ expect(page).to have_content(@collection.title)
203
203
  within('#document_'+@collection.noid) do
204
204
  click_link('Edit Collection')
205
205
  end
206
- page.should have_field('collection_title', with: @collection.title)
207
- page.should have_field('collection_description', with: @collection.description)
208
- page.should have_content(@gw1.title)
209
- page.should have_content(@gw2.title)
206
+ expect(page).to have_field('collection_title', with: @collection.title)
207
+ expect(page).to have_field('collection_description', with: @collection.description)
208
+ expect(page).to have_content(@gw1.title)
209
+ expect(page).to have_content(@gw2.title)
210
210
  first('input#check_all').click
211
211
  click_button('Remove From Collection')
212
- page.should have_content(@collection.title)
213
- page.should have_content(@collection.description)
214
- page.should_not have_content(@gw1.title)
215
- page.should_not have_content(@gw2.title)
212
+ expect(page).to have_content(@collection.title)
213
+ expect(page).to have_content(@collection.description)
214
+ expect(page).to_not have_content(@gw1.title)
215
+ expect(page).to_not have_content(@gw2.title)
216
216
  end
217
217
  end
218
218
 
@@ -228,11 +228,11 @@ describe 'collection' do
228
228
  end
229
229
 
230
230
  it "should show a collection with a listing of Descriptive Metadata and catalog-style search results" do
231
- page.should have_content(@collection.title)
231
+ expect(page).to have_content(@collection.title)
232
232
  within('#document_'+@collection.noid) do
233
233
  click_link("collection title")
234
234
  end
235
- page.should have_css(".pager")
235
+ expect(page).to have_css(".pager")
236
236
  end
237
237
  end
238
238
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Worthwhile::CollectionsHelper do
4
+ describe "#link_to_remove_from_collection" do
5
+ let(:collection) { double(id: '123') }
6
+ let(:collectible) { double(id: '456') }
7
+ before do
8
+ assign(:collection, collection)
9
+ end
10
+ subject { helper.link_to_remove_from_collection(collectible) }
11
+
12
+ it "should have a form that routes to remove the collectible" do
13
+ expect(subject).to have_selector 'a[data-method=put]'
14
+ expect(subject).to have_link 'Remove From Collection',
15
+ href: collections.collection_path('123', collection: { members: 'remove'},
16
+ batch_document_ids: [ '456' ])
17
+ end
18
+ end
19
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  RSpec::Matchers.define :have_unique_field do |expected_field_name|
4
4
  match do |subject|
5
- subject.should respond_to(expected_field_name)
5
+ expect(subject).to respond_to(expected_field_name)
6
6
  field_value = subject.send(expected_field_name)
7
7
  field_value.nil? || !field_value.kind_of?(Array)
8
8
  end
@@ -18,8 +18,8 @@ end
18
18
 
19
19
  RSpec::Matchers.define :have_multivalue_field do |expected_field_name|
20
20
  match do |subject|
21
- subject.should respond_to(expected_field_name)
22
- subject.send(expected_field_name).should be_instance_of Array
21
+ expect(subject).to respond_to(expected_field_name)
22
+ expect(subject.send(expected_field_name)).to be_instance_of Array
23
23
  end
24
24
 
25
25
  description do
@@ -14,41 +14,41 @@ describe Collection do
14
14
  it 'can contain another collection' do
15
15
  another_collection = FactoryGirl.create(:collection)
16
16
  subject.members << another_collection
17
- subject.members.should == [another_collection]
17
+ expect(subject.members).to eq [another_collection]
18
18
  end
19
19
 
20
20
  it 'updates solr with pids of its parent collections' do
21
21
  another_collection = FactoryGirl.create(:collection)
22
22
  another_collection.members << subject
23
23
  another_collection.save
24
- subject.reload.to_solr[Solrizer.solr_name(:collection)].should == [another_collection.pid]
24
+ expect(subject.reload.to_solr[Solrizer.solr_name(:collection)]).to eq [another_collection.pid]
25
25
  end
26
26
 
27
27
  it 'cannot contain itself' do
28
28
  subject.members << subject
29
29
  subject.save
30
- reloaded_subject.members.should == []
30
+ expect(reloaded_subject.members).to eq []
31
31
  end
32
32
 
33
33
  describe "when visibility is private" do
34
34
  it "should not be open_access?" do
35
- subject.should_not be_open_access
35
+ expect(subject).to_not be_open_access
36
36
  end
37
37
  it "should not be authenticated_only_access?" do
38
- subject.should_not be_authenticated_only_access
38
+ expect(subject).to_not be_authenticated_only_access
39
39
  end
40
40
  it "should not be private_access?" do
41
- subject.should be_private_access
41
+ expect(subject).to be_private_access
42
42
  end
43
43
  end
44
44
 
45
45
  describe "visibility" do
46
46
  it "should have visibility accessor" do
47
- subject.visibility.should == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
47
+ expect(subject.visibility).to eq Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
48
48
  end
49
49
  it "should have visibility writer" do
50
50
  subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
51
- subject.should be_open_access
51
+ expect(subject).to be_open_access
52
52
  end
53
53
  end
54
54
 
@@ -68,19 +68,19 @@ describe Collection do
68
68
 
69
69
  describe '#human_readable_type' do
70
70
  it "indicates collection" do
71
- subject.human_readable_type.should == 'Collection'
71
+ expect(subject.human_readable_type).to eq 'Collection'
72
72
  end
73
73
  end
74
74
 
75
75
  describe '#add_member' do
76
76
  it 'adds the member to the collection and returns true' do
77
77
  work = FactoryGirl.create(:generic_work)
78
- subject.add_member(work).should be true
79
- reloaded_subject.members.should == [work]
78
+ expect(subject.add_member(work)).to be true
79
+ expect(reloaded_subject.members).to eq [work]
80
80
 
81
81
  work.reload
82
- work.collections.should == [subject]
83
- work.to_solr["collection_sim"].should == [subject.pid]
82
+ expect(work.collections).to eq [subject]
83
+ expect(work.to_solr["collection_sim"]).to eq [subject.pid]
84
84
  end
85
85
 
86
86
  it 'returns nil if there is nothing to add' do
@@ -92,7 +92,7 @@ describe Collection do
92
92
  work = FactoryGirl.create(:generic_work)
93
93
  allow(subject).to receive(:save).and_return(false)
94
94
  expect(subject.add_member(work)).to be false
95
- reloaded_subject.members.should == []
95
+ expect(reloaded_subject.members).to eq []
96
96
  end
97
97
  end
98
98
 
@@ -100,26 +100,26 @@ describe Collection do
100
100
  it 'removes the member from the collection and returns true' do
101
101
  work = FactoryGirl.create(:generic_work)
102
102
  subject.members << work
103
- subject.members.should == [work]
103
+ expect(subject.members).to eq [work]
104
104
  subject.save
105
105
 
106
106
  work.reload
107
- work.collections.should == [subject]
108
- work.to_solr["collection_tesim"].should == [subject.pid]
107
+ expect(work.collections).to eq [subject]
108
+ expect(work.to_solr["collection_tesim"]).to eq [subject.pid]
109
109
  solr_doc = ActiveFedora::SolrInstanceLoader.new(ActiveFedora::Base, work.pid).send(:solr_doc)
110
- solr_doc["collection_tesim"].should == [subject.pid]
110
+ expect(solr_doc["collection_tesim"]).to eq [subject.pid]
111
111
 
112
- subject.members.delete(work).should == [work]
112
+ expect(subject.members.delete(work)).to eq [work]
113
113
  subject.save!
114
- reloaded_subject.members.should == []
114
+ expect(reloaded_subject.members).to eq []
115
115
 
116
116
  solr_doc = ActiveFedora::SolrInstanceLoader.new(ActiveFedora::Base, work.pid).send(:solr_doc)
117
- solr_doc["collection_tesim"].should be_nil
117
+ expect(solr_doc["collection_tesim"]).to be_nil
118
118
 
119
119
 
120
120
  work.reload
121
- work.collections.should == []
122
- work.to_solr["collection_tesim"].should == []
121
+ expect(work.collections).to eq []
122
+ expect(work.to_solr["collection_tesim"]).to eq []
123
123
  end
124
124
  end
125
125
 
@@ -17,8 +17,8 @@ describe CurationConcern::CollectionModel do
17
17
  let(:proposed_collectible) { double(collections: []) }
18
18
  subject { EssentialCollection.new }
19
19
  before(:each) {
20
- proposed_collectible.stub(:can_be_member_of_collection?).with(subject).and_return(collectible?)
21
- proposed_collectible.stub(:save).and_return(true)
20
+ allow(proposed_collectible).to receive(:can_be_member_of_collection?).with(subject).and_return(collectible?)
21
+ allow(proposed_collectible).to receive(:save).and_return(true)
22
22
  }
23
23
 
24
24
  context 'with itself' do
@@ -9,8 +9,8 @@ module Worthwhile
9
9
  let(:raw_version) { double(dsCreateDate: created_on, versionID: version_id) }
10
10
  subject { described_class.new(content, raw_version) }
11
11
 
12
- before(:each) do
13
- content.stub(:version_committer).with(raw_version).and_return(committer_name)
12
+ before do
13
+ expect(content).to receive(:version_committer).with(raw_version).and_return(committer_name)
14
14
  end
15
15
  its(:created_on) { should eq(created_on) }
16
16
  its(:committer_name) { should eq(committer_name) }
@@ -6,27 +6,27 @@ describe Worthwhile::LinkedResource do
6
6
  it { should respond_to(:human_readable_type) }
7
7
 
8
8
  it 'has a #human_readable_short_description' do
9
- subject.human_readable_short_description.length.should_not == 0
9
+ expect(subject.human_readable_short_description.length).to_not eq 0
10
10
  end
11
11
 
12
12
  it 'has a .human_readable_short_description' do
13
- subject.class.human_readable_short_description.length.should_not == 0
13
+ expect(subject.class.human_readable_short_description.length).to_not eq 0
14
14
  end
15
15
 
16
16
  it 'uses #noid for #to_param' do
17
- subject.stub(:persisted?).and_return(true)
18
- subject.to_param.should == subject.noid
17
+ allow(subject).to receive(:persisted?).and_return(true)
18
+ expect(subject.to_param).to eq subject.noid
19
19
  end
20
20
 
21
21
  it 'has no url to display' do
22
- subject.to_s.should == nil
22
+ expect(subject.to_s).to eq nil
23
23
  end
24
24
 
25
25
  describe "validating" do
26
26
  subject {Worthwhile::LinkedResource.new}
27
27
  it "should not validate and have an error" do
28
- subject.should_not be_valid
29
- subject.errors[:url].should == ["can't be blank"]
28
+ expect(subject).to_not be_valid
29
+ expect(subject.errors[:url]).to eq ["can't be blank"]
30
30
  end
31
31
  end
32
32
 
@@ -34,7 +34,7 @@ describe Worthwhile::LinkedResource do
34
34
  context "javascript uri" do
35
35
  subject { FactoryGirl.build(:linked_resource, url: "javascript:void(alert('Hello'));") }
36
36
  it "should be cleared" do
37
- subject.url.should be_nil
37
+ expect(subject.url).to be_nil
38
38
  end
39
39
  end
40
40
  context "http uri" do
@@ -2,13 +2,12 @@ require "spec_helper"
2
2
 
3
3
  module Worthwhile
4
4
  describe "routing" do
5
-
6
5
 
7
6
  describe "Classify concerns" do
8
7
  routes { Worthwhile::Engine.routes }
9
8
  it "routes to #new" do
10
9
  expect(new_classify_concern_path).to eq '/classify_concerns/new'
11
- get("/classify_concerns/new").should route_to("worthwhile/classify_concerns#new")
10
+ expect(get("/classify_concerns/new")).to route_to("worthwhile/classify_concerns#new")
12
11
  end
13
12
  end
14
13
 
@@ -16,7 +15,7 @@ module Worthwhile
16
15
  routes { Rails.application.routes }
17
16
  it 'routes to #new' do
18
17
  expect(new_curation_concern_generic_work_path).to eq '/concern/generic_works/new'
19
- get("/concern/generic_works/new").should route_to("curation_concern/generic_works#new")
18
+ expect(get("/concern/generic_works/new")).to route_to("curation_concern/generic_works#new")
20
19
  end
21
20
  end
22
21
  end
data/spec/spec_helper.rb CHANGED
@@ -15,22 +15,15 @@ require 'capybara/rspec'
15
15
  require 'capybara/rails'
16
16
 
17
17
 
18
- if ENV['COVERAGE']
18
+ if ENV['COVERAGE'] || ENV['CI']
19
19
  require 'simplecov'
20
+ require 'coveralls'
20
21
 
21
22
  ENGINE_ROOT = File.expand_path('../..', __FILE__)
22
-
23
- # Out of the box, SimpleCov was looking at file in ENGINE_ROOT/spec/internal;
24
- # After all that was where Rails was pointed at.
25
- SimpleCov.root(ENGINE_ROOT)
26
- SimpleCov.start 'rails' do
27
- filters.clear
28
- add_filter do |src|
29
- src.filename !~ /^#{ENGINE_ROOT}/
30
- end
23
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter if ENV["CI"]
24
+ SimpleCov.start do
31
25
  add_filter '/spec/'
32
26
  end
33
- SimpleCov.command_name "spec"
34
27
  end
35
28
 
36
29
  require 'worthwhile'
@@ -59,6 +52,7 @@ RSpec.configure do |config|
59
52
  DatabaseCleaner.clean
60
53
  end
61
54
 
55
+ config.include FactoryGirl::Syntax::Methods
62
56
  config.include Devise::TestHelpers, type: :controller
63
57
  config.include Devise::TestHelpers, type: :view
64
58
  config.include Warden::Test::Helpers, type: :feature