mongoid_monkey 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 118a2a99faa547a7a3336586d933db15563d8069
4
- data.tar.gz: 97f311b750030497fd6c1a63da61d369bbcfbdb1
3
+ metadata.gz: 9e3e1b1c557dfd20838b9e10d567598992c3a986
4
+ data.tar.gz: 1e208434a126d2271cc7149adbc907a2bd89b2dd
5
5
  SHA512:
6
- metadata.gz: 0a3e0791c5012535b304f706f4484c781c2230d6b9ceabde4d39100de8512aef245c02063be791cb8e52734516be7cd50221bd6037dd223b38942ec922c147cd
7
- data.tar.gz: b84df91ff37ffbea35e9dc2d559ec7a5cd0aa20d063caf5d583011a6e33c0e9fc307201eec53bba9fe0e3667653448bd3d32bb493c44168bc2f8950137019b6a
6
+ metadata.gz: dc3164dc9b3105e266d32c46276a46f1f973bcf785a1a3adc47db3488a54511844d041810969814e618f71afeef4063a19a49d7cde0767804fcd2f167b592d30
7
+ data.tar.gz: baef2bf7858100e7ab2eb3c9e4dee5680fab26b3cdff96a091b6a0a396b93b261a6176856a42de97ddf4110a9db14e64340942c5173a961c67da9475069a5311
@@ -37,7 +37,6 @@ if Mongoid::VERSION =~ /\A3\./
37
37
 
38
38
  def only(*args)
39
39
  args = args.flatten
40
- puts args.inspect
41
40
  option(*args) do |options|
42
41
  options.store(
43
42
  :fields,
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module MongoidMonkey
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -1,266 +1,266 @@
1
- require "spec_helper"
2
-
3
- if Mongoid::VERSION =~ /\A3\./
4
-
5
- describe Mongoid::Persistence::Atomic::AddToSet do
6
-
7
- describe "#persist" do
8
-
9
- context "when the document is new" do
10
-
11
- let(:person) do
12
- Person.new
13
- end
14
-
15
- context "when adding a single value" do
16
-
17
- let!(:added) do
18
- person.add_to_set(:aliases, "Bond")
19
- end
20
-
21
- it "adds the value onto the array" do
22
- person.aliases.should eq([ "Bond" ])
23
- end
24
-
25
- it "does not reset the dirty flagging" do
26
- person.changes["aliases"].should eq([nil, ["Bond"]])
27
- end
28
-
29
- it "returns the new array value" do
30
- added.should eq([ "Bond" ])
31
- end
32
- end
33
-
34
- context "when adding multiple values" do
35
-
36
- let!(:added) do
37
- person.add_to_set(:aliases, [ "Bond", "James" ])
38
- end
39
-
40
- it "adds the value onto the array" do
41
- person.aliases.should eq([ "Bond", "James" ])
42
- end
43
-
44
- it "does not reset the dirty flagging" do
45
- person.changes["aliases"].should eq([nil, ["Bond", "James"]])
46
- end
47
-
48
- it "returns the new array value" do
49
- added.should eq([ "Bond", "James" ])
50
- end
51
- end
52
- end
53
-
54
- context "when the field exists" do
55
-
56
- context "when the value is unique" do
57
-
58
- let(:person) do
59
- Person.create(aliases: [ "007" ])
60
- end
61
-
62
- context "when adding a single value" do
63
-
64
- let!(:added) do
65
- person.add_to_set(:aliases, "Bond")
66
- end
67
-
68
- let(:reloaded) do
69
- person.reload
70
- end
71
-
72
- it "adds the value onto the array" do
73
- person.aliases.should eq([ "007", "Bond" ])
74
- end
75
-
76
- it "persists the data" do
77
- reloaded.aliases.should eq([ "007", "Bond" ])
78
- end
79
-
80
- it "removes the field from the dirty attributes" do
81
- person.changes["aliases"].should be_nil
82
- end
83
-
84
- it "resets the document dirty flag" do
85
- person.should_not be_changed
86
- end
87
-
88
- it "returns the new array value" do
89
- added.should eq([ "007", "Bond" ])
90
- end
91
- end
92
-
93
- context "when adding a multiple values" do
94
-
95
- let!(:added) do
96
- person.add_to_set(:aliases, [ "Bond", "James" ])
97
- end
98
-
99
- let(:reloaded) do
100
- person.reload
101
- end
102
-
103
- it "adds the value onto the array" do
104
- person.aliases.should eq([ "007", "Bond", "James" ])
105
- end
106
-
107
- it "persists the data" do
108
- reloaded.aliases.should eq([ "007", "Bond", "James" ])
109
- end
110
-
111
- it "removes the field from the dirty attributes" do
112
- person.changes["aliases"].should be_nil
113
- end
114
-
115
- it "resets the document dirty flag" do
116
- person.should_not be_changed
117
- end
118
-
119
- it "returns the new array value" do
120
- added.should eq([ "007", "Bond", "James" ])
121
- end
122
- end
123
- end
124
-
125
- context "when the value is not unique" do
126
-
127
- let(:person) do
128
- Person.create(aliases: [ "Bond" ])
129
- end
130
-
131
- context "when adding a single value" do
132
-
133
- let!(:added) do
134
- person.add_to_set(:aliases, "Bond")
135
- end
136
-
137
- let(:reloaded) do
138
- person.reload
139
- end
140
-
141
- it "does not add the value" do
142
- person.aliases.should eq([ "Bond" ])
143
- end
144
-
145
- it "persists the data" do
146
- reloaded.aliases.should eq([ "Bond" ])
147
- end
148
-
149
- it "removes the field from the dirty attributes" do
150
- person.changes["aliases"].should be_nil
151
- end
152
-
153
- it "resets the document dirty flag" do
154
- person.should_not be_changed
155
- end
156
-
157
- it "returns the array value" do
158
- added.should eq([ "Bond" ])
159
- end
160
- end
161
-
162
- context "when adding multiple values" do
163
-
164
- let!(:added) do
165
- person.add_to_set(:aliases, [ "Bond", "James" ])
166
- end
167
-
168
- let(:reloaded) do
169
- person.reload
170
- end
171
-
172
- it "does not add the duplicate value" do
173
- person.aliases.should eq([ "Bond", "James" ])
174
- end
175
-
176
- it "persists the data" do
177
- reloaded.aliases.should eq([ "Bond", "James" ])
178
- end
179
-
180
- it "removes the field from the dirty attributes" do
181
- person.changes["aliases"].should be_nil
182
- end
183
-
184
- it "resets the document dirty flag" do
185
- person.should_not be_changed
186
- end
187
-
188
- it "returns the array value" do
189
- added.should eq([ "Bond", "James" ])
190
- end
191
- end
192
- end
193
- end
194
-
195
- context "when the field does not exist" do
196
-
197
- let(:person) do
198
- Person.create
199
- end
200
-
201
- context "when adding a single value" do
202
-
203
- let!(:added) do
204
- person.add_to_set(:aliases, "Bond")
205
- end
206
-
207
- let(:reloaded) do
208
- person.reload
209
- end
210
-
211
- it "adds the value onto the array" do
212
- person.aliases.should eq([ "Bond" ])
213
- end
214
-
215
- it "persists the data" do
216
- reloaded.aliases.should eq([ "Bond" ])
217
- end
218
-
219
- it "removes the field from the dirty attributes" do
220
- person.changes["aliases"].should be_nil
221
- end
222
-
223
- it "resets the document dirty flag" do
224
- person.should_not be_changed
225
- end
226
-
227
- it "returns the new array value" do
228
- added.should eq([ "Bond" ])
229
- end
230
- end
231
-
232
- context "when adding multiple values" do
233
-
234
- let!(:added) do
235
- person.add_to_set(:aliases, [ "Bond", "James" ])
236
- end
237
-
238
- let(:reloaded) do
239
- person.reload
240
- end
241
-
242
- it "adds the value onto the array" do
243
- person.aliases.should eq([ "Bond", "James" ])
244
- end
245
-
246
- it "persists the data" do
247
- reloaded.aliases.should eq([ "Bond", "James" ])
248
- end
249
-
250
- it "removes the field from the dirty attributes" do
251
- person.changes["aliases"].should be_nil
252
- end
253
-
254
- it "resets the document dirty flag" do
255
- person.should_not be_changed
256
- end
257
-
258
- it "returns the new array value" do
259
- added.should eq([ "Bond", "James" ])
260
- end
261
- end
262
- end
263
- end
264
- end
265
-
266
- end
1
+ require "spec_helper"
2
+
3
+ if Mongoid::VERSION =~ /\A3\./
4
+
5
+ describe Mongoid::Persistence::Atomic::AddToSet do
6
+
7
+ describe "#persist" do
8
+
9
+ context "when the document is new" do
10
+
11
+ let(:person) do
12
+ Person.new
13
+ end
14
+
15
+ context "when adding a single value" do
16
+
17
+ let!(:added) do
18
+ person.add_to_set(:aliases, "Bond")
19
+ end
20
+
21
+ it "adds the value onto the array" do
22
+ person.aliases.should eq([ "Bond" ])
23
+ end
24
+
25
+ it "does not reset the dirty flagging" do
26
+ person.changes["aliases"].should eq([nil, ["Bond"]])
27
+ end
28
+
29
+ it "returns the new array value" do
30
+ added.should eq([ "Bond" ])
31
+ end
32
+ end
33
+
34
+ context "when adding multiple values" do
35
+
36
+ let!(:added) do
37
+ person.add_to_set(:aliases, [ "Bond", "James" ])
38
+ end
39
+
40
+ it "adds the value onto the array" do
41
+ person.aliases.should eq([ "Bond", "James" ])
42
+ end
43
+
44
+ it "does not reset the dirty flagging" do
45
+ person.changes["aliases"].should eq([nil, ["Bond", "James"]])
46
+ end
47
+
48
+ it "returns the new array value" do
49
+ added.should eq([ "Bond", "James" ])
50
+ end
51
+ end
52
+ end
53
+
54
+ context "when the field exists" do
55
+
56
+ context "when the value is unique" do
57
+
58
+ let(:person) do
59
+ Person.create(aliases: [ "007" ])
60
+ end
61
+
62
+ context "when adding a single value" do
63
+
64
+ let!(:added) do
65
+ person.add_to_set(:aliases, "Bond")
66
+ end
67
+
68
+ let(:reloaded) do
69
+ person.reload
70
+ end
71
+
72
+ it "adds the value onto the array" do
73
+ person.aliases.should eq([ "007", "Bond" ])
74
+ end
75
+
76
+ it "persists the data" do
77
+ reloaded.aliases.should eq([ "007", "Bond" ])
78
+ end
79
+
80
+ it "removes the field from the dirty attributes" do
81
+ person.changes["aliases"].should be_nil
82
+ end
83
+
84
+ it "resets the document dirty flag" do
85
+ person.should_not be_changed
86
+ end
87
+
88
+ it "returns the new array value" do
89
+ added.should eq([ "007", "Bond" ])
90
+ end
91
+ end
92
+
93
+ context "when adding a multiple values" do
94
+
95
+ let!(:added) do
96
+ person.add_to_set(:aliases, [ "Bond", "James" ])
97
+ end
98
+
99
+ let(:reloaded) do
100
+ person.reload
101
+ end
102
+
103
+ it "adds the value onto the array" do
104
+ person.aliases.should eq([ "007", "Bond", "James" ])
105
+ end
106
+
107
+ it "persists the data" do
108
+ reloaded.aliases.should eq([ "007", "Bond", "James" ])
109
+ end
110
+
111
+ it "removes the field from the dirty attributes" do
112
+ person.changes["aliases"].should be_nil
113
+ end
114
+
115
+ it "resets the document dirty flag" do
116
+ person.should_not be_changed
117
+ end
118
+
119
+ it "returns the new array value" do
120
+ added.should eq([ "007", "Bond", "James" ])
121
+ end
122
+ end
123
+ end
124
+
125
+ context "when the value is not unique" do
126
+
127
+ let(:person) do
128
+ Person.create(aliases: [ "Bond" ])
129
+ end
130
+
131
+ context "when adding a single value" do
132
+
133
+ let!(:added) do
134
+ person.add_to_set(:aliases, "Bond")
135
+ end
136
+
137
+ let(:reloaded) do
138
+ person.reload
139
+ end
140
+
141
+ it "does not add the value" do
142
+ person.aliases.should eq([ "Bond" ])
143
+ end
144
+
145
+ it "persists the data" do
146
+ reloaded.aliases.should eq([ "Bond" ])
147
+ end
148
+
149
+ it "removes the field from the dirty attributes" do
150
+ person.changes["aliases"].should be_nil
151
+ end
152
+
153
+ it "resets the document dirty flag" do
154
+ person.should_not be_changed
155
+ end
156
+
157
+ it "returns the array value" do
158
+ added.should eq([ "Bond" ])
159
+ end
160
+ end
161
+
162
+ context "when adding multiple values" do
163
+
164
+ let!(:added) do
165
+ person.add_to_set(:aliases, [ "Bond", "James" ])
166
+ end
167
+
168
+ let(:reloaded) do
169
+ person.reload
170
+ end
171
+
172
+ it "does not add the duplicate value" do
173
+ person.aliases.should eq([ "Bond", "James" ])
174
+ end
175
+
176
+ it "persists the data" do
177
+ reloaded.aliases.should eq([ "Bond", "James" ])
178
+ end
179
+
180
+ it "removes the field from the dirty attributes" do
181
+ person.changes["aliases"].should be_nil
182
+ end
183
+
184
+ it "resets the document dirty flag" do
185
+ person.should_not be_changed
186
+ end
187
+
188
+ it "returns the array value" do
189
+ added.should eq([ "Bond", "James" ])
190
+ end
191
+ end
192
+ end
193
+ end
194
+
195
+ context "when the field does not exist" do
196
+
197
+ let(:person) do
198
+ Person.create
199
+ end
200
+
201
+ context "when adding a single value" do
202
+
203
+ let!(:added) do
204
+ person.add_to_set(:aliases, "Bond")
205
+ end
206
+
207
+ let(:reloaded) do
208
+ person.reload
209
+ end
210
+
211
+ it "adds the value onto the array" do
212
+ person.aliases.should eq([ "Bond" ])
213
+ end
214
+
215
+ it "persists the data" do
216
+ reloaded.aliases.should eq([ "Bond" ])
217
+ end
218
+
219
+ it "removes the field from the dirty attributes" do
220
+ person.changes["aliases"].should be_nil
221
+ end
222
+
223
+ it "resets the document dirty flag" do
224
+ person.should_not be_changed
225
+ end
226
+
227
+ it "returns the new array value" do
228
+ added.should eq([ "Bond" ])
229
+ end
230
+ end
231
+
232
+ context "when adding multiple values" do
233
+
234
+ let!(:added) do
235
+ person.add_to_set(:aliases, [ "Bond", "James" ])
236
+ end
237
+
238
+ let(:reloaded) do
239
+ person.reload
240
+ end
241
+
242
+ it "adds the value onto the array" do
243
+ person.aliases.should eq([ "Bond", "James" ])
244
+ end
245
+
246
+ it "persists the data" do
247
+ reloaded.aliases.should eq([ "Bond", "James" ])
248
+ end
249
+
250
+ it "removes the field from the dirty attributes" do
251
+ person.changes["aliases"].should be_nil
252
+ end
253
+
254
+ it "resets the document dirty flag" do
255
+ person.should_not be_changed
256
+ end
257
+
258
+ it "returns the new array value" do
259
+ added.should eq([ "Bond", "James" ])
260
+ end
261
+ end
262
+ end
263
+ end
264
+ end
265
+
266
+ end