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,159 +1,159 @@
1
- require "spec_helper"
2
-
3
- if Mongoid::VERSION =~ /\A3\./
4
-
5
- describe 'Mongoid::Persistable::Unsettable' do
6
-
7
- describe "#unset" do
8
-
9
- context "when the document is a root document" do
10
-
11
- shared_examples_for "an unsettable root document" do
12
-
13
- it "unsets the first field" do
14
- expect(person.title).to be_nil
15
- end
16
-
17
- it "unsets the second field" do
18
- expect(person.age).to be_nil
19
- end
20
-
21
- # it "returns self object" do
22
- # expect(unset).to eq(person)
23
- # end
24
-
25
- it "persists the first unset" do
26
- expect(person.reload.title).to be_nil
27
- end
28
-
29
- it "persists the last_unset" do
30
- expect(person.reload.age).to eq(100)
31
- end
32
-
33
- it "clears out dirty changes for the fields" do
34
- expect(person).to_not be_changed
35
- end
36
- end
37
-
38
- let(:date) do
39
- Date.new(1976, 11, 19)
40
- end
41
-
42
- let(:person) do
43
- Person.create(title: "test", age: 30, dob: date)
44
- end
45
-
46
- context "when provided a splat of symbols" do
47
-
48
- let!(:unset) do
49
- person.unset(:title, :age)
50
- end
51
-
52
- it_behaves_like "an unsettable root document"
53
- end
54
-
55
- context "when provided a splat of strings" do
56
-
57
- let!(:unset) do
58
- person.unset("title", "age")
59
- end
60
-
61
- it_behaves_like "an unsettable root document"
62
- end
63
-
64
- context "when provided an array of symbols" do
65
-
66
- let!(:unset) do
67
- person.unset([ :title, :age ])
68
- end
69
-
70
- it_behaves_like "an unsettable root document"
71
- end
72
-
73
- context "when provided an array of strings" do
74
-
75
- let!(:unset) do
76
- person.unset([ "title", "age" ])
77
- end
78
-
79
- it_behaves_like "an unsettable root document"
80
- end
81
- end
82
-
83
- context "when the document is embedded" do
84
-
85
- shared_examples_for "an unsettable embedded document" do
86
-
87
- it "unsets the first field" do
88
- expect(address.number).to be_nil
89
- end
90
-
91
- it "unsets the second field" do
92
- expect(address.city).to be_nil
93
- end
94
-
95
- # it "returns self object" do
96
- # expect(unset).to eq(address)
97
- # end
98
-
99
- it "persists the first unset" do
100
- expect(address.reload.number).to be_nil
101
- end
102
-
103
- it "persists the last_unset" do
104
- expect(address.reload.city).to be_nil
105
- end
106
-
107
- it "clears out dirty changes for the fields" do
108
- expect(address).to_not be_changed
109
- end
110
- end
111
-
112
- let(:person) do
113
- Person.create
114
- end
115
-
116
- let(:address) do
117
- person.addresses.create(street: "kreuzberg", number: 40, city: "Berlin")
118
- end
119
-
120
- context "when provided a splat of symbols" do
121
-
122
- let!(:unset) do
123
- address.unset(:number, :city)
124
- end
125
-
126
- it_behaves_like "an unsettable embedded document"
127
- end
128
-
129
- context "when provided a splat of strings" do
130
-
131
- let!(:unset) do
132
- address.unset("number", "city")
133
- end
134
-
135
- it_behaves_like "an unsettable embedded document"
136
- end
137
-
138
- context "when provided an array of symbols" do
139
-
140
- let!(:unset) do
141
- address.unset([ :number, :city ])
142
- end
143
-
144
- it_behaves_like "an unsettable embedded document"
145
- end
146
-
147
- context "when provided an array of strings" do
148
-
149
- let!(:unset) do
150
- address.unset([ "number", "city" ])
151
- end
152
-
153
- it_behaves_like "an unsettable embedded document"
154
- end
155
- end
156
- end
157
- end
158
-
159
- end
1
+ require "spec_helper"
2
+
3
+ if Mongoid::VERSION =~ /\A3\./
4
+
5
+ describe 'Mongoid::Persistable::Unsettable' do
6
+
7
+ describe "#unset" do
8
+
9
+ context "when the document is a root document" do
10
+
11
+ shared_examples_for "an unsettable root document" do
12
+
13
+ it "unsets the first field" do
14
+ expect(person.title).to be_nil
15
+ end
16
+
17
+ it "unsets the second field" do
18
+ expect(person.age).to be_nil
19
+ end
20
+
21
+ # it "returns self object" do
22
+ # expect(unset).to eq(person)
23
+ # end
24
+
25
+ it "persists the first unset" do
26
+ expect(person.reload.title).to be_nil
27
+ end
28
+
29
+ it "persists the last_unset" do
30
+ expect(person.reload.age).to eq(100)
31
+ end
32
+
33
+ it "clears out dirty changes for the fields" do
34
+ expect(person).to_not be_changed
35
+ end
36
+ end
37
+
38
+ let(:date) do
39
+ Date.new(1976, 11, 19)
40
+ end
41
+
42
+ let(:person) do
43
+ Person.create(title: "test", age: 30, dob: date)
44
+ end
45
+
46
+ context "when provided a splat of symbols" do
47
+
48
+ let!(:unset) do
49
+ person.unset(:title, :age)
50
+ end
51
+
52
+ it_behaves_like "an unsettable root document"
53
+ end
54
+
55
+ context "when provided a splat of strings" do
56
+
57
+ let!(:unset) do
58
+ person.unset("title", "age")
59
+ end
60
+
61
+ it_behaves_like "an unsettable root document"
62
+ end
63
+
64
+ context "when provided an array of symbols" do
65
+
66
+ let!(:unset) do
67
+ person.unset([ :title, :age ])
68
+ end
69
+
70
+ it_behaves_like "an unsettable root document"
71
+ end
72
+
73
+ context "when provided an array of strings" do
74
+
75
+ let!(:unset) do
76
+ person.unset([ "title", "age" ])
77
+ end
78
+
79
+ it_behaves_like "an unsettable root document"
80
+ end
81
+ end
82
+
83
+ context "when the document is embedded" do
84
+
85
+ shared_examples_for "an unsettable embedded document" do
86
+
87
+ it "unsets the first field" do
88
+ expect(address.number).to be_nil
89
+ end
90
+
91
+ it "unsets the second field" do
92
+ expect(address.city).to be_nil
93
+ end
94
+
95
+ # it "returns self object" do
96
+ # expect(unset).to eq(address)
97
+ # end
98
+
99
+ it "persists the first unset" do
100
+ expect(address.reload.number).to be_nil
101
+ end
102
+
103
+ it "persists the last_unset" do
104
+ expect(address.reload.city).to be_nil
105
+ end
106
+
107
+ it "clears out dirty changes for the fields" do
108
+ expect(address).to_not be_changed
109
+ end
110
+ end
111
+
112
+ let(:person) do
113
+ Person.create
114
+ end
115
+
116
+ let(:address) do
117
+ person.addresses.create(street: "kreuzberg", number: 40, city: "Berlin")
118
+ end
119
+
120
+ context "when provided a splat of symbols" do
121
+
122
+ let!(:unset) do
123
+ address.unset(:number, :city)
124
+ end
125
+
126
+ it_behaves_like "an unsettable embedded document"
127
+ end
128
+
129
+ context "when provided a splat of strings" do
130
+
131
+ let!(:unset) do
132
+ address.unset("number", "city")
133
+ end
134
+
135
+ it_behaves_like "an unsettable embedded document"
136
+ end
137
+
138
+ context "when provided an array of symbols" do
139
+
140
+ let!(:unset) do
141
+ address.unset([ :number, :city ])
142
+ end
143
+
144
+ it_behaves_like "an unsettable embedded document"
145
+ end
146
+
147
+ context "when provided an array of strings" do
148
+
149
+ let!(:unset) do
150
+ address.unset([ "number", "city" ])
151
+ end
152
+
153
+ it_behaves_like "an unsettable embedded document"
154
+ end
155
+ end
156
+ end
157
+ end
158
+
159
+ end
@@ -1,139 +1,139 @@
1
- require "spec_helper"
2
-
3
- if Mongoid::VERSION =~ /\A3\./
4
-
5
- describe 'Mongoid::Persistable::Renamable' do
6
-
7
- describe "#rename" do
8
-
9
- context "when the document is a root document" do
10
-
11
- shared_examples_for "a renamable root document" do
12
-
13
- it "renames the first field" do
14
- expect(person.salutation).to eq("sir")
15
- end
16
-
17
- it "removes the first original value" do
18
- expect(person.title).to be_nil
19
- end
20
-
21
- it "renames the second field" do
22
- expect(person.date_of_birth.to_date).to eq(date)
23
- end
24
-
25
- it "removes the second original value" do
26
- expect(person.dob).to be_nil
27
- end
28
-
29
- it "returns self object" do
30
- expect(rename).to eq(person)
31
- end
32
-
33
- it "persists the first rename" do
34
- expect(person.reload.salutation).to eq("sir")
35
- end
36
-
37
- it "persists the first original removal" do
38
- expect(person.reload.title).to be_nil
39
- end
40
-
41
- it "persists the second rename" do
42
- expect(person.reload.date_of_birth.to_date).to eq(date)
43
- end
44
-
45
- it "persists the second original removal" do
46
- expect(person.reload.dob).to be_nil
47
- end
48
-
49
- it "clears out the dirty changes" do
50
- expect(person).to_not be_changed
51
- end
52
- end
53
-
54
- let(:date) do
55
- Date.new(2013, 1, 1)
56
- end
57
-
58
- let(:person) do
59
- Person.create(title: "sir", dob: date)
60
- end
61
-
62
- context "when provided symbol names" do
63
-
64
- let!(:rename) do
65
- person.rename(title: :salutation, dob: :date_of_birth)
66
- end
67
-
68
- it_behaves_like "a renamable root document"
69
- end
70
-
71
- context "when provided string names" do
72
-
73
- let!(:rename) do
74
- person.rename(title: "salutation", dob: "date_of_birth")
75
- end
76
-
77
- it_behaves_like "a renamable root document"
78
- end
79
- end
80
-
81
- context "when the document is embedded" do
82
-
83
- shared_examples_for "a renamable embedded document" do
84
-
85
- it "renames the first field" do
86
- expect(name.mi).to eq("blah")
87
- end
88
-
89
- it "removes the first original value" do
90
- expect(name.middle).to be_nil
91
- end
92
-
93
- it "returns self object" do
94
- expect(rename).to eq(name)
95
- end
96
-
97
- it "persists the first rename" do
98
- expect(name.reload.mi).to eq("blah")
99
- end
100
-
101
- it "persists the first original removal" do
102
- expect(name.reload.middle).to be_nil
103
- end
104
-
105
- it "clears out the dirty changes" do
106
- expect(name).to_not be_changed
107
- end
108
- end
109
-
110
- let(:person) do
111
- Person.create
112
- end
113
-
114
- let(:name) do
115
- person.create_name(first_name: "test", last_name: "user", middle: "blah")
116
- end
117
-
118
- context "when provided symbol names" do
119
-
120
- let!(:rename) do
121
- name.rename(middle: :mi)
122
- end
123
-
124
- it_behaves_like "a renamable embedded document"
125
- end
126
-
127
- context "when provided string names" do
128
-
129
- let!(:rename) do
130
- name.rename(middle: "mi")
131
- end
132
-
133
- it_behaves_like "a renamable embedded document"
134
- end
135
- end
136
- end
137
- end
138
-
139
- end
1
+ require "spec_helper"
2
+
3
+ if Mongoid::VERSION =~ /\A3\./
4
+
5
+ describe 'Mongoid::Persistable::Renamable' do
6
+
7
+ describe "#rename" do
8
+
9
+ context "when the document is a root document" do
10
+
11
+ shared_examples_for "a renamable root document" do
12
+
13
+ it "renames the first field" do
14
+ expect(person.salutation).to eq("sir")
15
+ end
16
+
17
+ it "removes the first original value" do
18
+ expect(person.title).to be_nil
19
+ end
20
+
21
+ it "renames the second field" do
22
+ expect(person.date_of_birth.to_date).to eq(date)
23
+ end
24
+
25
+ it "removes the second original value" do
26
+ expect(person.dob).to be_nil
27
+ end
28
+
29
+ it "returns self object" do
30
+ expect(rename).to eq(person)
31
+ end
32
+
33
+ it "persists the first rename" do
34
+ expect(person.reload.salutation).to eq("sir")
35
+ end
36
+
37
+ it "persists the first original removal" do
38
+ expect(person.reload.title).to be_nil
39
+ end
40
+
41
+ it "persists the second rename" do
42
+ expect(person.reload.date_of_birth.to_date).to eq(date)
43
+ end
44
+
45
+ it "persists the second original removal" do
46
+ expect(person.reload.dob).to be_nil
47
+ end
48
+
49
+ it "clears out the dirty changes" do
50
+ expect(person).to_not be_changed
51
+ end
52
+ end
53
+
54
+ let(:date) do
55
+ Date.new(2013, 1, 1)
56
+ end
57
+
58
+ let(:person) do
59
+ Person.create(title: "sir", dob: date)
60
+ end
61
+
62
+ context "when provided symbol names" do
63
+
64
+ let!(:rename) do
65
+ person.rename(title: :salutation, dob: :date_of_birth)
66
+ end
67
+
68
+ it_behaves_like "a renamable root document"
69
+ end
70
+
71
+ context "when provided string names" do
72
+
73
+ let!(:rename) do
74
+ person.rename(title: "salutation", dob: "date_of_birth")
75
+ end
76
+
77
+ it_behaves_like "a renamable root document"
78
+ end
79
+ end
80
+
81
+ context "when the document is embedded" do
82
+
83
+ shared_examples_for "a renamable embedded document" do
84
+
85
+ it "renames the first field" do
86
+ expect(name.mi).to eq("blah")
87
+ end
88
+
89
+ it "removes the first original value" do
90
+ expect(name.middle).to be_nil
91
+ end
92
+
93
+ it "returns self object" do
94
+ expect(rename).to eq(name)
95
+ end
96
+
97
+ it "persists the first rename" do
98
+ expect(name.reload.mi).to eq("blah")
99
+ end
100
+
101
+ it "persists the first original removal" do
102
+ expect(name.reload.middle).to be_nil
103
+ end
104
+
105
+ it "clears out the dirty changes" do
106
+ expect(name).to_not be_changed
107
+ end
108
+ end
109
+
110
+ let(:person) do
111
+ Person.create
112
+ end
113
+
114
+ let(:name) do
115
+ person.create_name(first_name: "test", last_name: "user", middle: "blah")
116
+ end
117
+
118
+ context "when provided symbol names" do
119
+
120
+ let!(:rename) do
121
+ name.rename(middle: :mi)
122
+ end
123
+
124
+ it_behaves_like "a renamable embedded document"
125
+ end
126
+
127
+ context "when provided string names" do
128
+
129
+ let!(:rename) do
130
+ name.rename(middle: "mi")
131
+ end
132
+
133
+ it_behaves_like "a renamable embedded document"
134
+ end
135
+ end
136
+ end
137
+ end
138
+
139
+ end