hydra-works 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.rubocop.yml +0 -1
  4. data/README.md +9 -9
  5. data/Rakefile +12 -12
  6. data/hydra-works.gemspec +3 -3
  7. data/lib/hydra/works/models/characterization/fits_datastream.rb +1 -1
  8. data/lib/hydra/works/models/work.rb +4 -1
  9. data/lib/hydra/works/services/add_file_to_file_set.rb +5 -5
  10. data/lib/hydra/works/services/characterization_service.rb +2 -2
  11. data/lib/hydra/works/version.rb +1 -1
  12. data/lib/hydra/works.rb +1 -1
  13. data/solr/config/_rest_managed.json +3 -0
  14. data/solr/config/admin-extra.html +31 -0
  15. data/solr/config/elevate.xml +36 -0
  16. data/solr/config/mapping-ISOLatin1Accent.txt +246 -0
  17. data/solr/config/protwords.txt +21 -0
  18. data/solr/config/schema.xml +372 -0
  19. data/solr/config/scripts.conf +24 -0
  20. data/solr/config/solrconfig.xml +419 -0
  21. data/solr/config/spellings.txt +2 -0
  22. data/solr/config/stopwords.txt +58 -0
  23. data/solr/config/stopwords_en.txt +58 -0
  24. data/solr/config/synonyms.txt +31 -0
  25. data/solr/config/xslt/example.xsl +132 -0
  26. data/solr/config/xslt/example_atom.xsl +67 -0
  27. data/solr/config/xslt/example_rss.xsl +66 -0
  28. data/solr/config/xslt/luke.xsl +337 -0
  29. data/spec/hydra/works/models/collection_spec.rb +17 -17
  30. data/spec/hydra/works/models/file_set_spec.rb +8 -8
  31. data/spec/hydra/works/models/{generic_work_spec.rb → work_spec.rb} +57 -57
  32. data/spec/hydra/works/services/add_file_to_file_set_spec.rb +23 -23
  33. data/spec/hydra/works/services/upload_file_spec.rb +22 -22
  34. data/spec/hydra/works_spec.rb +18 -18
  35. data/spec/spec_helper.rb +3 -2
  36. metadata +36 -24
  37. data/config/solrconfig.xml +0 -223
  38. data/lib/hydra/works/models/generic_work.rb +0 -9
  39. data/lib/tasks/hydra-works_tasks.rake +0 -89
  40. data/lib/tasks/jetty.rake +0 -15
@@ -4,11 +4,11 @@ describe Hydra::Works::Collection do
4
4
  let(:collection) { described_class.new }
5
5
 
6
6
  let(:collection1) { described_class.new }
7
- let(:generic_work1) { Hydra::Works::GenericWork.new }
7
+ let(:work1) { Hydra::Works::Work.new }
8
8
 
9
9
  describe '#collections' do
10
10
  it 'returns empty array when only works are aggregated' do
11
- collection.ordered_members << generic_work1
11
+ collection.ordered_members << work1
12
12
  expect(collection.collections).to eq []
13
13
  end
14
14
 
@@ -17,7 +17,7 @@ describe Hydra::Works::Collection do
17
17
  before do
18
18
  collection.ordered_members << collection1
19
19
  collection.ordered_members << collection2
20
- collection.ordered_members << generic_work1
20
+ collection.ordered_members << work1
21
21
  end
22
22
 
23
23
  it 'returns only collections' do
@@ -35,16 +35,16 @@ describe Hydra::Works::Collection do
35
35
  end
36
36
  end
37
37
 
38
- context 'with collections and generic works' do
39
- let(:generic_work2) { Hydra::Works::GenericWork.new }
38
+ context 'with collections and works' do
39
+ let(:work2) { Hydra::Works::Work.new }
40
40
  before do
41
41
  collection.ordered_members << collection1
42
- collection.ordered_members << generic_work1
43
- collection.ordered_members << generic_work2
42
+ collection.ordered_members << work1
43
+ collection.ordered_members << work2
44
44
  end
45
45
 
46
- it 'returns only generic works' do
47
- expect(subject).to eq [generic_work1, generic_work2]
46
+ it 'returns only works' do
47
+ expect(subject).to eq [work1, work2]
48
48
  end
49
49
  end
50
50
  end
@@ -58,16 +58,16 @@ describe Hydra::Works::Collection do
58
58
  end
59
59
  end
60
60
 
61
- context 'with collections and generic works' do
62
- let(:generic_work2) { Hydra::Works::GenericWork.new }
61
+ context 'with collections and works' do
62
+ let(:work2) { Hydra::Works::Work.new }
63
63
  before do
64
64
  collection.ordered_members << collection1
65
- collection.ordered_members << generic_work1
66
- collection.ordered_members << generic_work2
65
+ collection.ordered_members << work1
66
+ collection.ordered_members << work2
67
67
  end
68
68
 
69
- it 'returns only generic works' do
70
- expect(subject).to eq [generic_work1, generic_work2]
69
+ it 'returns only works' do
70
+ expect(subject).to eq [work1, work2]
71
71
  end
72
72
  end
73
73
  end
@@ -75,8 +75,8 @@ describe Hydra::Works::Collection do
75
75
  describe "#ordered_work_ids" do
76
76
  subject { collection.ordered_work_ids }
77
77
  it "returns IDs of ordered works" do
78
- collection.ordered_members << generic_work1
79
- expect(subject).to eq [generic_work1.id]
78
+ collection.ordered_members << work1
79
+ expect(subject).to eq [work1.id]
80
80
  end
81
81
  end
82
82
 
@@ -33,25 +33,25 @@ describe Hydra::Works::FileSet do
33
33
 
34
34
  describe '#in_works' do
35
35
  subject { file_set.in_works }
36
- let(:generic_work) { Hydra::Works::GenericWork.create }
36
+ let(:work) { Hydra::Works::Work.create }
37
37
  before do
38
- generic_work.ordered_members << file_set
39
- generic_work.save
38
+ work.ordered_members << file_set
39
+ work.save
40
40
  end
41
41
 
42
- it { is_expected.to eq [generic_work] }
42
+ it { is_expected.to eq [work] }
43
43
  end
44
44
 
45
45
  describe '#destroy' do
46
- let(:generic_work) { Hydra::Works::GenericWork.create }
46
+ let(:work) { Hydra::Works::Work.create }
47
47
  before do
48
- generic_work.ordered_members << file_set
49
- generic_work.save
48
+ work.ordered_members << file_set
49
+ work.save
50
50
  end
51
51
 
52
52
  it "Removes the proxy, the list_node and the FileSet" do
53
53
  expect { file_set.destroy }.to change { ActiveFedora::Aggregation::Proxy.count }.by(-1)
54
- .and change { generic_work.reload.ordered_member_proxies.to_a.length }.by(-1)
54
+ .and change { work.reload.ordered_member_proxies.to_a.length }.by(-1)
55
55
  end
56
56
  end
57
57
  end
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Hydra::Works::GenericWork do
3
+ describe Hydra::Works::Work do
4
4
  subject { described_class.new }
5
5
 
6
- let(:generic_work1) { described_class.new }
7
- let(:generic_work2) { described_class.new }
8
- let(:generic_work3) { described_class.new }
9
- let(:generic_work4) { described_class.new }
10
- let(:generic_work5) { described_class.new }
6
+ let(:work1) { described_class.new }
7
+ let(:work2) { described_class.new }
8
+ let(:work3) { described_class.new }
9
+ let(:work4) { described_class.new }
10
+ let(:work5) { described_class.new }
11
11
 
12
12
  let(:file_set1) { Hydra::Works::FileSet.new }
13
13
  let(:file_set2) { Hydra::Works::FileSet.new }
@@ -19,72 +19,72 @@ describe Hydra::Works::GenericWork do
19
19
 
20
20
  describe "#file_set_ids" do
21
21
  it "returns non-ordered file set IDs" do
22
- generic_work1.members << file_set1
23
- generic_work1.ordered_members << file_set2
22
+ work1.members << file_set1
23
+ work1.ordered_members << file_set2
24
24
 
25
- expect(generic_work1.file_set_ids).to eq [file_set1.id, file_set2.id]
26
- expect(generic_work1.ordered_file_set_ids).to eq [file_set2.id]
25
+ expect(work1.file_set_ids).to eq [file_set1.id, file_set2.id]
26
+ expect(work1.ordered_file_set_ids).to eq [file_set2.id]
27
27
  end
28
28
  end
29
29
 
30
30
  describe "#file_sets" do
31
31
  it "returns non-ordered file sets" do
32
- generic_work1.members << file_set1
33
- generic_work1.ordered_members << file_set2
32
+ work1.members << file_set1
33
+ work1.ordered_members << file_set2
34
34
 
35
- expect(generic_work1.file_sets).to eq [file_set1, file_set2]
35
+ expect(work1.file_sets).to eq [file_set1, file_set2]
36
36
  end
37
37
  end
38
38
 
39
39
  describe "#work_ids" do
40
40
  it "returns non-ordered file set IDs" do
41
- generic_work1.members << generic_work2
42
- generic_work1.ordered_members << generic_work3
41
+ work1.members << work2
42
+ work1.ordered_members << work3
43
43
 
44
- expect(generic_work1.work_ids).to eq [generic_work2.id, generic_work3.id]
45
- expect(generic_work1.ordered_work_ids).to eq [generic_work3.id]
44
+ expect(work1.work_ids).to eq [work2.id, work3.id]
45
+ expect(work1.ordered_work_ids).to eq [work3.id]
46
46
  end
47
47
  end
48
48
 
49
49
  describe "#works" do
50
50
  it "returns non-ordered file sets" do
51
- generic_work1.members << generic_work2
52
- generic_work1.ordered_members << generic_work3
51
+ work1.members << work2
52
+ work1.ordered_members << work3
53
53
 
54
- expect(generic_work1.works).to eq [generic_work2, generic_work3]
54
+ expect(work1.works).to eq [work2, work3]
55
55
  end
56
56
  end
57
57
 
58
58
  describe '#ordered_file_set_ids' do
59
59
  it 'lists file_set ids' do
60
- generic_work1.ordered_members = [file_set1, file_set2]
61
- expect(generic_work1.ordered_file_set_ids).to eq [file_set1.id, file_set2.id]
60
+ work1.ordered_members = [file_set1, file_set2]
61
+ expect(work1.ordered_file_set_ids).to eq [file_set1.id, file_set2.id]
62
62
  end
63
63
  end
64
64
 
65
65
  context 'sub-class' do
66
66
  before do
67
- class TestWork < Hydra::Works::GenericWork
67
+ class TestWork < Hydra::Works::Work
68
68
  end
69
69
  end
70
70
 
71
71
  subject { TestWork.new(ordered_members: [file_set1]) }
72
72
 
73
- it 'has many generic files' do
73
+ it 'has many file sets' do
74
74
  expect(subject.ordered_file_sets).to eq [file_set1]
75
75
  end
76
76
  end
77
77
 
78
78
  describe 'Related objects' do
79
- let(:generic_work1) { described_class.new }
79
+ let(:work1) { described_class.new }
80
80
  let(:object1) { Hydra::PCDM::Object.new }
81
81
 
82
82
  before do
83
- generic_work1.related_objects = [object1]
83
+ work1.related_objects = [object1]
84
84
  end
85
85
 
86
86
  it 'persists' do
87
- expect(generic_work1.related_objects).to eq [object1]
87
+ expect(work1.related_objects).to eq [object1]
88
88
  end
89
89
  end
90
90
 
@@ -94,13 +94,13 @@ describe Hydra::Works::GenericWork do
94
94
  before do
95
95
  subject.ordered_members << file_set1
96
96
  subject.ordered_members << file_set2
97
- subject.ordered_members << generic_work1
98
- subject.ordered_members << generic_work2
97
+ subject.ordered_members << work1
98
+ subject.ordered_members << work2
99
99
  end
100
100
 
101
- it 'adds generic_work to generic_work with file_sets and works' do
102
- subject.ordered_members << generic_work3
103
- expect(subject.ordered_works).to eq [generic_work1, generic_work2, generic_work3]
101
+ it 'adds work to work with file_sets and works' do
102
+ subject.ordered_members << work3
103
+ expect(subject.ordered_works).to eq [work1, work2, work3]
104
104
  end
105
105
  end
106
106
 
@@ -113,21 +113,21 @@ describe Hydra::Works::GenericWork do
113
113
  after { Object.send(:remove_const, :DummyIncWork) }
114
114
  let(:iwork1) { DummyIncWork.new }
115
115
 
116
- it 'accepts implementing generic_work as a child' do
116
+ it 'accepts implementing work as a child' do
117
117
  subject.ordered_members << iwork1
118
118
  expect(subject.ordered_works).to eq [iwork1]
119
119
  end
120
120
  end
121
121
 
122
- describe 'aggregates works that extend Hydra::Works::GenericWork' do
122
+ describe 'aggregates works that extend Hydra::Works::Work' do
123
123
  before do
124
- class DummyExtWork < Hydra::Works::GenericWork
124
+ class DummyExtWork < Hydra::Works::Work
125
125
  end
126
126
  end
127
127
  after { Object.send(:remove_const, :DummyExtWork) }
128
128
  let(:ework1) { DummyExtWork.new }
129
129
 
130
- it 'accepts extending generic_work as a child' do
130
+ it 'accepts extending work as a child' do
131
131
  subject.ordered_members << ework1
132
132
  expect(subject.ordered_works).to eq [ework1]
133
133
  end
@@ -135,25 +135,25 @@ describe Hydra::Works::GenericWork do
135
135
  end
136
136
  end
137
137
 
138
- context 'move generic file' do
138
+ context 'move file set' do
139
139
  before do
140
140
  subject.ordered_members << file_set1
141
141
  subject.ordered_members << file_set2
142
142
  end
143
143
  it 'moves file from one work to another' do
144
144
  expect(subject.ordered_file_sets).to eq([file_set1, file_set2])
145
- expect(generic_work1.ordered_file_sets).to eq([])
145
+ expect(work1.ordered_file_sets).to eq([])
146
146
  subject.ordered_member_proxies.delete_at(0)
147
- generic_work1.ordered_members << file_set1
147
+ work1.ordered_members << file_set1
148
148
  expect(subject.ordered_file_sets).to eq([file_set2])
149
- expect(generic_work1.ordered_file_sets).to eq([file_set1])
149
+ expect(work1.ordered_file_sets).to eq([file_set1])
150
150
  end
151
151
  end
152
152
 
153
153
  describe '#file_sets' do
154
154
  it 'returns empty array when only works are aggregated' do
155
- subject.ordered_members << generic_work1
156
- subject.ordered_members << generic_work2
155
+ subject.ordered_members << work1
156
+ subject.ordered_members << work2
157
157
  expect(subject.ordered_file_sets).to eq []
158
158
  end
159
159
 
@@ -161,8 +161,8 @@ describe Hydra::Works::GenericWork do
161
161
  before do
162
162
  subject.ordered_members << file_set1
163
163
  subject.ordered_members << file_set2
164
- subject.ordered_members << generic_work1
165
- subject.ordered_members << generic_work2
164
+ subject.ordered_members << work1
165
+ subject.ordered_members << work2
166
166
  end
167
167
 
168
168
  it 'returns only file_sets' do
@@ -179,10 +179,10 @@ describe Hydra::Works::GenericWork do
179
179
  before do
180
180
  subject.ordered_members << file_set1
181
181
  subject.ordered_members << file_set2
182
- subject.ordered_members << generic_work2
182
+ subject.ordered_members << work2
183
183
  subject.ordered_members << file_set3
184
184
  subject.ordered_members << file_set4
185
- subject.ordered_members << generic_work1
185
+ subject.ordered_members << work1
186
186
  subject.ordered_members << file_set5
187
187
  expect(subject.ordered_file_sets).to eq [file_set1, file_set2, file_set3, file_set4, file_set5]
188
188
  end
@@ -190,19 +190,19 @@ describe Hydra::Works::GenericWork do
190
190
  it 'removes first collection' do
191
191
  subject.ordered_member_proxies.delete_at(0)
192
192
  expect(subject.ordered_file_sets).to eq [file_set2, file_set3, file_set4, file_set5]
193
- expect(subject.ordered_works).to eq [generic_work2, generic_work1]
193
+ expect(subject.ordered_works).to eq [work2, work1]
194
194
  end
195
195
 
196
196
  it 'removes last collection' do
197
197
  subject.ordered_member_proxies.delete_at(6)
198
198
  expect(subject.ordered_file_sets).to eq [file_set1, file_set2, file_set3, file_set4]
199
- expect(subject.ordered_works).to eq [generic_work2, generic_work1]
199
+ expect(subject.ordered_works).to eq [work2, work1]
200
200
  end
201
201
 
202
202
  it 'removes middle collection' do
203
203
  subject.ordered_member_proxies.delete_at(3)
204
204
  expect(subject.ordered_file_sets).to eq [file_set1, file_set2, file_set4, file_set5]
205
- expect(subject.ordered_works).to eq [generic_work2, generic_work1]
205
+ expect(subject.ordered_works).to eq [work2, work1]
206
206
  end
207
207
  end
208
208
  end
@@ -210,21 +210,21 @@ describe Hydra::Works::GenericWork do
210
210
  describe 'should have parent work and collection accessors' do
211
211
  let(:collection1) { Hydra::Works::Collection.new }
212
212
  before do
213
- collection1.ordered_members << generic_work2
214
- generic_work1.ordered_members << generic_work2
213
+ collection1.ordered_members << work2
214
+ work1.ordered_members << work2
215
215
  collection1.save
216
- generic_work1.save
217
- generic_work2.save
216
+ work1.save
217
+ work2.save
218
218
  end
219
219
 
220
220
  it 'has parents' do
221
- expect(generic_work2.member_of).to eq [collection1, generic_work1]
221
+ expect(work2.member_of).to eq [collection1, work1]
222
222
  end
223
223
  it 'has a parent collection' do
224
- expect(generic_work2.in_collections).to eq [collection1]
224
+ expect(work2.in_collections).to eq [collection1]
225
225
  end
226
- it 'has a parent generic_work' do
227
- expect(generic_work2.in_works).to eq [generic_work1]
226
+ it 'has a parent work' do
227
+ expect(work2.in_works).to eq [work1]
228
228
  end
229
229
  end
230
230
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Hydra::Works::AddFileToFileSet do
4
- let(:generic_file) { Hydra::Works::FileSet.new }
4
+ let(:file_set) { Hydra::Works::FileSet.new }
5
5
  let(:filename) { 'sample-file.pdf' }
6
6
  let(:filename2) { 'updated-file.txt' }
7
7
  let(:original_name) { 'original-name.pdf' }
@@ -11,21 +11,21 @@ describe Hydra::Works::AddFileToFileSet do
11
11
  let(:update_existing) { true }
12
12
  let(:mime_type) { 'application/pdf' }
13
13
 
14
- context 'when generic_file is not persisted' do
15
- let(:generic_file) { Hydra::Works::FileSet.new }
16
- it 'saves generic_file' do
17
- described_class.call(generic_file, file, type)
18
- expect(generic_file.persisted?).to be true
14
+ context 'when file_set is not persisted' do
15
+ let(:file_set) { Hydra::Works::FileSet.new }
16
+ it 'saves file_set' do
17
+ described_class.call(file_set, file, type)
18
+ expect(file_set.persisted?).to be true
19
19
  end
20
20
  end
21
21
 
22
- context 'when generic_file is not valid' do
22
+ context 'when file_set is not valid' do
23
23
  before do
24
- generic_file.save
25
- allow(generic_file).to receive(:valid?).and_return(false)
24
+ file_set.save
25
+ allow(file_set).to receive(:valid?).and_return(false)
26
26
  end
27
27
  it 'returns false' do
28
- expect(described_class.call(generic_file, file, type)).to be false
28
+ expect(described_class.call(file_set, file, type)).to be false
29
29
  end
30
30
  end
31
31
 
@@ -33,9 +33,9 @@ describe Hydra::Works::AddFileToFileSet do
33
33
  before do
34
34
  allow(file).to receive(:mime_type).and_return(mime_type)
35
35
  allow(file).to receive(:original_name).and_return(original_name)
36
- described_class.call(generic_file, file, type)
36
+ described_class.call(file_set, file, type)
37
37
  end
38
- subject { generic_file.filter_files_by_type(type).first }
38
+ subject { file_set.filter_files_by_type(type).first }
39
39
  it 'uses the mime_type and original_name methods' do
40
40
  expect(subject.mime_type).to eq(mime_type)
41
41
  expect(subject.original_name).to eq(original_name)
@@ -46,38 +46,38 @@ describe Hydra::Works::AddFileToFileSet do
46
46
  it 'defaults to Hydra::PCDM for mimetype and ::File for basename.' do
47
47
  expect(Hydra::PCDM::GetMimeTypeForFile).to receive(:call).with(file.path)
48
48
  expect(::File).to receive(:basename).with(file.path)
49
- described_class.call(generic_file, file, type)
49
+ described_class.call(file_set, file, type)
50
50
  end
51
51
  end
52
52
 
53
53
  it 'adds the given file and applies the specified type to it' do
54
- described_class.call(generic_file, file, type, update_existing: update_existing)
55
- expect(generic_file.filter_files_by_type(type).first.content).to start_with('%PDF-1.3')
54
+ described_class.call(file_set, file, type, update_existing: update_existing)
55
+ expect(file_set.filter_files_by_type(type).first.content).to start_with('%PDF-1.3')
56
56
  end
57
57
 
58
58
  context 'when :type is the name of an association' do
59
59
  let(:type) { :extracted_text }
60
60
  before do
61
- described_class.call(generic_file, file, type)
61
+ described_class.call(file_set, file, type)
62
62
  end
63
63
  it "builds and uses the association's target" do
64
- expect(generic_file.extracted_text.content).to start_with('%PDF-1.3')
64
+ expect(file_set.extracted_text.content).to start_with('%PDF-1.3')
65
65
  end
66
66
  end
67
67
 
68
68
  context 'when :versioning => true' do
69
69
  let(:type) { :original_file }
70
70
  let(:versioning) { true }
71
- subject { generic_file }
71
+ subject { file_set }
72
72
  it 'updates the file and creates a version' do
73
- described_class.call(generic_file, file, type, versioning: versioning)
73
+ described_class.call(file_set, file, type, versioning: versioning)
74
74
  expect(subject.original_file.versions.all.count).to eq(1)
75
75
  expect(subject.original_file.content).to start_with('%PDF-1.3')
76
76
  end
77
77
  context 'and there are already versions' do
78
78
  before do
79
- described_class.call(generic_file, file, type, versioning: versioning)
80
- described_class.call(generic_file, file2, type, versioning: versioning)
79
+ described_class.call(file_set, file, type, versioning: versioning)
80
+ described_class.call(file_set, file2, type, versioning: versioning)
81
81
  end
82
82
  it 'adds to the version history' do
83
83
  expect(subject.original_file.versions.all.count).to eq(2)
@@ -90,9 +90,9 @@ describe Hydra::Works::AddFileToFileSet do
90
90
  let(:type) { :original_file }
91
91
  let(:versioning) { false }
92
92
  before do
93
- described_class.call(generic_file, file, type, versioning: versioning)
93
+ described_class.call(file_set, file, type, versioning: versioning)
94
94
  end
95
- subject { generic_file }
95
+ subject { file_set }
96
96
  it 'skips creating versions' do
97
97
  expect(subject.original_file.versions.all.count).to eq(0)
98
98
  expect(subject.original_file.content).to start_with('%PDF-1.3')
@@ -1,27 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Hydra::Works::UploadFileToFileSet do
4
- let(:generic_work) { Hydra::Works::GenericWork.new }
5
- let(:generic_file) { Hydra::Works::FileSet.new }
6
- let(:file) { File.open(File.join(fixture_path, 'sample-file.pdf')) }
7
- let(:updated_file) { File.open(File.join(fixture_path, 'updated-file.txt')) }
8
- let(:mime_type) { 'application/pdf' }
9
- let(:original_name) { 'my_original.pdf' }
10
- let(:updated_mime_type) { 'text/plain' }
11
- let(:updated_name) { 'my_updated.txt' }
4
+ let(:work) { Hydra::Works::Work.new }
5
+ let(:file_set) { Hydra::Works::FileSet.new }
6
+ let(:file) { File.open(File.join(fixture_path, 'sample-file.pdf')) }
7
+ let(:updated_file) { File.open(File.join(fixture_path, 'updated-file.txt')) }
8
+ let(:mime_type) { 'application/pdf' }
9
+ let(:original_name) { 'my_original.pdf' }
10
+ let(:updated_mime_type) { 'text/plain' }
11
+ let(:updated_name) { 'my_updated.txt' }
12
12
 
13
13
  context 'when you provide mime_type and original_name, etc' do
14
14
  it 'uses the provided values' do
15
- expect(Hydra::Works::AddFileToFileSet).to receive(:call).with(generic_file, file, :original_file, update_existing: true, versioning: true)
16
- described_class.call(generic_file, file)
15
+ expect(Hydra::Works::AddFileToFileSet).to receive(:call).with(file_set, file, :original_file, update_existing: true, versioning: true)
16
+ described_class.call(file_set, file)
17
17
  end
18
18
  end
19
19
 
20
20
  # Duplicate test from add_file_spec
21
- context 'without a proper generic file' do
22
- let(:error_message) { 'supplied object must be a generic file' }
21
+ context 'without a proper file set' do
22
+ let(:error_message) { 'supplied object must be a file set' }
23
23
  it 'raises an error' do
24
- expect(-> { described_class.call(generic_work, file) }).to raise_error(ArgumentError, error_message)
24
+ expect(-> { described_class.call(work, file) }).to raise_error(ArgumentError, error_message)
25
25
  end
26
26
  end
27
27
 
@@ -29,20 +29,20 @@ describe Hydra::Works::UploadFileToFileSet do
29
29
  context 'without file that responds to read.' do
30
30
  let(:error_message) { 'supplied file must respond to read' }
31
31
  it 'raises an error' do
32
- expect(-> { described_class.call(generic_file, ['this does not respond to read.']) }).to raise_error(ArgumentError, error_message)
32
+ expect(-> { described_class.call(file_set, ['this does not respond to read.']) }).to raise_error(ArgumentError, error_message)
33
33
  end
34
34
  end
35
35
 
36
- context 'with an empty generic file' do
36
+ context 'with an empty file set' do
37
37
  let(:additional_services) { [] }
38
38
  before do
39
39
  allow(file).to receive(:mime_type).and_return(mime_type)
40
40
  allow(file).to receive(:original_name).and_return(original_name)
41
- described_class.call(generic_file, file, additional_services: additional_services)
41
+ described_class.call(file_set, file, additional_services: additional_services)
42
42
  end
43
43
 
44
44
  describe 'the uploaded file' do
45
- subject { generic_file.original_file }
45
+ subject { file_set.original_file }
46
46
  it 'has updated properties' do
47
47
  expect(subject.content).to start_with('%PDF-1.3')
48
48
  expect(subject.mime_type).to eql mime_type
@@ -50,8 +50,8 @@ describe Hydra::Works::UploadFileToFileSet do
50
50
  end
51
51
  end
52
52
 
53
- describe "the generic file's generated files" do
54
- subject { generic_file }
53
+ describe "the file set's generated files" do
54
+ subject { file_set }
55
55
  it 'has content and generated files' do
56
56
  expect(subject.original_file.content).to start_with('%PDF-1.3')
57
57
  expect(subject.original_file.mime_type).to eql mime_type
@@ -68,12 +68,12 @@ describe Hydra::Works::UploadFileToFileSet do
68
68
  allow(updated_file).to receive(:mime_type).and_return(updated_mime_type)
69
69
  allow(updated_file).to receive(:original_name).and_return(updated_name)
70
70
 
71
- described_class.call(generic_file, file, additional_services: additional_services)
72
- described_class.call(generic_file, updated_file, additional_services: additional_services, update_existing: true)
71
+ described_class.call(file_set, file, additional_services: additional_services)
72
+ described_class.call(file_set, updated_file, additional_services: additional_services, update_existing: true)
73
73
  end
74
74
 
75
75
  describe 'the new file' do
76
- subject { generic_file.original_file }
76
+ subject { file_set.original_file }
77
77
  it 'has updated properties' do
78
78
  updated_file.rewind
79
79
  expect(subject.content).to eql updated_file.read