ddr-models 2.5.3 → 2.6.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/users/sessions_controller.rb +0 -5
- data/config/initializers/devise.rb +3 -2
- data/config/initializers/rsolr_monkey_patches.rb +7 -0
- data/config/initializers/subscriptions.rb +0 -2
- data/ddr-models.gemspec +2 -1
- data/lib/ddr/actions/virus_check.rb +0 -1
- data/lib/ddr/auth.rb +0 -4
- data/lib/ddr/auth/ability_definitions/role_based_ability_definitions.rb +9 -16
- data/lib/ddr/derivatives/generator.rb +0 -2
- data/lib/ddr/derivatives/png_generator.rb +2 -4
- data/lib/ddr/derivatives/ptif_generator.rb +6 -7
- data/lib/ddr/index/fields.rb +18 -2
- data/lib/ddr/jobs.rb +0 -4
- data/lib/ddr/managers.rb +0 -1
- data/lib/ddr/managers/derivatives_manager.rb +3 -4
- data/lib/ddr/managers/workflow_manager.rb +3 -0
- data/lib/ddr/models.rb +6 -3
- data/lib/ddr/models/base.rb +13 -0
- data/lib/ddr/models/has_admin_metadata.rb +4 -20
- data/lib/ddr/models/indexing.rb +16 -0
- data/lib/ddr/models/solr_document.rb +8 -0
- data/lib/ddr/models/version.rb +1 -1
- data/lib/ddr/models/year_facet.rb +60 -118
- data/spec/auth/ability_spec.rb +1 -1
- data/spec/auth/roles/role_spec.rb +9 -9
- data/spec/index/fields_spec.rb +96 -0
- data/spec/models/active_fedora_datastream_spec.rb +6 -5
- data/spec/models/has_admin_metadata_spec.rb +49 -125
- data/spec/models/indexing_spec.rb +50 -18
- data/spec/models/solr_document_spec.rb +28 -0
- data/spec/models/year_facet_spec.rb +49 -22
- data/spec/support/shared_examples_for_ddr_models.rb +54 -2
- metadata +21 -8
- data/lib/ddr/jobs/permanent_id.rb +0 -35
- data/lib/ddr/managers/permanent_id_manager.rb +0 -93
@@ -55,13 +55,13 @@ module ActiveFedora
|
|
55
55
|
context "the datstream is new" do
|
56
56
|
before { allow(subject).to receive(:new?) { true } }
|
57
57
|
it "should raise an exception" do
|
58
|
-
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error
|
58
|
+
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error(Ddr::Models::Error)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
context "the datastream content has changed" do
|
62
62
|
before { allow(subject).to receive(:content_changed?) { true } }
|
63
63
|
it "should raise an exception" do
|
64
|
-
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error
|
64
|
+
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error(Ddr::Models::Error)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -76,14 +76,15 @@ module ActiveFedora
|
|
76
76
|
context "and the repository internal checksum in invalid" do
|
77
77
|
before { allow(subject).to receive(:dsChecksumValid) { false } }
|
78
78
|
it "should raise an error" do
|
79
|
-
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error
|
79
|
+
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error(Ddr::Models::ChecksumInvalid)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
context "and the repository internal checksum is valid" do
|
83
83
|
before { allow(subject).to receive(:dsChecksumValid) { true } }
|
84
84
|
context "and the checksum type is invalid" do
|
85
|
+
before { allow(subject).to receive(:content) { "foo" } }
|
85
86
|
it "should raise an exception" do
|
86
|
-
expect { subject.validate_checksum!("0123456789abcdef", "FOO-BAR") }.to raise_error
|
87
|
+
expect { subject.validate_checksum!("0123456789abcdef", "FOO-BAR") }.to raise_error(ArgumentError)
|
87
88
|
end
|
88
89
|
end
|
89
90
|
context "and the checksum type is nil" do
|
@@ -106,7 +107,7 @@ module ActiveFedora
|
|
106
107
|
end
|
107
108
|
context "and the checksum doesn't match" do
|
108
109
|
it "should raise an exception" do
|
109
|
-
expect { subject.validate_checksum!("0123456789abcdef", checksum_type) }.to raise_error
|
110
|
+
expect { subject.validate_checksum!("0123456789abcdef", checksum_type) }.to raise_error(Ddr::Models::ChecksumInvalid)
|
110
111
|
end
|
111
112
|
end
|
112
113
|
end
|
@@ -4,113 +4,7 @@ require 'support/ezid_mock_identifier'
|
|
4
4
|
module Ddr::Models
|
5
5
|
RSpec.describe HasAdminMetadata, type: :model, contacts: true do
|
6
6
|
|
7
|
-
describe "permanent id and permanent url" do
|
8
|
-
subject { FactoryGirl.build(:item) }
|
9
|
-
|
10
|
-
describe "#assign_permanent_id!" do
|
11
|
-
it "should assign the permanent id later" do
|
12
|
-
expect(subject.permanent_id_manager).to receive(:assign_later) { nil }
|
13
|
-
subject.assign_permanent_id!
|
14
|
-
end
|
15
|
-
context "when the object is created (first saved)" do
|
16
|
-
context "and auto-assignment is enabled" do
|
17
|
-
before { allow(Ddr::Models).to receive(:auto_assign_permanent_ids) { true } }
|
18
|
-
it "should assign a permanent id" do
|
19
|
-
expect(subject).to receive(:assign_permanent_id!) { nil }
|
20
|
-
subject.save!
|
21
|
-
end
|
22
|
-
end
|
23
|
-
context "and auto-assignment is disabled" do
|
24
|
-
before { allow(Ddr::Models).to receive(:auto_assign_permanent_ids) { false } }
|
25
|
-
it "should not assign a permanent id" do
|
26
|
-
expect(subject).not_to receive(:assign_permanent_id!)
|
27
|
-
subject.save!
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
context "when saved" do
|
32
|
-
context "and auto-assignment is enabled" do
|
33
|
-
before { allow(Ddr::Models).to receive(:auto_assign_permanent_ids) { true } }
|
34
|
-
it "should assign a permanent id once" do
|
35
|
-
expect(subject).to receive(:assign_permanent_id!).once { nil }
|
36
|
-
subject.save!
|
37
|
-
subject.title = ["New Title"]
|
38
|
-
subject.save!
|
39
|
-
end
|
40
|
-
end
|
41
|
-
context "and auto-assignment is disabled" do
|
42
|
-
before { allow(Ddr::Models).to receive(:auto_assign_permanent_ids) { false } }
|
43
|
-
it "should not assign a permanent id" do
|
44
|
-
expect(subject).not_to receive(:assign_permanent_id!)
|
45
|
-
subject.save!
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "lifecycle" do
|
52
|
-
subject { FactoryGirl.create(:item) }
|
53
|
-
let!(:identifier) {
|
54
|
-
Ezid::MockIdentifier.create(subject.permanent_id_manager.default_metadata)
|
55
|
-
}
|
56
|
-
before do
|
57
|
-
allow(Ddr::Models).to receive(:auto_assign_permanent_ids) { false }
|
58
|
-
allow(Ezid::Identifier).to receive(:find).with(identifier.id) { identifier }
|
59
|
-
subject.permanent_id = identifier.id
|
60
|
-
subject.save!
|
61
|
-
end
|
62
|
-
describe "identifier creation" do
|
63
|
-
it "sets default metadata" do
|
64
|
-
expect(identifier.profile).to eq("dc")
|
65
|
-
expect(identifier.export).to eq("no")
|
66
|
-
expect(identifier["fcrepo3.pid"]).to eq(subject.pid)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
describe "object destruction" do
|
70
|
-
it "marks the identifier as unavailable" do
|
71
|
-
expect { subject.destroy }
|
72
|
-
.to change(identifier, :status)
|
73
|
-
.to("unavailable | deleted")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
describe "object deaccession" do
|
77
|
-
it "marks the identifier as unavailable" do
|
78
|
-
expect { subject.deaccession }
|
79
|
-
.to change(identifier, :status)
|
80
|
-
.to("unavailable | deaccessioned")
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "events" do
|
86
|
-
before { allow(Ddr::Models).to receive(:auto_assign_permanent_ids) { true } }
|
87
|
-
context "when the operation succeeds" do
|
88
|
-
let!(:mock_identifier) { Ezid::MockIdentifier.new(id: "ark:/99999/fk4zzz",
|
89
|
-
metadata: "_target: http://example.com") }
|
90
|
-
before do
|
91
|
-
allow(Ezid::Identifier).to receive(:create) { mock_identifier }
|
92
|
-
allow(Ezid::Identifier).to receive(:find) { mock_identifier }
|
93
|
-
allow(subject.permanent_id_manager).to receive(:record) { mock_identifier }
|
94
|
-
end
|
95
|
-
it "should create a success event" do
|
96
|
-
expect { subject.save }.to change { subject.update_events.count }.by(1)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
context "when there's an exception" do
|
100
|
-
before { allow(Ezid::Identifier).to receive(:create).and_raise(Ezid::Error) }
|
101
|
-
it "should create a failure event" do
|
102
|
-
begin
|
103
|
-
subject.save
|
104
|
-
rescue Ezid::Error
|
105
|
-
end
|
106
|
-
expect(subject.update_events.last).to be_failure
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
7
|
describe "workflow" do
|
113
|
-
|
114
8
|
let(:collection) { FactoryGirl.create(:collection) }
|
115
9
|
let(:item) { FactoryGirl.create(:item) }
|
116
10
|
let(:component) { FactoryGirl.create(:component) }
|
@@ -122,17 +16,34 @@ module Ddr::Models
|
|
122
16
|
end
|
123
17
|
|
124
18
|
describe "#published?" do
|
19
|
+
subject { collection }
|
125
20
|
context "object is published" do
|
126
|
-
before {
|
127
|
-
it
|
128
|
-
expect(collection).to be_published
|
129
|
-
end
|
21
|
+
before { subject.workflow_state = Ddr::Managers::WorkflowManager::PUBLISHED }
|
22
|
+
it { is_expected.to be_published }
|
130
23
|
end
|
131
|
-
context "object is not
|
132
|
-
before {
|
133
|
-
it
|
134
|
-
|
135
|
-
|
24
|
+
context "object workflow is not set" do
|
25
|
+
before { subject.workflow_state = nil }
|
26
|
+
it { is_expected.not_to be_published }
|
27
|
+
end
|
28
|
+
context "object is unpublished" do
|
29
|
+
before { subject.workflow_state = Ddr::Managers::WorkflowManager::UNPUBLISHED }
|
30
|
+
it { is_expected.not_to be_published }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#unpublished?" do
|
35
|
+
subject { collection }
|
36
|
+
context "object is published" do
|
37
|
+
before { subject.workflow_state = Ddr::Managers::WorkflowManager::PUBLISHED }
|
38
|
+
it { is_expected.not_to be_unpublished }
|
39
|
+
end
|
40
|
+
context "object is unpublished" do
|
41
|
+
before { subject.workflow_state = Ddr::Managers::WorkflowManager::UNPUBLISHED }
|
42
|
+
it { is_expected.to be_unpublished }
|
43
|
+
end
|
44
|
+
context "object workflow is not set" do
|
45
|
+
before { subject.workflow_state = nil }
|
46
|
+
it { is_expected.not_to be_unpublished }
|
136
47
|
end
|
137
48
|
end
|
138
49
|
|
@@ -167,7 +78,6 @@ module Ddr::Models
|
|
167
78
|
end
|
168
79
|
|
169
80
|
describe "roles" do
|
170
|
-
|
171
81
|
subject { FactoryGirl.build(:item) }
|
172
82
|
|
173
83
|
describe "#copy_resource_roles_from" do
|
@@ -207,9 +117,7 @@ module Ddr::Models
|
|
207
117
|
end
|
208
118
|
|
209
119
|
describe "contacts" do
|
210
|
-
|
211
120
|
subject { FactoryGirl.build(:item) }
|
212
|
-
|
213
121
|
before do
|
214
122
|
allow(Ddr::Models::Contact).to receive(:get).with(:find, slug: 'xa') do
|
215
123
|
{'id'=>1, 'slug'=>'xa', 'name'=>'Contact A', 'short_name'=>'A'}
|
@@ -227,19 +135,37 @@ module Ddr::Models
|
|
227
135
|
end
|
228
136
|
|
229
137
|
describe "locking" do
|
230
|
-
|
231
138
|
subject { FactoryGirl.build(:item) }
|
232
139
|
|
233
140
|
describe "#locked?" do
|
234
141
|
context "object is locked" do
|
235
142
|
before { subject.is_locked = true }
|
236
|
-
|
237
|
-
|
143
|
+
context "repository is locked" do
|
144
|
+
before { Ddr::Models.repository_locked = true }
|
145
|
+
after { Ddr::Models.repository_locked = false }
|
146
|
+
it "should be true" do
|
147
|
+
expect(subject.locked?).to be true
|
148
|
+
end
|
149
|
+
end
|
150
|
+
context "repository is not locked" do
|
151
|
+
it "should be true" do
|
152
|
+
expect(subject.locked?).to be true
|
153
|
+
end
|
238
154
|
end
|
239
155
|
end
|
240
156
|
context "object is not locked" do
|
241
|
-
|
242
|
-
|
157
|
+
before { subject.is_locked = false }
|
158
|
+
context "repository is locked" do
|
159
|
+
before { Ddr::Models.repository_locked = true }
|
160
|
+
after { Ddr::Models.repository_locked = false }
|
161
|
+
it "should be true" do
|
162
|
+
expect(subject.locked?).to be true
|
163
|
+
end
|
164
|
+
end
|
165
|
+
context "repository is not locked" do
|
166
|
+
it "should be false" do
|
167
|
+
expect(subject.locked?).to be false
|
168
|
+
end
|
243
169
|
end
|
244
170
|
end
|
245
171
|
end
|
@@ -273,8 +199,6 @@ module Ddr::Models
|
|
273
199
|
expect(subject.locked?).to be false
|
274
200
|
end
|
275
201
|
end
|
276
|
-
|
277
202
|
end
|
278
|
-
|
279
203
|
end
|
280
204
|
end
|
@@ -23,39 +23,71 @@ module Ddr::Models
|
|
23
23
|
obj.rightsMetadata.license.title = ["License Title"]
|
24
24
|
obj.rightsMetadata.license.url = ["http://library.duke.edu"]
|
25
25
|
obj.roles.grant role1, role2, role3, role4
|
26
|
-
obj.set_desc_metadata_values(:
|
27
|
-
obj.set_desc_metadata_values(:
|
28
|
-
obj.set_desc_metadata_values(:
|
29
|
-
obj.set_desc_metadata_values(:
|
30
|
-
obj.set_desc_metadata_values(:
|
31
|
-
obj.set_desc_metadata_values(:
|
32
|
-
obj.set_desc_metadata_values(:
|
33
|
-
obj.set_desc_metadata_values(:
|
34
|
-
obj.set_desc_metadata_values(:
|
26
|
+
obj.set_desc_metadata_values(:arranger, "Arranger Value")
|
27
|
+
obj.set_desc_metadata_values(:category, "Category Value")
|
28
|
+
obj.set_desc_metadata_values(:company, "Company Value")
|
29
|
+
obj.set_desc_metadata_values(:composer, "Composer Value")
|
30
|
+
obj.set_desc_metadata_values(:engraver, "Engraver Value")
|
31
|
+
obj.set_desc_metadata_values(:folder, "Folder Value")
|
32
|
+
obj.set_desc_metadata_values(:genre, "Genre Value")
|
33
|
+
obj.set_desc_metadata_values(:illustrated, "Illustrated Value")
|
34
|
+
obj.set_desc_metadata_values(:illustrator, "Illustrator Value")
|
35
|
+
obj.set_desc_metadata_values(:instrumentation, "Instrumentation Value")
|
36
|
+
obj.set_desc_metadata_values(:interviewer_name, "Interviewer Name Value")
|
37
|
+
obj.set_desc_metadata_values(:lithographer, "Lithographer Value")
|
38
|
+
obj.set_desc_metadata_values(:lyricist, "Lyricist Value")
|
39
|
+
obj.set_desc_metadata_values(:medium, "Medium Value")
|
40
|
+
obj.set_desc_metadata_values(:performer, "Performer Value")
|
41
|
+
obj.set_desc_metadata_values(:placement_company, "Placement Company Value")
|
42
|
+
obj.set_desc_metadata_values(:producer, "Producer Value")
|
43
|
+
obj.set_desc_metadata_values(:product, "Product Value")
|
44
|
+
obj.set_desc_metadata_values(:publication, "Publication Value")
|
45
|
+
obj.set_desc_metadata_values(:roll_number, "10")
|
46
|
+
obj.set_desc_metadata_values(:setting, "Setting Value")
|
47
|
+
obj.set_desc_metadata_values(:subseries, "Subseries Value")
|
48
|
+
obj.set_desc_metadata_values(:temporal, "Temporal Value")
|
49
|
+
obj.set_desc_metadata_values(:tone, "Tone Value")
|
50
|
+
obj.set_desc_metadata_values(:volume, "100")
|
35
51
|
end
|
36
52
|
|
37
53
|
its([Indexing::ACCESS_ROLE]) { is_expected.to eq(obj.roles.to_json) }
|
54
|
+
its([Indexing::ARRANGER_FACET]) { is_expected.to eq(["Arranger Value"]) }
|
38
55
|
its([Indexing::ASPACE_ID]) { is_expected.to eq("aspace_dccea43034e1b8261e14cf999e86449d") }
|
39
|
-
its([Indexing::CATEGORY_FACET]) { is_expected.to eq(["Category
|
40
|
-
its([Indexing::COMPANY_FACET]) { is_expected.to eq(["Company
|
56
|
+
its([Indexing::CATEGORY_FACET]) { is_expected.to eq(["Category Value"]) }
|
57
|
+
its([Indexing::COMPANY_FACET]) { is_expected.to eq(["Company Value"]) }
|
58
|
+
its([Indexing::COMPOSER_FACET]) { is_expected.to eq(["Composer Value"]) }
|
41
59
|
its([Indexing::DISPLAY_FORMAT]) { is_expected.to eq("Image") }
|
42
60
|
its([Indexing::DOI]) { is_expected.to eq(["http://doi.org/10.1000/182"]) }
|
43
|
-
its([Indexing::
|
61
|
+
its([Indexing::ENGRAVER_FACET]) { is_expected.to eq(["Engraver Value"]) }
|
62
|
+
its([Indexing::FOLDER_FACET]) { is_expected.to eq(["Folder Value"]) }
|
63
|
+
its([Indexing::GENRE_FACET]) { is_expected.to eq(["Genre Value"]) }
|
64
|
+
its([Indexing::ILLUSTRATED_FACET]) { is_expected.to eq(["Illustrated Value"]) }
|
65
|
+
its([Indexing::ILLUSTRATOR_FACET]) { is_expected.to eq(["Illustrator Value"]) }
|
66
|
+
its([Indexing::INSTRUMENTATION_FACET]) { is_expected.to eq(["Instrumentation Value"]) }
|
67
|
+
its([Indexing::INTERVIEWER_NAME_FACET]) { is_expected.to eq(["Interviewer Name Value"]) }
|
44
68
|
its([Indexing::LICENSE]) { is_expected.to eq("cc-by-nc-nd-40") }
|
45
69
|
its([Indexing::LICENSE_DESCRIPTION]) { is_expected.to eq("License Description") }
|
46
70
|
its([Indexing::LICENSE_TITLE]) { is_expected.to eq("License Title") }
|
47
71
|
its([Indexing::LICENSE_URL]) { is_expected.to eq("http://library.duke.edu") }
|
72
|
+
its([Indexing::LITHOGRAPHER_FACET]) { is_expected.to eq(["Lithographer Value"]) }
|
48
73
|
its([Indexing::LOCAL_ID]) { is_expected.to eq("foo") }
|
49
|
-
its([Indexing::
|
74
|
+
its([Indexing::LYRICIST_FACET]) { is_expected.to eq(["Lyricist Value"]) }
|
75
|
+
its([Indexing::MEDIUM_FACET]) { is_expected.to eq(["Medium Value"]) }
|
76
|
+
its([Indexing::PERFORMER_FACET]) { is_expected.to eq(["Performer Value"]) }
|
50
77
|
its([Indexing::PERMANENT_ID]) { is_expected.to eq("ark:/99999/fk4zzz") }
|
51
78
|
its([Indexing::PERMANENT_URL]) { is_expected.to eq("http://id.library.duke.edu/ark:/99999/fk4zzz") }
|
52
|
-
its([Indexing::PLACEMENT_COMPANY_FACET]) { is_expected.to eq(["Placement Company
|
79
|
+
its([Indexing::PLACEMENT_COMPANY_FACET]) { is_expected.to eq(["Placement Company Value"]) }
|
53
80
|
its([Indexing::POLICY_ROLE]) { is_expected.to contain_exactly(role2.agent.first, role3.agent.first, role4.agent.first) }
|
54
|
-
its([Indexing::
|
55
|
-
its([Indexing::
|
81
|
+
its([Indexing::PRODUCER_FACET]) { is_expected.to eq(["Producer Value"]) }
|
82
|
+
its([Indexing::PRODUCT_FACET]) { is_expected.to eq(["Product Value"]) }
|
83
|
+
its([Indexing::PUBLICATION_FACET]) { is_expected.to eq(["Publication Value"]) }
|
56
84
|
its([Indexing::RESOURCE_ROLE]) { is_expected.to contain_exactly(role1.agent.first) }
|
57
|
-
its([Indexing::
|
58
|
-
its([Indexing::
|
85
|
+
its([Indexing::ROLL_NUMBER_FACET]) { is_expected.to eq(["10"]) }
|
86
|
+
its([Indexing::SETTING_FACET]) { is_expected.to eq(["Setting Value"]) }
|
87
|
+
its([Indexing::SUBSERIES_FACET]) { is_expected.to eq(["Subseries Value"]) }
|
88
|
+
its([Indexing::TEMPORAL_FACET]) { is_expected.to eq(["Temporal Value"]) }
|
89
|
+
its([Indexing::TONE_FACET]) { is_expected.to eq(["Tone Value"]) }
|
90
|
+
its([Indexing::VOLUME_FACET]) { is_expected.to eq(["100"]) }
|
59
91
|
end
|
60
92
|
|
61
93
|
describe "content-bearing object indexing" do
|
@@ -2,6 +2,33 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe SolrDocument, type: :model, contacts: true do
|
4
4
|
|
5
|
+
describe "class methods" do
|
6
|
+
describe ".find" do
|
7
|
+
describe "when it exists" do
|
8
|
+
before { Item.create(pid: "test:1") }
|
9
|
+
subject { described_class.find("test:1") }
|
10
|
+
its(:id) { is_expected.to eq("test:1") }
|
11
|
+
end
|
12
|
+
describe "when not found" do
|
13
|
+
it "raises an error" do
|
14
|
+
expect { described_class.find("foo") }.to raise_error(SolrDocument::NotFound)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
describe ".find_by_permanent_id" do
|
19
|
+
describe "when it exists" do
|
20
|
+
before { Item.create(pid: "test:1", permanent_id: "foo") }
|
21
|
+
subject { described_class.find_by_permanent_id("foo") }
|
22
|
+
its(:id) { is_expected.to eq("test:1") }
|
23
|
+
end
|
24
|
+
describe "when not found" do
|
25
|
+
it "raises an error" do
|
26
|
+
expect { described_class.find_by_permanent_id("foo") }.to raise_error(SolrDocument::NotFound)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
5
32
|
describe "index field method access" do
|
6
33
|
describe "when there is an index field" do
|
7
34
|
before { Ddr::Index::Fields.const_set(:FOO_BAR, "foo_bar_ssim") }
|
@@ -195,4 +222,5 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
195
222
|
end
|
196
223
|
end
|
197
224
|
end
|
225
|
+
|
198
226
|
end
|
@@ -1,64 +1,91 @@
|
|
1
1
|
module Ddr::Models
|
2
2
|
RSpec.describe YearFacet do
|
3
3
|
|
4
|
-
subject { described_class.
|
4
|
+
subject { described_class.call(obj) }
|
5
5
|
let(:obj) { Item.new }
|
6
6
|
before { obj.date = [ date ] }
|
7
7
|
|
8
8
|
describe "splitting on semicolons" do
|
9
9
|
let(:date) { "1935; 1936; 1937; 1938" }
|
10
|
-
|
10
|
+
it { is_expected.to eq([1935, 1936, 1937, 1938]) }
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "year range" do
|
14
|
-
%w( 1935-1940 1935/1940 ).each do |value|
|
14
|
+
%w( 1935-1940 1935/1940 1935?/1940? 1935~/1940~ ).each do |value|
|
15
15
|
describe value do
|
16
16
|
let(:date) { value }
|
17
|
-
|
17
|
+
it { is_expected.to eq((1935..1940).to_a) }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
describe "
|
23
|
-
%w( 192x 192X 192? 192- 192-? ).each do |value|
|
22
|
+
describe "decade" do
|
23
|
+
%w( 192u 192x 192X 192? 192- 192-? 1920s 1920s? ).each do |value|
|
24
24
|
describe value do
|
25
25
|
let(:date) { value }
|
26
|
-
|
26
|
+
it { is_expected.to eq((1920..1929).to_a) }
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
describe "
|
32
|
-
|
33
|
-
|
31
|
+
describe "century" do
|
32
|
+
%w( 19xx 19uu ).each do |value|
|
33
|
+
describe value do
|
34
|
+
let(:date) { value }
|
35
|
+
it { is_expected.to eq((1900..1999).to_a) }
|
36
|
+
end
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
|
-
describe "
|
37
|
-
|
40
|
+
describe "uncertain interval" do
|
41
|
+
let(:date) { "199u/200u" }
|
42
|
+
it { is_expected.to eq((1990..2009).to_a) }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "set" do
|
46
|
+
let(:date) { "[1999,2000,2003]" }
|
47
|
+
it { is_expected.to eq([1999, 2000, 2003]) }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "year" do
|
51
|
+
%w( 2010 2010? 2010~ ).each do |value|
|
38
52
|
describe value do
|
39
53
|
let(:date) { value }
|
40
|
-
|
54
|
+
it { is_expected.to eq([2010]) }
|
41
55
|
end
|
42
56
|
end
|
43
57
|
end
|
44
58
|
|
45
|
-
describe "
|
46
|
-
%w( 2010-01 2010/01 ).each do |value|
|
59
|
+
describe "month" do
|
60
|
+
%w( 2010-01 2010/01 2010-12? 2010-11/2010-12 ).each do |value|
|
47
61
|
describe value do
|
48
62
|
let(:date) { value }
|
49
|
-
|
63
|
+
it { is_expected.to eq([2010]) }
|
50
64
|
end
|
51
65
|
end
|
52
66
|
end
|
53
67
|
|
54
|
-
describe "
|
55
|
-
|
56
|
-
|
68
|
+
describe "day" do
|
69
|
+
%w( 2010-12-10 2010-12-10? 2010-12-10/2010-12-20 ).each do |value|
|
70
|
+
describe value do
|
71
|
+
let(:date) { value }
|
72
|
+
it { is_expected.to eq([2010]) }
|
73
|
+
end
|
74
|
+
end
|
57
75
|
end
|
58
76
|
|
59
|
-
describe "
|
60
|
-
|
61
|
-
|
77
|
+
describe "season" do
|
78
|
+
%w( 2010-21 2010-22 2010-23 2010-24 ).each do |value|
|
79
|
+
describe value do
|
80
|
+
let(:date) { value }
|
81
|
+
it { is_expected.to eq([2010]) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "between" do
|
87
|
+
let(:date) { "Between 1965 and 1968" }
|
88
|
+
it { is_expected.to eq((1965..1968).to_a) }
|
62
89
|
end
|
63
90
|
|
64
91
|
end
|