ddr-models 3.0.0.beta.3 → 3.0.0.beta.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/config/locales/ddr-models.en.yml +74 -0
  4. data/ddr-models.gemspec +3 -2
  5. data/lib/ddr/auth.rb +5 -2
  6. data/lib/ddr/auth/roles.rb +0 -2
  7. data/lib/ddr/auth/roles/role_set.rb +1 -0
  8. data/lib/ddr/derivatives/generators/png_generator.rb +1 -1
  9. data/lib/ddr/index.rb +6 -2
  10. data/lib/ddr/index/abstract_query_result.rb +1 -1
  11. data/lib/ddr/index/csv_options.rb +14 -0
  12. data/lib/ddr/index/csv_query_result.rb +39 -32
  13. data/lib/ddr/index/field.rb +11 -1
  14. data/lib/ddr/index/field_attribute.rb +22 -0
  15. data/lib/ddr/index/fields.rb +29 -20
  16. data/lib/ddr/index/filter.rb +81 -30
  17. data/lib/ddr/index/filters.rb +15 -10
  18. data/lib/ddr/index/query.rb +34 -13
  19. data/lib/ddr/index/query_builder.rb +150 -30
  20. data/lib/ddr/index/query_clause.rb +64 -19
  21. data/lib/ddr/index/query_params.rb +40 -0
  22. data/lib/ddr/index/solr_csv_options.rb +18 -0
  23. data/lib/ddr/index/sort_order.rb +28 -0
  24. data/lib/ddr/jobs.rb +5 -1
  25. data/lib/ddr/jobs/fits_file_characterization.rb +3 -41
  26. data/lib/ddr/jobs/fixity_check.rb +13 -0
  27. data/lib/ddr/jobs/job.rb +36 -0
  28. data/lib/ddr/jobs/queue.rb +27 -0
  29. data/lib/ddr/jobs/update_index.rb +13 -0
  30. data/lib/ddr/models.rb +20 -3
  31. data/lib/ddr/models/admin_set.rb +7 -3
  32. data/lib/ddr/models/contact.rb +19 -0
  33. data/lib/ddr/models/error.rb +3 -0
  34. data/lib/ddr/models/file_characterization.rb +37 -0
  35. data/lib/ddr/models/finding_aid.rb +35 -2
  36. data/lib/ddr/models/has_admin_metadata.rb +5 -1
  37. data/lib/ddr/models/has_content.rb +4 -2
  38. data/lib/ddr/models/indexing.rb +7 -0
  39. data/lib/ddr/models/licenses/license.rb +7 -3
  40. data/lib/ddr/models/solr_document.rb +2 -2
  41. data/lib/ddr/models/version.rb +1 -1
  42. data/lib/ddr/models/with_content_file.rb +37 -0
  43. data/lib/ddr/vocab/asset.rb +3 -0
  44. data/spec/derivatives/png_generator_spec.rb +8 -1
  45. data/spec/fixtures/arrow1rightred_e0.gif +0 -0
  46. data/spec/index/fields_spec.rb +197 -0
  47. data/spec/index/filter_spec.rb +155 -30
  48. data/spec/index/query_builder_spec.rb +116 -0
  49. data/spec/index/query_clause_spec.rb +58 -0
  50. data/spec/index/query_spec.rb +39 -10
  51. data/spec/jobs/fits_file_characterization_spec.rb +7 -43
  52. data/spec/jobs/fixity_check_spec.rb +22 -0
  53. data/spec/jobs/job_spec.rb +40 -0
  54. data/spec/jobs/update_index_spec.rb +22 -0
  55. data/spec/managers/derivatives_manager_spec.rb +15 -11
  56. data/spec/models/admin_set_spec.rb +28 -10
  57. data/spec/models/contact_spec.rb +42 -0
  58. data/spec/models/effective_license_spec.rb +17 -7
  59. data/spec/models/file_characterization_spec.rb +38 -0
  60. data/spec/models/finding_aid_spec.rb +31 -8
  61. data/spec/models/has_admin_metadata_spec.rb +8 -5
  62. data/spec/models/indexing_spec.rb +2 -0
  63. data/spec/models/license_spec.rb +31 -10
  64. data/spec/models/solr_document_spec.rb +23 -3
  65. data/spec/models/with_content_file_spec.rb +32 -0
  66. data/spec/spec_helper.rb +2 -0
  67. metadata +66 -28
  68. data/lib/ddr/contacts.rb +0 -25
  69. data/lib/ddr/index/query_value.rb +0 -18
  70. data/lib/ddr/models/access_controllable.rb +0 -12
  71. data/spec/auth/ldap_gateway_spec.rb +0 -9
  72. data/spec/contacts/contacts_spec.rb +0 -26
  73. data/spec/index/filters_spec.rb +0 -17
@@ -1,45 +1,170 @@
1
1
  module Ddr::Index
2
2
  RSpec.describe Filter do
3
3
 
4
- describe "#where(conditions)" do
5
- it "should add raw query filters for the field, value hash of conditions" do
6
- subject.where("foo"=>"bar", "spam"=>"eggs", "stuff"=>["dog", "cat", "bird"])
7
- expect(subject.clauses).to eq(["{!term f=foo}bar", "{!term f=spam}eggs", "stuff:(dog OR cat OR bird)"])
8
- end
9
- end
4
+ its(:clauses) { are_expected.to eq [] }
10
5
 
11
- describe "#raw(*clauses)" do
12
- it "should add the clauses w/o escaping" do
13
- subject.raw("foo:bar", "spam:eggs")
14
- expect(subject.clauses).to eq(["foo:bar", "spam:eggs"])
6
+ describe "equality" do
7
+ describe "when the other is a Filter instance" do
8
+ describe "and the clauses are equal" do
9
+ subject { described_class.new(clauses: ["foo:bar", "spam:eggs"]) }
10
+ let(:other) { described_class.new(clauses: ["foo:bar", "spam:eggs"]) }
11
+ specify { expect(subject).to eq other }
12
+ end
13
+ describe "and the clauses are not equal" do
14
+ subject { described_class.new(clauses: ["foo:bar", "bam:baz"]) }
15
+ let(:other) { described_class.new(clauses: ["foo:bar", "spam:eggs"]) }
16
+ specify { expect(subject).not_to eq other }
17
+ end
15
18
  end
16
- end
17
-
18
- describe "#present(field)" do
19
- it "should add a \"field present\" clause" do
20
- subject.present("foo")
21
- expect(subject.clauses).to eq(["foo:[* TO *]"])
19
+ describe "when the other is not a Filter instance" do
20
+ subject { described_class.new(clauses: ["foo:bar", "spam:eggs"]) }
21
+ let(:other) { double(clauses: ["foo:bar", "spam:eggs"]) }
22
+ specify { expect(subject).not_to eq other }
22
23
  end
23
24
  end
24
25
 
25
- describe "#absent(field)" do
26
- it "should add a \"field not present\" clause" do
27
- subject.absent("foo")
28
- expect(subject.clauses).to eq(["-foo:[* TO *]"])
26
+ describe "class methods" do
27
+ describe ".is_governed_by" do
28
+ describe "with an object" do
29
+ subject { described_class.is_governed_by(Item.new(id: "test-1")) }
30
+ its(:clauses) {
31
+ are_expected.to eq([QueryClause.term(:is_governed_by, "test-1")])
32
+ }
33
+ end
34
+ describe "with an ID" do
35
+ subject { described_class.is_governed_by("test-1") }
36
+ its(:clauses) {
37
+ are_expected.to eq([QueryClause.term(:is_governed_by, "test-1")])
38
+ }
39
+ end
29
40
  end
30
- end
31
-
32
- describe "#before_days(field, days)" do
33
- it "should add a date range query clause" do
34
- subject.before_days("foo", 60)
35
- expect(subject.clauses).to eq(["foo:[* TO NOW-60DAYS]"])
41
+ describe ".is_member_of_collection" do
42
+ describe "with an object" do
43
+ subject { described_class.is_member_of_collection(Item.new(id: "test-1")) }
44
+ its(:clauses) {
45
+ are_expected.to eq([QueryClause.term(:is_member_of_collection, "test-1")])
46
+ }
47
+ end
48
+ describe "with an ID" do
49
+ subject { described_class.is_member_of_collection("test-1") }
50
+ its(:clauses) {
51
+ are_expected.to eq([QueryClause.term(:is_member_of_collection, "test-1")])
52
+ }
53
+ end
54
+ end
55
+ describe ".has_content" do
56
+ subject { described_class.has_content }
57
+ its(:clauses) {
58
+ are_expected.to eq([QueryClause.where(:active_fedora_model, ["Component", "Attachment", "Target"])])
59
+ }
60
+ end
61
+ describe ".model" do
62
+ describe "with a single model" do
63
+ subject { described_class.model("Component") }
64
+ its(:clauses) {
65
+ are_expected.to eq([QueryClause.where(:active_fedora_model, "Component")])
66
+ }
67
+ end
68
+ describe "with a list of models" do
69
+ subject { described_class.model("Component", "Attachment", "Target") }
70
+ its(:clauses) {
71
+ are_expected.to eq([QueryClause.where(:active_fedora_model, ["Component", "Attachment", "Target"])])
72
+ }
73
+ end
74
+ end
75
+ describe ".where" do
76
+ subject { described_class.where("foo"=>"bar", "spam"=>"eggs", "stuff"=>["dog", "cat", "bird"]) }
77
+ its(:clauses) {
78
+ are_expected.to eq([QueryClause.where("foo", "bar"),
79
+ QueryClause.where("spam", "eggs"),
80
+ QueryClause.where("stuff", ["dog", "cat", "bird"])
81
+ ])
82
+ }
83
+ end
84
+ describe ".raw" do
85
+ subject { described_class.raw("foo:bar", "spam:eggs") }
86
+ its(:clauses) { are_expected.to eq(["foo:bar", "spam:eggs"]) }
87
+ end
88
+ describe ".negative" do
89
+ subject { described_class.negative("foo", "bar") }
90
+ its(:clauses) { are_expected.to eq([QueryClause.negative("foo", "bar")]) }
91
+ end
92
+ describe ".present" do
93
+ subject { described_class.present("foo") }
94
+ its(:clauses) { are_expected.to eq([QueryClause.present("foo")]) }
95
+ end
96
+ describe ".absent" do
97
+ subject { described_class.absent("foo") }
98
+ its(:clauses) { are_expected.to eq([QueryClause.absent("foo")]) }
99
+ end
100
+ describe ".before_days" do
101
+ subject { described_class.before_days("foo", 60) }
102
+ its(:clauses) { are_expected.to eq([QueryClause.before_days("foo", 60)]) }
103
+ end
104
+ describe ".before" do
105
+ subject { described_class.before("foo", DateTime.parse("Thu, 27 Aug 2015 17:42:34 -0400")) }
106
+ its(:clauses) {
107
+ are_expected.to eq([QueryClause.before("foo", DateTime.parse("Thu, 27 Aug 2015 17:42:34 -0400"))])
108
+ }
36
109
  end
37
110
  end
38
111
 
39
- describe "#before(field, date_time)" do
40
- it "should add a date range query clause" do
41
- subject.before("foo", DateTime.parse("Thu, 27 Aug 2015 17:42:34 -0400"))
42
- expect(subject.clauses).to eq(["foo:[* TO 2015-08-27T21:42:34Z]"])
112
+ describe "API methods" do
113
+ describe "#where" do
114
+ it "adds query clauses for the hash of conditions" do
115
+ subject.where("foo"=>"bar", "spam"=>"eggs", "stuff"=>["dog", "cat", "bird"])
116
+ expect(subject.clauses).to eq([QueryClause.where("foo", "bar"),
117
+ QueryClause.where("spam", "eggs"),
118
+ QueryClause.where("stuff", ["dog", "cat", "bird"])
119
+ ])
120
+ end
121
+ end
122
+ describe "#where_not" do
123
+ it "adds negative query clauses for the hash of conditions" do
124
+ subject.where_not("foo"=>"bar", "spam"=>"eggs", "stuff"=>["dog", "cat", "bird"])
125
+ expect(subject.clauses).to eq([QueryClause.negative("foo", "bar"),
126
+ QueryClause.negative("spam", "eggs"),
127
+ QueryClause.negative("stuff", "dog"),
128
+ QueryClause.negative("stuff", "cat"),
129
+ QueryClause.negative("stuff", "bird")
130
+ ])
131
+ end
132
+ end
133
+ describe "#raw" do
134
+ it "adds the query clauses w/o escaping" do
135
+ subject.raw("foo:bar", "spam:eggs")
136
+ expect(subject.clauses).to eq(["foo:bar", "spam:eggs"])
137
+ end
138
+ end
139
+ describe "#negative" do
140
+ it "adds a negation query clause" do
141
+ subject.negative("foo", "bar")
142
+ expect(subject.clauses).to eq([QueryClause.negative("foo", "bar")])
143
+ end
144
+ end
145
+ describe "#present" do
146
+ it "adds a \"field present\" query clause" do
147
+ subject.present("foo")
148
+ expect(subject.clauses).to eq([QueryClause.present("foo")])
149
+ end
150
+ end
151
+ describe "#absent" do
152
+ it "adds a \"field not present\" query clause" do
153
+ subject.absent("foo")
154
+ expect(subject.clauses).to eq([QueryClause.absent("foo")])
155
+ end
156
+ end
157
+ describe "#before_days" do
158
+ it "adds a date range query clause" do
159
+ subject.before_days("foo", 60)
160
+ expect(subject.clauses).to eq([QueryClause.before_days("foo", 60)])
161
+ end
162
+ end
163
+ describe "#before" do
164
+ it "adds a date range query clause" do
165
+ subject.before("foo", DateTime.parse("Thu, 27 Aug 2015 17:42:34 -0400"))
166
+ expect(subject.clauses).to eq([QueryClause.before("foo", DateTime.parse("Thu, 27 Aug 2015 17:42:34 -0400"))])
167
+ end
43
168
  end
44
169
  end
45
170
 
@@ -0,0 +1,116 @@
1
+ module Ddr::Index
2
+ RSpec.describe QueryBuilder do
3
+
4
+ describe "DSL" do
5
+ describe "id" do
6
+ subject { described_class.new { id "test:1" } }
7
+ specify {
8
+ expect(subject.query.rows).to eq 1
9
+ expect(subject.query.q).to eq QueryClause.id("test:1")
10
+ }
11
+ end
12
+ describe "q" do
13
+ subject { described_class.new { q "foo:bar" } }
14
+ specify { expect(subject.query.q).to eq "foo:bar" }
15
+ end
16
+ describe "asc" do
17
+ subject { described_class.new { asc "foo", "bar" } }
18
+ specify {
19
+ expect(subject.query.sort).to eq [SortOrder.asc("foo"), SortOrder.asc("bar")]
20
+ }
21
+ end
22
+ describe "desc" do
23
+ subject { described_class.new { desc "foo", "bar" } }
24
+ specify {
25
+ expect(subject.query.sort).to eq [SortOrder.desc("foo"), SortOrder.desc("bar")]
26
+ }
27
+ end
28
+ describe "filter" do
29
+ subject { described_class.new { filter Filter.where("foo"=>"bar") } }
30
+ specify { expect(subject.query.filters).to eq [Filter.where("foo"=>"bar")] }
31
+ end
32
+ describe "filters" do
33
+ subject {
34
+ described_class.new { filters Filter.where("foo"=>"bar"), Filter.where("bing"=>"bang") }
35
+ }
36
+ specify {
37
+ expect(subject.query.filters).to eq([Filter.where("foo"=>"bar"),
38
+ Filter.where("bing"=>"bang")
39
+ ])
40
+ }
41
+ end
42
+ describe "field" do
43
+ subject { described_class.new { field "foo", "bar" } }
44
+ specify { expect(subject.query.fields).to include("foo", "bar") }
45
+ end
46
+ describe "fields" do
47
+ subject { described_class.new { fields "foo", "bar" } }
48
+ specify { expect(subject.query.fields).to include("foo", "bar") }
49
+ end
50
+ describe "sort" do
51
+ subject { described_class.new { sort "foo"=>"asc", "bar"=>"desc" } }
52
+ specify {
53
+ expect(subject.query.sort).to eq([SortOrder.new(field: "foo", order: "asc"),
54
+ SortOrder.new(field: "bar", order: "desc")
55
+ ])
56
+ }
57
+ end
58
+ describe "order_by" do
59
+ subject { described_class.new { order_by "foo"=>"asc", "bar"=>"desc" } }
60
+ specify { expect(subject.query.sort).to eq [SortOrder.new(field: "foo", order: "asc"), SortOrder.new(field: "bar", order: "desc")] }
61
+ end
62
+ describe "limit" do
63
+ subject { described_class.new { limit 5 } }
64
+ specify { expect(subject.query.rows).to eq 5 }
65
+ end
66
+ describe "rows" do
67
+ subject { described_class.new { rows 5 } }
68
+ specify { expect(subject.query.rows).to eq 5 }
69
+ end
70
+ describe "raw" do
71
+ subject { described_class.new { raw "foo:bar" } }
72
+ specify { expect(subject.query.filters).to eq [Filter.raw("foo:bar")] }
73
+ end
74
+ describe "where" do
75
+ subject { described_class.new { where "foo"=>"bar" } }
76
+ specify { expect(subject.query.filters).to eq [Filter.where("foo"=>"bar")] }
77
+ end
78
+ describe "absent" do
79
+ subject { described_class.new { absent "foo" } }
80
+ specify { expect(subject.query.filters).to eq [Filter.absent("foo")] }
81
+ end
82
+ describe "present" do
83
+ subject { described_class.new { present "foo" } }
84
+ specify { expect(subject.query.filters).to eq [Filter.present("foo")] }
85
+ end
86
+ describe "before" do
87
+ subject {
88
+ described_class.new { before "foo", DateTime.parse("2015-12-14T20:40:06Z") }
89
+ }
90
+ specify {
91
+ expect(subject.query.filters).to eq [Filter.before("foo", DateTime.parse("2015-12-14T20:40:06Z"))]
92
+ }
93
+ end
94
+ describe "before_days" do
95
+ subject { described_class.new { before_days "foo", 7 } }
96
+ specify { expect(subject.query.filters).to eq [Filter.before_days("foo", 7)] }
97
+ end
98
+ end
99
+
100
+ describe "using static filters" do
101
+ describe "has_content" do
102
+ before { subject.has_content }
103
+ specify { expect(subject.query.filters).to eq [Filter.has_content] }
104
+ end
105
+ describe "is_governed_by" do
106
+ before { subject.is_governed_by "test:1" }
107
+ specify { expect(subject.query.filters).to eq [Filter.is_governed_by("test:1")] }
108
+ end
109
+ describe "is_governed_by" do
110
+ before { subject.is_member_of_collection "test:1" }
111
+ specify { expect(subject.query.filters).to eq [Filter.is_member_of_collection("test:1")] }
112
+ end
113
+ end
114
+
115
+ end
116
+ end
@@ -0,0 +1,58 @@
1
+ module Ddr::Index
2
+ RSpec.describe QueryClause do
3
+
4
+ describe "class methods" do
5
+ describe ".unique_key" do
6
+ subject { described_class.unique_key("test:1") }
7
+ its(:to_s) { is_expected.to eq "{!term f=id}test:1" }
8
+ end
9
+ describe ".id" do
10
+ subject { described_class.id("test:1") }
11
+ its(:to_s) { is_expected.to eq "{!term f=id}test:1" }
12
+ end
13
+ describe ".negative" do
14
+ subject { described_class.negative("foo", "Jungle Fever") }
15
+ its(:to_s) { is_expected.to eq "-foo:\"Jungle Fever\"" }
16
+ end
17
+ describe ".present" do
18
+ subject { described_class.present("foo") }
19
+ its(:to_s) { is_expected.to eq "foo:[* TO *]" }
20
+ end
21
+ describe ".absent" do
22
+ subject { described_class.absent("foo") }
23
+ its(:to_s) { is_expected.to eq "-foo:[* TO *]" }
24
+ end
25
+ describe ".disjunction" do
26
+ subject { described_class.disjunction("foo", ["Jungle Fever", "bar"]) }
27
+ its(:to_s) { is_expected.to eq "{!lucene q.op=OR df=foo}\"Jungle Fever\" bar" }
28
+ end
29
+ describe ".before" do
30
+ subject { described_class.before("foo", DateTime.parse("2015-12-14T20:40:06Z")) }
31
+ its(:to_s) { is_expected.to eq "foo:[* TO 2015-12-14T20:40:06Z]" }
32
+ end
33
+ describe ".before_days" do
34
+ subject { described_class.before_days("foo", 5) }
35
+ its(:to_s) { is_expected.to eq "foo:[* TO NOW-5DAYS]" }
36
+ end
37
+ describe ".term" do
38
+ subject { described_class.term("foo", "bar") }
39
+ its(:to_s) { is_expected.to eq "{!term f=foo}bar" }
40
+ end
41
+ describe ".where" do
42
+ describe "when the value is a string" do
43
+ subject { described_class.where("foo", "Jungle Fever") }
44
+ its(:to_s) { is_expected.to eq "foo:\"Jungle Fever\"" }
45
+ end
46
+ describe "when the value is an Array with one entry" do
47
+ subject { described_class.where("foo", ["Jungle Fever"]) }
48
+ its(:to_s) { is_expected.to eq "foo:\"Jungle Fever\"" }
49
+ end
50
+ describe "when the value is an array with multiple entries" do
51
+ subject { described_class.where("foo", ["Jungle Fever", "bar"]) }
52
+ its(:to_s) { is_expected.to eq "{!lucene q.op=OR df=foo}\"Jungle Fever\" bar" }
53
+ end
54
+ end
55
+ end
56
+
57
+ end
58
+ end
@@ -1,19 +1,48 @@
1
1
  module Ddr::Index
2
2
  RSpec.describe Query do
3
3
 
4
- subject do
5
- QueryBuilder.build do |query|
6
- query
7
- .q("foo:bar")
8
- .where("spam"=>"eggs")
9
- .fields("id", "foo", "spam")
10
- .limit(50)
11
- end
4
+ describe "initialized with attributes" do
5
+ let(:id) { UniqueKeyField.instance }
6
+ let(:foo) { Field.new("foo") }
7
+ let(:spam) { Field.new("spam") }
8
+ let(:filter) { Filter.where(spam=>"eggs") }
9
+ let(:sort_order) { SortOrder.new(field: foo, order: "asc") }
10
+ let(:fields) { [id, foo, spam] }
11
+
12
+ subject {
13
+ described_class.new(q: "foo:bar",
14
+ filters: [filter],
15
+ fields: fields,
16
+ sort: sort_order,
17
+ rows: 50)
18
+ }
19
+
20
+ its(:to_s) {
21
+ is_expected.to eq "q=foo%3Abar&fq=spam%3Aeggs&fl=id%2Cfoo%2Cspam&sort=foo+asc&rows=50"
22
+ }
23
+ its(:params) {
24
+ is_expected.to eq({q: "foo:bar", fl: "id,foo,spam", fq: ["spam:eggs"], sort: "foo asc", rows: 50})
25
+ }
12
26
  end
13
27
 
14
- its(:to_s) { is_expected.to eq("q=foo%3Abar&fq=%7B%21term+f%3Dspam%7Deggs&fl=id%2Cfoo%2Cspam&rows=50") }
28
+ describe "initialized with a block" do
29
+ subject {
30
+ described_class.new do
31
+ q "foo:bar"
32
+ where "spam"=>"eggs"
33
+ fields :id, "foo", "spam"
34
+ asc "foo"
35
+ limit 50
36
+ end
37
+ }
15
38
 
16
- its(:params) { is_expected.to eq({q: "foo:bar", fl: "id,foo,spam", fq: ["{!term f=spam}eggs"], rows: 50}) }
39
+ its(:to_s) {
40
+ is_expected.to eq "q=foo%3Abar&fq=spam%3Aeggs&fl=id%2Cfoo%2Cspam&sort=foo+asc&rows=50"
41
+ }
42
+ its(:params) {
43
+ is_expected.to eq({q: "foo:bar", fl: "id,foo,spam", fq: ["spam:eggs"], sort: "foo asc", rows: 50})
44
+ }
45
+ end
17
46
 
18
47
  end
19
48
  end
@@ -3,50 +3,14 @@ require 'spec_helper'
3
3
  module Ddr::Jobs
4
4
  RSpec.describe FitsFileCharacterization, jobs: true, file_characterization: true do
5
5
 
6
- shared_examples "has a fits update event" do
7
- let(:event) { object.update_events.last }
8
- it "should have the correct event attributes" do
9
- expect(event.outcome).to eq(expected_outcome)
10
- expect(event.detail).to eq(expected_detail)
11
- expect(event.software).to eq("fits #{fits_version}")
12
- end
13
- end
6
+ let(:obj) { double }
14
7
 
15
- context "content-bearing object" do
16
- let(:object) { TestContent.create }
17
- let(:stdout_msg) { '<fits />' }
18
- let(:stderr_msg) { 'stderr msg' }
19
- let(:fits_version) { '0.9.9 '}
20
- before { allow(Ddr::Jobs::FitsFileCharacterization).to receive(:fits_version) { fits_version } }
21
- context "fits command is successful" do
22
- let(:expected_outcome) { Ddr::Events::Event::SUCCESS }
23
- let(:expected_detail) { nil }
24
- before do
25
- allow(Open3).to receive(:capture3) { [ stdout_msg, stderr_msg, $? ] }
26
- allow_any_instance_of(Process::Status).to receive(:success?) { true }
27
- Ddr::Jobs::FitsFileCharacterization.perform(object.id)
28
- object.reload
29
- end
30
- it "should populate the fits datastream" do
31
- expect(object.fits.content).to be_present
32
- end
33
- it_behaves_like "has a fits update event"
34
- end
35
- context "fits command is not successful" do
36
- let(:expected_outcome) { Ddr::Events::Event::FAILURE }
37
- let(:expected_detail) { stderr_msg }
38
- before do
39
- allow(Open3).to receive(:capture3) { [ stdout_msg, stderr_msg, $? ] }
40
- allow_any_instance_of(Process::Status).to receive(:success?) { false }
41
- Ddr::Jobs::FitsFileCharacterization.perform(object.id)
42
- object.reload
43
- end
44
- it "should not populate the fits datastream" do
45
- expect(object.fits.content).to_not be_present
46
- end
47
- it_behaves_like "has a fits update event"
48
- end
49
- end
8
+ before { allow(ActiveFedora::Base).to receive(:find).with("test:1") { obj } }
9
+
10
+ specify {
11
+ expect(Ddr::Models::FileCharacterization).to receive(:call).with(obj) { nil }
12
+ described_class.perform("test:1")
13
+ }
50
14
 
51
15
  end
52
16
  end