mongoid-list 0.1.2 → 0.1.3
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.
- data/lib/mongoid/list.rb +17 -4
- data/lib/mongoid/list/abstract.rb +22 -0
- data/lib/mongoid/list/collection.rb +7 -11
- data/lib/mongoid/list/embedded.rb +15 -15
- data/lib/mongoid/list/version.rb +1 -1
- data/mongoid-list.gemspec +1 -0
- data/test/mongoid/list/collection_test.rb +78 -0
- data/test/mongoid/list/embedded_test.rb +107 -0
- data/test/mongoid/list_test.rb +350 -1
- metadata +25 -23
- data/lib/mongoid/list/scoping.rb +0 -23
- data/test/mongoid/list/scoping_test.rb +0 -354
data/lib/mongoid/list.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
require "mongoid/list/scoping"
|
2
|
-
|
3
1
|
module Mongoid
|
4
2
|
|
5
3
|
|
6
4
|
module List
|
7
5
|
extend ActiveSupport::Concern
|
8
|
-
include Mongoid::List::Scoping
|
9
6
|
|
10
7
|
autoload :Collection, 'mongoid/list/collection'
|
11
8
|
autoload :Embedded, 'mongoid/list/embedded'
|
@@ -43,6 +40,23 @@ module Mongoid
|
|
43
40
|
attr_accessor :_process_list_change
|
44
41
|
|
45
42
|
|
43
|
+
def list_scoped?
|
44
|
+
fields["position"].options.has_key?(:scope)
|
45
|
+
end
|
46
|
+
|
47
|
+
def list_scope_field
|
48
|
+
fields["position"].options[:scope]
|
49
|
+
end
|
50
|
+
|
51
|
+
def list_scope_value
|
52
|
+
public_send(list_scope_field)
|
53
|
+
end
|
54
|
+
|
55
|
+
def list_scope_conditions
|
56
|
+
list_scoped? ? { list_scope_field.to_sym => list_scope_value } : {}
|
57
|
+
end
|
58
|
+
|
59
|
+
|
46
60
|
private
|
47
61
|
|
48
62
|
|
@@ -74,7 +88,6 @@ module Mongoid
|
|
74
88
|
embedded? ? Embedded.new(self).count : Collection.new(self).count
|
75
89
|
end
|
76
90
|
|
77
|
-
|
78
91
|
end
|
79
92
|
|
80
93
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Mongoid
|
2
|
+
module List
|
3
|
+
class Abstract
|
4
|
+
|
5
|
+
attr_accessor :obj
|
6
|
+
|
7
|
+
def initialize(obj)
|
8
|
+
@obj = obj
|
9
|
+
end
|
10
|
+
|
11
|
+
def changes
|
12
|
+
obj._process_list_change
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def conditions
|
17
|
+
obj.list_scope_conditions
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,30 +1,26 @@
|
|
1
|
+
require 'mongoid/list/abstract'
|
2
|
+
|
1
3
|
module Mongoid
|
2
4
|
module List
|
3
|
-
class Collection
|
4
|
-
|
5
|
-
attr_accessor :obj
|
6
|
-
|
7
|
-
def initialize(obj)
|
8
|
-
@obj = obj
|
9
|
-
end
|
5
|
+
class Collection < Abstract
|
10
6
|
|
11
7
|
def update_positions!
|
12
8
|
obj.class.collection.update(
|
13
9
|
criteria,
|
14
|
-
{ '$inc' => { position:
|
10
|
+
{ '$inc' => { position: changes[:by] } },
|
15
11
|
multi: true
|
16
12
|
)
|
17
13
|
end
|
18
14
|
|
19
15
|
def count
|
20
|
-
obj.class.where(
|
16
|
+
obj.class.where(conditions).count
|
21
17
|
end
|
22
18
|
|
23
19
|
private
|
24
20
|
|
25
21
|
def criteria
|
26
|
-
position = { '$lte' =>
|
27
|
-
|
22
|
+
position = { '$lte' => changes[:max], '$gte' => changes[:min] }.delete_if { |k, v| v.nil? }
|
23
|
+
conditions.merge({ _id: { '$ne' => obj.id }, position: position })
|
28
24
|
end
|
29
25
|
|
30
26
|
end
|
@@ -1,24 +1,20 @@
|
|
1
|
+
require 'mongoid/list/abstract'
|
2
|
+
|
1
3
|
module Mongoid
|
2
4
|
module List
|
3
|
-
class Embedded
|
4
|
-
|
5
|
-
attr_accessor :obj
|
6
|
-
|
7
|
-
def initialize(obj)
|
8
|
-
@obj = obj
|
9
|
-
end
|
5
|
+
class Embedded < Abstract
|
10
6
|
|
11
7
|
def update_positions!
|
12
8
|
items.each do |item|
|
13
9
|
next unless should_operate_on_item?(item)
|
14
|
-
criteria = { "#{
|
15
|
-
|
16
|
-
|
10
|
+
criteria = { "#{relation_name}._id" => item.id }
|
11
|
+
updates = { '$inc' => { "#{relation_name}.$.position" => changes[:by] } }
|
12
|
+
container.class.collection.update(criteria, updates)
|
17
13
|
end
|
18
14
|
end
|
19
15
|
|
20
16
|
def count
|
21
|
-
|
17
|
+
items.excludes(_id: obj.id).where(conditions).count
|
22
18
|
end
|
23
19
|
|
24
20
|
|
@@ -26,25 +22,29 @@ module Mongoid
|
|
26
22
|
|
27
23
|
|
28
24
|
def items
|
29
|
-
|
25
|
+
container.send(relation_name)
|
30
26
|
end
|
31
27
|
|
32
28
|
def should_operate_on_item?(item)
|
33
29
|
# TODO: This includes duplicate logic from :list_scope_conditions
|
34
30
|
![
|
35
31
|
item == obj,
|
36
|
-
|
37
|
-
|
32
|
+
changes[:min].present? && item.position < changes[:min],
|
33
|
+
changes[:max].present? && item.position > changes[:max],
|
38
34
|
obj.list_scoped? && item.list_scope_value != obj.list_scope_value
|
39
35
|
].any?
|
40
36
|
end
|
41
37
|
|
42
|
-
def
|
38
|
+
def container
|
43
39
|
# TODO: MONGOID: Mongoid is not currently setting up the metadata properly so we have to do some extra
|
44
40
|
# work with getting the values we need out of the partial information.
|
45
41
|
obj.send(obj.metadata.inverse_setter.sub('=', '').to_sym)
|
46
42
|
end
|
47
43
|
|
44
|
+
def relation_name
|
45
|
+
obj.metadata.name.to_sym
|
46
|
+
end
|
47
|
+
|
48
48
|
|
49
49
|
end
|
50
50
|
end
|
data/lib/mongoid/list/version.rb
CHANGED
data/mongoid-list.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.authors = [ 'Dave Krupinski' ]
|
12
12
|
s.email = 'dave@davekrupinski.com'
|
13
13
|
s.summary = 'Simple list behavior for Mongoid'
|
14
|
+
s.homepage = 'https://github.com/davekrupinski/mongoid-list'
|
14
15
|
|
15
16
|
s.add_dependency('mongoid', [ '>= 2.0.0' ])
|
16
17
|
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Mongoid::List::Collection do
|
4
|
+
|
5
|
+
describe "#initialization" do
|
6
|
+
|
7
|
+
let :simple do
|
8
|
+
Simple.create
|
9
|
+
end
|
10
|
+
|
11
|
+
let :collection do
|
12
|
+
Mongoid::List::Collection.new(simple)
|
13
|
+
end
|
14
|
+
|
15
|
+
should "assign @simple to :obj" do
|
16
|
+
assert_equal simple, collection.obj
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
describe "#count" do
|
24
|
+
|
25
|
+
context "when unscoped" do
|
26
|
+
|
27
|
+
let :collection do
|
28
|
+
Mongoid::List::Collection.new(Simple.new)
|
29
|
+
end
|
30
|
+
|
31
|
+
setup do
|
32
|
+
5.times { Simple.create }
|
33
|
+
end
|
34
|
+
|
35
|
+
should "be 5" do
|
36
|
+
assert_equal 5, collection.count
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
context "when scoped" do
|
43
|
+
|
44
|
+
setup do
|
45
|
+
4.times { Scoped.create(group: "airplane 1") }
|
46
|
+
3.times { Scoped.create(group: "airplane 2") }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "group 1" do
|
50
|
+
|
51
|
+
let :collection do
|
52
|
+
Mongoid::List::Collection.new(Scoped.new(group: "airplane 1"))
|
53
|
+
end
|
54
|
+
|
55
|
+
should "be 4" do
|
56
|
+
assert_equal 4, collection.count
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
context "group 2" do
|
62
|
+
|
63
|
+
let :collection do
|
64
|
+
Mongoid::List::Collection.new(Scoped.new(group: "airplane 2"))
|
65
|
+
end
|
66
|
+
|
67
|
+
should "be 3" do
|
68
|
+
assert_equal 3, collection.count
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Mongoid::List::Embedded do
|
4
|
+
|
5
|
+
describe "#initialization" do
|
6
|
+
|
7
|
+
let :container do
|
8
|
+
Container.create
|
9
|
+
end
|
10
|
+
|
11
|
+
let :item do
|
12
|
+
container.items.create
|
13
|
+
end
|
14
|
+
|
15
|
+
let :embedded do
|
16
|
+
Mongoid::List::Embedded.new(item)
|
17
|
+
end
|
18
|
+
|
19
|
+
should "assign @item to :obj" do
|
20
|
+
assert_equal item, embedded.obj
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
describe "#count" do
|
28
|
+
|
29
|
+
context "when unscoped" do
|
30
|
+
|
31
|
+
let :container do
|
32
|
+
Container.create!
|
33
|
+
end
|
34
|
+
|
35
|
+
let :container2 do
|
36
|
+
Container.create!
|
37
|
+
end
|
38
|
+
|
39
|
+
let :item do
|
40
|
+
container.items.build
|
41
|
+
end
|
42
|
+
|
43
|
+
let :embedded do
|
44
|
+
Mongoid::List::Embedded.new(item)
|
45
|
+
end
|
46
|
+
|
47
|
+
setup do
|
48
|
+
3.times { container.items.create! }
|
49
|
+
2.times { container2.items.create! }
|
50
|
+
end
|
51
|
+
|
52
|
+
should "be 3" do
|
53
|
+
assert_equal 3, embedded.count
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
context "when scoped" do
|
60
|
+
|
61
|
+
let :container do
|
62
|
+
Container.create!
|
63
|
+
end
|
64
|
+
|
65
|
+
setup do
|
66
|
+
3.times { container.scoped_items.create!(group: "alien") }
|
67
|
+
2.times { container.scoped_items.create!(group: "aliens") }
|
68
|
+
end
|
69
|
+
|
70
|
+
context "group 1" do
|
71
|
+
|
72
|
+
let :item do
|
73
|
+
container.scoped_items.build(group: "alien")
|
74
|
+
end
|
75
|
+
|
76
|
+
let :embedded do
|
77
|
+
Mongoid::List::Embedded.new(item)
|
78
|
+
end
|
79
|
+
|
80
|
+
should "be 3" do
|
81
|
+
assert_equal 3, embedded.count
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
context "group 2" do
|
87
|
+
|
88
|
+
let :item do
|
89
|
+
container.scoped_items.build(group: "aliens")
|
90
|
+
end
|
91
|
+
|
92
|
+
let :embedded do
|
93
|
+
Mongoid::List::Embedded.new(item)
|
94
|
+
end
|
95
|
+
|
96
|
+
should "be 2" do
|
97
|
+
assert_equal 2, embedded.count
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
end
|
data/test/mongoid/list_test.rb
CHANGED
@@ -335,5 +335,354 @@ describe Mongoid::List do
|
|
335
335
|
end
|
336
336
|
|
337
337
|
|
338
|
-
end
|
339
338
|
|
339
|
+
|
340
|
+
describe "#list_scope_field" do
|
341
|
+
|
342
|
+
let :obj do
|
343
|
+
Scoped.create
|
344
|
+
end
|
345
|
+
|
346
|
+
should "be :group" do
|
347
|
+
assert_equal :group, obj.list_scope_field
|
348
|
+
end
|
349
|
+
|
350
|
+
end
|
351
|
+
|
352
|
+
|
353
|
+
describe "#list_scope_conditions" do
|
354
|
+
|
355
|
+
context "when unscoped" do
|
356
|
+
|
357
|
+
let :obj do
|
358
|
+
Simple.new
|
359
|
+
end
|
360
|
+
|
361
|
+
let :expected_conditions do
|
362
|
+
{ }
|
363
|
+
end
|
364
|
+
|
365
|
+
should "be an empty hash" do
|
366
|
+
assert_equal expected_conditions, obj.list_scope_conditions
|
367
|
+
end
|
368
|
+
|
369
|
+
end
|
370
|
+
|
371
|
+
context "when scoped" do
|
372
|
+
|
373
|
+
let :obj do
|
374
|
+
Scoped.new(group: "a grouping")
|
375
|
+
end
|
376
|
+
|
377
|
+
let :expected_conditions do
|
378
|
+
{ group: "a grouping" }
|
379
|
+
end
|
380
|
+
|
381
|
+
should "have be for a :group of 'a grouping'" do
|
382
|
+
assert_equal expected_conditions, obj.list_scope_conditions
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
end
|
387
|
+
|
388
|
+
|
389
|
+
describe "Initializing in multiple scopes" do
|
390
|
+
|
391
|
+
context "on a Collection" do
|
392
|
+
|
393
|
+
setup do
|
394
|
+
@group1_1 = Scoped.create(group: 1)
|
395
|
+
@group2_1 = Scoped.create(group: 2)
|
396
|
+
@group2_2 = Scoped.create(group: 2)
|
397
|
+
end
|
398
|
+
|
399
|
+
should "default @group1_1 to a :position of 1" do
|
400
|
+
assert_equal 1, @group1_1.position
|
401
|
+
end
|
402
|
+
|
403
|
+
should "default @group2_1 to a :position of 1" do
|
404
|
+
assert_equal 1, @group2_1.position
|
405
|
+
end
|
406
|
+
|
407
|
+
should "default @group2_2 to a :position of 2" do
|
408
|
+
assert_equal 2, @group2_2.position
|
409
|
+
end
|
410
|
+
|
411
|
+
end
|
412
|
+
|
413
|
+
context "on Embedded Documents" do
|
414
|
+
|
415
|
+
setup do
|
416
|
+
@container = Container.create
|
417
|
+
@group1_1 = @container.scoped_items.create(group: 1)
|
418
|
+
@group1_2 = @container.scoped_items.create(group: 1)
|
419
|
+
@group2_1 = @container.scoped_items.create(group: 2)
|
420
|
+
@group2_2 = @container.scoped_items.create(group: 2)
|
421
|
+
@group2_3 = @container.scoped_items.create(group: 2)
|
422
|
+
@group3_1 = @container.scoped_items.create(group: 3)
|
423
|
+
end
|
424
|
+
|
425
|
+
should "default @group1_1 to a :position of 1" do
|
426
|
+
assert_equal 1, @group1_1.position
|
427
|
+
end
|
428
|
+
|
429
|
+
should "default @group1_2 to a :position of 2" do
|
430
|
+
assert_equal 2, @group1_2.position
|
431
|
+
end
|
432
|
+
|
433
|
+
should "default @group2_1 to a :position of 1" do
|
434
|
+
assert_equal 1, @group2_1.position
|
435
|
+
end
|
436
|
+
|
437
|
+
should "default @group2_2 to a :position of 2" do
|
438
|
+
assert_equal 2, @group2_2.position
|
439
|
+
end
|
440
|
+
|
441
|
+
should "default @group2_3 to a :position of 3" do
|
442
|
+
assert_equal 3, @group2_3.position
|
443
|
+
end
|
444
|
+
|
445
|
+
should "default @group3_1 to a :position of 1" do
|
446
|
+
assert_equal 1, @group3_1.position
|
447
|
+
end
|
448
|
+
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
describe "#update :position" do
|
455
|
+
|
456
|
+
context "for Collection List" do
|
457
|
+
|
458
|
+
setup do
|
459
|
+
@group1_1 = Scoped.create(group: 1)
|
460
|
+
@group1_2 = Scoped.create(group: 1)
|
461
|
+
@group2_1 = Scoped.create(group: 2)
|
462
|
+
@group2_2 = Scoped.create(group: 2)
|
463
|
+
@group2_3 = Scoped.create(group: 2)
|
464
|
+
end
|
465
|
+
|
466
|
+
context "@group1_2 to :position 1" do
|
467
|
+
|
468
|
+
setup do
|
469
|
+
@group1_2.update_attribute(:position, 1)
|
470
|
+
end
|
471
|
+
|
472
|
+
should "have updated @group1_1 to :position of 2" do
|
473
|
+
assert_equal 1, @group1_1.position
|
474
|
+
assert_equal 2, @group1_1.reload.position
|
475
|
+
end
|
476
|
+
|
477
|
+
should "not have updated :group2_1's :position" do
|
478
|
+
assert_equal @group2_1.position, @group2_1.reload.position
|
479
|
+
end
|
480
|
+
|
481
|
+
should "not have updated :group2_2's :position" do
|
482
|
+
assert_equal @group2_2.position, @group2_2.reload.position
|
483
|
+
end
|
484
|
+
|
485
|
+
should "not have updated :group2_3's :position" do
|
486
|
+
assert_equal @group2_3.position, @group2_3.reload.position
|
487
|
+
end
|
488
|
+
|
489
|
+
end
|
490
|
+
|
491
|
+
|
492
|
+
context "@group2_2 to :position 3" do
|
493
|
+
|
494
|
+
setup do
|
495
|
+
@group2_2.update_attribute(:position, 3)
|
496
|
+
end
|
497
|
+
|
498
|
+
should "not have updated @group1_1's :position" do
|
499
|
+
assert_equal @group1_1.position, @group1_1.reload.position
|
500
|
+
end
|
501
|
+
|
502
|
+
should "not have updated @group1_2's :position" do
|
503
|
+
assert_equal @group1_2.position, @group1_2.reload.position
|
504
|
+
end
|
505
|
+
|
506
|
+
should "not have updated @group2_1's :position" do
|
507
|
+
assert_equal @group2_1.position, @group2_1.reload.position
|
508
|
+
end
|
509
|
+
|
510
|
+
should "have updated @group2_2's :position to 3" do
|
511
|
+
assert_equal 3, @group2_2.position
|
512
|
+
end
|
513
|
+
|
514
|
+
should "have updated @group2_3's :position to 2" do
|
515
|
+
assert_equal 3, @group2_3.position
|
516
|
+
assert_equal 2, @group2_3.reload.position
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
end
|
521
|
+
|
522
|
+
|
523
|
+
context "for an Embedded List" do
|
524
|
+
|
525
|
+
setup do
|
526
|
+
@container = Container.create
|
527
|
+
@group1_1 = @container.scoped_items.create(group: 1)
|
528
|
+
@group1_2 = @container.scoped_items.create(group: 1)
|
529
|
+
@group2_1 = @container.scoped_items.create(group: 2)
|
530
|
+
@group2_2 = @container.scoped_items.create(group: 2)
|
531
|
+
@group2_3 = @container.scoped_items.create(group: 2)
|
532
|
+
end
|
533
|
+
|
534
|
+
context "moving @group1_1 to :position 2" do
|
535
|
+
|
536
|
+
setup do
|
537
|
+
@group1_1.update_attributes(position: 2)
|
538
|
+
end
|
539
|
+
|
540
|
+
should "update @group1_1's :position to 2" do
|
541
|
+
assert_equal 2, @group1_1.position
|
542
|
+
end
|
543
|
+
|
544
|
+
should "update @group1_2's :position to 1" do
|
545
|
+
assert_equal 2, @group1_2.position
|
546
|
+
assert_equal 1, @group1_2.reload.position
|
547
|
+
end
|
548
|
+
|
549
|
+
should "not update @group2_1's :position" do
|
550
|
+
assert_equal 1, @group2_1.position
|
551
|
+
assert_equal 1, @group2_1.reload.position
|
552
|
+
end
|
553
|
+
|
554
|
+
should "not update @group2_2's :position" do
|
555
|
+
assert_equal 2, @group2_2.position
|
556
|
+
assert_equal 2, @group2_2.reload.position
|
557
|
+
end
|
558
|
+
|
559
|
+
should "not update @group2_3's :position" do
|
560
|
+
assert_equal 3, @group2_3.position
|
561
|
+
assert_equal 3, @group2_3.reload.position
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
|
566
|
+
context "moving @group2_3 to :position 1" do
|
567
|
+
|
568
|
+
setup do
|
569
|
+
@group2_3.update_attributes(position: 1)
|
570
|
+
end
|
571
|
+
|
572
|
+
should "not update @group1_1's :position" do
|
573
|
+
assert_equal 1, @group1_1.position
|
574
|
+
assert_equal 1, @group1_1.reload.position
|
575
|
+
end
|
576
|
+
|
577
|
+
should "not update @group1_2's :position" do
|
578
|
+
assert_equal 2, @group1_2.position
|
579
|
+
assert_equal 2, @group1_2.reload.position
|
580
|
+
end
|
581
|
+
|
582
|
+
should "update @group2_1's :position to 2" do
|
583
|
+
assert_equal 1, @group2_1.position
|
584
|
+
assert_equal 2, @group2_1.reload.position
|
585
|
+
end
|
586
|
+
|
587
|
+
should "update @group2_2's :position to 3" do
|
588
|
+
assert_equal 2, @group2_2.position
|
589
|
+
assert_equal 3, @group2_2.reload.position
|
590
|
+
end
|
591
|
+
|
592
|
+
should "update @group2_3's :position to 1" do
|
593
|
+
assert_equal 1, @group2_3.position
|
594
|
+
assert_equal 1, @group2_3.reload.position
|
595
|
+
end
|
596
|
+
end
|
597
|
+
|
598
|
+
end
|
599
|
+
|
600
|
+
end
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
describe "#destroy" do
|
605
|
+
|
606
|
+
context "from a Collection" do
|
607
|
+
|
608
|
+
setup do
|
609
|
+
@group1_1 = Scoped.create(group: 1)
|
610
|
+
@group1_2 = Scoped.create(group: 1)
|
611
|
+
@group2_1 = Scoped.create(group: 2)
|
612
|
+
@group2_2 = Scoped.create(group: 2)
|
613
|
+
@group2_3 = Scoped.create(group: 2)
|
614
|
+
end
|
615
|
+
|
616
|
+
context "for @group2_1" do
|
617
|
+
|
618
|
+
setup do
|
619
|
+
@group2_1.destroy
|
620
|
+
end
|
621
|
+
|
622
|
+
should "not update @group1_1's :position" do
|
623
|
+
assert_equal 1, @group1_1.position
|
624
|
+
assert_equal 1, @group1_1.reload.position
|
625
|
+
end
|
626
|
+
|
627
|
+
should "not update @group1_2's :position" do
|
628
|
+
assert_equal 2, @group1_2.position
|
629
|
+
assert_equal 2, @group1_2.reload.position
|
630
|
+
end
|
631
|
+
|
632
|
+
should "update @group2_2's :position to 1" do
|
633
|
+
assert_equal 2, @group2_2.position
|
634
|
+
assert_equal 1, @group2_2.reload.position
|
635
|
+
end
|
636
|
+
|
637
|
+
should "update @group2_3's :position to 2" do
|
638
|
+
assert_equal 3, @group2_3.position
|
639
|
+
assert_equal 2, @group2_3.reload.position
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
end
|
644
|
+
|
645
|
+
|
646
|
+
context "from an Embedded Collection" do
|
647
|
+
|
648
|
+
setup do
|
649
|
+
@container = Container.create
|
650
|
+
@group1_1 = @container.scoped_items.create(group: 1)
|
651
|
+
@group1_2 = @container.scoped_items.create(group: 1)
|
652
|
+
@group2_1 = @container.scoped_items.create(group: 2)
|
653
|
+
@group2_2 = @container.scoped_items.create(group: 2)
|
654
|
+
@group2_3 = @container.scoped_items.create(group: 2)
|
655
|
+
end
|
656
|
+
|
657
|
+
context "for @group2_2" do
|
658
|
+
|
659
|
+
setup do
|
660
|
+
@group2_2.destroy
|
661
|
+
end
|
662
|
+
|
663
|
+
should "not update @group1_1's :position" do
|
664
|
+
assert_equal 1, @group1_1.position
|
665
|
+
assert_equal 1, @group1_1.reload.position
|
666
|
+
end
|
667
|
+
|
668
|
+
should "not update @group1_2's :position" do
|
669
|
+
assert_equal 2, @group1_2.position
|
670
|
+
assert_equal 2, @group1_2.reload.position
|
671
|
+
end
|
672
|
+
|
673
|
+
should "not update @group2_1's :position" do
|
674
|
+
assert_equal 1, @group2_1.position
|
675
|
+
assert_equal 1, @group2_1.reload.position
|
676
|
+
end
|
677
|
+
|
678
|
+
should "update @group2_3's :position to 2" do
|
679
|
+
assert_equal 3, @group2_3.position
|
680
|
+
assert_equal 2, @container.reload.scoped_items.find(@group2_3.id).position
|
681
|
+
end
|
682
|
+
end
|
683
|
+
|
684
|
+
end
|
685
|
+
|
686
|
+
|
687
|
+
end
|
688
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-28 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
16
|
-
requirement: &
|
16
|
+
requirement: &2164486340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2164486340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bson_ext
|
27
|
-
requirement: &
|
27
|
+
requirement: &2164485920 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2164485920
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: minitest
|
38
|
-
requirement: &
|
38
|
+
requirement: &2164485360 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.7.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2164485360
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: mini_shoulda
|
49
|
-
requirement: &
|
49
|
+
requirement: &2164484820 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.4.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2164484820
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: spork
|
60
|
-
requirement: &
|
60
|
+
requirement: &2164484300 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.9.0.rc
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2164484300
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: spork-testunit
|
71
|
-
requirement: &
|
71
|
+
requirement: &2164483660 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.0.6
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2164483660
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: guard-minitest
|
82
|
-
requirement: &
|
82
|
+
requirement: &2164483040 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 0.4.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2164483040
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: guard-spork
|
93
|
-
requirement: &
|
93
|
+
requirement: &2164482400 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 0.3.1
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2164482400
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: turn
|
104
|
-
requirement: &
|
104
|
+
requirement: &2164481620 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: 0.8.3
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *2164481620
|
113
113
|
description:
|
114
114
|
email: dave@davekrupinski.com
|
115
115
|
executables: []
|
@@ -125,12 +125,13 @@ files:
|
|
125
125
|
- Rakefile
|
126
126
|
- lib/mongoid-list.rb
|
127
127
|
- lib/mongoid/list.rb
|
128
|
+
- lib/mongoid/list/abstract.rb
|
128
129
|
- lib/mongoid/list/collection.rb
|
129
130
|
- lib/mongoid/list/embedded.rb
|
130
|
-
- lib/mongoid/list/scoping.rb
|
131
131
|
- lib/mongoid/list/version.rb
|
132
132
|
- mongoid-list.gemspec
|
133
|
-
- test/mongoid/list/
|
133
|
+
- test/mongoid/list/collection_test.rb
|
134
|
+
- test/mongoid/list/embedded_test.rb
|
134
135
|
- test/mongoid/list_test.rb
|
135
136
|
- test/support/models/container.rb
|
136
137
|
- test/support/models/embedded.rb
|
@@ -138,7 +139,7 @@ files:
|
|
138
139
|
- test/support/models/scoped_embedded.rb
|
139
140
|
- test/support/models/simple.rb
|
140
141
|
- test/test_helper.rb
|
141
|
-
homepage:
|
142
|
+
homepage: https://github.com/davekrupinski/mongoid-list
|
142
143
|
licenses: []
|
143
144
|
post_install_message:
|
144
145
|
rdoc_options: []
|
@@ -163,7 +164,8 @@ signing_key:
|
|
163
164
|
specification_version: 3
|
164
165
|
summary: Simple list behavior for Mongoid
|
165
166
|
test_files:
|
166
|
-
- test/mongoid/list/
|
167
|
+
- test/mongoid/list/collection_test.rb
|
168
|
+
- test/mongoid/list/embedded_test.rb
|
167
169
|
- test/mongoid/list_test.rb
|
168
170
|
- test/support/models/container.rb
|
169
171
|
- test/support/models/embedded.rb
|
data/lib/mongoid/list/scoping.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Mongoid
|
2
|
-
module List
|
3
|
-
module Scoping
|
4
|
-
|
5
|
-
def list_scoped?
|
6
|
-
fields["position"].options.has_key?(:scope)
|
7
|
-
end
|
8
|
-
|
9
|
-
def list_scope_field
|
10
|
-
fields["position"].options[:scope]
|
11
|
-
end
|
12
|
-
|
13
|
-
def list_scope_value
|
14
|
-
public_send(list_scope_field)
|
15
|
-
end
|
16
|
-
|
17
|
-
def list_scope_conditions
|
18
|
-
list_scoped? ? { list_scope_field.to_sym => list_scope_value } : {}
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,354 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Mongoid::List::Scoping do
|
4
|
-
|
5
|
-
describe "#list_scope_field" do
|
6
|
-
|
7
|
-
let :obj do
|
8
|
-
Scoped.create
|
9
|
-
end
|
10
|
-
|
11
|
-
should "be :group" do
|
12
|
-
assert_equal :group, obj.list_scope_field
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
describe "#list_scope_conditions" do
|
19
|
-
|
20
|
-
context "when unscoped" do
|
21
|
-
|
22
|
-
let :obj do
|
23
|
-
Simple.new
|
24
|
-
end
|
25
|
-
|
26
|
-
let :expected_conditions do
|
27
|
-
{ }
|
28
|
-
end
|
29
|
-
|
30
|
-
should "be an empty hash" do
|
31
|
-
assert_equal expected_conditions, obj.list_scope_conditions
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
context "when scoped" do
|
37
|
-
|
38
|
-
let :obj do
|
39
|
-
Scoped.new(group: "a grouping")
|
40
|
-
end
|
41
|
-
|
42
|
-
let :expected_conditions do
|
43
|
-
{ group: "a grouping" }
|
44
|
-
end
|
45
|
-
|
46
|
-
should "have be for a :group of 'a grouping'" do
|
47
|
-
assert_equal expected_conditions, obj.list_scope_conditions
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
describe "Initializing in multiple scopes" do
|
55
|
-
|
56
|
-
context "on a Collection" do
|
57
|
-
|
58
|
-
setup do
|
59
|
-
@group1_1 = Scoped.create(group: 1)
|
60
|
-
@group2_1 = Scoped.create(group: 2)
|
61
|
-
@group2_2 = Scoped.create(group: 2)
|
62
|
-
end
|
63
|
-
|
64
|
-
should "default @group1_1 to a :position of 1" do
|
65
|
-
assert_equal 1, @group1_1.position
|
66
|
-
end
|
67
|
-
|
68
|
-
should "default @group2_1 to a :position of 1" do
|
69
|
-
assert_equal 1, @group2_1.position
|
70
|
-
end
|
71
|
-
|
72
|
-
should "default @group2_2 to a :position of 2" do
|
73
|
-
assert_equal 2, @group2_2.position
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
context "on Embedded Documents" do
|
79
|
-
|
80
|
-
setup do
|
81
|
-
@container = Container.create
|
82
|
-
@group1_1 = @container.scoped_items.create(group: 1)
|
83
|
-
@group1_2 = @container.scoped_items.create(group: 1)
|
84
|
-
@group2_1 = @container.scoped_items.create(group: 2)
|
85
|
-
@group2_2 = @container.scoped_items.create(group: 2)
|
86
|
-
@group2_3 = @container.scoped_items.create(group: 2)
|
87
|
-
@group3_1 = @container.scoped_items.create(group: 3)
|
88
|
-
end
|
89
|
-
|
90
|
-
should "default @group1_1 to a :position of 1" do
|
91
|
-
assert_equal 1, @group1_1.position
|
92
|
-
end
|
93
|
-
|
94
|
-
should "default @group1_2 to a :position of 2" do
|
95
|
-
assert_equal 2, @group1_2.position
|
96
|
-
end
|
97
|
-
|
98
|
-
should "default @group2_1 to a :position of 1" do
|
99
|
-
assert_equal 1, @group2_1.position
|
100
|
-
end
|
101
|
-
|
102
|
-
should "default @group2_2 to a :position of 2" do
|
103
|
-
assert_equal 2, @group2_2.position
|
104
|
-
end
|
105
|
-
|
106
|
-
should "default @group2_3 to a :position of 3" do
|
107
|
-
assert_equal 3, @group2_3.position
|
108
|
-
end
|
109
|
-
|
110
|
-
should "default @group3_1 to a :position of 1" do
|
111
|
-
assert_equal 1, @group3_1.position
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
describe "#update :position" do
|
120
|
-
|
121
|
-
context "for Collection List" do
|
122
|
-
|
123
|
-
setup do
|
124
|
-
@group1_1 = Scoped.create(group: 1)
|
125
|
-
@group1_2 = Scoped.create(group: 1)
|
126
|
-
@group2_1 = Scoped.create(group: 2)
|
127
|
-
@group2_2 = Scoped.create(group: 2)
|
128
|
-
@group2_3 = Scoped.create(group: 2)
|
129
|
-
end
|
130
|
-
|
131
|
-
context "@group1_2 to :position 1" do
|
132
|
-
|
133
|
-
setup do
|
134
|
-
@group1_2.update_attribute(:position, 1)
|
135
|
-
end
|
136
|
-
|
137
|
-
should "have updated @group1_1 to :position of 2" do
|
138
|
-
assert_equal 1, @group1_1.position
|
139
|
-
assert_equal 2, @group1_1.reload.position
|
140
|
-
end
|
141
|
-
|
142
|
-
should "not have updated :group2_1's :position" do
|
143
|
-
assert_equal @group2_1.position, @group2_1.reload.position
|
144
|
-
end
|
145
|
-
|
146
|
-
should "not have updated :group2_2's :position" do
|
147
|
-
assert_equal @group2_2.position, @group2_2.reload.position
|
148
|
-
end
|
149
|
-
|
150
|
-
should "not have updated :group2_3's :position" do
|
151
|
-
assert_equal @group2_3.position, @group2_3.reload.position
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
|
156
|
-
|
157
|
-
context "@group2_2 to :position 3" do
|
158
|
-
|
159
|
-
setup do
|
160
|
-
@group2_2.update_attribute(:position, 3)
|
161
|
-
end
|
162
|
-
|
163
|
-
should "not have updated @group1_1's :position" do
|
164
|
-
assert_equal @group1_1.position, @group1_1.reload.position
|
165
|
-
end
|
166
|
-
|
167
|
-
should "not have updated @group1_2's :position" do
|
168
|
-
assert_equal @group1_2.position, @group1_2.reload.position
|
169
|
-
end
|
170
|
-
|
171
|
-
should "not have updated @group2_1's :position" do
|
172
|
-
assert_equal @group2_1.position, @group2_1.reload.position
|
173
|
-
end
|
174
|
-
|
175
|
-
should "have updated @group2_2's :position to 3" do
|
176
|
-
assert_equal 3, @group2_2.position
|
177
|
-
end
|
178
|
-
|
179
|
-
should "have updated @group2_3's :position to 2" do
|
180
|
-
assert_equal 3, @group2_3.position
|
181
|
-
assert_equal 2, @group2_3.reload.position
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
end
|
186
|
-
|
187
|
-
|
188
|
-
context "for an Embedded List" do
|
189
|
-
|
190
|
-
setup do
|
191
|
-
@container = Container.create
|
192
|
-
@group1_1 = @container.scoped_items.create(group: 1)
|
193
|
-
@group1_2 = @container.scoped_items.create(group: 1)
|
194
|
-
@group2_1 = @container.scoped_items.create(group: 2)
|
195
|
-
@group2_2 = @container.scoped_items.create(group: 2)
|
196
|
-
@group2_3 = @container.scoped_items.create(group: 2)
|
197
|
-
end
|
198
|
-
|
199
|
-
context "moving @group1_1 to :position 2" do
|
200
|
-
|
201
|
-
setup do
|
202
|
-
@group1_1.update_attributes(position: 2)
|
203
|
-
end
|
204
|
-
|
205
|
-
should "update @group1_1's :position to 2" do
|
206
|
-
assert_equal 2, @group1_1.position
|
207
|
-
end
|
208
|
-
|
209
|
-
should "update @group1_2's :position to 1" do
|
210
|
-
assert_equal 2, @group1_2.position
|
211
|
-
assert_equal 1, @group1_2.reload.position
|
212
|
-
end
|
213
|
-
|
214
|
-
should "not update @group2_1's :position" do
|
215
|
-
assert_equal 1, @group2_1.position
|
216
|
-
assert_equal 1, @group2_1.reload.position
|
217
|
-
end
|
218
|
-
|
219
|
-
should "not update @group2_2's :position" do
|
220
|
-
assert_equal 2, @group2_2.position
|
221
|
-
assert_equal 2, @group2_2.reload.position
|
222
|
-
end
|
223
|
-
|
224
|
-
should "not update @group2_3's :position" do
|
225
|
-
assert_equal 3, @group2_3.position
|
226
|
-
assert_equal 3, @group2_3.reload.position
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
|
231
|
-
context "moving @group2_3 to :position 1" do
|
232
|
-
|
233
|
-
setup do
|
234
|
-
@group2_3.update_attributes(position: 1)
|
235
|
-
end
|
236
|
-
|
237
|
-
should "not update @group1_1's :position" do
|
238
|
-
assert_equal 1, @group1_1.position
|
239
|
-
assert_equal 1, @group1_1.reload.position
|
240
|
-
end
|
241
|
-
|
242
|
-
should "not update @group1_2's :position" do
|
243
|
-
assert_equal 2, @group1_2.position
|
244
|
-
assert_equal 2, @group1_2.reload.position
|
245
|
-
end
|
246
|
-
|
247
|
-
should "update @group2_1's :position to 2" do
|
248
|
-
assert_equal 1, @group2_1.position
|
249
|
-
assert_equal 2, @group2_1.reload.position
|
250
|
-
end
|
251
|
-
|
252
|
-
should "update @group2_2's :position to 3" do
|
253
|
-
assert_equal 2, @group2_2.position
|
254
|
-
assert_equal 3, @group2_2.reload.position
|
255
|
-
end
|
256
|
-
|
257
|
-
should "update @group2_3's :position to 1" do
|
258
|
-
assert_equal 1, @group2_3.position
|
259
|
-
assert_equal 1, @group2_3.reload.position
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
end
|
264
|
-
|
265
|
-
end
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
describe "#destroy" do
|
270
|
-
|
271
|
-
context "from a Collection" do
|
272
|
-
|
273
|
-
setup do
|
274
|
-
@group1_1 = Scoped.create(group: 1)
|
275
|
-
@group1_2 = Scoped.create(group: 1)
|
276
|
-
@group2_1 = Scoped.create(group: 2)
|
277
|
-
@group2_2 = Scoped.create(group: 2)
|
278
|
-
@group2_3 = Scoped.create(group: 2)
|
279
|
-
end
|
280
|
-
|
281
|
-
context "for @group2_1" do
|
282
|
-
|
283
|
-
setup do
|
284
|
-
@group2_1.destroy
|
285
|
-
end
|
286
|
-
|
287
|
-
should "not update @group1_1's :position" do
|
288
|
-
assert_equal 1, @group1_1.position
|
289
|
-
assert_equal 1, @group1_1.reload.position
|
290
|
-
end
|
291
|
-
|
292
|
-
should "not update @group1_2's :position" do
|
293
|
-
assert_equal 2, @group1_2.position
|
294
|
-
assert_equal 2, @group1_2.reload.position
|
295
|
-
end
|
296
|
-
|
297
|
-
should "update @group2_2's :position to 1" do
|
298
|
-
assert_equal 2, @group2_2.position
|
299
|
-
assert_equal 1, @group2_2.reload.position
|
300
|
-
end
|
301
|
-
|
302
|
-
should "update @group2_3's :position to 2" do
|
303
|
-
assert_equal 3, @group2_3.position
|
304
|
-
assert_equal 2, @group2_3.reload.position
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
end
|
309
|
-
|
310
|
-
|
311
|
-
context "from an Embedded Collection" do
|
312
|
-
|
313
|
-
setup do
|
314
|
-
@container = Container.create
|
315
|
-
@group1_1 = @container.scoped_items.create(group: 1)
|
316
|
-
@group1_2 = @container.scoped_items.create(group: 1)
|
317
|
-
@group2_1 = @container.scoped_items.create(group: 2)
|
318
|
-
@group2_2 = @container.scoped_items.create(group: 2)
|
319
|
-
@group2_3 = @container.scoped_items.create(group: 2)
|
320
|
-
end
|
321
|
-
|
322
|
-
context "for @group2_2" do
|
323
|
-
|
324
|
-
setup do
|
325
|
-
@group2_2.destroy
|
326
|
-
end
|
327
|
-
|
328
|
-
should "not update @group1_1's :position" do
|
329
|
-
assert_equal 1, @group1_1.position
|
330
|
-
assert_equal 1, @group1_1.reload.position
|
331
|
-
end
|
332
|
-
|
333
|
-
should "not update @group1_2's :position" do
|
334
|
-
assert_equal 2, @group1_2.position
|
335
|
-
assert_equal 2, @group1_2.reload.position
|
336
|
-
end
|
337
|
-
|
338
|
-
should "not update @group2_1's :position" do
|
339
|
-
assert_equal 1, @group2_1.position
|
340
|
-
assert_equal 1, @group2_1.reload.position
|
341
|
-
end
|
342
|
-
|
343
|
-
should "update @group2_3's :position to 2" do
|
344
|
-
assert_equal 3, @group2_3.position
|
345
|
-
assert_equal 2, @container.reload.scoped_items.find(@group2_3.id).position
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
end
|
350
|
-
|
351
|
-
|
352
|
-
end
|
353
|
-
|
354
|
-
end
|