ddr-models 1.8.1 → 1.9.0
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/Rakefile +1 -1
- data/app/controllers/users/omniauth_callbacks_controller.rb +11 -0
- data/app/controllers/users/sessions_controller.rb +7 -0
- data/app/controllers/users/sessions_controller.rb~ +11 -0
- data/config/initializers/devise.rb +15 -1
- data/config/routes.rb +4 -0
- data/lib/ddr/auth/user.rb +17 -4
- data/lib/ddr/managers/#index_manager.rb# +21 -0
- data/lib/ddr/models/#index_fields.rb# +13 -0
- data/lib/ddr/models/engine.rb +3 -22
- data/lib/ddr/models/version.rb +1 -1
- data/spec/dummy/config/routes.rb +0 -54
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +4702 -0
- data/spec/dummy/log/production.log +5 -0
- data/spec/dummy/log/test.log +50543 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- metadata +44 -26
- data/db/migrate/20150109192134_drop_workflow_state.rb~ +0 -11
- data/db/migrate/20150110023410_drop_workflow_states.rb~ +0 -4
- data/lib/ddr/datastreams/admin_metadata_datastream.rb~ +0 -13
- data/lib/ddr/index.rb~ +0 -8
- data/lib/ddr/managers/index_manager.rb~ +0 -7
- data/lib/ddr/managers/manager.rb~ +0 -14
- data/lib/ddr/managers/role_manager.rb~ +0 -21
- data/lib/ddr/managers/workflow_manager.rb~ +0 -33
- data/lib/ddr/models/#index.rb# +0 -25
- data/lib/ddr/models/#indexing.rb# +0 -108
- data/lib/ddr/models/has_admin_metadata.rb~ +0 -34
- data/lib/ddr/vocab.rb~ +0 -9
- data/lib/ddr/vocab/workflow.rb~ +0 -7
- data/spec/models/has_admin_metadata_spec.rb~ +0 -144
@@ -1,34 +0,0 @@
|
|
1
|
-
module Ddr
|
2
|
-
module Models
|
3
|
-
module HasAdminMetadata
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
has_metadata "adminMetadata",
|
8
|
-
type: Ddr::Datastreams::AdminMetadataDatastream,
|
9
|
-
versionable: true,
|
10
|
-
control_group: "M"
|
11
|
-
|
12
|
-
has_attributes :permanent_id, :permanent_url,
|
13
|
-
datastream: "adminMetadata", multiple: false
|
14
|
-
|
15
|
-
delegate :principal_has_role?, to: :roles
|
16
|
-
|
17
|
-
after_create :assign_permanent_id!, if: "Ddr::Models.auto_assign_permanent_ids"
|
18
|
-
end
|
19
|
-
|
20
|
-
def permanent_id_manager
|
21
|
-
@permanent_id_manager ||= Ddr::Managers::PermanentIdManager.new(self)
|
22
|
-
end
|
23
|
-
|
24
|
-
def roles
|
25
|
-
@roles || Ddr::Managers::RoleMananger.new(self)
|
26
|
-
end
|
27
|
-
|
28
|
-
def assign_permanent_id!
|
29
|
-
permanent_id_manager.assign_later
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/ddr/vocab.rb~
DELETED
data/lib/ddr/vocab/workflow.rb~
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Ddr
|
4
|
-
module Models
|
5
|
-
RSpec.describe HasAdminMetadata, type: :model do
|
6
|
-
|
7
|
-
describe "permanent id and permanent url" do
|
8
|
-
|
9
|
-
before(:all) do
|
10
|
-
class PermanentlyIdentifiable < ActiveFedora::Base
|
11
|
-
include Ddr::Models::Describable
|
12
|
-
include Ddr::Models::Indexing
|
13
|
-
include Ddr::Models::HasWorkflow
|
14
|
-
include Ddr::Models::HasAdminMetadata
|
15
|
-
include Ddr::Models::EventLoggable
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
after(:all) do
|
20
|
-
Ddr::Models.send(:remove_const, :PermanentlyIdentifiable)
|
21
|
-
end
|
22
|
-
|
23
|
-
subject { PermanentlyIdentifiable.new }
|
24
|
-
|
25
|
-
describe "permanent_id" do
|
26
|
-
describe "when a permanent id has not been assigned" do
|
27
|
-
it "should be nil" do
|
28
|
-
expect(subject.permanent_id).to be_nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "object lifecycle" do
|
34
|
-
context "when created" do
|
35
|
-
context "and auto-assignment is enabled" do
|
36
|
-
before { allow(Ddr::Models).to receive(:auto_assign_permanent_ids) { true } }
|
37
|
-
it "should assign a permanent id" do
|
38
|
-
expect_any_instance_of(PermanentlyIdentifiable).to receive(:assign_permanent_id!) { nil }
|
39
|
-
PermanentlyIdentifiable.create
|
40
|
-
end
|
41
|
-
end
|
42
|
-
context "and auto-assignment is disabled" do
|
43
|
-
before { allow(Ddr::Models).to receive(:auto_assign_permanent_ids) { false } }
|
44
|
-
it "should not assign a permanent id" do
|
45
|
-
expect_any_instance_of(PermanentlyIdentifiable).not_to receive(:assign_permanent_id!)
|
46
|
-
PermanentlyIdentifiable.create
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
context "when saved" do
|
51
|
-
context "and auto-assignment is enabled" do
|
52
|
-
before { allow(Ddr::Models).to receive(:auto_assign_permanent_ids) { true } }
|
53
|
-
it "should assign a permanent id once" do
|
54
|
-
expect(subject).to receive(:assign_permanent_id!).once { nil }
|
55
|
-
subject.save
|
56
|
-
subject.title = ["New Title"]
|
57
|
-
subject.save
|
58
|
-
end
|
59
|
-
end
|
60
|
-
context "and auto-assignment is disabled" do
|
61
|
-
before { allow(Ddr::Models).to receive(:auto_assign_permanent_ids) { false } }
|
62
|
-
it "should not assign a permanent id" do
|
63
|
-
expect(subject).not_to receive(:assign_permanent_id!)
|
64
|
-
subject.save
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "#assign_permanent_id!" do
|
71
|
-
it "should assign the permanent id later" do
|
72
|
-
expect(subject.permanent_id_manager).to receive(:assign_later) { nil }
|
73
|
-
subject.assign_permanent_id!
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "events" do
|
78
|
-
before { allow(Ddr::Models).to receive(:auto_assign_permanent_ids) { true } }
|
79
|
-
context "when the operation succeeds" do
|
80
|
-
let(:stub_identifier) { double(id: "ark:/99999/fk4zzz", metadata: "_target: http://example.com") }
|
81
|
-
before { allow_any_instance_of(Ddr::Managers::PermanentIdManager).to receive(:mint) { stub_identifier } }
|
82
|
-
it "should create a success event" do
|
83
|
-
expect { subject.save }.to change { subject.update_events.count }.by(1)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
context "when there's an exception" do
|
87
|
-
before { allow(Ezid::Identifier).to receive(:create).and_raise(Ezid::Error) }
|
88
|
-
it "should create a failure event" do
|
89
|
-
begin
|
90
|
-
subject.save
|
91
|
-
rescue Ezid::Error
|
92
|
-
end
|
93
|
-
expect(subject.update_events.last).to be_failure
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "indexing" do
|
99
|
-
let(:permanent_id) { "ark:/99999/fk4zzz" }
|
100
|
-
let(:permanent_url) { "http://id.library.duke.edu/ark:/99999/fk4zzz" }
|
101
|
-
before do
|
102
|
-
subject.permanent_id = permanent_id
|
103
|
-
subject.permanent_url = permanent_url
|
104
|
-
end
|
105
|
-
it "should index the permanent id value" do
|
106
|
-
expect(subject.to_solr[Ddr::IndexFields::PERMANENT_ID]).to eq(permanent_id)
|
107
|
-
end
|
108
|
-
it "should index the permanent url" do
|
109
|
-
expect(subject.to_solr[Ddr::IndexFields::PERMANENT_URL]).to eq(permanent_url)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "role assignments" do
|
116
|
-
|
117
|
-
before(:all) do
|
118
|
-
class RoleAssignable < ActiveFedora::Base
|
119
|
-
include HasRoleAssignments
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
after(:all) do
|
124
|
-
Ddr::Models.send(:remove_const, :RoleAssignable)
|
125
|
-
end
|
126
|
-
|
127
|
-
subject { RoleAssignable.new }
|
128
|
-
|
129
|
-
describe "#principal_has_role?" do
|
130
|
-
it "should respond when given a list of principals and a valid role" do
|
131
|
-
expect { subject.principal_has_role?(["bob", "admins"], :administrator) }.not_to raise_error
|
132
|
-
end
|
133
|
-
it "should respond when given a principal name and a valid role" do
|
134
|
-
expect { subject.principal_has_role?("bob", :administrator) }.not_to raise_error
|
135
|
-
end
|
136
|
-
it "should raise an error when given an invalid role" do
|
137
|
-
expect { subject.principal_has_role?("bob", :foo) }.to raise_error
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|