rhodes-framework 1.1.1 → 1.2.0

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.
@@ -3,7 +3,7 @@ require 'rhom/rhom_object'
3
3
 
4
4
  module Rhom
5
5
  class RhomSource
6
- include RhomObject
6
+ include ::Rhom::RhomObject
7
7
  attr_accessor :source_url
8
8
  attr_reader :source_id, :name, :last_updated, :last_inserted_size,
9
9
  :last_deleted_size, :last_sync_duration,
@@ -25,14 +25,14 @@ module Rhom
25
25
  @last_sync_duration = args['last_sync_duration'].to_i
26
26
  @last_sync_success = args['last_sync_success'].to_i == 1 ? true : false
27
27
  @distinct_objects = ::Rhom::RhomDbAdapter::select_from_table(
28
- ::Rhom::TABLE_NAME,
28
+ 'object_values',
29
29
  'object',
30
30
  {"source_id"=>@source_id},
31
31
  {"distinct"=>true}).length
32
32
  end
33
33
 
34
34
  class << self
35
- include RhomObject
35
+ include ::Rhom::RhomObject
36
36
  def find(*args)
37
37
  list = []
38
38
  if args.first == :all
@@ -48,12 +48,12 @@ module Rhom
48
48
  end
49
49
  list.size > 1 ? list : list[0]
50
50
  end
51
- end
52
-
53
- def update_attributes(params=nil)
54
- if params
55
- ::Rhom::RhomDbAdapter::update_into_table('sources', {"source_url"=>params['source_url']},
56
- {"source_id"=>strip_braces(params['source_id'])})
51
+
52
+ def update_attributes(params=nil)
53
+ if params
54
+ ::Rhom::RhomDbAdapter::update_into_table('sources', {"source_url"=>params['source_url']},
55
+ {"source_id"=>strip_braces(params['source_id'])})
56
+ end
57
57
  end
58
58
  end
59
59
  end
data/lib/singleton.rb CHANGED
@@ -9,9 +9,9 @@
9
9
  # * this ensures that only one instance of Klass lets call it
10
10
  # ``the instance'' can be created.
11
11
  #
12
- # a,b = Klass.instance, Klass.instance
13
- # a == b # => true
14
- # a.new # NoMethodError - new is private ...
12
+ # a,b = Klass.instance, Klass.instance
13
+ # a == b # => true
14
+ # Klass.new # NoMethodError - new is private ...
15
15
  #
16
16
  # * ``The instance'' is created at instantiation time, in other
17
17
  # words the first call of Klass.instance(), thus
data/lib/time.rb CHANGED
@@ -87,8 +87,26 @@ class Time
87
87
  end
88
88
 
89
89
  def zone_utc?(zone)
90
- # * +0000 means localtime. [RFC 2822]
91
- # * GMT is a localtime abbreviation in Europe/London, etc.
90
+ # * +0000
91
+ # In RFC 2822, +0000 indicate a time zone at Universal Time.
92
+ # Europe/London is "a time zone at Universal Time" in Winter.
93
+ # Europe/Lisbon is "a time zone at Universal Time" in Winter.
94
+ # Atlantic/Reykjavik is "a time zone at Universal Time".
95
+ # Africa/Dakar is "a time zone at Universal Time".
96
+ # So +0000 is a local time such as Europe/London, etc.
97
+ # * GMT
98
+ # GMT is used as a time zone abbreviation in Europe/London,
99
+ # Africa/Dakar, etc.
100
+ # So it is a local time.
101
+ #
102
+ # * -0000, -00:00
103
+ # In RFC 2822, -0000 the date-time contains no information about the
104
+ # local time zone.
105
+ # In RFC 3339, -00:00 is used for the time in UTC is known,
106
+ # but the offset to local time is unknown.
107
+ # They are not appropriate for specific time zone such as
108
+ # Europe/London because time zone neutral,
109
+ # So -00:00 and -0000 are treated as UTC.
92
110
  if /\A(?:-00:00|-0000|-00|UTC|Z|UT)\z/i =~ zone
93
111
  true
94
112
  else
data/lib/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module RhodesFramework
2
2
  unless defined? RhodesFramework::VERSION
3
- VERSION = '1.1.1'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  unless defined? RhodesFramework::DBVERSION
6
- DBVERSION = '1.1.1'
6
+ DBVERSION = '1.2.0'
7
7
  end
8
8
  end
@@ -8,7 +8,8 @@ class RaiseErrorMatcher
8
8
  def matches?(proc)
9
9
  proc.call
10
10
  return false
11
- rescue Exception => @actual
11
+ rescue Exception => err
12
+ @actual = err
12
13
  return false unless @exception === @actual
13
14
  if @message then
14
15
  case @message
@@ -41,7 +41,7 @@ id|source_id|attrib|object|value|update_type|attrib_type
41
41
  -8943188|1|phone_alternate|44e804f2-4933-4e20-271c-48fcecd9450d||query|
42
42
  63546948|1|billing_address_state|44e804f2-4933-4e20-271c-48fcecd9450d||query|
43
43
  114237576|1|modified_user_id|44e804f2-4933-4e20-271c-48fcecd9450d|1|query|
44
- 220076107|1|description|44e804f2-4933-4e20-271c-48fcecd9450d||query|
44
+ 220076107|1|description|44e804f2-4933-4e20-271c-48fcecd9450d|Hello description!|query|
45
45
  326182291|1|modified_by_name|44e804f2-4933-4e20-271c-48fcecd9450d|admin|query|
46
46
  517349454|1|employees|44e804f2-4933-4e20-271c-48fcecd9450d||query|
47
47
  596458092|1|shipping_address_postalcode|44e804f2-4933-4e20-271c-48fcecd9450d||query|
@@ -53,7 +53,7 @@ id|source_id|attrib|object|value|update_type|attrib_type
53
53
  1065948343|1|created_by_name|44e804f2-4933-4e20-271c-48fcecd9450d|admin|query|
54
54
  1072561171|1|shipping_address_state|44e804f2-4933-4e20-271c-48fcecd9450d||query|
55
55
  -1036293295|1|phone_fax|63cf13da-cff4-99e7-f946-48fcec93f1cc||query|
56
- -1015063951|1|description|63cf13da-cff4-99e7-f946-48fcec93f1cc||query|
56
+ -1015063951|1|description|63cf13da-cff4-99e7-f946-48fcec93f1cc|NULL|query|
57
57
  -992493612|1|ownership|63cf13da-cff4-99e7-f946-48fcec93f1cc||query|
58
58
  -991176969|1|date_modified|63cf13da-cff4-99e7-f946-48fcec93f1cc|2008-10-22 20:30:48|query|
59
59
  -981671585|1|billing_address_city|63cf13da-cff4-99e7-f946-48fcec93f1cc|Mountain View|query|
@@ -0,0 +1,91 @@
1
+ id|source_id|attrib|object|value|update_type|attrib_type
2
+ 3974518272|1|name|722182959|i6mu98hel8|query|
3
+ 4664309006|1|address|722182959|s8ganw9i49|query|
4
+ 589446524|1|industry|722182959|v2zjhoetsk|query|
5
+ 3876717954|1|name|7480317731|79nqr7ekzr|query|
6
+ 1047652407|1|address|7480317731|emv1tezmdf|query|
7
+ 7940339732|1|industry|7480317731|1zg7f7q6ib|query|
8
+ 1453307208|1|name|9703256901|m9ibat6pln|query|
9
+ 5456472891|1|address|9703256901|ksoi86kwyc|query|
10
+ 6075196515|1|industry|9703256901|zl2zw45pn6|query|
11
+ 5230840089|1|name|3195084835|pjpl6sobl3|query|
12
+ 1929483477|1|address|3195084835|46kknwty4n|query|
13
+ 9740966958|1|industry|3195084835|96st4bu34a|query|
14
+ 7554672898|1|name|8219349185|cfcau6hu6q|query|
15
+ 4262441275|1|address|8219349185|5ubw1mbmou|query|
16
+ 2432667078|1|industry|8219349185|tmm1oniagk|query|
17
+ 2040389189|1|name|3788304956|c2z5izd8w9|query|
18
+ 7210816262|1|address|3788304956|6rd9nv8dml|query|
19
+ 4077709208|1|industry|3788304956|hxua4d6ttl|query|
20
+ 484525050|1|name|8027894003|5h9na4kko4|query|
21
+ 374989352|1|address|8027894003|ch5y19t1am|query|
22
+ 4571097261|1|industry|8027894003|andru1w2mh|query|
23
+ 9443114267|1|name|1624803503|uvwfd2wg9m|query|
24
+ 4130674901|1|address|1624803503|ugw28merrh|query|
25
+ 9576733217|1|industry|1624803503|xtu32wf5jz|query|
26
+ 2916529985|1|name|582939287|9o8eqtit6t|query|
27
+ 8567865384|1|address|582939287|gijtz958h5|query|
28
+ 96887757|1|industry|582939287|u4ymg2m2zi|query|
29
+ 7641527628|1|name|8763523348|39afj8vbj6|query|
30
+ 3849164324|1|address|8763523348|x7jincp3xj|query|
31
+ 6241904090|1|industry|8763523348|sge128jo9o|query|
32
+ 7519723638|1|name|4177558452|n7v3cp7tv9|query|
33
+ 9188001335|1|address|4177558452|9xzm6x951r|query|
34
+ 9651970835|1|industry|4177558452|lcm13yye47|query|
35
+ 8238171029|1|name|9559781556|koelvv2o9b|query|
36
+ 7812936798|1|address|9559781556|a195i7az2q|query|
37
+ 7630562848|1|industry|9559781556|rikqunzzd1|query|
38
+ 9679383363|1|name|5440884324|a8ndhdim5d|query|
39
+ 3088649963|1|address|5440884324|xywggb3pjs|query|
40
+ 5492167833|1|industry|5440884324|xjaivb6tn4|query|
41
+ 871068039|1|name|3286353653|uc7tak51ya|query|
42
+ 9666820827|1|address|3286353653|eu4dm28hnw|query|
43
+ 3879374462|1|industry|3286353653|nj3cjxsemo|query|
44
+ 1927465246|1|name|9897778878|n5qx54qcye|query|
45
+ 9107742171|1|address|9897778878|stzc1x7upn|query|
46
+ 4005202237|1|industry|9897778878|9kdinrjlcx|query|
47
+ 9411476383|1|name|1439722928|6ls8u98dfd|query|
48
+ 6118455758|1|address|1439722928|s28czydd5y|query|
49
+ 3105418573|1|industry|1439722928|uelsjlq4ps|query|
50
+ 4618953217|1|name|1715509841|doiwnygkz1|query|
51
+ 3202706158|1|address|1715509841|nu97261eix|query|
52
+ 9826021200|1|industry|1715509841|b3m4sswkg9|query|
53
+ 644887737|1|name|532060249|bad8ei15oc|query|
54
+ 7472846965|1|address|532060249|fci62a3i2g|query|
55
+ 5745448554|1|industry|532060249|cz4n2udhp1|query|
56
+ 848581571|1|name|892827894|igjernnrke|query|
57
+ 9292713023|1|address|892827894|8bhxhtd3qw|query|
58
+ 9611544405|1|industry|892827894|tp535844r8|query|
59
+ 5229692242|1|name|3119932988|9ayg49v9tx|query|
60
+ 9600330393|1|address|3119932988|go72f9az69|query|
61
+ 2073992524|1|industry|3119932988|rwyk7udigr|query|
62
+ 2613952071|1|name|5277763718|c1ekv44ald|query|
63
+ 5504223361|1|address|5277763718|kohrans65v|query|
64
+ 3339356668|1|industry|5277763718|ml2ghjs1yk|query|
65
+ 4557519944|1|name|4654600856|ushf7xcah6|query|
66
+ 4775818524|1|address|4654600856|4lfxmtllja|query|
67
+ 1133728008|1|industry|4654600856|o1b39qjvjr|query|
68
+ 1069996400|1|name|1655351781|4k2c5yfc8f|query|
69
+ 7837083732|1|address|1655351781|sczu2hfdyj|query|
70
+ 8927726574|1|industry|1655351781|ekctzoz4m8|query|
71
+ 5780896975|1|name|1309838006|e88yfcytke|query|
72
+ 4274270111|1|address|1309838006|booh7m2fit|query|
73
+ 519751842|1|industry|1309838006|hl6vj2ax4e|query|
74
+ 7646452151|1|name|8903473873|lmptpbx53p|query|
75
+ 2782146309|1|address|8903473873|bxd7mermv5|query|
76
+ 8949644025|1|industry|8903473873|4r6zbfz99e|query|
77
+ 6984271752|1|name|9229834060|92zmxntghe|query|
78
+ 9941761060|1|address|9229834060|23gutsl1n3|query|
79
+ 8712994862|1|industry|9229834060|zyrwtn24je|query|
80
+ 8535323717|1|name|5736612273|7t7yepm6wb|query|
81
+ 1216942042|1|address|5736612273|pm6ybo5eoh|query|
82
+ 5513088546|1|industry|5736612273|xj3y2udqqd|query|
83
+ 8711188148|1|name|7529312408|1fgbzmyf9k|query|
84
+ 5091631871|1|address|7529312408|8mr6hhd4ep|query|
85
+ 9736561282|1|industry|7529312408|7r56i8dkqd|query|
86
+ 174146755|1|name|1553806230|j5sc8ii27l|query|
87
+ 6963850495|1|address|1553806230|n2jovgvmw9|query|
88
+ 9394990834|1|industry|1553806230|xusnhhgrgz|query|
89
+ 7825564826|1|name|527579259|dgx6foa3bw|query|
90
+ 4011313493|1|address|527579259|bcgi7t4e3e|query|
91
+ 3633057181|1|industry|527579259|ozjdrljgm2|query|
@@ -27,7 +27,7 @@ describe "Rho::RhoController" do
27
27
  before do
28
28
  @c = Rho::RhoController.new
29
29
  @c.stub!(:send).and_return(nil)
30
- @c.serve(nil,{'application' => 'application', 'model' => 'model'},{})
30
+ @c.serve(AppApplication.new,nil,{'application' => 'application', 'model' => 'model'},{})
31
31
  end
32
32
 
33
33
  it "should generate urls for empty params" do
@@ -112,7 +112,7 @@ describe "Rho::RhoController" do
112
112
  @response['headers'] = {}
113
113
  @c = Rho::RhoController.new
114
114
  @c.stub!(:send).and_return(nil)
115
- @c.serve(nil,{'application' => 'application', 'model' => 'model'},@response)
115
+ @c.serve(AppApplication.new,nil,{'application' => 'application', 'model' => 'model'},@response)
116
116
  end
117
117
 
118
118
  it "should redirect to a url" do
@@ -22,7 +22,8 @@ require 'spec/spec_helper'
22
22
  describe "Rho" do
23
23
 
24
24
  before(:each) do
25
- Rho::RhoConfig.config = {'start_path'=>'/app','options_path'=>'/app/Settings'}
25
+ Rho::RhoConfig.config['start_path'] = '/app'
26
+ Rho::RhoConfig.config['options_path'] = '/app/Settings'
26
27
  end
27
28
 
28
29
  it "should populate configuration in sources table" do
@@ -39,7 +40,7 @@ describe "Rho" do
39
40
  end
40
41
 
41
42
  it "should set start_path" do
42
- Rho::RhoConfig.config['start_path'] = '/foo/bar'
43
+ Rho::RhoConfig.start_path = '/foo/bar'
43
44
  Rho::RhoConfig.start_path.should == '/foo/bar'
44
45
  end
45
46
 
@@ -48,7 +49,11 @@ describe "Rho" do
48
49
  end
49
50
 
50
51
  it "should set options_path" do
51
- Rho::RhoConfig.config['options_path'] = '/ops2'
52
+ Rho::RhoConfig.options_path = '/ops2'
52
53
  Rho::RhoConfig.options_path.should == '/ops2'
53
54
  end
55
+
56
+ it "should read arbitrary options" do
57
+ Rho::RhoConfig.arbitrary_option.should == 'rhodes rocks!'
58
+ end
54
59
  end
@@ -0,0 +1,27 @@
1
+ #
2
+ # rhom_db_adapter_spec.rb
3
+ # rhodes
4
+ #
5
+ # Copyright (C) 2008 Rhomobile, Inc. All rights reserved.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ #
20
+ require 'spec/spec_helper'
21
+
22
+ # describe "RhomDbAdapter" do
23
+ #
24
+ # it "should return attributes as columns" do
25
+ #
26
+ # end
27
+ # end
@@ -17,8 +17,9 @@
17
17
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
  require 'spec/spec_helper'
20
+ require 'rhom'
20
21
 
21
- describe "Rhom::RhomObjectFactory" do
22
+ describe "Rhom::RhomObject" do
22
23
 
23
24
  it_should_behave_like "rhom initializer"
24
25
 
@@ -58,21 +59,30 @@ describe "Rhom::RhomObjectFactory" do
58
59
  results[1].industry.should == "Technology"
59
60
  end
60
61
 
62
+ it "should respond to find_all" do
63
+ results = Account.find_all
64
+ results.length.should == 2
65
+ results[0].name.should == "Mobio India"
66
+ results[0].industry.should == "Technology"
67
+ results[1].name.should == "Aeroprise"
68
+ results[1].industry.should == "Technology"
69
+ end
70
+
61
71
  it "should have correct number of attributes" do
62
72
  @account = Account.find(:all).first
63
73
 
64
- @account.instance_variables.size.should == 36
74
+ @account.vars.size.should == 37
65
75
  end
66
76
 
67
77
  it "should get count of objects" do
68
78
  Account.count.should == 2
69
79
  end
70
80
 
71
- # it "should raise RecordNotFound error if nil given as find argument" do
72
- # lambda {
73
- # get 'index'
74
- # }.should_raise(Rhom::RecordNotFound)
75
- # end
81
+ it "should raise RecordNotFound error if nil given as find argument" do
82
+ lambda {
83
+ Account.find(nil)
84
+ }.should raise_error(::Rhom::RecordNotFound)
85
+ end
76
86
 
77
87
  it "should create multiple records offline" do
78
88
  vars = {"name"=>"foobarthree", "industry"=>"entertainment"}
@@ -94,6 +104,19 @@ describe "Rhom::RhomObjectFactory" do
94
104
  acct.industry.should == 'solar'
95
105
  end
96
106
 
107
+ it "should create records with no attribs in database" do
108
+ ::Rhom::RhomDbAdapter.delete_all_from_table('object_values')
109
+ res = ::Rhom::RhomDbAdapter.select_from_table('object_values',"*")
110
+ res.length.should == 0
111
+ vars = {"name"=>"foobarthree", "industry"=>"entertainment"}
112
+ account = Account.new(vars)
113
+ obj = account.object
114
+ account.save
115
+ acct = Account.find(obj)
116
+ acct.name.should == 'foobarthree'
117
+ acct.industry.should == 'entertainment'
118
+ end
119
+
97
120
  it "should create a record" do
98
121
  vars = {"name"=>"some new record", "industry"=>"electronics"}
99
122
  @account1 = Account.new(vars)
@@ -349,6 +372,13 @@ describe "Rhom::RhomObjectFactory" do
349
372
  @accts[1].industry.should == "Technology"
350
373
  end
351
374
 
375
+ it "should find with multiple conditions" do
376
+ @accts = Account.find(:all, :conditions => {'name' => 'Mobio India', 'industry' => 'Technology'})
377
+ @accts.length.should == 1
378
+ @accts[0].name.should == "Mobio India"
379
+ @accts[0].industry.should == "Technology"
380
+ end
381
+
352
382
  it "should find first with conditions" do
353
383
  @mobio_ind_acct = Account.find(:first, :conditions => {'name' => 'Mobio India'})
354
384
  @mobio_ind_acct.name.should == "Mobio India"
@@ -407,7 +437,7 @@ describe "Rhom::RhomObjectFactory" do
407
437
 
408
438
  @accts[0].name.should == "Mobio India"
409
439
  @accts[0].industry.should be_nil
410
- @accts[0].instance_variables.length.should == 2
440
+ @accts[0].vars.length.should == 2
411
441
  end
412
442
 
413
443
  it "should include only selected columns" do
@@ -416,7 +446,7 @@ describe "Rhom::RhomObjectFactory" do
416
446
  @accts[0].name.should == "Mobio India"
417
447
  @accts[0].industry.should == "Technology"
418
448
  @accts[0].shipping_address_street.should be_nil
419
- @accts[0].instance_variables.length.should == 3
449
+ @accts[0].vars.length.should == 3
420
450
  end
421
451
 
422
452
  it "should include selected columns and conditions" do
@@ -425,6 +455,91 @@ describe "Rhom::RhomObjectFactory" do
425
455
  @accts[0].name.should == "Mobio India"
426
456
  @accts[0].industry.should == "Technology"
427
457
  @accts[0].shipping_address_street.should be_nil
428
- @accts[0].instance_variables.length.should == 3
458
+ @accts[0].vars.length.should == 3
459
+ end
460
+
461
+ it "should support find with conditions => nil" do
462
+ @accts = Account.find(:all, :conditions => {'description' => nil})
463
+ @accts.length.should == 1
464
+ @accts[0].name.should == "Aeroprise"
465
+ @accts[0].industry.should == "Technology"
466
+ end
467
+
468
+ it "should support sql conditions arg" do
469
+ @accts = Account.find(:all, :conditions => "name = 'Mobio India'")
470
+ @accts.length.should == 1
471
+ @accts[0].name.should == "Mobio India"
472
+ @accts[0].industry.should == "Technology"
473
+ end
474
+
475
+ it "should support complex sql conditions arg" do
476
+ @accts = Account.find(:all, :conditions => "name like 'Mobio%'")
477
+ @accts.length.should == 1
478
+ @accts[0].name.should == "Mobio India"
479
+ @accts[0].industry.should == "Technology"
480
+ end
481
+
482
+ it "should support sql conditions single filter" do
483
+ @accts = Account.find(:all, :conditions => ["name like ?", "'Mob%'"])
484
+ @accts.length.should == 1
485
+ @accts[0].name.should == "Mobio India"
486
+ @accts[0].industry.should == "Technology"
487
+ end
488
+
489
+ it "should support sql conditions with multiple filters" do
490
+ @accts = Account.find(:all, :conditions => ["name like ? and industry like ?", "'Mob%'", "'Tech%'"])
491
+ @accts.length.should == 1
492
+ @accts[0].name.should == "Mobio India"
493
+ @accts[0].industry.should == "Technology"
494
+ end
495
+
496
+ describe "Rhom#paginate" do
497
+ before(:each) do
498
+ Rho::RhoUtils.load_offline_data(['object_values'], 'spec/pagination')
499
+ end
500
+
501
+ after(:each) do
502
+ Rhom::RhomDbAdapter.start_transaction
503
+ Rhom::RhomDbAdapter.delete_all_from_table('client_info')
504
+ Rhom::RhomDbAdapter.delete_all_from_table('object_values')
505
+ Rhom::RhomDbAdapter.commit
506
+ end
507
+
508
+ @expected = [{:object => '3788304956', :name => 'c2z5izd8w9', :address => '6rd9nv8dml', :industry => 'hxua4d6ttl'},
509
+ {:object => '7480317731', :name => '79nqr7ekzr', :address => 'emv1tezmdf', :industry => '1zg7f7q6ib'},
510
+ {:object => '9897778878', :name => 'n5qx54qcye', :address => 'stzc1x7upn', :industry => '9kdinrjlcx'}]
511
+
512
+ it "should support paginate with no options" do
513
+ 3.times do |x|
514
+ @accts = Account.paginate(:page => x)
515
+ @accts.length.should == 10
516
+ @accts[9].object.should == "{#{@expected[x][:object]}}"
517
+ @accts[9].name.should == @expected[x][:name]
518
+ @accts[9].address.should == @expected[x][:address]
519
+ @accts[9].industry.should == @expected[x][:industry]
520
+ end
521
+ @accts = Account.paginate(:page => 3)
522
+ @accts.length.should == 0
523
+ end
524
+
525
+ it "should support paginate with options" do
526
+ @accts = Account.paginate(:page => 0, :per_page => 20)
527
+ @accts.length.should == 20
528
+ @accts[9].object.should == "{#{@expected[0][:object]}}"
529
+ @accts[9].name.should == @expected[0][:name]
530
+ @accts[9].address.should == @expected[0][:address]
531
+ @accts[9].industry.should == @expected[0][:industry]
532
+ @accts = Account.paginate(:page => 3)
533
+ @accts.length.should == 0
534
+ end
535
+
536
+ it "should support paginate with options and conditions" do
537
+ @accts = Account.paginate(:page => 0, :per_page => 20, :conditions => {'name' => 'c2z5izd8w9'})
538
+ @accts.length.should == 1
539
+ @accts[0].object.should == "{#{@expected[0][:object]}}"
540
+ @accts[0].name.should == @expected[0][:name]
541
+ @accts[0].address.should == @expected[0][:address]
542
+ @accts[0].industry.should == @expected[0][:industry]
543
+ end
429
544
  end
430
545
  end