repository-manager 0.1.30 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 145f1e8967f2e0ab92b1b3e4956a9c24d6630275
4
- data.tar.gz: 0e532d15212ec9cd2594796bb7238c6ca38d2d12
3
+ metadata.gz: cf952fb3752184fb64aa5278be4d0d0f12efd79b
4
+ data.tar.gz: c16ab36bac207d748e4ed0acb716b141cb616e12
5
5
  SHA512:
6
- metadata.gz: eb7cb764141c843c0ad2df051c3a6da2d50d82bc15465bbf01bf4ad52a5928772c4cc7378a458efff6b45f5a3c09039365325e35f035bf873387080bef31283c
7
- data.tar.gz: 329f18f7c9dfd9b4ae4bc0f3808b8156dfa392da5b4ab2a7ae9f08fefc95289dceacced4dcd0aa7ffaffe9865d1ce24f2dfc3a103f7ef1597f0711d377b2516e
6
+ metadata.gz: bb2137ad712f97e313e27ce012fe4a909de4134d92be97845f66605c3e7343c155596102debac1634dc931ed9651a41d9931e06009a4471f8a4e18da8eedb94d
7
+ data.tar.gz: 54138b1cef9e644e8037eac0482d2987d7bd5e3a9862af381d193c4a432fc0c322b417802322bd95f018a34135a4e21344847b80723649d28216bccb6fe10c10
data/README.md CHANGED
@@ -118,9 +118,9 @@ A few methods are written in those two ways :
118
118
 
119
119
  The two methods do the same, but the one with the "!" returns an Exception error if it is a problem (PermissionException or RepositoryManagerException for instance) and the method without "!" return false if it has a problem.
120
120
 
121
- ### How can I create/delete/move a repo_item (file or folder)
121
+ ### How can I manage a repo_item (file or folder)
122
122
 
123
- You just have to call the `has_repository` methods `create_file`, `create_folder`, `move_repo_item`, `copy_repo_item` or `delete_repo_item`. [Check here for all `has_repository` methods] (https://github.com/Texicitys/repository-manager/wiki/Has_repository-methods).
123
+ You just have to call the `has_repository` methods `create_file`, `create_folder`, `move_repo_item`, `copy_repo_item`, `rename_repo_item` or `delete_repo_item`.
124
124
 
125
125
  ```ruby
126
126
  # user1 wants to create a folder in his repository
@@ -174,7 +174,7 @@ test_folder = user1.create_folder('Test folder')
174
174
  # |-- 'Test folder'
175
175
 
176
176
  # user1 want to move 'The new folder' in 'Test folder'
177
- user1.move_repo_item(the_new_folder, test_folder)
177
+ user1.move_repo_item(the_new_folder, source_folder: test_folder)
178
178
 
179
179
  # user1 own repository :
180
180
  # |-- 'Root folder'
@@ -194,7 +194,7 @@ user1.rename_repo_item(the_new_folder, 'The renamed folder')
194
194
  # | | |-- 'file.txt'
195
195
 
196
196
  # user1 want to copy 'Root folder' into 'Test folder'
197
- user1.copy_repo_item(source_folder, test_folder)
197
+ user1.copy_repo_item(source_folder, source_folder: test_folder)
198
198
 
199
199
  # user1 own repository :
200
200
  # |-- 'Root folder'
@@ -242,7 +242,7 @@ WARNING : There is no verification if the user1 has the permission to create a f
242
242
 
243
243
  ### How can I share a repo_item (file/folder)
244
244
 
245
- Now, user1 want to share his folder 'The new folder' with a Group object `group1` and another User object `user2`. You can use the `has_repository` method `share(repo_item, member, options = nil)`.
245
+ Now, user1 want to share his folder 'The new folder' with a Group object `group1` and another User object `user2`. You can use the `has_repository` method `share_repo_item(repo_item, member, options = nil)`.
246
246
 
247
247
 
248
248
  ```ruby
@@ -253,12 +253,24 @@ members = []
253
253
  members << group1
254
254
  members << user2
255
255
 
256
- sharing = user1.share(the_new_folder, members)
256
+ sharing = user1.share_repo_item(the_new_folder, members)
257
257
 
258
258
  # If you want to customize your sharing options, you can do it like this:
259
- options = {sharing_permissions: {can_add: true, can_remove: true}, repo_item_permissions: {can_read: true, can_create: true, can_update: true, can_delete: true, can_share: true}}
260
-
261
- sharing = user1.share(the_new_folder, members, options)
259
+ options = {
260
+ sharing_permissions: {
261
+ can_add: true,
262
+ can_remove: false
263
+ },
264
+ repo_item_permissions: {
265
+ can_read: true,
266
+ can_create: true,
267
+ can_update: true,
268
+ can_delete: false,
269
+ can_share: true
270
+ }
271
+ }
272
+
273
+ sharing = user1.share_repo_item(the_new_folder, members, options)
262
274
  ```
263
275
 
264
276
  `repo_item_permissions` specifies what kind of permissions you give on the repo_item in a specific sharing.
@@ -282,16 +294,16 @@ children = @user1.create_folder('Children', nested)
282
294
  # | |-- 'Nested'
283
295
  # | | |-- 'Children'
284
296
 
285
- @user1.share(nested, @user2)
297
+ @user1.share_repo_item(nested, @user2)
286
298
 
287
299
  nested.can_be_shared_without_nesting? # Returns true (because `nested` is shared but there exist no nested sharing)
288
300
  parent.can_be_shared_without_nesting? # Returns false (because there is a sharing on one of his descendants)
289
301
  children.can_be_shared_without_nesting? # Returns false (because there is a sharing on one of his ancestors)
290
302
 
291
303
  # Here we can't share 'Parent' or 'Children' because it already exist a nested sharing.
292
- @user1.share(parent, @user2) # Returns false
293
- @user1.share!(parent, @user2) # Raise a NestedSharingException (note the "!")
294
- @user1.share!(children, @user2) # Raise a NestedSharingException (note the "!")
304
+ @user1.share_repo_item(parent, @user2) # Returns false
305
+ @user1.share_repo_item!(parent, @user2) # Raise a NestedSharingException (note the "!")
306
+ @user1.share_repo_item!(children, @user2) # Raise a NestedSharingException (note the "!")
295
307
  ```
296
308
 
297
309
  ### How can I see my repo_items
@@ -333,13 +345,15 @@ Recall: a repo_item can be:
333
345
 
334
346
  ```ruby
335
347
  # We want to know if the object repo_item is a file or a folder:
336
- if repo_item.is_folder
348
+ if repo_item.is_folder?
337
349
  repo_item.name #=> Returns the name of the folder (for instance : 'New folder').
338
350
  elsif repo_item.is_file?
339
351
  repo_item.name #=> Returns the name of the file (for instance : 'file.png').
340
352
  # Here is the file
341
353
  repo_item.file.url # => '/url/to/stored_file.png'
342
354
  repo_item.file.current_path # => 'path/to/stored_file.png'
355
+ else
356
+ # Wait... WHAT ?!
343
357
  end
344
358
  ```
345
359
 
@@ -437,21 +451,21 @@ Like the repo_item permissions, you can get the sharing permissions of an `objec
437
451
 
438
452
  ### Download a repository
439
453
 
440
- RepositoryManager make the download of a `repo_item` easy. If the user want to download a file, use the `has_repository` method : `download`. This method returns you the path of the file (if the user `can_read` it).
454
+ RepositoryManager make the download of a `repo_item` easy. If the user want to download a file, use the `has_repository` method : `download_repo_item`. This method returns you the path of the file (if the user `can_read` it).
441
455
 
442
456
  If the `repo_item` is a file, the method returns you the path of this file.
443
457
  If the `repo_item` is a folder, it automatically generates a zip file with all the constant that the user `can_read`. The method returns the path of this zip file.
444
458
 
445
459
  ```ruby
446
460
  # user1 want to download the_file
447
- path_to_file = user1.download(the_file)
461
+ path_to_file = user1.download_repo_item(the_file)
448
462
  # don't forget to specify the name of the file (it could have been changed since uploaded)
449
463
  send_file path_to_file, filename: the_file.name
450
464
  ```
451
465
 
452
466
  ```ruby
453
467
  # user1 want to download the_folder
454
- path_to_zip = user1.download(the_folder)
468
+ path_to_zip = user1.download_repo_item(the_folder)
455
469
 
456
470
  # Then you can do what you want with this path, you can use the send_file method from rails in your controller
457
471
  send_file path_to_zip
@@ -473,7 +487,7 @@ the_folder.delete_zip
473
487
 
474
488
  ### Errors handling
475
489
 
476
- When an error happen, you (and the user also) want to know what was the source of this problem. I tried to make it the most simple as possible.
490
+ When an error happen, you (and the user also) want to know what is the source of the problem. I tried to make it the most simple as possible.
477
491
 
478
492
  For the two `has_repository` methods `create_file` and `create_folder`, the errors are pushed into the `options` hash parameter with the key `errors` (`options[:errors]`)
479
493
 
@@ -498,7 +512,7 @@ else
498
512
  options[:errors] # Contains array of errors
499
513
  ```
500
514
 
501
- For the other `has_repository` methods, the error is added to the first object passed in parameter (for instance: `repo_item` or `sharing`)
515
+ For the other `has_repository` methods, the errors are added in the first object passed in parameter (for instance: `repo_item` or `sharing`)
502
516
 
503
517
 
504
518
  ```ruby
@@ -506,18 +520,18 @@ For the other `has_repository` methods, the error is added to the first object p
506
520
  if @group.delete_repo_item(@repo_item)
507
521
  redirect_to :back, notice: 'Item deleted'
508
522
  else
509
- # repo_item.errors ==> Contains the errors
510
523
  redirect_to :back, alert: repo_item.errors.messages[:delete].first
511
524
  end
525
+
526
+ # repo_item.errors ==> Contains the errors
512
527
  ```
513
528
 
514
529
 
515
530
  ## TODO
516
531
 
517
- - Test the rename file method
518
532
  - Write the methods : share_link.
519
- - Snapshot the file if possible
520
533
  - Versioning
534
+ - Snapshot the file if possible
521
535
  - ...
522
536
 
523
537
 
@@ -43,7 +43,7 @@ module RepositoryManager
43
43
  # options[:sharing_permissions] contains :
44
44
  # <tt>:can_add</tt> - Specify if the member can add objects to the sharing
45
45
  # <tt>:can_remove</tt> - Specify if the member can remove object to the sharing
46
- def share!(repo_item, members, options = {})
46
+ def share_repo_item!(repo_item, members, options = {})
47
47
 
48
48
  # Nested sharing are not accepted
49
49
  if !RepositoryManager.accept_nested_sharing
@@ -86,9 +86,9 @@ module RepositoryManager
86
86
  end
87
87
  end
88
88
 
89
- def share(repo_item, members, options = {})
89
+ def share_repo_item(repo_item, members, options = {})
90
90
  begin
91
- share!(repo_item, members, options)
91
+ share_repo_item!(repo_item, members, options)
92
92
  rescue RepositoryManager::PermissionException, RepositoryManager::NestedSharingException, RepositoryManager::RepositoryManagerException
93
93
  false
94
94
  rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
@@ -275,7 +275,7 @@ module RepositoryManager
275
275
  # We zip all the content that the object has access.
276
276
  # options
277
277
  # :path => 'path/to/zip'
278
- def download!(repo_item, options = {})
278
+ def download_repo_item!(repo_item, options = {})
279
279
  if can_download?(repo_item)
280
280
  path = options[:path] if options[:path]
281
281
 
@@ -286,9 +286,9 @@ module RepositoryManager
286
286
  end
287
287
  end
288
288
 
289
- def download(repo_item, options = {})
289
+ def download_repo_item(repo_item, options = {})
290
290
  begin
291
- download!(repo_item, options)
291
+ download_repo_item!(repo_item, options)
292
292
  rescue RepositoryManager::PermissionException
293
293
  false
294
294
  end
@@ -313,9 +313,12 @@ module RepositoryManager
313
313
  end
314
314
 
315
315
  # Move the repo_item
316
- # target => move into this source_folder
317
- # if target == nil, move to the root
318
- def move_repo_item!(repo_item, target = nil)
316
+ # options
317
+ # :source_folder => move into this source_folder
318
+ # if :source_folder == nil, move to the root
319
+ def move_repo_item!(repo_item, options = {})
320
+ target = options[:source_folder]
321
+
319
322
  if !can_read?(repo_item)
320
323
  repo_item.errors.add(:move, I18n.t('repository_manager.errors.repo_item.move.no_permission'))
321
324
  raise RepositoryManager::PermissionException.new("move repo_item failed. You don't have the permission to read the repo_item '#{repo_item.name}'")
@@ -348,9 +351,9 @@ module RepositoryManager
348
351
  repo_item.move!(source_folder: target)
349
352
  end
350
353
 
351
- def move_repo_item(repo_item, target = nil)
354
+ def move_repo_item(repo_item, options = {})
352
355
  begin
353
- move_repo_item!(repo_item, target)
356
+ move_repo_item!(repo_item, options)
354
357
  rescue RepositoryManager::PermissionException, RepositoryManager::ItemExistException
355
358
  false
356
359
  rescue RepositoryManager::RepositoryManagerException, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
@@ -360,10 +363,12 @@ module RepositoryManager
360
363
  end
361
364
 
362
365
  # Copy the repo_item in the source_folder or in own root
363
- # target => the folder in witch we want to copy the repo item
364
366
  # options
367
+ # :source_folder => the folder in witch we want to copy the repo item
365
368
  # :sender => the new sender (by default => still the old sender)
366
- def copy_repo_item!(repo_item, target = nil, options = {})
369
+ def copy_repo_item!(repo_item, options = {})
370
+ target = options[:source_folder]
371
+
367
372
  unless can_read?(repo_item)
368
373
  repo_item.errors.add(:copy, I18n.t('repository_manager.errors.repo_item.copy.no_permission'))
369
374
  raise RepositoryManager::PermissionException.new("copy repo_item failed. You don't have the permission to read the repo_item '#{repo_item.name}'")
@@ -385,9 +390,9 @@ module RepositoryManager
385
390
  repo_item.copy!(source_folder: target, owner: owner, sender: options[:sender])
386
391
  end
387
392
 
388
- def copy_repo_item(repo_item, target = nil, options = {})
393
+ def copy_repo_item(repo_item, options = {})
389
394
  begin
390
- copy_repo_item!(repo_item, target, options)
395
+ copy_repo_item!(repo_item, options)
391
396
  rescue RepositoryManager::PermissionException, RepositoryManager::ItemExistException
392
397
  false
393
398
  rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
@@ -1,3 +1,3 @@
1
1
  module RepositoryManager
2
- VERSION = '0.1.30'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -35,7 +35,7 @@ describe 'HasRepository' do
35
35
  members << @user2
36
36
  members << @user3
37
37
 
38
- @user1.share(rep, members)
38
+ @user1.share_repo_item(rep, members)
39
39
 
40
40
  #expect(@user1.sharings.count).to eq(0)
41
41
  expect(@user2.sharings.count).to eq(1)
@@ -57,7 +57,7 @@ describe 'HasRepository' do
57
57
  members = []
58
58
  members << @user2
59
59
 
60
- @user1.share(rep, members)
60
+ @user1.share_repo_item(rep, members)
61
61
 
62
62
  expect(rep.errors.messages).to eq({sharing: ['You don\'t have the permission to share this item']})
63
63
 
@@ -74,11 +74,11 @@ describe 'HasRepository' do
74
74
  members << @user2
75
75
 
76
76
  # here user3 can share because he is the owner
77
- @user3.share(rep, members)
77
+ @user3.share_repo_item(rep, members)
78
78
  # here user2 should can share because he has the permission
79
79
  members = []
80
80
  members << @user1
81
- @user2.share(rep, members)
81
+ @user2.share_repo_item(rep, members)
82
82
 
83
83
  expect(@user1.sharings.count).to eq(0)
84
84
  expect(@user2.sharings_owners.count).to eq(0)
@@ -96,11 +96,11 @@ describe 'HasRepository' do
96
96
  options = {repo_item_permissions: {can_share: true}}
97
97
 
98
98
  # here user3 can share because he is the owner
99
- @user3.share(rep, members, options)
99
+ @user3.share_repo_item(rep, members, options)
100
100
  # here user2 should can share because he has the permission
101
101
  members = []
102
102
  members << @user1
103
- @user2.share(rep, members)
103
+ @user2.share_repo_item(rep, members)
104
104
 
105
105
  expect(@user1.sharings.count).to eq(1)
106
106
  expect(@user2.sharings_owners.count).to eq(1)
@@ -118,13 +118,13 @@ describe 'HasRepository' do
118
118
  options = {repo_item_permissions: {can_read: true, can_share: true}}
119
119
 
120
120
  # here user3 can share because he is the owner
121
- @user3.share(rep, members, options)
121
+ @user3.share_repo_item(rep, members, options)
122
122
  # here user2 should can share because he has the permission
123
123
  # But he has only the permission of read (can_read = true), He can't share with more permissions
124
124
  members = []
125
125
  members << @user1
126
126
  #Here the permissions should be : :can_read => true, and all others false
127
- @user2.share(rep, members)
127
+ @user2.share_repo_item(rep, members)
128
128
 
129
129
  sharing_of_user_1 = @user1.sharings.last
130
130
 
@@ -147,7 +147,7 @@ describe 'HasRepository' do
147
147
  options = {repo_item_permissions: {can_read: true, can_share: true}}
148
148
 
149
149
  # here user3 can share because he is the owner
150
- @user3.share(rep, members, options)
150
+ @user3.share_repo_item(rep, members, options)
151
151
  # here user2 should can share because he has the permission
152
152
  # But he has only the permission of read (can_read = true), He can't share with more permissions
153
153
  members = []
@@ -156,7 +156,7 @@ describe 'HasRepository' do
156
156
  options = {repo_item_permissions: {can_read: true, can_update: true, can_share: true}}
157
157
 
158
158
  #Here the permissions should be : :can_read => true, :can_share => true and all others false
159
- @user2.share(rep, members, options)
159
+ @user2.share_repo_item(rep, members, options)
160
160
 
161
161
  sharing_of_user_1 = @user1.sharings.last
162
162
 
@@ -178,7 +178,7 @@ describe 'HasRepository' do
178
178
  options = {sharing_permissions: {can_add: true, can_remove: false}}
179
179
 
180
180
  # here user3 can share because he is the owner
181
- @user3.share(rep, members, options)
181
+ @user3.share_repo_item(rep, members, options)
182
182
 
183
183
  sharing_member_of_user_2 = @user2.sharings_members.last
184
184
 
@@ -202,14 +202,14 @@ describe 'HasRepository' do
202
202
  # children.add(file)
203
203
  #
204
204
  # options = {repo_item_permissions: {can_read: true, can_update: true, can_share: false}}
205
- # @user3.share(parent, @user1, options)
205
+ # @user3.share_repo_item(parent, @user1, options)
206
206
  #
207
207
  # options = {repo_item_permissions: {can_read: true, can_update: true, can_share: true}}
208
- # @user3.share(children, @user1, options)
208
+ # @user3.share_repo_item(children, @user1, options)
209
209
  #
210
- # @user1.share(middle, @user2)
210
+ # @user1.share_repo_item(middle, @user2)
211
211
  # expect(@user2.sharings.count).to eq(0)
212
- # @user1.share(file, @user2)
212
+ # @user1.share_repo_item(file, @user2)
213
213
  # expect(@user2.sharings.count).to eq(1)
214
214
  #end
215
215
 
@@ -223,14 +223,14 @@ describe 'HasRepository' do
223
223
  # | |-- 'Nested'
224
224
  # | | |-- 'Children'
225
225
 
226
- @user1.share(nested, @user2)
226
+ @user1.share_repo_item(nested, @user2)
227
227
 
228
228
  expect(nested.can_be_shared_without_nesting?).to eq(true) # Returns true (because `nested` is shared but there is no nested sharing)
229
229
  expect(parent.can_be_shared_without_nesting?).to eq(false) # Returns false (because there is a sharing on one of his descendants)
230
230
  expect(parent.can_be_shared_without_nesting?).to eq(false) # Returns false (because there is a sharing on one of his ancestors)
231
231
 
232
232
  # Here we can't share 'Parent' or 'Children' because it already exist a nested sharing.
233
- expect(@user1.share(parent, @user2)).to eq(false) # Returns false
233
+ expect(@user1.share_repo_item(parent, @user2)).to eq(false) # Returns false
234
234
  expect(parent.errors.messages).to eq({sharing: ['You can\'t share this item because another sharing exist on its ancestors or descendants']})
235
235
 
236
236
  end
@@ -249,14 +249,14 @@ describe 'HasRepository' do
249
249
  children.add(file)
250
250
 
251
251
  options = {repo_item_permissions: {can_read: true, can_update: true, can_share: true}}
252
- @user3.share(parent, @user1, options)
252
+ @user3.share_repo_item(parent, @user1, options)
253
253
 
254
254
  options = {repo_item_permissions: {can_read: true, can_update: true, can_share: true}}
255
- @user3.share(children, @user1, options)
255
+ @user3.share_repo_item(children, @user1, options)
256
256
 
257
- @user1.share(middle, @user2)
257
+ @user1.share_repo_item(middle, @user2)
258
258
  expect(@user2.sharings.count).to eq(0)
259
- @user1.share(file, @user2)
259
+ @user1.share_repo_item(file, @user2)
260
260
  expect(@user2.sharings.count).to eq(0)
261
261
 
262
262
  end
@@ -278,7 +278,7 @@ describe 'HasRepository' do
278
278
 
279
279
  it 'can put a creator for a specific sharing' do
280
280
  folder = @group1.create_folder('a')
281
- sharing = @group1.share(folder, @user2, creator: @user1)
281
+ sharing = @group1.share_repo_item(folder, @user2, creator: @user1)
282
282
 
283
283
  expect(sharing.reload.owner).to eq(@group1)
284
284
  expect(sharing.creator).to eq(@user1)
@@ -286,7 +286,7 @@ describe 'HasRepository' do
286
286
 
287
287
  it 'is by default owner = creator' do
288
288
  folder = @group1.create_folder('a')
289
- sharing = @group1.share(folder, @user2)
289
+ sharing = @group1.share_repo_item(folder, @user2)
290
290
 
291
291
  expect(sharing.reload.owner).to eq(@group1)
292
292
  expect(sharing.creator).to eq(@group1)
@@ -87,7 +87,7 @@ describe 'RepoItem' do
87
87
 
88
88
  it 'can return only the sharing repo_items' do
89
89
  #expect(@user2.shared_repo_items.count).to eq(0)
90
- @user1.share(@user1_file, @user2)
90
+ @user1.share_repo_item(@user1_file, @user2)
91
91
  expect(@user2.shared_repo_items.count).to eq(1)
92
92
  end
93
93
 
@@ -98,12 +98,12 @@ describe 'RepoItem' do
98
98
  end
99
99
 
100
100
  it 'user can download a file with permission' do
101
- @user1.download(@user1_file)
101
+ @user1.download_repo_item(@user1_file)
102
102
  #expect(@user2.shared_repo_items.count).to eq(1)
103
103
  end
104
104
 
105
105
  it 'user can\'t download a file without permission' do
106
- path = @user2.download(@user1_file)
106
+ path = @user2.download_repo_item(@user1_file)
107
107
  expect(path).to eq(false)
108
108
  expect(@user1_file.errors.messages).to eq({download: ['You don\'t have the permission to download this item']})
109
109
 
@@ -129,8 +129,8 @@ describe 'RepoItem' do
129
129
  user1_file3.save
130
130
  @user1.create_file(user1_file3, source_folder: @user1_folder)
131
131
 
132
- @user1.download(@user1_folder)
133
- @user1.download(@user1_folder)
132
+ @user1.download_repo_item(@user1_folder)
133
+ @user1.download_repo_item(@user1_folder)
134
134
  @user1_folder.download
135
135
 
136
136
  @user1_folder.delete_zip
@@ -149,7 +149,7 @@ describe 'RepoItem' do
149
149
  #@user2.create_file!(file, source_folder: a)
150
150
  #@user2.create_file!(file, source_folder: nested)
151
151
  @user2.create_file!(file, source_folder: c)
152
- @user2.download(nested)
152
+ @user2.download_repo_item(nested)
153
153
  @user2.delete_download_path()
154
154
  end
155
155
 
@@ -165,9 +165,9 @@ describe 'RepoItem' do
165
165
  #@user2.create_file!(file, source_folder: a)
166
166
  #@user2.create_file!(file, source_folder: nested)
167
167
  @user2.create_file!(file, source_folder: c)
168
- @user2.share!(nested, @user1, repo_item_permissions: {can_read: true})
168
+ @user2.share_repo_item!(nested, @user1, repo_item_permissions: {can_read: true})
169
169
  copy = @user1.copy_repo_item!(nested)
170
- @user1.download(copy)
170
+ @user1.download_repo_item(copy)
171
171
  @user1.delete_download_path()
172
172
  end
173
173
 
@@ -179,7 +179,7 @@ describe 'RepoItem' do
179
179
  test_folder = @user1.create_folder('Test folder', source_folder: root_test_folder)
180
180
  @user1.create_folder('Nested test folder', source_folder: test_folder)
181
181
 
182
- @user1.move_repo_item(test_folder, @user1_folder)
182
+ @user1.move_repo_item(test_folder, source_folder: @user1_folder)
183
183
 
184
184
  expect(test_folder.parent_id).to eq(@user1_folder.id)
185
185
  end
@@ -284,7 +284,7 @@ describe 'RepoItem' do
284
284
  file = @user2.create_file(File.open("#{Rails.root}/../fixture/textfile.txt"))
285
285
  folder = @user2.create_folder('folder')
286
286
 
287
- @user2.move_repo_item!(file, folder)
287
+ @user2.move_repo_item!(file, source_folder: folder)
288
288
 
289
289
  expect(folder.children).to eq([file])
290
290
  end
@@ -292,7 +292,7 @@ describe 'RepoItem' do
292
292
  it "can move a folder into a folder" do
293
293
  folder = @user2.create_folder('folder')
294
294
  folder2 = @user2.create_folder('folder2')
295
- @user2.move_repo_item!(folder, folder2)
295
+ @user2.move_repo_item!(folder, source_folder: folder2)
296
296
 
297
297
  expect(folder2.children).to eq([folder])
298
298
  end
@@ -301,7 +301,7 @@ describe 'RepoItem' do
301
301
  file = @user2.create_file(File.open("#{Rails.root}/../fixture/textfile.txt"))
302
302
  folder = @user2.create_folder('folder')
303
303
 
304
- expect(@user2.move_repo_item(folder, file)).to eq(false)
304
+ expect(@user2.move_repo_item(folder, source_folder: file)).to eq(false)
305
305
  expect(folder.errors.messages).to eq({move: ['This item was not moved']})
306
306
 
307
307
 
@@ -336,8 +336,15 @@ describe 'RepoItem' do
336
336
  end
337
337
 
338
338
  it "can copy a file with read permission" do
339
- @user1.share(@user1_file, @user2, repo_item_permissions: {can_read:true})
339
+ @user1.share_repo_item(@user1_file, @user2, repo_item_permissions: {can_read:true})
340
340
  @user2.copy_repo_item(@user1_file)
341
341
  expect(@user2.root_repo_items.count).to eq(1)
342
342
  end
343
+
344
+ it "can copy a file with read permission in a folder" do
345
+ @user1.share_repo_item(@user1_file, @user2, repo_item_permissions: {can_read:true})
346
+ fold = @user2.create_folder!('fold')
347
+ @user2.copy_repo_item!(@user1_file, source_folder: fold)
348
+ expect(fold.children.count).to eq(1)
349
+ end
343
350
  end
@@ -12,46 +12,46 @@ describe 'Sharing' do
12
12
  end
13
13
 
14
14
  it 'can add a member in his own sharing' do
15
- sharing = @user1.share(@user1_file, @user2, {sharing_permissions:{can_add: false, can_remove: false}})
15
+ sharing = @user1.share_repo_item(@user1_file, @user2, {sharing_permissions:{can_add: false, can_remove: false}})
16
16
  @user1.add_members_to(sharing, @user3)
17
17
  expect(@user3.shared_repo_items.count).to eq(1)
18
18
  end
19
19
 
20
20
  it 'can\'t add a member in a sharing without permission' do
21
- sharing = @user1.share(@user1_file, @user2, {sharing_permissions:{can_add: false, can_remove: false}})
21
+ sharing = @user1.share_repo_item(@user1_file, @user2, {sharing_permissions:{can_add: false, can_remove: false}})
22
22
  @user2.add_members_to(sharing, @user3)
23
23
  expect(@user3.shared_repo_items.count).to eq(0)
24
24
  end
25
25
 
26
26
  it 'can add a member in a sharing with permission' do
27
- sharing = @user1.share(@user1_file, @user2, {sharing_permissions:{can_add: true, can_remove: false}})
27
+ sharing = @user1.share_repo_item(@user1_file, @user2, {sharing_permissions:{can_add: true, can_remove: false}})
28
28
  @user2.add_members_to(sharing, @user3)
29
29
  expect(@user3.shared_repo_items.count).to eq(1)
30
30
  end
31
31
 
32
32
  it 'can remove a member in his own sharing' do
33
- sharing = @user1.share(@user1_file, @user2, {sharing_permissions:{can_add: false, can_remove: false}})
33
+ sharing = @user1.share_repo_item(@user1_file, @user2, {sharing_permissions:{can_add: false, can_remove: false}})
34
34
  @user1.remove_members_from(sharing, @user2)
35
35
  expect(@user2.shared_repo_items.count).to eq(0)
36
36
  end
37
37
 
38
38
 
39
39
  it 'can remove a member in a sharing with permission' do
40
- sharing = @user1.share(@user1_file, @user2, {sharing_permissions:{can_add: false, can_remove: true}})
40
+ sharing = @user1.share_repo_item(@user1_file, @user2, {sharing_permissions:{can_add: false, can_remove: true}})
41
41
  @user1.add_members_to(sharing, @user3)
42
42
  @user2.remove_members_from(sharing, @user3)
43
43
  expect(@user3.shared_repo_items.count).to eq(0)
44
44
  end
45
45
 
46
46
  it 'can\'t remove a member in a sharing without permission' do
47
- sharing = @user1.share(@user1_file, @user2, {sharing_permissions:{can_add: false, can_remove: false}})
47
+ sharing = @user1.share_repo_item(@user1_file, @user2, {sharing_permissions:{can_add: false, can_remove: false}})
48
48
  @user1.add_members_to(sharing, @user3)
49
49
  @user2.remove_members_from(sharing, @user3)
50
50
  expect(@user3.shared_repo_items.count).to eq(1)
51
51
  end
52
52
 
53
53
  it 'can remove and add an array of members in a sharing with permission' do
54
- sharing = @user1.share(@user1_file, @user2, {sharing_permissions:{can_add: true, can_remove: true}})
54
+ sharing = @user1.share_repo_item(@user1_file, @user2, {sharing_permissions:{can_add: true, can_remove: true}})
55
55
  user4 = FactoryGirl.create(:user)
56
56
  @user2.add_members_to(sharing, [@user3, user4])
57
57
  expect(user4.shared_repo_items.count).to eq(1)
@@ -60,7 +60,7 @@ describe 'Sharing' do
60
60
  end
61
61
 
62
62
  it 'can\'t add a members in a sharing with permission that he has not' do
63
- sharing = @user1.share(@user1_file, @user2, {sharing_permissions:{can_add: true, can_remove: false}})
63
+ sharing = @user1.share_repo_item(@user1_file, @user2, {sharing_permissions:{can_add: true, can_remove: false}})
64
64
  @user2.add_members_to(sharing, @user3, {can_add:true, can_remove:true})
65
65
  @user3.remove_members_from(sharing, @user2)
66
66
  expect(@user2.shared_repo_items.count).to eq(1)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repository-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.30
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Baumann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-08 00:00:00.000000000 Z
11
+ date: 2014-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails