rhoconnect 4.0.4 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG.md +54 -5
  3. data/CREDITS +219 -219
  4. data/Gemfile +2 -2
  5. data/Gemfile.lock +68 -79
  6. data/Rakefile +1 -2
  7. data/bench/benchapp/spec/models/ruby/mock_adapter_spec.rb +17 -17
  8. data/bench/benchapp/spec/models/ruby/queue_mock_adapter_spec.rb +17 -17
  9. data/bench/benchapp/spec/spec_helper.rb +3 -3
  10. data/bench/blobapp/spec/models/ruby/blob_adapter_spec.rb +17 -17
  11. data/bench/blobapp/spec/spec_helper.rb +3 -3
  12. data/bench/lib/bench/runner.rb +1 -69
  13. data/bench/lib/bench.rb +18 -18
  14. data/bench/spec/mock_adapter_spec.rb +54 -55
  15. data/bench/spec/mock_client_spec.rb +47 -48
  16. data/bench/spec/result_spec.rb +41 -44
  17. data/bench/spec/utils_spec.rb +24 -25
  18. data/commands/generators/app.rb +7 -5
  19. data/commands/generators/controller.rb +7 -5
  20. data/commands/generators/model.rb +7 -5
  21. data/commands/generators/source.rb +7 -5
  22. data/commands/parser.rb +1 -1
  23. data/commands/redis/redis_download.rb +1 -1
  24. data/doc/async-jobs.txt +9 -9
  25. data/doc/supported-platforms.txt +0 -2
  26. data/generators/rhoconnect.rb +92 -212
  27. data/generators/templates/application/rcgemfile +3 -3
  28. data/generators/templates/application/spec/application_controller_spec.rb +14 -16
  29. data/generators/templates/application/spec/js_spec.rb +20 -20
  30. data/generators/templates/application/spec/spec_helper.rb +1 -1
  31. data/generators/templates/source/controllers/ruby/controller_spec.rb +18 -19
  32. data/generators/templates/source/models/ruby/model_spec.rb +17 -17
  33. data/install.sh +10 -21
  34. data/installer/unix-like/rho_connect_install_constants.rb +5 -5
  35. data/installer/unix-like/rho_connect_install_installers.rb +4 -4
  36. data/installer/utils/constants.rb +6 -6
  37. data/installer/utils/nix_install_test.rb +29 -29
  38. data/installer/utils/package_upload/repos.rake +16 -26
  39. data/js-adapters/node.rb +4 -4
  40. data/js-adapters/node_channel.rb +4 -8
  41. data/lib/rhoconnect/db_adapter.rb +13 -13
  42. data/lib/rhoconnect/handler/changes/engine.rb +1 -1
  43. data/lib/rhoconnect/jobs/bulk_data_job.rb +29 -29
  44. data/lib/rhoconnect/license.rb +7 -7
  45. data/lib/rhoconnect/model/helpers/find_duplicates_on_update.rb +13 -13
  46. data/lib/rhoconnect/ping/apple.rb +4 -4
  47. data/lib/rhoconnect/server.rb +2 -2
  48. data/lib/rhoconnect/source.rb +2 -2
  49. data/lib/rhoconnect/store.rb +12 -6
  50. data/lib/rhoconnect/utilities.rb +2 -2
  51. data/lib/rhoconnect/version.rb +1 -1
  52. data/lib/rhoconnect.rb +6 -4
  53. data/rhoconnect.gemspec +5 -6
  54. data/spec/api/api_helper.rb +1 -1
  55. data/spec/api/app/fast_delete_spec.rb +22 -22
  56. data/spec/api/app/fast_insert_spec.rb +23 -23
  57. data/spec/api/app/fast_update_spec.rb +63 -63
  58. data/spec/api/app/push_deletes_spec.rb +11 -13
  59. data/spec/api/app/push_objects_spec.rb +39 -39
  60. data/spec/api/client/client_get_db_doc_spec.rb +29 -29
  61. data/spec/api/client/client_set_db_doc_spec.rb +11 -11
  62. data/spec/api/client/get_client_params_spec.rb +29 -29
  63. data/spec/api/client/list_client_docs_spec.rb +32 -34
  64. data/spec/api/client/reset_spec.rb +30 -30
  65. data/spec/api/readstate/set_refresh_time_spec.rb +43 -43
  66. data/spec/api/source/get_source_params_spec.rb +32 -34
  67. data/spec/api/source/list_sources_spec.rb +13 -13
  68. data/spec/api/source/update_source_params_spec.rb +19 -19
  69. data/spec/api/store/get_db_doc_spec.rb +27 -27
  70. data/spec/api/store/set_db_doc_spec.rb +38 -38
  71. data/spec/api/system/adapter_spec.rb +27 -29
  72. data/spec/api/system/get_license_info_spec.rb +11 -11
  73. data/spec/api/system/login_spec.rb +37 -37
  74. data/spec/api/system/reset_spec.rb +15 -15
  75. data/spec/api/system/stats_spec.rb +70 -71
  76. data/spec/api/user/create_user_spec.rb +37 -37
  77. data/spec/api/user/delete_client_spec.rb +7 -7
  78. data/spec/api/user/delete_user_spec.rb +62 -62
  79. data/spec/api/user/list_clients_spec.rb +24 -24
  80. data/spec/api/user/list_source_docs_spec.rb +29 -29
  81. data/spec/api/user/list_users_spec.rb +22 -22
  82. data/spec/api/user/ping_spec.rb +18 -18
  83. data/spec/api/user/show_user_spec.rb +10 -10
  84. data/spec/api/user/update_user_spec.rb +43 -43
  85. data/spec/api/user/user_get_db_doc_spec.rb +12 -12
  86. data/spec/api/user/user_set_db_doc_spec.rb +37 -37
  87. data/spec/api_token_spec.rb +8 -8
  88. data/spec/app_spec.rb +18 -17
  89. data/spec/apps/jstestapp/settings/settings.yml +2 -0
  90. data/spec/async_spec.rb +9 -11
  91. data/spec/bulk_data/bulk_data_spec.rb +120 -120
  92. data/spec/cli/cli_spec.rb +50 -53
  93. data/spec/client_spec.rb +105 -105
  94. data/spec/client_sync_spec.rb +529 -528
  95. data/spec/controllers/js_base_spec.rb +147 -141
  96. data/spec/doc/doc_spec.rb +51 -52
  97. data/spec/document_spec.rb +58 -58
  98. data/spec/dynamic_adapter_spec.rb +33 -36
  99. data/spec/generator/generator_spec.rb +76 -42
  100. data/spec/jobs/bulk_data_job_spec.rb +101 -102
  101. data/spec/jobs/ping_job_spec.rb +176 -177
  102. data/spec/jobs/source_job_spec.rb +24 -25
  103. data/spec/license_spec.rb +54 -55
  104. data/spec/models/js_base_spec.rb +121 -120
  105. data/spec/perf/bulk_data_perf_spec.rb +23 -24
  106. data/spec/perf/perf_spec_helper.rb +7 -7
  107. data/spec/perf/store_perf_spec.rb +139 -140
  108. data/spec/ping/apple_spec.rb +65 -65
  109. data/spec/ping/gcm_spec.rb +83 -84
  110. data/spec/ping/rhoconnect_push_spec.rb +52 -53
  111. data/spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb +100 -101
  112. data/spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb +29 -31
  113. data/spec/read_state_spec.rb +24 -25
  114. data/spec/rhoconnect_spec.rb +7 -7
  115. data/spec/server/server_spec.rb +664 -662
  116. data/spec/server/stats_spec.rb +12 -12
  117. data/spec/source_adapter_spec.rb +124 -125
  118. data/spec/source_spec.rb +148 -149
  119. data/spec/source_sync_spec.rb +736 -736
  120. data/spec/spec_helper.rb +4 -5
  121. data/spec/stats/record_spec.rb +22 -21
  122. data/spec/store_orm_spec.rb +48 -48
  123. data/spec/store_spec.rb +428 -426
  124. data/spec/support/shared_examples.rb +5 -7
  125. data/spec/sync_states_spec.rb +67 -67
  126. data/spec/test_methods_spec.rb +121 -123
  127. data/spec/testdata/10000-data.txt +0 -0
  128. data/spec/testdata/5000-data.txt +0 -0
  129. data/spec/user_spec.rb +102 -102
  130. data/tasks/redis.rake +3 -3
  131. metadata +154 -195
  132. data/bench/benchapp/tmp/pids/passenger.9292.pid.lock +0 -0
  133. data/bench/benchapp/tmp/restart.txt +0 -0
  134. data/bench/blobapp/settings/license.key.bak +0 -2
  135. data/bench/blobapp/tmp/restart.txt +0 -0
  136. data/bench/lib/testdata/1-data.txt +0 -0
  137. data/bench/lib/testdata/10-data.txt +0 -0
  138. data/bench/lib/testdata/2-data.txt +0 -0
  139. data/bench/lib/testdata/250-data.txt +0 -0
  140. data/bench/lib/testdata/5-blob_data.txt +0 -0
  141. data/bench/lib/testdata/5-data.txt +0 -0
  142. data/bench/lib/testdata/50-data.txt +0 -0
  143. data/bench/lib/testdata/500-data.txt +0 -0
  144. data/doc/protocol.html +0 -1993
  145. data/spec/coverage/rcov/assets/0.2.3/jquery-1.3.2.min.js +0 -19
  146. data/spec/coverage/rcov/assets/0.2.3/jquery.tablesorter.min.js +0 -15
  147. data/spec/coverage/rcov/assets/0.2.3/print.css +0 -12
  148. data/spec/coverage/rcov/assets/0.2.3/rcov.js +0 -42
  149. data/spec/coverage/rcov/assets/0.2.3/screen.css +0 -270
  150. data/spec/coverage/rcov/index.html +0 -88
  151. data/spec/generator/generator_spec_helper.rb +0 -9
@@ -1,45 +1,45 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiPushObjects" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should push new objects to rhoconnect's :md" do
6
- data = {'1' => @product1, '2' => @product2, '3' => @product3}
7
- post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/push_objects",
8
- {:user_id => @u.id, :objects => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
- last_response.should be_ok
10
- verify_doc_result(@s, {:md => data, :md_size=>'3'})
11
- end
12
-
13
- it "should push new objects to rhoconnect's :md with old api/source route and deprecation warning" do
14
- data = {'1' => @product1, '2' => @product2, '3' => @product3}
15
- post "/api/source/push_objects",
16
- {:user_id => @u.id, :source_id => @s_fields[:name], :objects => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
17
- last_response.should be_ok
18
- last_response.headers["Warning"].index('deprecated').should_not == nil
19
- verify_doc_result(@s, {:md => data, :md_size=>'3'})
20
- end
21
-
22
- it "should push new objects to rhoconnect's :md with oldest api route and deprecation warning" do
23
- data = {'1' => @product1, '2' => @product2, '3' => @product3}
24
- post "/api/push_objects",
25
- {:user_id => @u.id, :source_id => @s_fields[:name], :objects => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
26
- last_response.should be_ok
27
- last_response.headers["Warning"].index('deprecated').should_not == nil
28
- verify_doc_result(@s, {:md => data, :md_size=>'3'})
29
- end
4
+ include_examples "ApiHelper"
5
+
6
+ it "should push new objects to rhoconnect's :md" do
7
+ data = {'1' => @product1, '2' => @product2, '3' => @product3}
8
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/push_objects",
9
+ {:user_id => @u.id, :objects => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
10
+ last_response.should be_ok
11
+ verify_doc_result(@s, {:md => data, :md_size=>'3'})
12
+ end
13
+
14
+ it "should push new objects to rhoconnect's :md with old api/source route and deprecation warning" do
15
+ data = {'1' => @product1, '2' => @product2, '3' => @product3}
16
+ post "/api/source/push_objects",
17
+ {:user_id => @u.id, :source_id => @s_fields[:name], :objects => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
18
+ last_response.should be_ok
19
+ last_response.headers["Warning"].index('deprecated').should_not == nil
20
+ verify_doc_result(@s, {:md => data, :md_size=>'3'})
21
+ end
22
+
23
+ it "should push new objects to rhoconnect's :md with oldest api route and deprecation warning" do
24
+ data = {'1' => @product1, '2' => @product2, '3' => @product3}
25
+ post "/api/push_objects",
26
+ {:user_id => @u.id, :source_id => @s_fields[:name], :objects => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
27
+ last_response.should be_ok
28
+ last_response.headers["Warning"].index('deprecated').should_not == nil
29
+ verify_doc_result(@s, {:md => data, :md_size=>'3'})
30
+ end
30
31
 
31
- it "should push updates to existing objects to rhoconnect's :md" do
32
- data = {'1' => @product1, '2' => @product2, '3' => @product3}
33
- update = {'price' => '0.99', 'new_field' => 'value'}
34
- @s = Source.load(@s_fields[:name],@s_params)
35
- set_doc_state(@s, {:md => data, :md_size => '3'})
36
- update.each do |key,value|
37
- data['2'][key] = value
38
- end
39
- post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/push_objects",
40
- {:user_id => @u.id, :objects => {'2'=>update}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
41
- last_response.should be_ok
42
- verify_doc_result(@s, {:md => data, :md_size=>'3'})
32
+ it "should push updates to existing objects to rhoconnect's :md" do
33
+ data = {'1' => @product1, '2' => @product2, '3' => @product3}
34
+ update = {'price' => '0.99', 'new_field' => 'value'}
35
+ @s = Source.load(@s_fields[:name],@s_params)
36
+ set_doc_state(@s, {:md => data, :md_size => '3'})
37
+ update.each do |key,value|
38
+ data['2'][key] = value
43
39
  end
44
- end
40
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/push_objects",
41
+ {:user_id => @u.id, :objects => {'2'=>update}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
42
+ last_response.should be_ok
43
+ verify_doc_result(@s, {:md => data, :md_size=>'3'})
44
+ end
45
45
  end
@@ -1,33 +1,33 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiClientGetDbDoc" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should get clients's db document by doc key and data" do
6
- data = {'1' => {'foo' => 'bar'}}
7
- Client.define_valid_doctypes([:myclientdoc])
8
- dockey = 'myclientdoc'
9
- post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
10
- last_response.should be_ok
11
- get "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
12
- last_response.should be_ok
13
- JSON.parse(last_response.body).should == data
14
- Client.valid_doctypes.delete(dockey.to_sym)
15
- end
16
-
17
- it "should append data to the client's db document by doc name and data" do
18
- data = {'1' => {'foo' => 'bar'}}
19
- data2 = {'2' => {'foo1' => 'bar1'}}
20
- data3 = data.merge(data2)
21
- dockey = 'abc:abc'
22
- Client.define_valid_doctypes([dockey])
23
- post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
24
- last_response.should be_ok
25
- verify_doc_result(@c, dockey => data)
26
-
27
- post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data2, :append => true}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
28
- last_response.should be_ok
29
- verify_doc_result(@c, dockey => data3)
30
- Client.valid_doctypes.delete(dockey.to_sym)
31
- end
32
- end
4
+ include_examples "ApiHelper"
5
+
6
+ it "should get clients's db document by doc key and data" do
7
+ data = {'1' => {'foo' => 'bar'}}
8
+ Client.define_valid_doctypes([:myclientdoc])
9
+ dockey = 'myclientdoc'
10
+ post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
11
+ last_response.should be_ok
12
+ get "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
13
+ last_response.should be_ok
14
+ JSON.parse(last_response.body).should == data
15
+ Client.valid_doctypes.delete(dockey.to_sym)
16
+ end
17
+
18
+ it "should append data to the client's db document by doc name and data" do
19
+ data = {'1' => {'foo' => 'bar'}}
20
+ data2 = {'2' => {'foo1' => 'bar1'}}
21
+ data3 = data.merge(data2)
22
+ dockey = 'abc:abc'
23
+ Client.define_valid_doctypes([dockey])
24
+ post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
25
+ last_response.should be_ok
26
+ verify_doc_result(@c, dockey => data)
27
+
28
+ post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data2, :append => true}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
29
+ last_response.should be_ok
30
+ verify_doc_result(@c, dockey => data3)
31
+ Client.valid_doctypes.delete(dockey.to_sym)
32
+ end
33
33
  end
@@ -1,15 +1,15 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiClientSetDbDoc" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should set client's db document by doc key and data" do
6
- data = {'1' => {'foo' => 'bar'}}
7
- dockey = 'myclientdoc'
8
- Client.define_valid_doctypes([dockey])
9
- post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
10
- last_response.should be_ok
11
- verify_doc_result(@c, dockey => data)
12
- Client.valid_doctypes.delete(dockey.to_sym)
13
- end
14
- end
4
+ include_examples "ApiHelper"
5
+
6
+ it "should set client's db document by doc key and data" do
7
+ data = {'1' => {'foo' => 'bar'}}
8
+ dockey = 'myclientdoc'
9
+ Client.define_valid_doctypes([dockey])
10
+ post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
11
+ last_response.should be_ok
12
+ verify_doc_result(@c, dockey => data)
13
+ Client.valid_doctypes.delete(dockey.to_sym)
14
+ end
15
15
  end
@@ -1,33 +1,33 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiGetClientParams" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should list client attributes" do
6
- get "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
7
- res = JSON.parse(last_response.body)
8
- res.delete_if { |attrib| attrib['name'] == 'rho__id' || attrib['name'] == 'last_sync'}
9
- res.sort{|x,y| x['name']<=>y['name']}.should == [
10
- {"name"=>"device_type", "value"=>"Apple", "type"=>"string"},
11
- {"name"=>"device_pin", "value"=>"abcd", "type"=>"string"},
12
- {"name"=>"device_port", "value"=>"3333", "type"=>"string"},
13
- {"name"=>"device_push_type", "type"=>"string", "value"=>nil},
14
- {"name"=>"user_id", "value"=>"testuser", "type"=>"string"},
15
- {"name"=>"phone_id", "value"=>nil, "type"=>"string"},
16
- {"name"=>"app_id", "value"=>"application", "type"=>"string"}].sort{|x,y| x['name']<=>y['name']}
17
- end
18
-
19
- it "should list client attributes with old route and deprecation warning" do
20
- post "/api/get_client_params", {:api_token => @api_token, :client_id =>@c.id}
21
- res = JSON.parse(last_response.body)
22
- res.delete_if { |attrib| attrib['name'] == 'rho__id' || attrib['name'] == 'last_sync'}
23
- res.sort{|x,y| x['name']<=>y['name']}.should == [
24
- {"name"=>"device_type", "value"=>"Apple", "type"=>"string"},
25
- {"name"=>"device_pin", "value"=>"abcd", "type"=>"string"},
26
- {"name"=>"device_port", "value"=>"3333", "type"=>"string"},
27
- {"name"=>"device_push_type", "type"=>"string", "value"=>nil},
28
- {"name"=>"user_id", "value"=>"testuser", "type"=>"string"},
29
- {"name"=>"phone_id", "value"=>nil, "type"=>"string"},
30
- {"name"=>"app_id", "value"=>"application", "type"=>"string"}].sort{|x,y| x['name']<=>y['name']}
31
- end
32
- end
4
+ include_examples "ApiHelper"
5
+
6
+ it "should list client attributes" do
7
+ get "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
8
+ res = JSON.parse(last_response.body)
9
+ res.delete_if { |attrib| attrib['name'] == 'rho__id' || attrib['name'] == 'last_sync'}
10
+ res.sort{|x,y| x['name']<=>y['name']}.should == [
11
+ {"name"=>"device_type", "value"=>"Apple", "type"=>"string"},
12
+ {"name"=>"device_pin", "value"=>"abcd", "type"=>"string"},
13
+ {"name"=>"device_port", "value"=>"3333", "type"=>"string"},
14
+ {"name"=>"device_push_type", "type"=>"string", "value"=>nil},
15
+ {"name"=>"user_id", "value"=>"testuser", "type"=>"string"},
16
+ {"name"=>"phone_id", "value"=>nil, "type"=>"string"},
17
+ {"name"=>"app_id", "value"=>"application", "type"=>"string"}].sort{|x,y| x['name']<=>y['name']}
18
+ end
19
+
20
+ it "should list client attributes with old route and deprecation warning" do
21
+ post "/api/get_client_params", {:api_token => @api_token, :client_id =>@c.id}
22
+ res = JSON.parse(last_response.body)
23
+ res.delete_if { |attrib| attrib['name'] == 'rho__id' || attrib['name'] == 'last_sync'}
24
+ res.sort{|x,y| x['name']<=>y['name']}.should == [
25
+ {"name"=>"device_type", "value"=>"Apple", "type"=>"string"},
26
+ {"name"=>"device_pin", "value"=>"abcd", "type"=>"string"},
27
+ {"name"=>"device_port", "value"=>"3333", "type"=>"string"},
28
+ {"name"=>"device_push_type", "type"=>"string", "value"=>nil},
29
+ {"name"=>"user_id", "value"=>"testuser", "type"=>"string"},
30
+ {"name"=>"phone_id", "value"=>nil, "type"=>"string"},
31
+ {"name"=>"app_id", "value"=>"application", "type"=>"string"}].sort{|x,y| x['name']<=>y['name']}
32
+ end
33
33
  end
@@ -1,42 +1,40 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiListClientDocs" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should list client documents" do
6
- source_id = "SimpleAdapter"
4
+ include_examples "ApiHelper"
7
5
 
8
- Client.define_valid_doctypes(['mycustomdoc'])
9
- get "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{source_id}/docnames", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
10
- JSON.parse(last_response.body).should == {
11
- "cd"=>"client:application:testuser:#{@c.id}:#{source_id}:cd",
12
- "cd_size"=>"client:application:testuser:#{@c.id}:#{source_id}:cd_size",
13
- "page"=>"client:application:testuser:#{@c.id}:#{source_id}:page",
14
- "delete_page"=>"client:application:testuser:#{@c.id}:#{source_id}:delete_page",
15
- "create_links"=>"client:application:testuser:#{@c.id}:#{source_id}:create_links",
16
- "create_links_page"=>"client:application:testuser:#{@c.id}:#{source_id}:create_links_page",
17
- "metadata_page"=>"client:application:testuser:#{@c.id}:#{source_id}:metadata_page",
18
- "total_count_page"=>"client:application:testuser:#{@c.id}:#{source_id}:total_count_page",
19
- "page_token"=>"client:application:testuser:#{@c.id}:#{source_id}:page_token",
20
- "schema_sha1"=>"client:application:testuser:#{@c.id}:#{source_id}:schema_sha1",
21
- "schema_page"=>"client:application:testuser:#{@c.id}:#{source_id}:schema_page",
22
- "metadata_sha1"=>"client:application:testuser:#{@c.id}:#{source_id}:metadata_sha1",
23
- "search"=>"client:application:testuser:#{@c.id}:#{source_id}:search",
24
- "search_token"=>"client:application:testuser:#{@c.id}:#{source_id}:search_token",
25
- "search_page"=>"client:application:testuser:#{@c.id}:#{source_id}:search_page",
26
- "search_errors"=>"client:application:testuser:#{@c.id}:#{source_id}:search_errors",
27
- "create_errors"=>"client:application:testuser:#{@c.id}:#{source_id}:create_errors",
28
- "create_errors_page"=>"client:application:testuser:#{@c.id}:#{source_id}:create_errors_page",
29
- "update_errors"=>"client:application:testuser:#{@c.id}:#{source_id}:update_errors",
30
- "update_errors_page"=>"client:application:testuser:#{@c.id}:#{source_id}:update_errors_page",
31
- "update_rollback"=>"client:application:testuser:#{@c.id}:#{source_id}:update_rollback",
32
- "update_rollback_page"=>"client:application:testuser:#{@c.id}:#{source_id}:update_rollback_page",
33
- "delete_errors"=>"client:application:testuser:#{@c.id}:#{source_id}:delete_errors",
34
- "delete_errors_page"=>"client:application:testuser:#{@c.id}:#{source_id}:delete_errors_page",
6
+ it "should list client documents" do
7
+ source_id = "SimpleAdapter"
8
+ Client.define_valid_doctypes(['mycustomdoc'])
9
+ get "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{source_id}/docnames", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
10
+ JSON.parse(last_response.body).should == {
11
+ "cd"=>"client:application:testuser:#{@c.id}:#{source_id}:cd",
12
+ "cd_size"=>"client:application:testuser:#{@c.id}:#{source_id}:cd_size",
13
+ "page"=>"client:application:testuser:#{@c.id}:#{source_id}:page",
14
+ "delete_page"=>"client:application:testuser:#{@c.id}:#{source_id}:delete_page",
15
+ "create_links"=>"client:application:testuser:#{@c.id}:#{source_id}:create_links",
16
+ "create_links_page"=>"client:application:testuser:#{@c.id}:#{source_id}:create_links_page",
17
+ "metadata_page"=>"client:application:testuser:#{@c.id}:#{source_id}:metadata_page",
18
+ "total_count_page"=>"client:application:testuser:#{@c.id}:#{source_id}:total_count_page",
19
+ "page_token"=>"client:application:testuser:#{@c.id}:#{source_id}:page_token",
20
+ "schema_sha1"=>"client:application:testuser:#{@c.id}:#{source_id}:schema_sha1",
21
+ "schema_page"=>"client:application:testuser:#{@c.id}:#{source_id}:schema_page",
22
+ "metadata_sha1"=>"client:application:testuser:#{@c.id}:#{source_id}:metadata_sha1",
23
+ "search"=>"client:application:testuser:#{@c.id}:#{source_id}:search",
24
+ "search_token"=>"client:application:testuser:#{@c.id}:#{source_id}:search_token",
25
+ "search_page"=>"client:application:testuser:#{@c.id}:#{source_id}:search_page",
26
+ "search_errors"=>"client:application:testuser:#{@c.id}:#{source_id}:search_errors",
27
+ "create_errors"=>"client:application:testuser:#{@c.id}:#{source_id}:create_errors",
28
+ "create_errors_page"=>"client:application:testuser:#{@c.id}:#{source_id}:create_errors_page",
29
+ "update_errors"=>"client:application:testuser:#{@c.id}:#{source_id}:update_errors",
30
+ "update_errors_page"=>"client:application:testuser:#{@c.id}:#{source_id}:update_errors_page",
31
+ "update_rollback"=>"client:application:testuser:#{@c.id}:#{source_id}:update_rollback",
32
+ "update_rollback_page"=>"client:application:testuser:#{@c.id}:#{source_id}:update_rollback_page",
33
+ "delete_errors"=>"client:application:testuser:#{@c.id}:#{source_id}:delete_errors",
34
+ "delete_errors_page"=>"client:application:testuser:#{@c.id}:#{source_id}:delete_errors_page",
35
+ "mycustomdoc"=>"client:application:testuser:#{@c.id}:#{source_id}:mycustomdoc"}
35
36
 
36
- "mycustomdoc"=>"client:application:testuser:#{@c.id}:#{source_id}:mycustomdoc"}
37
-
38
- Client.valid_doctypes.delete('mycustomdoc'.to_sym)
39
- end
37
+ Client.valid_doctypes.delete('mycustomdoc'.to_sym)
40
38
  end
41
39
  end
42
40
 
@@ -1,36 +1,36 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiClientReset" do
4
- it_should_behave_like "ApiHelper" do
5
- before(:each) do
6
- do_post "/rc/#{Rhoconnect::API_VERSION}/app/login", "login" => @u.login, "password" => 'testpass'
7
- end
4
+ include_examples "ApiHelper"
8
5
 
9
- it "should handle client reset" do
10
- set_doc_state(@c, :cd => @data)
11
- post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/reset"
12
- last_response.should be_ok
13
- verify_doc_result(@c, :cd => {})
14
- Client.load(@c.id,{:source_name => @s.name}).should_not be_nil
15
- end
16
-
17
- it "should handle client reset on individual source adapters" do
18
- @c.source_name = 'SampleAdapter'
19
- set_doc_state(@c, :cd => @data)
20
- verify_doc_result(@c, :cd => @data)
21
-
22
- @c.source_name = 'SimpleAdapter'
23
- set_doc_state(@c, :cd => @data)
24
- verify_doc_result(@c, :cd => @data)
25
-
26
- sources = [{'name'=>'SimpleAdapter'}]
27
- do_post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/reset", {:sources => sources}
28
- last_response.should be_ok
29
-
30
- @c.source_name = 'SampleAdapter'
31
- verify_doc_result(@c, :cd => @data)
32
- @c.source_name = 'SimpleAdapter'
33
- verify_doc_result(@c, :cd => {})
34
- end
6
+ before(:each) do
7
+ do_post "/rc/#{Rhoconnect::API_VERSION}/app/login", "login" => @u.login, "password" => 'testpass'
8
+ end
9
+
10
+ it "should handle client reset" do
11
+ set_doc_state(@c, :cd => @data)
12
+ post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/reset"
13
+ last_response.should be_ok
14
+ verify_doc_result(@c, :cd => {})
15
+ Client.load(@c.id,{:source_name => @s.name}).should_not be_nil
16
+ end
17
+
18
+ it "should handle client reset on individual source adapters" do
19
+ @c.source_name = 'SampleAdapter'
20
+ set_doc_state(@c, :cd => @data)
21
+ verify_doc_result(@c, :cd => @data)
22
+
23
+ @c.source_name = 'SimpleAdapter'
24
+ set_doc_state(@c, :cd => @data)
25
+ verify_doc_result(@c, :cd => @data)
26
+
27
+ sources = [{'name'=>'SimpleAdapter'}]
28
+ do_post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/reset", {:sources => sources}
29
+ last_response.should be_ok
30
+
31
+ @c.source_name = 'SampleAdapter'
32
+ verify_doc_result(@c, :cd => @data)
33
+ @c.source_name = 'SimpleAdapter'
34
+ verify_doc_result(@c, :cd => {})
35
35
  end
36
36
  end
@@ -1,49 +1,49 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiSetRefreshTime" do
4
- it_should_behave_like "ApiHelper" do
5
- it "should set refresh time to 100s from 'now'" do
6
- before = Time.now.to_i
7
- put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}",
8
- {:refresh_time => 100}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
- after = Time.now.to_i
10
- last_response.should be_ok
11
- @s = Source.load(@s.id,@s_params)
12
- @s.read_state.refresh_time.should >= before + 100
13
- @s.read_state.refresh_time.should <= after + 100
14
- end
4
+ include_examples "ApiHelper"
15
5
 
16
- it "should set refresh time to 'now' if no refresh_time provided" do
17
- before = Time.now.to_i
18
- put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
19
- after = Time.now.to_i
20
- last_response.should be_ok
21
- @s = Source.load(@s.id,@s_params)
22
- @s.read_state.refresh_time.should >= before
23
- @s.read_state.refresh_time.should <= after
24
- end
6
+ it "should set refresh time to 100s from 'now'" do
7
+ before = Time.now.to_i
8
+ put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}",
9
+ {:refresh_time => 100}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
10
+ after = Time.now.to_i
11
+ last_response.should be_ok
12
+ @s = Source.load(@s.id,@s_params)
13
+ @s.read_state.refresh_time.should >= before + 100
14
+ @s.read_state.refresh_time.should <= after + 100
15
+ end
25
16
 
26
- it "should set poll interval" do
27
- put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}", {:poll_interval => 100}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
28
- last_response.should be_ok
29
- @s = Source.load(@s.id,@s_params)
30
- @s.poll_interval.should == 100
31
- end
32
-
33
- it "should should not set nil poll interval with old route and deprecation warning" do
34
- post "/api/set_refresh_time", :api_token => @api_token,
35
- :source_name => @s_fields[:name], :user_name => @u_fields[:login], :poll_interval => nil
36
- last_response.should be_ok
37
- last_response.headers["Warning"].index('deprecated').should_not == nil
38
- @s = Source.load(@s.id,@s_params)
39
- @s.poll_interval.should == 300
40
- end
41
-
42
- it "should should not set nil poll interval" do
43
- put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}", {:poll_interval => nil}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
44
- last_response.should be_ok
45
- @s = Source.load(@s.id,@s_params)
46
- @s.poll_interval.should == 300
47
- end
48
- end
17
+ it "should set refresh time to 'now' if no refresh_time provided" do
18
+ before = Time.now.to_i
19
+ put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
20
+ after = Time.now.to_i
21
+ last_response.should be_ok
22
+ @s = Source.load(@s.id,@s_params)
23
+ @s.read_state.refresh_time.should >= before
24
+ @s.read_state.refresh_time.should <= after
25
+ end
26
+
27
+ it "should set poll interval" do
28
+ put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}", {:poll_interval => 100}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
29
+ last_response.should be_ok
30
+ @s = Source.load(@s.id,@s_params)
31
+ @s.poll_interval.should == 100
32
+ end
33
+
34
+ it "should should not set nil poll interval with old route and deprecation warning" do
35
+ post "/api/set_refresh_time", :api_token => @api_token,
36
+ :source_name => @s_fields[:name], :user_name => @u_fields[:login], :poll_interval => nil
37
+ last_response.should be_ok
38
+ last_response.headers["Warning"].index('deprecated').should_not == nil
39
+ @s = Source.load(@s.id,@s_params)
40
+ @s.poll_interval.should == 300
41
+ end
42
+
43
+ it "should should not set nil poll interval" do
44
+ put "/rc/#{Rhoconnect::API_VERSION}/readstate/users/#{@u_fields[:login]}/sources/#{@s_fields[:name]}", {:poll_interval => nil}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
45
+ last_response.should be_ok
46
+ @s = Source.load(@s.id,@s_params)
47
+ @s.poll_interval.should == 300
48
+ end
49
49
  end
@@ -1,41 +1,39 @@
1
1
  require File.join(File.dirname(__FILE__),'..','api_helper')
2
2
 
3
3
  describe "RhoconnectApiGetSourceParams" do
4
+ include_examples "ApiHelper"
4
5
 
5
- it_should_behave_like "ApiHelper" do
6
-
7
- it "should list source attributes" do
8
- source_id = "SampleAdapter"
9
- get "/rc/#{Rhoconnect::API_VERSION}/sources/#{source_id}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
10
- result = JSON.parse(last_response.body).sort {|x,y| y["name"] <=> x["name"] }
11
- expected = [
12
- {"name"=>"rho__id", "value"=>"SampleAdapter", "type"=>"string"},
13
- {"name"=>"source_id", "value"=>nil, "type"=>"integer"},
14
- {"name"=>"name", "value"=>"SampleAdapter", "type"=>"string"},
15
- {"name"=>"url", "value"=>"http://example.com", "type"=>"string"},
16
- {"name"=>"login", "value"=>"testuser", "type"=>"string"},
17
- {"name"=>"password", "value"=>"testpass", "type"=>"string"},
18
- {"name"=>"priority", "value"=>1, "type"=>"integer"},
19
- {"name"=>"callback_url", "value"=>nil, "type"=>"string"},
20
- {"name"=>"poll_interval", "value"=>300, "type"=>"integer"},
21
- {"name"=>"retry_limit", "type"=>"integer", "value"=>0},
22
- {"name"=>"simulate_time", "value"=>0, "type"=>"integer"},
23
- {"name"=>"partition_type", "value"=>"user", "type"=>"string"},
24
- {"name"=>"push_notify", "value"=>"false", "type"=>"string"},
25
- {"name"=>"sync_type", "value"=>"incremental", "type"=>"string"},
26
- {"name"=>"belongs_to", "type"=>"string", "value"=>nil},
27
- {"name"=>"has_many", "type"=>"string", "value"=>"FixedSchemaAdapter,brand"},
28
- {"name"=>"id", "value"=>"SampleAdapter", "type"=>"string"},
29
- {"name"=>"queue", "value"=>nil, "type"=>"string"},
30
- {"name"=>"query_queue", "value"=>nil, "type"=>"string"},
31
- {"name"=>"pass_through", "value"=>nil, "type"=>"string"},
32
- {"name"=>"cud_queue", "value"=>nil, "type"=>"string"}].sort {|x,y| y["name"] <=> x["name"] }
33
- result.each_with_index do |item,i|
34
- expect = expected[i]
35
- item['name'].should == expect['name']
36
- item['value'].should == expect['value']
37
- item['type'].should == expect['type']
38
- end
6
+ it "should list source attributes" do
7
+ source_id = "SampleAdapter"
8
+ get "/rc/#{Rhoconnect::API_VERSION}/sources/#{source_id}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
+ result = JSON.parse(last_response.body).sort {|x,y| y["name"] <=> x["name"] }
10
+ expected = [
11
+ {"name"=>"rho__id", "value"=>"SampleAdapter", "type"=>"string"},
12
+ {"name"=>"source_id", "value"=>nil, "type"=>"integer"},
13
+ {"name"=>"name", "value"=>"SampleAdapter", "type"=>"string"},
14
+ {"name"=>"url", "value"=>"http://example.com", "type"=>"string"},
15
+ {"name"=>"login", "value"=>"testuser", "type"=>"string"},
16
+ {"name"=>"password", "value"=>"testpass", "type"=>"string"},
17
+ {"name"=>"priority", "value"=>1, "type"=>"integer"},
18
+ {"name"=>"callback_url", "value"=>nil, "type"=>"string"},
19
+ {"name"=>"poll_interval", "value"=>300, "type"=>"integer"},
20
+ {"name"=>"retry_limit", "type"=>"integer", "value"=>0},
21
+ {"name"=>"simulate_time", "value"=>0, "type"=>"integer"},
22
+ {"name"=>"partition_type", "value"=>"user", "type"=>"string"},
23
+ {"name"=>"push_notify", "value"=>"false", "type"=>"string"},
24
+ {"name"=>"sync_type", "value"=>"incremental", "type"=>"string"},
25
+ {"name"=>"belongs_to", "type"=>"string", "value"=>nil},
26
+ {"name"=>"has_many", "type"=>"string", "value"=>"FixedSchemaAdapter,brand"},
27
+ {"name"=>"id", "value"=>"SampleAdapter", "type"=>"string"},
28
+ {"name"=>"queue", "value"=>nil, "type"=>"string"},
29
+ {"name"=>"query_queue", "value"=>nil, "type"=>"string"},
30
+ {"name"=>"pass_through", "value"=>nil, "type"=>"string"},
31
+ {"name"=>"cud_queue", "value"=>nil, "type"=>"string"}].sort {|x,y| y["name"] <=> x["name"] }
32
+ result.each_with_index do |item,i|
33
+ expect = expected[i]
34
+ item['name'].should == expect['name']
35
+ item['value'].should == expect['value']
36
+ item['type'].should == expect['type']
39
37
  end
40
38
  end
41
39
  end