jnunemaker-mongomapper 0.3.2 → 0.3.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.
@@ -98,6 +98,65 @@ class ManyProxyTest < Test::Unit::TestCase
98
98
  end
99
99
  end
100
100
 
101
+ context "Unassociating documents" do
102
+ setup do
103
+ @project = Project.create
104
+ @project.statuses << Status.create(:name => '1')
105
+ @project.statuses << Status.create(:name => '2')
106
+
107
+ @project2 = Project.create
108
+ @project2.statuses << Status.create(:name => '1')
109
+ @project2.statuses << Status.create(:name => '2')
110
+ end
111
+
112
+ should "work with destroy all" do
113
+ @project.statuses.count.should == 2
114
+ @project.statuses.destroy_all
115
+ @project.statuses.count.should == 0
116
+
117
+ @project2.statuses.count.should == 2
118
+ Status.count.should == 2
119
+ end
120
+
121
+ should "work with destroy all and conditions" do
122
+ @project.statuses.count.should == 2
123
+ @project.statuses.destroy_all(:name => '1')
124
+ @project.statuses.count.should == 1
125
+
126
+ @project2.statuses.count.should == 2
127
+ Status.count.should == 3
128
+ end
129
+
130
+ should "work with delete all" do
131
+ @project.statuses.count.should == 2
132
+ @project.statuses.delete_all
133
+ @project.statuses.count.should == 0
134
+
135
+ @project2.statuses.count.should == 2
136
+ Status.count.should == 2
137
+ end
138
+
139
+ should "work with delete all and conditions" do
140
+ @project.statuses.count.should == 2
141
+ @project.statuses.delete_all(:name => '1')
142
+ @project.statuses.count.should == 1
143
+
144
+ @project2.statuses.count.should == 2
145
+ Status.count.should == 3
146
+ end
147
+
148
+ should "work with nullify" do
149
+ @project.statuses.count.should == 2
150
+ @project.statuses.nullify
151
+ @project.statuses.count.should == 0
152
+
153
+ @project2.statuses.count.should == 2
154
+ Status.count.should == 4
155
+ Status.count(:name => '1').should == 2
156
+ Status.count(:name => '2').should == 2
157
+ end
158
+ end
159
+
101
160
  context "Finding scoped to association" do
102
161
  setup do
103
162
  @project1 = Project.new(:name => 'Project 1')
@@ -148,7 +207,7 @@ class ManyProxyTest < Test::Unit::TestCase
148
207
 
149
208
  context "with :first" do
150
209
  should "work" do
151
- @project1.statuses.find(:first).should == @brand_new
210
+ @project1.statuses.find(:first, :order => 'name').should == @complete
152
211
  end
153
212
 
154
213
  should "work with conditions" do
@@ -159,7 +218,7 @@ class ManyProxyTest < Test::Unit::TestCase
159
218
 
160
219
  context "with #first" do
161
220
  should "work" do
162
- @project1.statuses.first.should == @brand_new
221
+ @project1.statuses.first(:order => 'name').should == @complete
163
222
  end
164
223
 
165
224
  should "work with conditions" do
@@ -217,7 +276,7 @@ class ManyProxyTest < Test::Unit::TestCase
217
276
 
218
277
  context "with #paginate" do
219
278
  setup do
220
- @statuses = @project2.statuses.paginate(:per_page => 2, :page => 1, :order => '$natural asc')
279
+ @statuses = @project2.statuses.paginate(:per_page => 2, :page => 1, :order => 'name asc')
221
280
  end
222
281
 
223
282
  should "return total pages" do
@@ -229,7 +288,7 @@ class ManyProxyTest < Test::Unit::TestCase
229
288
  end
230
289
 
231
290
  should "return the subject" do
232
- @statuses.should == [@in_progress, @archived]
291
+ @statuses.collect(&:name).should == %w(Archived Complete)
233
292
  end
234
293
  end
235
294
  end