mongoid_monkey 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/mongoid_monkey.rb +1 -0
  4. data/lib/patches/embedded_touch.rb +37 -0
  5. data/lib/version.rb +1 -1
  6. data/spec/unit/atomic/mongoid3_style/atomic/add_to_set_spec.rb +266 -266
  7. data/spec/unit/atomic/mongoid3_style/atomic/bit_spec.rb +92 -92
  8. data/spec/unit/atomic/mongoid3_style/atomic/inc_spec.rb +137 -137
  9. data/spec/unit/atomic/mongoid3_style/atomic/pop_spec.rb +115 -115
  10. data/spec/unit/atomic/mongoid3_style/atomic/pull_all_spec.rb +81 -81
  11. data/spec/unit/atomic/mongoid3_style/atomic/pull_spec.rb +84 -84
  12. data/spec/unit/atomic/mongoid3_style/atomic/push_all_spec.rb +81 -81
  13. data/spec/unit/atomic/mongoid3_style/atomic/push_spec.rb +81 -81
  14. data/spec/unit/atomic/mongoid3_style/atomic/rename_spec.rb +46 -46
  15. data/spec/unit/atomic/mongoid3_style/atomic/sets_spec.rb +158 -158
  16. data/spec/unit/atomic/mongoid3_style/atomic/unset_spec.rb +69 -69
  17. data/spec/unit/atomic/mongoid3_style/atomic_spec.rb +220 -220
  18. data/spec/unit/atomic/mongoid4_style/incrementable_spec.rb +232 -232
  19. data/spec/unit/atomic/mongoid4_style/logical_spec.rb +262 -262
  20. data/spec/unit/atomic/mongoid4_style/poppable_spec.rb +139 -139
  21. data/spec/unit/atomic/mongoid4_style/pullable_spec.rb +172 -172
  22. data/spec/unit/atomic/mongoid4_style/pushable_spec.rb +159 -159
  23. data/spec/unit/atomic/mongoid4_style/renamable_spec.rb +139 -139
  24. data/spec/unit/atomic/mongoid4_style/unsettable_spec.rb +28 -28
  25. data/spec/unit/embedded_touch_spec.rb +52 -0
  26. data/spec/unit/{only_pluck_localized.rb → only_pluck_localized_spec.rb} +0 -0
  27. metadata +7 -4
@@ -1,115 +1,115 @@
1
- require "spec_helper"
2
-
3
- if Mongoid::VERSION =~ /\A3\./
4
-
5
- describe Mongoid::Persistence::Atomic::Pop do
6
-
7
- describe "#persist" do
8
-
9
- context "when the field exists" do
10
-
11
- let(:person) do
12
- Person.create(aliases: [ "007", "008", "009" ])
13
- end
14
-
15
- context "when popping the last element" do
16
-
17
- let!(:popped) do
18
- person.pop(:aliases, 1)
19
- end
20
-
21
- let(:reloaded) do
22
- person.reload
23
- end
24
-
25
- it "pops the value from the array" do
26
- person.aliases.should eq([ "007", "008" ])
27
- end
28
-
29
- it "persists the data" do
30
- reloaded.aliases.should eq([ "007", "008" ])
31
- end
32
-
33
- it "removes the field from the dirty attributes" do
34
- person.changes["aliases"].should be_nil
35
- end
36
-
37
- it "resets the document dirty flag" do
38
- person.should_not be_changed
39
- end
40
-
41
- it "returns the new array value" do
42
- popped.should eq([ "007", "008" ])
43
- end
44
- end
45
-
46
- context "when popping the first element" do
47
-
48
- let!(:popped) do
49
- person.pop(:aliases, -1)
50
- end
51
-
52
- let(:reloaded) do
53
- person.reload
54
- end
55
-
56
- it "pops the value from the array" do
57
- person.aliases.should eq([ "008", "009" ])
58
- end
59
-
60
- it "persists the data" do
61
- reloaded.aliases.should eq([ "008", "009" ])
62
- end
63
-
64
- it "removes the field from the dirty attributes" do
65
- person.changes["aliases"].should be_nil
66
- end
67
-
68
- it "resets the document dirty flag" do
69
- person.should_not be_changed
70
- end
71
-
72
- it "returns the new array value" do
73
- popped.should eq([ "008", "009" ])
74
- end
75
- end
76
- end
77
-
78
- context "when the field does not exist" do
79
-
80
- let(:person) do
81
- Person.create
82
- end
83
-
84
- let!(:popped) do
85
- person.pop(:aliases, 1)
86
- end
87
-
88
- let(:reloaded) do
89
- person.reload
90
- end
91
-
92
- it "does not modify the field" do
93
- person.aliases.should be_nil
94
- end
95
-
96
- it "persists no data" do
97
- reloaded.aliases.should be_nil
98
- end
99
-
100
- it "removes the field from the dirty attributes" do
101
- person.changes["aliases"].should be_nil
102
- end
103
-
104
- it "resets the document dirty flag" do
105
- person.should_not be_changed
106
- end
107
-
108
- it "returns nil" do
109
- popped.should be_nil
110
- end
111
- end
112
- end
113
- end
114
-
115
- end
1
+ require "spec_helper"
2
+
3
+ if Mongoid::VERSION =~ /\A3\./
4
+
5
+ describe Mongoid::Persistence::Atomic::Pop do
6
+
7
+ describe "#persist" do
8
+
9
+ context "when the field exists" do
10
+
11
+ let(:person) do
12
+ Person.create(aliases: [ "007", "008", "009" ])
13
+ end
14
+
15
+ context "when popping the last element" do
16
+
17
+ let!(:popped) do
18
+ person.pop(:aliases, 1)
19
+ end
20
+
21
+ let(:reloaded) do
22
+ person.reload
23
+ end
24
+
25
+ it "pops the value from the array" do
26
+ person.aliases.should eq([ "007", "008" ])
27
+ end
28
+
29
+ it "persists the data" do
30
+ reloaded.aliases.should eq([ "007", "008" ])
31
+ end
32
+
33
+ it "removes the field from the dirty attributes" do
34
+ person.changes["aliases"].should be_nil
35
+ end
36
+
37
+ it "resets the document dirty flag" do
38
+ person.should_not be_changed
39
+ end
40
+
41
+ it "returns the new array value" do
42
+ popped.should eq([ "007", "008" ])
43
+ end
44
+ end
45
+
46
+ context "when popping the first element" do
47
+
48
+ let!(:popped) do
49
+ person.pop(:aliases, -1)
50
+ end
51
+
52
+ let(:reloaded) do
53
+ person.reload
54
+ end
55
+
56
+ it "pops the value from the array" do
57
+ person.aliases.should eq([ "008", "009" ])
58
+ end
59
+
60
+ it "persists the data" do
61
+ reloaded.aliases.should eq([ "008", "009" ])
62
+ end
63
+
64
+ it "removes the field from the dirty attributes" do
65
+ person.changes["aliases"].should be_nil
66
+ end
67
+
68
+ it "resets the document dirty flag" do
69
+ person.should_not be_changed
70
+ end
71
+
72
+ it "returns the new array value" do
73
+ popped.should eq([ "008", "009" ])
74
+ end
75
+ end
76
+ end
77
+
78
+ context "when the field does not exist" do
79
+
80
+ let(:person) do
81
+ Person.create
82
+ end
83
+
84
+ let!(:popped) do
85
+ person.pop(:aliases, 1)
86
+ end
87
+
88
+ let(:reloaded) do
89
+ person.reload
90
+ end
91
+
92
+ it "does not modify the field" do
93
+ person.aliases.should be_nil
94
+ end
95
+
96
+ it "persists no data" do
97
+ reloaded.aliases.should be_nil
98
+ end
99
+
100
+ it "removes the field from the dirty attributes" do
101
+ person.changes["aliases"].should be_nil
102
+ end
103
+
104
+ it "resets the document dirty flag" do
105
+ person.should_not be_changed
106
+ end
107
+
108
+ it "returns nil" do
109
+ popped.should be_nil
110
+ end
111
+ end
112
+ end
113
+ end
114
+
115
+ end
@@ -1,81 +1,81 @@
1
- require "spec_helper"
2
-
3
- if Mongoid::VERSION =~ /\A3\./
4
-
5
- describe Mongoid::Persistence::Atomic::PullAll do
6
-
7
- describe "#persist" do
8
-
9
- context "when the field exists" do
10
-
11
- let(:person) do
12
- Person.create(aliases: [ "007" ])
13
- end
14
-
15
- let!(:pulled) do
16
- person.pull_all(:aliases, [ "007" ])
17
- end
18
-
19
- let(:reloaded) do
20
- person.reload
21
- end
22
-
23
- it "pulls the value from the array" do
24
- person.aliases.should be_empty
25
- end
26
-
27
- it "persists the data" do
28
- reloaded.aliases.should be_empty
29
- end
30
-
31
- it "removes the field from the dirty attributes" do
32
- person.changes["aliases"].should be_nil
33
- end
34
-
35
- it "resets the document dirty flag" do
36
- person.should_not be_changed
37
- end
38
-
39
- it "returns the new array value" do
40
- pulled.should be_empty
41
- end
42
- end
43
-
44
- context "when the field does not exist" do
45
-
46
- let(:person) do
47
- Person.create
48
- end
49
-
50
- let!(:pulled) do
51
- person.pull_all(:aliases, [ "Bond" ])
52
- end
53
-
54
- let(:reloaded) do
55
- person.reload
56
- end
57
-
58
- it "does not modify the field" do
59
- person.aliases.should be_nil
60
- end
61
-
62
- it "persists no data" do
63
- reloaded.aliases.should be_nil
64
- end
65
-
66
- it "removes the field from the dirty attributes" do
67
- person.changes["aliases"].should be_nil
68
- end
69
-
70
- it "resets the document dirty flag" do
71
- person.should_not be_changed
72
- end
73
-
74
- it "returns nil" do
75
- pulled.should be_nil
76
- end
77
- end
78
- end
79
- end
80
-
81
- end
1
+ require "spec_helper"
2
+
3
+ if Mongoid::VERSION =~ /\A3\./
4
+
5
+ describe Mongoid::Persistence::Atomic::PullAll do
6
+
7
+ describe "#persist" do
8
+
9
+ context "when the field exists" do
10
+
11
+ let(:person) do
12
+ Person.create(aliases: [ "007" ])
13
+ end
14
+
15
+ let!(:pulled) do
16
+ person.pull_all(:aliases, [ "007" ])
17
+ end
18
+
19
+ let(:reloaded) do
20
+ person.reload
21
+ end
22
+
23
+ it "pulls the value from the array" do
24
+ person.aliases.should be_empty
25
+ end
26
+
27
+ it "persists the data" do
28
+ reloaded.aliases.should be_empty
29
+ end
30
+
31
+ it "removes the field from the dirty attributes" do
32
+ person.changes["aliases"].should be_nil
33
+ end
34
+
35
+ it "resets the document dirty flag" do
36
+ person.should_not be_changed
37
+ end
38
+
39
+ it "returns the new array value" do
40
+ pulled.should be_empty
41
+ end
42
+ end
43
+
44
+ context "when the field does not exist" do
45
+
46
+ let(:person) do
47
+ Person.create
48
+ end
49
+
50
+ let!(:pulled) do
51
+ person.pull_all(:aliases, [ "Bond" ])
52
+ end
53
+
54
+ let(:reloaded) do
55
+ person.reload
56
+ end
57
+
58
+ it "does not modify the field" do
59
+ person.aliases.should be_nil
60
+ end
61
+
62
+ it "persists no data" do
63
+ reloaded.aliases.should be_nil
64
+ end
65
+
66
+ it "removes the field from the dirty attributes" do
67
+ person.changes["aliases"].should be_nil
68
+ end
69
+
70
+ it "resets the document dirty flag" do
71
+ person.should_not be_changed
72
+ end
73
+
74
+ it "returns nil" do
75
+ pulled.should be_nil
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ end
@@ -1,84 +1,84 @@
1
- require "spec_helper"
2
-
3
- if Mongoid::VERSION =~ /\A3\./
4
-
5
- describe Mongoid::Persistence::Atomic::Pull do
6
-
7
- describe "#persist" do
8
-
9
- context "when the field exists" do
10
-
11
- let(:person) do
12
- Person.create(aliases: [ "007", "008" ])
13
- end
14
-
15
- context "when pulling an exact value" do
16
-
17
- let!(:pulled) do
18
- person.pull(:aliases, "007")
19
- end
20
-
21
- let(:reloaded) do
22
- person.reload
23
- end
24
-
25
- it "pulls the value from the array" do
26
- person.aliases.should eq([ "008" ])
27
- end
28
-
29
- it "persists the data" do
30
- reloaded.aliases.should eq([ "008" ])
31
- end
32
-
33
- it "removes the field from the dirty attributes" do
34
- person.changes["aliases"].should be_nil
35
- end
36
-
37
- it "resets the document dirty flag" do
38
- person.should_not be_changed
39
- end
40
-
41
- it "returns the new array value" do
42
- pulled.should eq([ "008" ])
43
- end
44
- end
45
- end
46
-
47
- context "when the field does not exist" do
48
-
49
- let(:person) do
50
- Person.create
51
- end
52
-
53
- let!(:pulled) do
54
- person.pull(:aliases, "Bond")
55
- end
56
-
57
- let(:reloaded) do
58
- person.reload
59
- end
60
-
61
- it "does not modify the field" do
62
- person.aliases.should be_nil
63
- end
64
-
65
- it "persists no data" do
66
- reloaded.aliases.should be_nil
67
- end
68
-
69
- it "removes the field from the dirty attributes" do
70
- person.changes["aliases"].should be_nil
71
- end
72
-
73
- it "resets the document dirty flag" do
74
- person.should_not be_changed
75
- end
76
-
77
- it "returns nil" do
78
- pulled.should be_nil
79
- end
80
- end
81
- end
82
- end
83
-
84
- end
1
+ require "spec_helper"
2
+
3
+ if Mongoid::VERSION =~ /\A3\./
4
+
5
+ describe Mongoid::Persistence::Atomic::Pull do
6
+
7
+ describe "#persist" do
8
+
9
+ context "when the field exists" do
10
+
11
+ let(:person) do
12
+ Person.create(aliases: [ "007", "008" ])
13
+ end
14
+
15
+ context "when pulling an exact value" do
16
+
17
+ let!(:pulled) do
18
+ person.pull(:aliases, "007")
19
+ end
20
+
21
+ let(:reloaded) do
22
+ person.reload
23
+ end
24
+
25
+ it "pulls the value from the array" do
26
+ person.aliases.should eq([ "008" ])
27
+ end
28
+
29
+ it "persists the data" do
30
+ reloaded.aliases.should eq([ "008" ])
31
+ end
32
+
33
+ it "removes the field from the dirty attributes" do
34
+ person.changes["aliases"].should be_nil
35
+ end
36
+
37
+ it "resets the document dirty flag" do
38
+ person.should_not be_changed
39
+ end
40
+
41
+ it "returns the new array value" do
42
+ pulled.should eq([ "008" ])
43
+ end
44
+ end
45
+ end
46
+
47
+ context "when the field does not exist" do
48
+
49
+ let(:person) do
50
+ Person.create
51
+ end
52
+
53
+ let!(:pulled) do
54
+ person.pull(:aliases, "Bond")
55
+ end
56
+
57
+ let(:reloaded) do
58
+ person.reload
59
+ end
60
+
61
+ it "does not modify the field" do
62
+ person.aliases.should be_nil
63
+ end
64
+
65
+ it "persists no data" do
66
+ reloaded.aliases.should be_nil
67
+ end
68
+
69
+ it "removes the field from the dirty attributes" do
70
+ person.changes["aliases"].should be_nil
71
+ end
72
+
73
+ it "resets the document dirty flag" do
74
+ person.should_not be_changed
75
+ end
76
+
77
+ it "returns nil" do
78
+ pulled.should be_nil
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ end