mongo_mapper-unstable 2010.2.9 → 2010.2.10

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.
@@ -104,20 +104,20 @@ class AssociationBaseTest < Test::Unit::TestCase
104
104
  end
105
105
  end
106
106
 
107
- context "finder_options" do
107
+ context "query_options" do
108
108
  should "default to empty hash" do
109
109
  base = Base.new(:many, :foos)
110
- base.finder_options.should == {}
110
+ base.query_options.should == {}
111
111
  end
112
112
 
113
113
  should "work with order" do
114
114
  base = Base.new(:many, :foos, :order => 'position')
115
- base.finder_options.should == {:order => 'position'}
115
+ base.query_options.should == {:order => 'position'}
116
116
  end
117
117
 
118
118
  should "correctly parse from options" do
119
119
  base = Base.new(:many, :foos, :order => 'position', :somekey => 'somevalue')
120
- base.finder_options.should == {:order => 'position', :somekey => 'somevalue'}
120
+ base.query_options.should == {:order => 'position', :somekey => 'somevalue'}
121
121
  end
122
122
  end
123
123
 
@@ -14,14 +14,14 @@ class PaginationTest < Test::Unit::TestCase
14
14
 
15
15
  should "should have accessors for subject" do
16
16
  subject = [1,2,3,4,5]
17
- collection = PaginationProxy.new(25, 2)
17
+ collection = Proxy.new(25, 2)
18
18
  collection.subject = subject
19
19
  collection.subject.should == subject
20
20
  end
21
21
 
22
22
  should "delegate any methods not defined to the subject" do
23
23
  subject = [1,2,3,4,5]
24
- collection = PaginationProxy.new(25, 2, 10)
24
+ collection = Proxy.new(25, 2, 10)
25
25
  collection.subject = subject
26
26
  collection.size.should == 5
27
27
  collection.each_with_index do |value, i|
@@ -32,96 +32,96 @@ class PaginationTest < Test::Unit::TestCase
32
32
  end
33
33
 
34
34
  should "return correct value for total_entries" do
35
- PaginationProxy.new(25, 2, 10).total_entries.should == 25
36
- PaginationProxy.new('25', 2, 10).total_entries.should == 25
35
+ Proxy.new(25, 2, 10).total_entries.should == 25
36
+ Proxy.new('25', 2, 10).total_entries.should == 25
37
37
  end
38
38
 
39
39
  should "return correct value for per_page" do
40
- PaginationProxy.new(25, 2, 10).per_page.should == 10
41
- PaginationProxy.new(25, 2, '10').per_page.should == 10
40
+ Proxy.new(25, 2, 10).per_page.should == 10
41
+ Proxy.new(25, 2, '10').per_page.should == 10
42
42
  end
43
43
 
44
44
  should "alias limit to per_page" do
45
- PaginationProxy.new(100, 1, 300).limit.should == 300
45
+ Proxy.new(100, 1, 300).limit.should == 300
46
46
  end
47
47
 
48
48
  should "set per_page to 25 if nil or blank" do
49
- PaginationProxy.new(25, 2).per_page.should == 25
50
- PaginationProxy.new(25, 2, '').per_page.should == 25
49
+ Proxy.new(25, 2).per_page.should == 25
50
+ Proxy.new(25, 2, '').per_page.should == 25
51
51
  end
52
52
 
53
53
  should "return correct value for current_page" do
54
- PaginationProxy.new(25, 2, 10).current_page.should == 2
55
- PaginationProxy.new(25, '2', 10).current_page.should == 2
54
+ Proxy.new(25, 2, 10).current_page.should == 2
55
+ Proxy.new(25, '2', 10).current_page.should == 2
56
56
  end
57
57
 
58
58
  should "not allow value less than 1 for current page" do
59
- PaginationProxy.new(25, -1).current_page.should == 1
59
+ Proxy.new(25, -1).current_page.should == 1
60
60
  end
61
61
 
62
62
  should "automatically calculate total_pages from total_entries and per page" do
63
- PaginationProxy.new(25, 2, 10).total_pages.should == 3
63
+ Proxy.new(25, 2, 10).total_pages.should == 3
64
64
  end
65
65
 
66
66
  should "know how many records to skip" do
67
- PaginationProxy.new(25, 2, 10).skip.should == 10
67
+ Proxy.new(25, 2, 10).skip.should == 10
68
68
  end
69
69
 
70
70
  should "alias offset to skip" do
71
- PaginationProxy.new(25, 2, 10).offset.should == 10
71
+ Proxy.new(25, 2, 10).offset.should == 10
72
72
  end
73
73
 
74
74
  should "return true for === Array" do
75
- collection = PaginationProxy.new(25, 2, 10)
75
+ collection = Proxy.new(25, 2, 10)
76
76
  collection.subject = [1, 2]
77
77
  collection.should === Array
78
78
  end
79
79
 
80
80
  context "previous_page" do
81
81
  should "be nil if current page 1" do
82
- PaginationProxy.new(25, 1, 10).previous_page.should be_nil
82
+ Proxy.new(25, 1, 10).previous_page.should be_nil
83
83
  end
84
84
 
85
85
  should "be one less than current page if current is > 1" do
86
- PaginationProxy.new(25, 2, 10).previous_page.should == 1
86
+ Proxy.new(25, 2, 10).previous_page.should == 1
87
87
  end
88
88
  end
89
89
 
90
90
  context "next_page" do
91
91
  should "be nil if current page is last page" do
92
- PaginationProxy.new(25, 3, 10).next_page.should be_nil
92
+ Proxy.new(25, 3, 10).next_page.should be_nil
93
93
  end
94
94
 
95
95
  should "work for any page that is not last" do
96
- PaginationProxy.new(25, 1, 10).next_page.should == 2
97
- PaginationProxy.new(25, 2, 10).next_page.should == 3
96
+ Proxy.new(25, 1, 10).next_page.should == 2
97
+ Proxy.new(25, 2, 10).next_page.should == 3
98
98
  end
99
99
  end
100
100
 
101
101
  context "previous_page" do
102
102
  should "be nil if current page is first page" do
103
- PaginationProxy.new(25, 1, 10).previous_page.should be_nil
103
+ Proxy.new(25, 1, 10).previous_page.should be_nil
104
104
  end
105
105
 
106
106
  should "work for any page other than first" do
107
- PaginationProxy.new(25, 2, 10).previous_page.should == 1
108
- PaginationProxy.new(25, 3, 10).previous_page.should == 2
107
+ Proxy.new(25, 2, 10).previous_page.should == 1
108
+ Proxy.new(25, 3, 10).previous_page.should == 2
109
109
  end
110
110
  end
111
111
 
112
112
  context "out_of_bounds?" do
113
113
  should "be true if current_page is greater than total_pages" do
114
- PaginationProxy.new(25, 10, 4).out_of_bounds?.should be_true
114
+ Proxy.new(25, 10, 4).out_of_bounds?.should be_true
115
115
  end
116
116
 
117
117
  should "be false if current_page is less than total_pages" do
118
- PaginationProxy.new(25, 10, 1).out_of_bounds?.should be_false
119
- PaginationProxy.new(25, 2, 10).out_of_bounds?.should be_false
118
+ Proxy.new(25, 10, 1).out_of_bounds?.should be_false
119
+ Proxy.new(25, 2, 10).out_of_bounds?.should be_false
120
120
  end
121
121
 
122
122
  should "be false if current_page is equal to total_pages" do
123
- PaginationProxy.new(25, 3, 10).out_of_bounds?.should be_false
123
+ Proxy.new(25, 3, 10).out_of_bounds?.should be_false
124
124
  end
125
125
  end
126
- end # end of pagination proxy
127
- end # end of test case
126
+ end
127
+ end
@@ -1,29 +1,29 @@
1
1
  require 'test_helper'
2
2
  require 'models'
3
3
 
4
- class FinderOptionsTest < Test::Unit::TestCase
4
+ class QueryTest < Test::Unit::TestCase
5
5
  include MongoMapper
6
6
 
7
7
  should "raise error if provided something other than a hash" do
8
- lambda { FinderOptions.new(Room) }.should raise_error(ArgumentError)
9
- lambda { FinderOptions.new(Room, 1) }.should raise_error(ArgumentError)
8
+ lambda { Query.new(Room) }.should raise_error(ArgumentError)
9
+ lambda { Query.new(Room, 1) }.should raise_error(ArgumentError)
10
10
  end
11
11
 
12
12
  should "symbolize the keys of the hash provided" do
13
- FinderOptions.new(Room, 'offset' => 1).options.keys.map do |key|
13
+ Query.new(Room, 'offset' => 1).options.keys.map do |key|
14
14
  key.should be_instance_of(Symbol)
15
15
  end
16
16
  end
17
17
 
18
18
  context "Converting conditions to criteria" do
19
19
  should "not add _type to query if model does not have superclass that is single collection inherited" do
20
- FinderOptions.new(Message, :foo => 'bar').criteria.should == {
20
+ Query.new(Message, :foo => 'bar').criteria.should == {
21
21
  :foo => 'bar'
22
22
  }
23
23
  end
24
24
 
25
25
  should "not add _type to nested conditions" do
26
- FinderOptions.new(Enter, :foo => 'bar', :age => {'$gt' => 21}).criteria.should == {
26
+ Query.new(Enter, :foo => 'bar', :age => {'$gt' => 21}).criteria.should == {
27
27
  :foo => 'bar',
28
28
  :age => {'$gt' => 21},
29
29
  :_type => 'Enter'
@@ -31,26 +31,32 @@ class FinderOptionsTest < Test::Unit::TestCase
31
31
  end
32
32
 
33
33
  should "automatically add _type to query if model is single collection inherited" do
34
- FinderOptions.new(Enter, :foo => 'bar').criteria.should == {
34
+ Query.new(Enter, :foo => 'bar').criteria.should == {
35
35
  :foo => 'bar',
36
36
  :_type => 'Enter'
37
37
  }
38
38
  end
39
39
 
40
- %w{gt lt gte lte ne in nin mod size where exists}.each do |operator|
40
+ %w{gt lt gte lte ne in nin mod all size where exists}.each do |operator|
41
41
  should "convert #{operator} conditions" do
42
- FinderOptions.new(Room, :age.send(operator) => 21).criteria.should == {
42
+ Query.new(Room, :age.send(operator) => 21).criteria.should == {
43
43
  :age => {"$#{operator}" => 21}
44
44
  }
45
45
  end
46
46
  end
47
47
 
48
+ should "normalize value when using symbol operators" do
49
+ time = Time.now.in_time_zone('Indiana (East)')
50
+ criteria = Query.new(Room, :created_at.gt => time).criteria
51
+ criteria[:created_at]['$gt'].should be_utc
52
+ end
53
+
48
54
  should "work with simple criteria" do
49
- FinderOptions.new(Room, :foo => 'bar').criteria.should == {
55
+ Query.new(Room, :foo => 'bar').criteria.should == {
50
56
  :foo => 'bar'
51
57
  }
52
58
 
53
- FinderOptions.new(Room, :foo => 'bar', :baz => 'wick').criteria.should == {
59
+ Query.new(Room, :foo => 'bar', :baz => 'wick').criteria.should == {
54
60
  :foo => 'bar',
55
61
  :baz => 'wick'
56
62
  }
@@ -58,71 +64,71 @@ class FinderOptionsTest < Test::Unit::TestCase
58
64
 
59
65
  should "convert id to _id" do
60
66
  id = Mongo::ObjectID.new
61
- FinderOptions.new(Room, :id => id).criteria.should == {:_id => id}
67
+ Query.new(Room, :id => id).criteria.should == {:_id => id}
62
68
  end
63
69
 
64
70
  should "convert id with symbol operator to _id with modifier" do
65
71
  id = Mongo::ObjectID.new
66
- FinderOptions.new(Room, :id.ne => id).criteria.should == {
72
+ Query.new(Room, :id.ne => id).criteria.should == {
67
73
  :_id => {'$ne' => id}
68
74
  }
69
75
  end
70
76
 
71
77
  should "make sure that _id's are object ids" do
72
78
  id = Mongo::ObjectID.new
73
- FinderOptions.new(Room, :_id => id.to_s).criteria.should == {:_id => id}
79
+ Query.new(Room, :_id => id.to_s).criteria.should == {:_id => id}
74
80
  end
75
81
 
76
82
  should "work fine with _id's that are object ids" do
77
83
  id = Mongo::ObjectID.new
78
- FinderOptions.new(Room, :_id => id).criteria.should == {:_id => id}
84
+ Query.new(Room, :_id => id).criteria.should == {:_id => id}
79
85
  end
80
86
 
81
87
  should "make sure other object id typed keys get converted" do
82
88
  id = Mongo::ObjectID.new
83
- FinderOptions.new(Message, :room_id => id.to_s).criteria.should == {:room_id => id}
89
+ Query.new(Message, :room_id => id.to_s).criteria.should == {:room_id => id}
84
90
  end
85
91
 
86
92
  should "work fine with object ids for object id typed keys" do
87
93
  id = Mongo::ObjectID.new
88
- FinderOptions.new(Message, :room_id => id).criteria.should == {:room_id => id}
94
+ Query.new(Message, :room_id => id).criteria.should == {:room_id => id}
89
95
  end
90
96
 
91
97
  should "convert times to utc if they aren't already" do
92
98
  time = Time.now.in_time_zone('Indiana (East)')
93
- criteria = FinderOptions.new(Room, :created_at => time).criteria
99
+ criteria = Query.new(Room, :created_at => time).criteria
94
100
  criteria[:created_at].utc?.should be_true
95
101
  end
96
102
 
97
103
  should "not funk with times already in utc" do
98
104
  time = Time.now.utc
99
- criteria = FinderOptions.new(Room, :created_at => time).criteria
105
+ criteria = Query.new(Room, :created_at => time).criteria
100
106
  criteria[:created_at].utc?.should be_true
101
107
  criteria[:created_at].should == time
102
108
  end
103
109
 
104
110
  should "use $in for arrays" do
105
- FinderOptions.new(Room, :foo => [1,2,3]).criteria.should == {
111
+ Query.new(Room, :foo => [1,2,3]).criteria.should == {
106
112
  :foo => {'$in' => [1,2,3]}
107
113
  }
108
114
  end
109
115
 
110
116
  should "not use $in for arrays if already using array operator" do
111
- FinderOptions.new(Room, :foo => {'$all' => [1,2,3]}).criteria.should == {
117
+ Query.new(Room, :foo => {'$all' => [1,2,3]}).criteria.should == {
112
118
  :foo => {'$all' => [1,2,3]}
113
119
  }
114
120
 
115
- FinderOptions.new(Room, :foo => {'$any' => [1,2,3]}).criteria.should == {
121
+ Query.new(Room, :foo => {'$any' => [1,2,3]}).criteria.should == {
116
122
  :foo => {'$any' => [1,2,3]}
117
123
  }
118
124
  end
119
125
 
120
126
  should "work arbitrarily deep" do
121
- FinderOptions.new(Room, :foo => {:bar => [1,2,3]}).criteria.should == {
127
+ Query.new(Room, :foo => {:bar => [1,2,3]}).criteria.should == {
122
128
  :foo => {:bar => {'$in' => [1,2,3]}}
123
129
  }
124
130
 
125
- FinderOptions.new(Room, :foo => {:bar => {'$any' => [1,2,3]}}).criteria.should == {
131
+ Query.new(Room, :foo => {:bar => {'$any' => [1,2,3]}}).criteria.should == {
126
132
  :foo => {:bar => {'$any' => [1,2,3]}}
127
133
  }
128
134
  end
@@ -131,179 +137,179 @@ class FinderOptionsTest < Test::Unit::TestCase
131
137
  context "ordering" do
132
138
  should "single field with ascending direction" do
133
139
  sort = [['foo', 1]]
134
- FinderOptions.new(Room, :order => 'foo asc').options[:sort].should == sort
135
- FinderOptions.new(Room, :order => 'foo ASC').options[:sort].should == sort
140
+ Query.new(Room, :order => 'foo asc').options[:sort].should == sort
141
+ Query.new(Room, :order => 'foo ASC').options[:sort].should == sort
136
142
  end
137
143
 
138
144
  should "single field with descending direction" do
139
145
  sort = [['foo', -1]]
140
- FinderOptions.new(Room, :order => 'foo desc').options[:sort].should == sort
141
- FinderOptions.new(Room, :order => 'foo DESC').options[:sort].should == sort
146
+ Query.new(Room, :order => 'foo desc').options[:sort].should == sort
147
+ Query.new(Room, :order => 'foo DESC').options[:sort].should == sort
142
148
  end
143
149
 
144
150
  should "convert order operators to mongo sort" do
145
- FinderOptions.new(Room, :order => :foo.asc).options[:sort].should == [['foo', 1]]
146
- FinderOptions.new(Room, :order => :foo.desc).options[:sort].should == [['foo', -1]]
151
+ Query.new(Room, :order => :foo.asc).options[:sort].should == [['foo', 1]]
152
+ Query.new(Room, :order => :foo.desc).options[:sort].should == [['foo', -1]]
147
153
  end
148
154
 
149
155
  should "convert array of order operators to mongo sort" do
150
- FinderOptions.new(Room, :order => [:foo.asc, :bar.desc]).options[:sort].should == [['foo', 1], ['bar', -1]]
156
+ Query.new(Room, :order => [:foo.asc, :bar.desc]).options[:sort].should == [['foo', 1], ['bar', -1]]
151
157
  end
152
158
 
153
159
  should "convert field without direction to ascending" do
154
160
  sort = [['foo', 1]]
155
- FinderOptions.new(Room, :order => 'foo').options[:sort].should == sort
161
+ Query.new(Room, :order => 'foo').options[:sort].should == sort
156
162
  end
157
163
 
158
164
  should "convert multiple fields with directions" do
159
165
  sort = [['foo', -1], ['bar', 1], ['baz', -1]]
160
- FinderOptions.new(Room, :order => 'foo desc, bar asc, baz desc').options[:sort].should == sort
166
+ Query.new(Room, :order => 'foo desc, bar asc, baz desc').options[:sort].should == sort
161
167
  end
162
168
 
163
169
  should "convert multiple fields with some missing directions" do
164
170
  sort = [['foo', -1], ['bar', 1], ['baz', 1]]
165
- FinderOptions.new(Room, :order => 'foo desc, bar, baz').options[:sort].should == sort
171
+ Query.new(Room, :order => 'foo desc, bar, baz').options[:sort].should == sort
166
172
  end
167
173
 
168
174
  should "just use sort if sort and order are present" do
169
175
  sort = [['$natural', 1]]
170
- FinderOptions.new(Room, :sort => sort, :order => 'foo asc').options[:sort].should == sort
176
+ Query.new(Room, :sort => sort, :order => 'foo asc').options[:sort].should == sort
171
177
  end
172
178
 
173
179
  should "convert natural in order to proper" do
174
180
  sort = [['$natural', 1]]
175
- FinderOptions.new(Room, :order => '$natural asc').options[:sort].should == sort
181
+ Query.new(Room, :order => '$natural asc').options[:sort].should == sort
176
182
  sort = [['$natural', -1]]
177
- FinderOptions.new(Room, :order => '$natural desc').options[:sort].should == sort
183
+ Query.new(Room, :order => '$natural desc').options[:sort].should == sort
178
184
  end
179
185
 
180
186
  should "work for natural order ascending" do
181
- FinderOptions.new(Room, :sort => {'$natural' => 1}).options[:sort]['$natural'].should == 1
187
+ Query.new(Room, :sort => {'$natural' => 1}).options[:sort]['$natural'].should == 1
182
188
  end
183
189
 
184
190
  should "work for natural order descending" do
185
- FinderOptions.new(Room, :sort => {'$natural' => -1}).options[:sort]['$natural'].should == -1
191
+ Query.new(Room, :sort => {'$natural' => -1}).options[:sort]['$natural'].should == -1
186
192
  end
187
193
  end
188
194
 
189
195
  context "skip" do
190
196
  should "default to 0" do
191
- FinderOptions.new(Room, {}).options[:skip].should == 0
197
+ Query.new(Room, {}).options[:skip].should == 0
192
198
  end
193
199
 
194
200
  should "use skip provided" do
195
- FinderOptions.new(Room, :skip => 2).options[:skip].should == 2
201
+ Query.new(Room, :skip => 2).options[:skip].should == 2
196
202
  end
197
203
 
198
204
  should "covert string to integer" do
199
- FinderOptions.new(Room, :skip => '2').options[:skip].should == 2
205
+ Query.new(Room, :skip => '2').options[:skip].should == 2
200
206
  end
201
207
 
202
208
  should "convert offset to skip" do
203
- FinderOptions.new(Room, :offset => 1).options[:skip].should == 1
209
+ Query.new(Room, :offset => 1).options[:skip].should == 1
204
210
  end
205
211
  end
206
212
 
207
213
  context "limit" do
208
214
  should "default to 0" do
209
- FinderOptions.new(Room, {}).options[:limit].should == 0
215
+ Query.new(Room, {}).options[:limit].should == 0
210
216
  end
211
217
 
212
218
  should "use limit provided" do
213
- FinderOptions.new(Room, :limit => 2).options[:limit].should == 2
219
+ Query.new(Room, :limit => 2).options[:limit].should == 2
214
220
  end
215
221
 
216
222
  should "covert string to integer" do
217
- FinderOptions.new(Room, :limit => '2').options[:limit].should == 2
223
+ Query.new(Room, :limit => '2').options[:limit].should == 2
218
224
  end
219
225
  end
220
226
 
221
227
  context "fields" do
222
228
  should "default to nil" do
223
- FinderOptions.new(Room, {}).options[:fields].should be(nil)
229
+ Query.new(Room, {}).options[:fields].should be(nil)
224
230
  end
225
231
 
226
232
  should "be converted to nil if empty string" do
227
- FinderOptions.new(Room, :fields => '').options[:fields].should be(nil)
233
+ Query.new(Room, :fields => '').options[:fields].should be(nil)
228
234
  end
229
235
 
230
236
  should "be converted to nil if []" do
231
- FinderOptions.new(Room, :fields => []).options[:fields].should be(nil)
237
+ Query.new(Room, :fields => []).options[:fields].should be(nil)
232
238
  end
233
239
 
234
240
  should "should work with array" do
235
- FinderOptions.new(Room, {:fields => %w(a b)}).options[:fields].should == %w(a b)
241
+ Query.new(Room, {:fields => %w(a b)}).options[:fields].should == %w(a b)
236
242
  end
237
243
 
238
244
  should "convert comma separated list to array" do
239
- FinderOptions.new(Room, {:fields => 'a, b'}).options[:fields].should == %w(a b)
245
+ Query.new(Room, {:fields => 'a, b'}).options[:fields].should == %w(a b)
240
246
  end
241
247
 
242
248
  should "also work as select" do
243
- FinderOptions.new(Room, :select => %w(a b)).options[:fields].should == %w(a b)
249
+ Query.new(Room, :select => %w(a b)).options[:fields].should == %w(a b)
244
250
  end
245
251
 
246
252
  should "also work with select as array of symbols" do
247
- FinderOptions.new(Room, :select => [:a, :b]).options[:fields].should == [:a, :b]
253
+ Query.new(Room, :select => [:a, :b]).options[:fields].should == [:a, :b]
248
254
  end
249
255
  end
250
256
 
251
257
  context "Condition auto-detection" do
252
258
  should "know :conditions are criteria" do
253
- finder = FinderOptions.new(Room, :conditions => {:foo => 'bar'})
259
+ finder = Query.new(Room, :conditions => {:foo => 'bar'})
254
260
  finder.criteria.should == {:foo => 'bar'}
255
261
  finder.options.keys.should_not include(:conditions)
256
262
  end
257
263
 
258
264
  should "know fields is an option" do
259
- finder = FinderOptions.new(Room, :fields => ['foo'])
265
+ finder = Query.new(Room, :fields => ['foo'])
260
266
  finder.options[:fields].should == ['foo']
261
267
  finder.criteria.keys.should_not include(:fields)
262
268
  end
263
269
 
264
270
  # select gets converted to fields so just checking keys
265
271
  should "know select is an option" do
266
- finder = FinderOptions.new(Room, :select => 'foo')
272
+ finder = Query.new(Room, :select => 'foo')
267
273
  finder.options.keys.should include(:sort)
268
274
  finder.criteria.keys.should_not include(:select)
269
275
  finder.criteria.keys.should_not include(:fields)
270
276
  end
271
277
 
272
278
  should "know skip is an option" do
273
- finder = FinderOptions.new(Room, :skip => 10)
279
+ finder = Query.new(Room, :skip => 10)
274
280
  finder.options[:skip].should == 10
275
281
  finder.criteria.keys.should_not include(:skip)
276
282
  end
277
283
 
278
284
  # offset gets converted to skip so just checking keys
279
285
  should "know offset is an option" do
280
- finder = FinderOptions.new(Room, :offset => 10)
286
+ finder = Query.new(Room, :offset => 10)
281
287
  finder.options.keys.should include(:skip)
282
288
  finder.criteria.keys.should_not include(:skip)
283
289
  finder.criteria.keys.should_not include(:offset)
284
290
  end
285
291
 
286
292
  should "know limit is an option" do
287
- finder = FinderOptions.new(Room, :limit => 10)
293
+ finder = Query.new(Room, :limit => 10)
288
294
  finder.options[:limit].should == 10
289
295
  finder.criteria.keys.should_not include(:limit)
290
296
  end
291
297
 
292
298
  should "know sort is an option" do
293
- finder = FinderOptions.new(Room, :sort => [['foo', 1]])
299
+ finder = Query.new(Room, :sort => [['foo', 1]])
294
300
  finder.options[:sort].should == [['foo', 1]]
295
301
  finder.criteria.keys.should_not include(:sort)
296
302
  end
297
303
 
298
304
  # order gets converted to sort so just checking keys
299
305
  should "know order is an option" do
300
- finder = FinderOptions.new(Room, :order => 'foo')
306
+ finder = Query.new(Room, :order => 'foo')
301
307
  finder.options.keys.should include(:sort)
302
308
  finder.criteria.keys.should_not include(:sort)
303
309
  end
304
310
 
305
311
  should "work with full range of things" do
306
- finder_options = FinderOptions.new(Room, {
312
+ query_options = Query.new(Room, {
307
313
  :foo => 'bar',
308
314
  :baz => true,
309
315
  :sort => [['foo', 1]],
@@ -312,12 +318,12 @@ class FinderOptionsTest < Test::Unit::TestCase
312
318
  :skip => 10,
313
319
  })
314
320
 
315
- finder_options.criteria.should == {
321
+ query_options.criteria.should == {
316
322
  :foo => 'bar',
317
323
  :baz => true,
318
324
  }
319
325
 
320
- finder_options.options.should == {
326
+ query_options.options.should == {
321
327
  :sort => [['foo', 1]],
322
328
  :fields => ['foo', 'baz'],
323
329
  :limit => 10,
@@ -325,5 +331,4 @@ class FinderOptionsTest < Test::Unit::TestCase
325
331
  }
326
332
  end
327
333
  end
328
-
329
- end # FinderOptionsTest
334
+ end