active-fedora 13.1.2 → 13.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github_changelog_generator +2 -0
- data/CHANGELOG.md +3362 -0
- data/CONTRIBUTING.md +23 -1
- data/README.md +4 -0
- data/active-fedora.gemspec +14 -13
- data/lib/active_fedora/version.rb +1 -1
- metadata +104 -206
- data/spec/config_helper.rb +0 -17
- data/spec/fixtures/dino.jpg +0 -0
- data/spec/fixtures/dino_jpg_no_file_ext +0 -0
- data/spec/fixtures/minivan.jpg +0 -0
- data/spec/fixtures/rails_root/config/fake_fedora.yml +0 -7
- data/spec/fixtures/rails_root/config/fedora.yml +0 -12
- data/spec/fixtures/rails_root/config/solr.yml +0 -15
- data/spec/fixtures/rails_root/config/solr_mappings.yml +0 -16
- data/spec/fixtures/rails_root/config/solr_mappings_af_0.1.yml +0 -9
- data/spec/fixtures/rails_root/config/solr_mappings_bl_2.4.yml +0 -17
- data/spec/integration/associations/rdf_spec.rb +0 -61
- data/spec/integration/associations_spec.rb +0 -680
- data/spec/integration/attached_files_spec.rb +0 -146
- data/spec/integration/attributes_spec.rb +0 -73
- data/spec/integration/autosave_association_spec.rb +0 -24
- data/spec/integration/base_spec.rb +0 -184
- data/spec/integration/basic_contains_association_spec.rb +0 -121
- data/spec/integration/belongs_to_association_spec.rb +0 -260
- data/spec/integration/caching_spec.rb +0 -59
- data/spec/integration/clean_connection_spec.rb +0 -21
- data/spec/integration/collection_association_spec.rb +0 -166
- data/spec/integration/date_time_properties_spec.rb +0 -41
- data/spec/integration/delete_all_spec.rb +0 -64
- data/spec/integration/direct_container_spec.rb +0 -250
- data/spec/integration/directly_contains_one_association_spec.rb +0 -96
- data/spec/integration/eradicate_spec.rb +0 -52
- data/spec/integration/fedora_solr_sync_spec.rb +0 -30
- data/spec/integration/file_fixity_spec.rb +0 -36
- data/spec/integration/file_spec.rb +0 -221
- data/spec/integration/generators/fedora_generator_spec.rb +0 -26
- data/spec/integration/generators/solr_generator_spec.rb +0 -23
- data/spec/integration/gone_spec.rb +0 -41
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +0 -414
- data/spec/integration/has_many_associations_spec.rb +0 -436
- data/spec/integration/has_subresource_spec.rb +0 -34
- data/spec/integration/indexing/descendant_fetcher_spec.rb +0 -64
- data/spec/integration/indexing_spec.rb +0 -110
- data/spec/integration/indirect_container_spec.rb +0 -290
- data/spec/integration/json_serialization_spec.rb +0 -32
- data/spec/integration/marshal_spec.rb +0 -39
- data/spec/integration/nested_attribute_spec.rb +0 -177
- data/spec/integration/nested_hash_resources_spec.rb +0 -43
- data/spec/integration/persistence_spec.rb +0 -37
- data/spec/integration/query_result_builder_spec.rb +0 -37
- data/spec/integration/rdf_nested_attributes_spec.rb +0 -85
- data/spec/integration/relation_delegation_spec.rb +0 -52
- data/spec/integration/relation_spec.rb +0 -117
- data/spec/integration/scoped_query_spec.rb +0 -134
- data/spec/integration/scoping_spec.rb +0 -48
- data/spec/integration/solr_hit_spec.rb +0 -32
- data/spec/integration/versionable_spec.rb +0 -256
- data/spec/integration/with_metadata_spec.rb +0 -111
- data/spec/lib/active_fedora/null_logger_spec.rb +0 -10
- data/spec/rcov.opts +0 -2
- data/spec/spec.opts +0 -5
- data/spec/spec_helper.rb +0 -106
- data/spec/support/an_active_model.rb +0 -29
- data/spec/unit/active_fedora/indexing/inserter_spec.rb +0 -35
- data/spec/unit/active_fedora_spec.rb +0 -118
- data/spec/unit/aggregation/list_source_spec.rb +0 -134
- data/spec/unit/aggregation/ordered_reader_spec.rb +0 -43
- data/spec/unit/association_hash_spec.rb +0 -64
- data/spec/unit/attached_files_spec.rb +0 -218
- data/spec/unit/attributes_spec.rb +0 -146
- data/spec/unit/base_active_model_spec.rb +0 -28
- data/spec/unit/base_cma_spec.rb +0 -15
- data/spec/unit/base_extra_spec.rb +0 -33
- data/spec/unit/base_spec.rb +0 -328
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +0 -8
- data/spec/unit/callback_spec.rb +0 -65
- data/spec/unit/change_set_spec.rb +0 -60
- data/spec/unit/checksum_spec.rb +0 -25
- data/spec/unit/code_configurator_spec.rb +0 -41
- data/spec/unit/collection_proxy_spec.rb +0 -25
- data/spec/unit/config_spec.rb +0 -18
- data/spec/unit/core/fedora_id_translator_spec.rb +0 -29
- data/spec/unit/core/fedora_uri_translator_spec.rb +0 -19
- data/spec/unit/core/logger_spec.rb +0 -18
- data/spec/unit/core_spec.rb +0 -242
- data/spec/unit/default_model_mapper_spec.rb +0 -39
- data/spec/unit/fedora_spec.rb +0 -31
- data/spec/unit/file/streaming_spec.rb +0 -33
- data/spec/unit/file_configurator_spec.rb +0 -295
- data/spec/unit/file_io_spec.rb +0 -137
- data/spec/unit/file_path_builder_spec.rb +0 -18
- data/spec/unit/file_spec.rb +0 -489
- data/spec/unit/files_hash_spec.rb +0 -52
- data/spec/unit/filter_spec.rb +0 -133
- data/spec/unit/finder_methods_spec.rb +0 -154
- data/spec/unit/fixity_service_spec.rb +0 -128
- data/spec/unit/forbidden_attributes_protection_spec.rb +0 -50
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +0 -125
- data/spec/unit/has_many_association_spec.rb +0 -131
- data/spec/unit/indexers/global_indexer_spec.rb +0 -41
- data/spec/unit/indexing/map/index_object_spec.rb +0 -25
- data/spec/unit/indexing/map_spec.rb +0 -27
- data/spec/unit/indexing_service_spec.rb +0 -28
- data/spec/unit/indexing_spec.rb +0 -86
- data/spec/unit/inheritance_spec.rb +0 -60
- data/spec/unit/ldp_resource_spec.rb +0 -15
- data/spec/unit/loadable_from_json_spec.rb +0 -40
- data/spec/unit/logger_spec.rb +0 -19
- data/spec/unit/model_classifier_spec.rb +0 -49
- data/spec/unit/ordered_spec.rb +0 -367
- data/spec/unit/orders/list_node_spec.rb +0 -151
- data/spec/unit/orders/ordered_list_spec.rb +0 -335
- data/spec/unit/orders/reflection_spec.rb +0 -22
- data/spec/unit/pathing_spec.rb +0 -35
- data/spec/unit/persistence_spec.rb +0 -115
- data/spec/unit/property_predicate_spec.rb +0 -35
- data/spec/unit/property_spec.rb +0 -25
- data/spec/unit/query_result_builder_spec.rb +0 -31
- data/spec/unit/query_spec.rb +0 -307
- data/spec/unit/querying_spec.rb +0 -24
- data/spec/unit/rdf/indexing_service_spec.rb +0 -114
- data/spec/unit/rdf_vocab_spec.rb +0 -30
- data/spec/unit/readonly_spec.rb +0 -24
- data/spec/unit/reflection_spec.rb +0 -42
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +0 -37
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +0 -38
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +0 -38
- data/spec/unit/schema_indexing_strategy_spec.rb +0 -68
- data/spec/unit/scoping_spec.rb +0 -67
- data/spec/unit/serializers_spec.rb +0 -19
- data/spec/unit/solr_config_options_spec.rb +0 -57
- data/spec/unit/solr_hit_spec.rb +0 -57
- data/spec/unit/solr_query_builder_spec.rb +0 -18
- data/spec/unit/solr_service_spec.rb +0 -165
- data/spec/unit/sparql_insert_spec.rb +0 -31
- data/spec/unit/validations_spec.rb +0 -92
- data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +0 -29
- data/spec/unit/with_metadata/metadata_node_spec.rb +0 -69
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::Base do
|
4
|
-
describe "active model methods" do
|
5
|
-
class BarHistory < ActiveFedora::Base
|
6
|
-
property :fubar, predicate: ::RDF::URI('http://example.com/fubar'), multiple: false
|
7
|
-
property :duck, predicate: ::RDF::URI('http://example.com/duck'), multiple: false
|
8
|
-
end
|
9
|
-
subject(:history) { BarHistory.new }
|
10
|
-
|
11
|
-
describe "attributes=" do
|
12
|
-
it "sets attributes" do
|
13
|
-
history.attributes = { fubar: "baz", duck: "Quack" }
|
14
|
-
expect(history.fubar).to eq "baz"
|
15
|
-
expect(history.duck).to eq "Quack"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "update_attributes" do
|
20
|
-
it "sets attributes and save" do
|
21
|
-
history.update_attributes(fubar: "baz", duck: "Quack")
|
22
|
-
history.reload
|
23
|
-
expect(history.fubar).to eq "baz"
|
24
|
-
expect(history.duck).to eq "Quack"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/spec/unit/base_cma_spec.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::Base do
|
4
|
-
before do
|
5
|
-
@test_object = described_class.new
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '.save' do
|
9
|
-
it "adds hasModel relationship that points to the CModel if @new_object" do
|
10
|
-
allow(@test_object).to receive(:update_index)
|
11
|
-
expect(@test_object).to receive(:refresh)
|
12
|
-
@test_object.save
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::Base do
|
4
|
-
subject(:object) { described_class.new }
|
5
|
-
describe ".update_index" do
|
6
|
-
before do
|
7
|
-
mock_conn = instance_double(RSolr::Client)
|
8
|
-
expect(mock_conn).to receive(:add) do |_, opts|
|
9
|
-
expect(opts).to eq(params: { softCommit: true })
|
10
|
-
end
|
11
|
-
mock_ss = instance_double(ActiveFedora::SolrService)
|
12
|
-
allow(mock_ss).to receive(:conn).and_return(mock_conn)
|
13
|
-
allow(ActiveFedora::SolrService).to receive(:instance).and_return(mock_ss)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "makes the solr_document with to_solr and add it" do
|
17
|
-
expect(object).to receive(:to_solr)
|
18
|
-
object.update_index
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe ".delete" do
|
23
|
-
before do
|
24
|
-
allow(object).to receive(:new_record?).and_return(false)
|
25
|
-
allow(ActiveFedora.fedora.connection).to receive(:delete)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "deletes object from repository and index" do
|
29
|
-
expect(ActiveFedora::SolrService).to receive(:delete).with(nil)
|
30
|
-
object.delete
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/spec/unit/base_spec.rb
DELETED
@@ -1,328 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
@@last_id = 0
|
3
|
-
|
4
|
-
describe ActiveFedora::Base do
|
5
|
-
it_behaves_like "An ActiveModel"
|
6
|
-
|
7
|
-
describe "id=" do
|
8
|
-
before do
|
9
|
-
class FooHistory < ActiveFedora::Base
|
10
|
-
property :title, predicate: ::RDF::Vocab::DC.title
|
11
|
-
end
|
12
|
-
end
|
13
|
-
after do
|
14
|
-
Object.send(:remove_const, :FooHistory)
|
15
|
-
end
|
16
|
-
|
17
|
-
subject(:history) { FooHistory.new(title: ["A good title"]) }
|
18
|
-
before { history.id = 9 }
|
19
|
-
|
20
|
-
it "is settable" do
|
21
|
-
expect(history.id).to eq '9'
|
22
|
-
expect(history.title).to eq ["A good title"]
|
23
|
-
end
|
24
|
-
|
25
|
-
it "is only settable once" do
|
26
|
-
expect { history.id = 10 }.to raise_error "ID has already been set to 9"
|
27
|
-
expect(history.id).to eq '9'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe ".type" do
|
32
|
-
before do
|
33
|
-
class FooHistory < ActiveFedora::Base
|
34
|
-
type ::RDF::URI.new('http://example.com/foo')
|
35
|
-
property :title, predicate: ::RDF::Vocab::DC.title
|
36
|
-
end
|
37
|
-
end
|
38
|
-
after do
|
39
|
-
Object.send(:remove_const, :FooHistory)
|
40
|
-
end
|
41
|
-
|
42
|
-
subject(:history) { FooHistory.new.type }
|
43
|
-
|
44
|
-
it { is_expected.to eq [RDF::URI('http://example.com/foo')] }
|
45
|
-
|
46
|
-
context "when type is called before propertes" do
|
47
|
-
subject(:history) { FooHistory.resource_class.reflect_on_property(:title) }
|
48
|
-
it "does not wipe out the properties" do
|
49
|
-
expect(history).to be_kind_of ActiveTriples::NodeConfig
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe ".rdf_label" do
|
55
|
-
context "on a concrete class" do
|
56
|
-
before do
|
57
|
-
class FooHistory < ActiveFedora::Base
|
58
|
-
rdf_label ::RDF::Vocab::DC.title
|
59
|
-
property :title, predicate: ::RDF::Vocab::DC.title
|
60
|
-
end
|
61
|
-
end
|
62
|
-
after do
|
63
|
-
Object.send(:remove_const, :FooHistory)
|
64
|
-
end
|
65
|
-
|
66
|
-
subject { instance.rdf_label }
|
67
|
-
let(:instance) { FooHistory.new(title: ['A label']) }
|
68
|
-
|
69
|
-
it { is_expected.to eq ['A label'] }
|
70
|
-
end
|
71
|
-
|
72
|
-
context "on an inherited class" do
|
73
|
-
before do
|
74
|
-
class Agent < ActiveFedora::Base
|
75
|
-
rdf_label ::RDF::Vocab::FOAF.name
|
76
|
-
property :foaf_name, predicate: ::RDF::Vocab::FOAF.name
|
77
|
-
end
|
78
|
-
class Person < Agent
|
79
|
-
rdf_label ::RDF::URI('http://example.com/foo')
|
80
|
-
property :job, predicate: ::RDF::URI('http://example.com/foo')
|
81
|
-
end
|
82
|
-
class Creator < Person
|
83
|
-
end
|
84
|
-
end
|
85
|
-
after do
|
86
|
-
Object.send(:remove_const, :Person)
|
87
|
-
Object.send(:remove_const, :Agent)
|
88
|
-
Object.send(:remove_const, :Creator)
|
89
|
-
end
|
90
|
-
|
91
|
-
subject { instance.rdf_label }
|
92
|
-
let(:instance) { Creator.new(foaf_name: ['Carolyn'], job: ['Developer']) }
|
93
|
-
|
94
|
-
it { is_expected.to eq ['Developer'] }
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe 'descendants' do
|
99
|
-
before do
|
100
|
-
class SpecialThing < ActiveFedora::Base
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
after do
|
105
|
-
Object.send(:remove_const, :SpecialThing)
|
106
|
-
end
|
107
|
-
|
108
|
-
it "records the decendants" do
|
109
|
-
expect(described_class.descendants).to include(SpecialThing)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
describe "With a test class" do
|
114
|
-
before do
|
115
|
-
class FooHistory < ActiveFedora::Base
|
116
|
-
property :fubar, predicate: ::RDF::URI('http://example.com/fubar')
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
after do
|
121
|
-
Object.send(:remove_const, :FooHistory)
|
122
|
-
end
|
123
|
-
|
124
|
-
def increment_id
|
125
|
-
@@last_id += 1
|
126
|
-
end
|
127
|
-
|
128
|
-
before do
|
129
|
-
@this_id = increment_id.to_s
|
130
|
-
@test_object = described_class.new
|
131
|
-
allow(@test_object).to receive(:assign_id).and_return(@this_id)
|
132
|
-
end
|
133
|
-
|
134
|
-
describe '#new' do
|
135
|
-
before do
|
136
|
-
allow_any_instance_of(FooHistory).to receive(:assign_id).and_return(@this_id)
|
137
|
-
end
|
138
|
-
|
139
|
-
context "with no arguments" do
|
140
|
-
it "does not get an id on init" do
|
141
|
-
expect(FooHistory.new.id).to be_nil
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context "with a hash argument" do
|
146
|
-
context "that has an id" do
|
147
|
-
it "is able to create with a custom id" do
|
148
|
-
expect(FooHistory).to receive(:id_to_uri).and_call_original
|
149
|
-
f = FooHistory.new(id: 'baz_1')
|
150
|
-
expect(f.id).to eq 'baz_1'
|
151
|
-
expect(f.id).to eq 'baz_1'
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context "that doesn't have an id" do
|
156
|
-
it "is able to create with a custom id" do
|
157
|
-
f = FooHistory.new(fubar: ['baz_1'])
|
158
|
-
expect(f.id).to be_nil
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
### Methods for ActiveModel::Conversions
|
165
|
-
context "before saving" do
|
166
|
-
context "#to_param" do
|
167
|
-
subject { @test_object.to_param }
|
168
|
-
it { is_expected.to be_nil }
|
169
|
-
end
|
170
|
-
context "#to_key" do
|
171
|
-
subject { @test_object.to_key }
|
172
|
-
it { is_expected.to be_nil }
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
context "when its saved" do
|
177
|
-
before do
|
178
|
-
allow(@test_object).to receive(:new_record?).and_return(false)
|
179
|
-
allow(@test_object).to receive(:uri).and_return("#{ActiveFedora.fedora.host}/test/one/two/three")
|
180
|
-
end
|
181
|
-
|
182
|
-
context "#to_param" do
|
183
|
-
subject { @test_object.to_param }
|
184
|
-
it { is_expected.to eq 'one/two/three' }
|
185
|
-
end
|
186
|
-
|
187
|
-
context "#to_key" do
|
188
|
-
subject { @test_object.to_key }
|
189
|
-
it { is_expected.to eq ['one/two/three'] }
|
190
|
-
end
|
191
|
-
end
|
192
|
-
### end ActiveModel::Conversions
|
193
|
-
|
194
|
-
### Methods for ActiveModel::Naming
|
195
|
-
it "knows the model_name" do
|
196
|
-
expect(FooHistory.model_name).to eq 'FooHistory'
|
197
|
-
expect(FooHistory.model_name.human).to eq 'Foo history'
|
198
|
-
end
|
199
|
-
### End ActiveModel::Naming
|
200
|
-
|
201
|
-
it 'provides #find' do
|
202
|
-
expect(described_class).to respond_to(:find)
|
203
|
-
end
|
204
|
-
|
205
|
-
it "provides .create_date" do
|
206
|
-
expect(@test_object).to respond_to(:create_date)
|
207
|
-
end
|
208
|
-
|
209
|
-
it "provides .modified_date" do
|
210
|
-
expect(@test_object).to respond_to(:modified_date)
|
211
|
-
end
|
212
|
-
|
213
|
-
describe '.save' do
|
214
|
-
it "creates a new record" do
|
215
|
-
allow(@test_object).to receive(:new_record?).and_return(true)
|
216
|
-
expect(@test_object).to receive(:serialize_attached_files)
|
217
|
-
expect(@test_object).to receive(:assign_rdf_subject)
|
218
|
-
expect(@test_object.ldp_source).to receive(:create)
|
219
|
-
expect(@test_object).to receive(:refresh)
|
220
|
-
expect(@test_object).to receive(:update_index)
|
221
|
-
@test_object.save
|
222
|
-
end
|
223
|
-
|
224
|
-
context "on an existing record" do
|
225
|
-
it "updates" do
|
226
|
-
allow(@test_object).to receive(:new_record?).and_return(false)
|
227
|
-
expect(@test_object).to receive(:serialize_attached_files)
|
228
|
-
allow_any_instance_of(Ldp::Orm).to receive(:save) { true }
|
229
|
-
expect(@test_object).to receive(:refresh)
|
230
|
-
expect(@test_object).to receive(:update_index)
|
231
|
-
@test_object.save
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
context "when assign id returns a value" do
|
236
|
-
context "an no id has been set" do
|
237
|
-
it "sets the id" do
|
238
|
-
@test_object.save
|
239
|
-
expect(@test_object.id).to eq @this_id
|
240
|
-
end
|
241
|
-
|
242
|
-
context "and the object has properties" do
|
243
|
-
let(:test_object) { WithProperty.new(title: ['foo']) }
|
244
|
-
before do
|
245
|
-
class WithProperty < ActiveFedora::Base
|
246
|
-
property :title, predicate: ::RDF::Vocab::DC.title
|
247
|
-
end
|
248
|
-
allow(test_object).to receive(:assign_id).and_return(@this_id)
|
249
|
-
test_object.save
|
250
|
-
end
|
251
|
-
after do
|
252
|
-
Object.send(:remove_const, :WithProperty)
|
253
|
-
end
|
254
|
-
|
255
|
-
it "updates the resource" do
|
256
|
-
expect(test_object.resource.rdf_subject).to eq ::RDF::URI.new("#{ActiveFedora.fedora.base_uri}/#{@this_id}")
|
257
|
-
expect(test_object.title).to eq ['foo']
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
context "when an id is set" do
|
263
|
-
before do
|
264
|
-
@test_object = described_class.new(id: '999')
|
265
|
-
allow(@test_object).to receive(:assign_id).and_return(@this_id)
|
266
|
-
end
|
267
|
-
it "does not set the id" do
|
268
|
-
@test_object.save
|
269
|
-
expect(@test_object.id).to eq '999'
|
270
|
-
end
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
describe "#create" do
|
276
|
-
it "builds a new record and save it" do
|
277
|
-
obj = instance_double(FooHistory)
|
278
|
-
expect(obj).to receive(:save)
|
279
|
-
expect(FooHistory).to receive(:new).and_return(obj)
|
280
|
-
FooHistory.create(fubar: 'ta')
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
describe "update_attributes" do
|
285
|
-
it "sets the attributes and save" do
|
286
|
-
m = FooHistory.new
|
287
|
-
att = { "fubar" => '1234', "baz" => 'stuff' }
|
288
|
-
|
289
|
-
expect(m).to receive(:fubar=).with('1234')
|
290
|
-
expect(m).to receive(:baz=).with('stuff')
|
291
|
-
expect(m).to receive(:save)
|
292
|
-
m.update_attributes(att)
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
describe "update" do
|
297
|
-
it "sets the attributes and save" do
|
298
|
-
m = FooHistory.new
|
299
|
-
att = { "fubar" => '1234', "baz" => 'stuff' }
|
300
|
-
|
301
|
-
expect(m).to receive(:fubar=).with('1234')
|
302
|
-
expect(m).to receive(:baz=).with('stuff')
|
303
|
-
expect(m).to receive(:save)
|
304
|
-
m.update(att)
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
describe '.dangerous_attribute_method?' do
|
310
|
-
before do
|
311
|
-
class FooHistory < ActiveFedora::Base
|
312
|
-
type ::RDF::URI.new('http://example.com/foo')
|
313
|
-
property :title, predicate: ::RDF::Vocab::DC.title
|
314
|
-
end
|
315
|
-
end
|
316
|
-
after do
|
317
|
-
Object.send(:remove_const, :FooHistory)
|
318
|
-
end
|
319
|
-
|
320
|
-
it 'is dangerous if it is defined by the class' do
|
321
|
-
expect(FooHistory.dangerous_attribute_method?(:save)).to eq true
|
322
|
-
end
|
323
|
-
|
324
|
-
it 'is not dangerous if it is defined outside of ActiveFedora' do
|
325
|
-
expect(FooHistory.dangerous_attribute_method?(:puts)).to eq false
|
326
|
-
end
|
327
|
-
end
|
328
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::Associations::Builder::HasAndBelongsToMany do
|
4
|
-
describe "valid_options" do
|
5
|
-
subject { described_class.valid_options({}) }
|
6
|
-
it { is_expected.to match_array [:class_name, :predicate, :type_validator, :before_add, :after_add, :before_remove, :after_remove, :inverse_of, :solr_page_size, :autosave] }
|
7
|
-
end
|
8
|
-
end
|
data/spec/unit/callback_spec.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::Base do
|
4
|
-
before do
|
5
|
-
class CallbackStub < ActiveFedora::Base
|
6
|
-
after_initialize :a_init
|
7
|
-
before_save :b_save
|
8
|
-
after_save :a_save
|
9
|
-
before_create :b_create
|
10
|
-
after_create :a_create
|
11
|
-
before_update :b_update
|
12
|
-
after_update :a_update
|
13
|
-
after_find :a_find
|
14
|
-
|
15
|
-
after_update_index :a_update_index
|
16
|
-
before_update_index :b_update_index
|
17
|
-
|
18
|
-
before_destroy :do_stuff
|
19
|
-
|
20
|
-
def do_stuff
|
21
|
-
:noop
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
after do
|
26
|
-
@cb.destroy if @cb && @cb.persisted? # this only is called if the test failed to run all the way through.
|
27
|
-
Object.send(:remove_const, :CallbackStub)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "has after_initialize, before_save, after_save, before_create, after_create, after_update_index, before_update_index" do
|
31
|
-
allow_any_instance_of(CallbackStub).to receive(:a_init)
|
32
|
-
allow_any_instance_of(CallbackStub).to receive :b_create
|
33
|
-
allow_any_instance_of(CallbackStub).to receive :a_create
|
34
|
-
allow_any_instance_of(CallbackStub).to receive(:b_save)
|
35
|
-
allow_any_instance_of(CallbackStub).to receive(:a_save)
|
36
|
-
allow_any_instance_of(CallbackStub).to receive(:a_update_index)
|
37
|
-
allow_any_instance_of(CallbackStub).to receive(:b_update_index)
|
38
|
-
@cb = CallbackStub.new
|
39
|
-
@cb.save
|
40
|
-
end
|
41
|
-
|
42
|
-
it "has after_initialize, before_save, after_save, before_create, after_create, after_update, before_update, before_destroy" do
|
43
|
-
allow_any_instance_of(CallbackStub).to receive(:a_init)
|
44
|
-
allow_any_instance_of(CallbackStub).to receive(:b_create)
|
45
|
-
allow_any_instance_of(CallbackStub).to receive(:a_create)
|
46
|
-
allow_any_instance_of(CallbackStub).to receive(:b_save)
|
47
|
-
allow_any_instance_of(CallbackStub).to receive(:a_save)
|
48
|
-
allow_any_instance_of(CallbackStub).to receive(:a_update_index)
|
49
|
-
allow_any_instance_of(CallbackStub).to receive(:b_update_index)
|
50
|
-
@cb = CallbackStub.new
|
51
|
-
@cb.save
|
52
|
-
allow_any_instance_of(CallbackStub).to receive(:a_init)
|
53
|
-
allow_any_instance_of(CallbackStub).to receive(:b_save)
|
54
|
-
allow_any_instance_of(CallbackStub).to receive(:a_save)
|
55
|
-
allow_any_instance_of(CallbackStub).to receive(:a_find)
|
56
|
-
allow_any_instance_of(CallbackStub).to receive(:b_update)
|
57
|
-
allow_any_instance_of(CallbackStub).to receive(:a_update)
|
58
|
-
allow_any_instance_of(CallbackStub).to receive(:do_stuff)
|
59
|
-
|
60
|
-
@cb = CallbackStub.find(@cb.id)
|
61
|
-
@cb.save!
|
62
|
-
|
63
|
-
@cb.destroy
|
64
|
-
end
|
65
|
-
end
|