apidae 0.9.26 → 0.9.31

Sign up to get free protection for your applications and to get access to all the features.
@@ -153,6 +153,29 @@ module Apidae
153
153
  assert_equal 0, Selection.count
154
154
  end
155
155
 
156
+ test "object deletion cancelled if used by another project" do
157
+ proj = Project.create(apidae_id: 123)
158
+ other_proj = Project.create(apidae_id: 456)
159
+ sel = Selection.create(apidae_id: 49063, apidae_project_id: proj.id, label: 'Sélection 2', reference: 'selection-2')
160
+ other_sel = Selection.create(apidae_id: 49999, apidae_project_id: other_proj.id, label: 'Sélection 99', reference: 'selection-99')
161
+ sel.objects << Obj.create(apidae_id: 503, title: 'Société des violoncellistes aixois')
162
+ sel.objects << Obj.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
163
+ other_sel.objects << Obj.find_by_apidae_id(504)
164
+
165
+ assert_equal 2, sel.objects.count
166
+ assert_equal 1, other_sel.objects.count
167
+
168
+ selections_json = File.read('test/data/shared_selections.json')
169
+ FileImport.add_or_update_selections(proj, selections_json, @result)
170
+ deletion_json = File.read('test/data/deletion.json')
171
+ FileImport.delete_objects(deletion_json, @result)
172
+
173
+ assert_equal 2, Obj.count
174
+ assert_equal({created: 0, updated: 0, deleted: 1, selections:
175
+ [{:apidae_id=>49063, :reference=>"selection-2", :objects=>1}]}, @result)
176
+ assert_equal 1, other_sel.objects.count
177
+ end
178
+
156
179
  test "full import process" do
157
180
  Obj.create(apidae_id: 123, title: 'Objet à supprimer')
158
181
  Obj.create(apidae_id: 4826186, title: 'Objet à mettre à jour')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apidae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.26
4
+ version: 0.9.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-06 00:00:00.000000000 Z
11
+ date: 2021-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -194,6 +194,7 @@ files:
194
194
  - test/data/hot_fr_en.json
195
195
  - test/data/json_export.zip
196
196
  - test/data/selections.json
197
+ - test/data/shared_selections.json
197
198
  - test/data/structure.json
198
199
  - test/data/update_selections.json
199
200
  - test/dummy/README.rdoc
@@ -230,6 +231,7 @@ files:
230
231
  - test/dummy/config/secrets.yml
231
232
  - test/dummy/db/schema.rb
232
233
  - test/dummy/log/development.log
234
+ - test/dummy/log/test.log
233
235
  - test/dummy/public/404.html
234
236
  - test/dummy/public/422.html
235
237
  - test/dummy/public/500.html
@@ -310,6 +312,7 @@ test_files:
310
312
  - test/dummy/public/500.html
311
313
  - test/dummy/public/404.html
312
314
  - test/dummy/db/schema.rb
315
+ - test/dummy/log/test.log
313
316
  - test/dummy/log/development.log
314
317
  - test/dummy/README.rdoc
315
318
  - test/integration/navigation_test.rb
@@ -334,6 +337,7 @@ test_files:
334
337
  - test/controllers/apidae/dashboard_controller_test.rb
335
338
  - test/controllers/apidae/references_controller_test.rb
336
339
  - test/controllers/apidae/import_controller_test.rb
340
+ - test/data/shared_selections.json
337
341
  - test/data/equ_groups.json
338
342
  - test/data/update_selections.json
339
343
  - test/data/json_export.zip