rhoconnect 4.0.4 → 5.1.1

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.
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,69 +1,69 @@
1
1
  require File.join(File.dirname(__FILE__),'spec_helper')
2
2
 
3
3
  describe "Document" do
4
- it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
5
- before(:each) do
6
- @valid_docs = [:foo1, :foo, :key, :key1, :key2]
7
- Client.define_valid_doctypes(@valid_docs)
8
- @s = Source.load(@s_fields[:name],@s_params)
9
- end
4
+ include_examples "SharedRhoconnectHelper", :rhoconnect_data => true
10
5
 
11
- after(:each) do
12
- @valid_docs.each do |doctype|
13
- Client.valid_doctypes.delete(doctype)
14
- end
15
- end
16
-
17
- it "should generate client docname" do
18
- @c.docname(:foo).should == "client:#{@a.id}:#{@u.id}:#{@c.id}:#{@s_fields[:name]}:foo"
19
- end
6
+ before(:each) do
7
+ @valid_docs = [:foo1, :foo, :key, :key1, :key2]
8
+ Client.define_valid_doctypes(@valid_docs)
9
+ @s = Source.load(@s_fields[:name],@s_params)
10
+ end
20
11
 
21
- it "should generate InvalidDocumentException for invalid client doctype" do
22
- lambda { @c.put_data(:foo_invalid,{'1'=>@product1}) }.should raise_error(InvalidDocumentException, "Invalid document type foo_invalid for Rhoconnect::Client")
23
- store_index = @c.store_index(:foo_invalid)
24
- Store.get_store(store_index).db.keys(@c.docname('*')).should == []
12
+ after(:each) do
13
+ @valid_docs.each do |doctype|
14
+ Client.valid_doctypes.delete(doctype)
25
15
  end
16
+ end
26
17
 
27
- it "should generate source docname" do
28
- @s.docname(:foo).should == "source:#{@a.id}:#{@u.id}:#{@s_fields[:name]}:foo"
29
- end
18
+ it "should generate client docname" do
19
+ @c.docname(:foo).should == "client:#{@a.id}:#{@u.id}:#{@c.id}:#{@s_fields[:name]}:foo"
20
+ end
30
21
 
31
- it "should flush_data for docname" do
32
- @c.put_data(:foo1,{'1'=>@product1})
33
- docname = @c.docname(:foo1)
34
- bucket_index = get_sha1('1')[0..1]
35
- store_index = @c.store_index(:foo1)
36
- Store.get_store(store_index).db.keys(@c.docname('*')).sort.should == ["#{docname}:#{bucket_index}", "#{docname}:indices"].sort
37
- @c.flush_all_documents
38
- Store.get_store(store_index).db.keys(@c.docname('*')).should == []
39
- end
40
-
41
- it "should flush_data for arrays" do
42
- @c.put_list(:foo1,['1', '2', '3'])
43
- @c.exists?(:foo1).should == true
44
- @c.flush_all_documents
45
- @c.exists?(:foo1).should == false
46
- end
47
-
48
- it "should get_data for arrays" do
49
- @c.put_list(:foo1,['1', '2', '3'])
50
- @c.get_data(:foo1, Array).should == ['1', '2', '3']
51
- JSON.parse(@c.get_db_doc(:foo1)).should == ['1', '2', '3']
52
- end
22
+ it "should generate InvalidDocumentException for invalid client doctype" do
23
+ lambda { @c.put_data(:foo_invalid,{'1'=>@product1}) }.should raise_error(InvalidDocumentException, "Invalid document type foo_invalid for Rhoconnect::Client")
24
+ store_index = @c.store_index(:foo_invalid)
25
+ Store.get_store(store_index).db.keys(@c.docname('*')).should == []
26
+ end
53
27
 
54
- it "should rename doc" do
55
- @c.put_data(:key1, @data)
56
- @c.rename(:key1,:key2)
57
- @c.exists?(:key1).should == false
58
- @c.get_data(:key2).should == @data
59
- end
60
-
61
- it "should operate with individual object" do
62
- key = '1'
63
- data = {'foo' => 'bar'}
64
- @c.put_object(:cd, key, data)
65
- obj = @c.get_object(:cd, key)
66
- obj.should == data
67
- end
28
+ it "should generate source docname" do
29
+ @s.docname(:foo).should == "source:#{@a.id}:#{@u.id}:#{@s_fields[:name]}:foo"
30
+ end
31
+
32
+ it "should flush_data for docname" do
33
+ @c.put_data(:foo1,{'1'=>@product1})
34
+ docname = @c.docname(:foo1)
35
+ bucket_index = get_sha1('1')[0..1]
36
+ store_index = @c.store_index(:foo1)
37
+ Store.get_store(store_index).db.keys(@c.docname('*')).sort.should == ["#{docname}:#{bucket_index}", "#{docname}:indices"].sort
38
+ @c.flush_all_documents
39
+ Store.get_store(store_index).db.keys(@c.docname('*')).should == []
40
+ end
41
+
42
+ it "should flush_data for arrays" do
43
+ @c.put_list(:foo1,['1', '2', '3'])
44
+ @c.exists?(:foo1).should == true
45
+ @c.flush_all_documents
46
+ @c.exists?(:foo1).should == false
47
+ end
48
+
49
+ it "should get_data for arrays" do
50
+ @c.put_list(:foo1,['1', '2', '3'])
51
+ @c.get_data(:foo1, Array).should == ['1', '2', '3']
52
+ JSON.parse(@c.get_db_doc(:foo1)).should == ['1', '2', '3']
53
+ end
54
+
55
+ it "should rename doc" do
56
+ @c.put_data(:key1, @data)
57
+ @c.rename(:key1,:key2)
58
+ @c.exists?(:key1).should == false
59
+ @c.get_data(:key2).should == @data
60
+ end
61
+
62
+ it "should operate with individual object" do
63
+ key = '1'
64
+ data = {'foo' => 'bar'}
65
+ @c.put_object(:cd, key, data)
66
+ obj = @c.get_object(:cd, key)
67
+ obj.should == data
68
68
  end
69
69
  end
@@ -1,41 +1,38 @@
1
1
  require File.join(File.dirname(__FILE__),'spec_helper')
2
2
 
3
3
  describe "Rhoconnect::Model::DynamicAdapterModel" do
4
- it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
5
-
6
- it "should return login when backend service defined" do
7
- stub_request(:post, "http://test.com/rhoconnect/authenticate").to_return(:body => "lucas")
8
- Rhoconnect.appserver = 'http://test.com'
9
- Rhoconnect::Model::DynamicAdapterModel.authenticate('lucas','').should == 'lucas'
10
- end
11
-
12
- it "should query dynamic adapter service" do
13
- data = {'1'=>@product1}
14
- stub_request(:post, "http://test.com/rhoconnect/query").with(:headers => {'Content-Type' => 'application/json'}).to_return(:status => 200, :body => data.to_json)
15
- da = Rhoconnect::Model::DynamicAdapterModel.new(@s2,nil,'http://test.com')
16
- da.query.should == data
17
- end
18
-
19
- it "should create new object using dynamic adapter" do
20
- stub_request(:post, "http://test.com/rhoconnect/create").with(:headers => {'Content-Type' => 'application/json'}).to_return(:body => {:id => 5})
21
- da = Rhoconnect::Model::DynamicAdapterModel.new(@s2,nil,'http://test.com')
22
- da.create(@product1).should == {:id => 5}
23
- end
24
-
25
- it "should update object using dynamic adapter" do
26
- data = {'id' => 2}
27
- stub_request(:post, "http://test.com/rhoconnect/update").with(:headers => {'Content-Type' => 'application/json'}).to_return(:body => {:id => 5})
28
- da = Rhoconnect::Model::DynamicAdapterModel.new(@s2,nil,'http://test.com')
29
- da.update(data).should == {:id => 5}
30
- end
31
-
32
- it "should delete object using dynamic adapter" do
33
- data = {'id' => 2}
34
- stub_request(:post, "http://test.com/rhoconnect/delete").with(:headers => {'Content-Type' => 'application/json'}).to_return(:body => {:id => 5})
35
- da = Rhoconnect::Model::DynamicAdapterModel.new(@s2,nil,'http://test.com')
36
- da.delete(data).should == {:id => 5}
37
- end
38
-
39
-
4
+ include_examples "SharedRhoconnectHelper", :rhoconnect_data => true
5
+
6
+ it "should return login when backend service defined" do
7
+ stub_request(:post, "http://test.com/rhoconnect/authenticate").to_return(:body => "lucas")
8
+ Rhoconnect.appserver = 'http://test.com'
9
+ Rhoconnect::Model::DynamicAdapterModel.authenticate('lucas','').should == 'lucas'
10
+ end
11
+
12
+ it "should query dynamic adapter service" do
13
+ data = {'1'=>@product1}
14
+ stub_request(:post, "http://test.com/rhoconnect/query").with(:headers => {'Content-Type' => 'application/json'}).to_return(:status => 200, :body => data.to_json)
15
+ da = Rhoconnect::Model::DynamicAdapterModel.new(@s2,nil,'http://test.com')
16
+ da.query.should == data
17
+ end
18
+
19
+ it "should create new object using dynamic adapter" do
20
+ stub_request(:post, "http://test.com/rhoconnect/create").with(:headers => {'Content-Type' => 'application/json'}).to_return(:body => {:id => 5})
21
+ da = Rhoconnect::Model::DynamicAdapterModel.new(@s2,nil,'http://test.com')
22
+ da.create(@product1).should == {:id => 5}
23
+ end
24
+
25
+ it "should update object using dynamic adapter" do
26
+ data = {'id' => 2}
27
+ stub_request(:post, "http://test.com/rhoconnect/update").with(:headers => {'Content-Type' => 'application/json'}).to_return(:body => {:id => 5})
28
+ da = Rhoconnect::Model::DynamicAdapterModel.new(@s2,nil,'http://test.com')
29
+ da.update(data).should == {:id => 5}
30
+ end
31
+
32
+ it "should delete object using dynamic adapter" do
33
+ data = {'id' => 2}
34
+ stub_request(:post, "http://test.com/rhoconnect/delete").with(:headers => {'Content-Type' => 'application/json'}).to_return(:body => {:id => 5})
35
+ da = Rhoconnect::Model::DynamicAdapterModel.new(@s2,nil,'http://test.com')
36
+ da.delete(data).should == {:id => 5}
40
37
  end
41
38
  end
@@ -1,66 +1,100 @@
1
- require File.join(File.dirname(__FILE__),'generator_spec_helper')
1
+ require 'rspec'
2
+ require_relative "../../lib/rhoconnect"
3
+ require_relative "../../generators/rhoconnect"
2
4
 
3
5
  describe "Generator" do
4
6
  appname = 'mynewapp'
5
7
  source = 'mysource'
6
8
  path = File.expand_path(File.join(File.dirname(__FILE__)))
7
-
9
+
8
10
  before(:each) do
9
11
  FileUtils.mkdir_p '/tmp'
10
12
  end
11
-
13
+
12
14
  describe "AppGenerator" do
13
15
  it "should complain if no name is specified" do
14
16
  lambda {
15
- Rhoconnect::AppGenerator.new('/tmp',{})
16
- }.should raise_error(Templater::TooFewArgumentsError)
17
+ Rhoconnect::AppGenerator.new()
18
+ }.should raise_error(Thor::RequiredArgumentMissingError)
17
19
  end
18
-
19
- before(:each) do
20
- @generator = Rhoconnect::AppGenerator.new('/tmp',{},appname)
21
- end
22
-
20
+
23
21
  it "should create new ruby application files" do
24
- SecureRandom.should_receive(:hex).with(64).any_number_of_times
25
- [
26
- 'Gemfile',
27
- 'Rakefile',
28
- "controllers/ruby/application_controller.rb",
29
- 'spec/controllers/ruby/application_controller_spec.rb',
30
- 'config.ru',
31
- 'public',
32
- 'settings/settings.yml',
33
- 'settings/license.key',
34
- 'spec/spec_helper.rb'
35
- ].each do |template|
36
- @generator.should create("/tmp/#{appname}/#{template}")
22
+ allow(SecureRandom).to receive(:hex).with(64)
23
+ Dir.chdir '/tmp' do
24
+ FileUtils.rm_rf(appname)
25
+ Bundler.with_clean_env do
26
+ generator = Rhoconnect::AppGenerator.new([appname])
27
+ generator.invoke_all
28
+ Dir.chdir(appname) do
29
+ [
30
+ 'Gemfile',
31
+ ".rcgemfile",
32
+ 'Rakefile',
33
+ "controllers/ruby/application_controller.rb",
34
+ 'spec/controllers/ruby/application_controller_spec.rb',
35
+ 'config.ru',
36
+ 'public',
37
+ 'settings/settings.yml',
38
+ 'settings/license.key',
39
+ 'spec/spec_helper.rb'
40
+ ].each do |template|
41
+ File.exist?("/tmp/#{appname}/#{template}").should be_true
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ it "should create new js application files" do
49
+ allow(SecureRandom).to receive(:hex).with(64)
50
+ Dir.chdir '/tmp' do
51
+ FileUtils.rm_rf(appname)
52
+ Bundler.with_clean_env do
53
+ Rhoconnect::AppGenerator.start([appname, '--js'])
54
+ Dir.chdir(appname) do
55
+ [
56
+ 'Gemfile',
57
+ ".rcgemfile",
58
+ 'package.json',
59
+ 'Rakefile',
60
+ 'controllers/js/application_controller.js',
61
+ 'config.ru',
62
+ 'public',
63
+ 'settings/settings.yml',
64
+ 'settings/license.key'
65
+ ].each do |template|
66
+ File.exist?("/tmp/#{appname}/#{template}").should be_true
67
+ end
68
+ end
69
+ end
37
70
  end
38
71
  end
39
72
  end
40
-
73
+
41
74
  describe "SourceGenerator" do
75
+
42
76
  it "should complain if no name is specified" do
43
77
  lambda {
44
- Rhoconnect::SourceGenerator.new('/tmp',{})
45
- }.should raise_error(Templater::TooFewArgumentsError)
46
- end
47
-
48
- before(:each) do
49
- FileUtils.rm_rf "/tmp/#{appname}"
50
- @app_generator = Rhoconnect::AppGenerator.new('/tmp',{},appname)
51
- @app_generator.invoke!
52
- Bundler.with_clean_env do
53
- @app_generator.after_run
54
- end
55
- @generator = Rhoconnect::SourceGenerator.new("/tmp/#{appname}",{},source)
78
+ Rhoconnect::SourceGenerator.new()
79
+ }.should raise_error(Thor::RequiredArgumentMissingError)
56
80
  end
57
-
81
+
58
82
  it "should create new source adapter and spec" do
59
- @generator.should create("/tmp/#{appname}/models/ruby/#{source}.rb")
60
- @generator.should create("/tmp/#{appname}/controllers/ruby/#{source}_controller.rb")
61
- @generator.should create("/tmp/#{appname}/spec/models/ruby/#{source}_spec.rb")
62
- @generator.should create("/tmp/#{appname}/spec/controllers/ruby/#{source}_controller_spec.rb")
83
+ Dir.chdir '/tmp' do
84
+ FileUtils.rm_rf(appname)
85
+ Bundler.with_clean_env do
86
+ Rhoconnect::AppGenerator.start([appname])
87
+ Dir.chdir appname do
88
+ Rhoconnect::SourceGenerator.start([source])
89
+
90
+ File.exist?("/tmp/#{appname}/models/ruby/#{source}.rb").should be_true
91
+ File.exist?("/tmp/#{appname}/controllers/ruby/#{source}_controller.rb").should be_true
92
+ File.exist?("/tmp/#{appname}/spec/models/ruby/#{source}_spec.rb").should be_true
93
+ File.exist?("/tmp/#{appname}/spec/controllers/ruby/#{source}_controller_spec.rb").should be_true
94
+ end
95
+ end
96
+ end
63
97
  end
64
98
  end
65
-
99
+
66
100
  end
@@ -1,130 +1,129 @@
1
1
  require File.join(File.dirname(__FILE__),'..','spec_helper')
2
2
 
3
3
  describe "BulkDataJob" do
4
- it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
4
+ include_examples "SharedRhoconnectHelper", :rhoconnect_data => true
5
5
 
6
- after(:each) do
7
- delete_data_directory
8
- end
9
-
10
- let(:mock_schema) { {"property" => { "name" => "string", "brand" => "string" }, "version" => "1.0"} }
6
+ after(:each) do
7
+ delete_data_directory
8
+ end
9
+
10
+ let(:mock_schema) { {"property" => { "name" => "string", "brand" => "string" }, "version" => "1.0"} }
11
+
12
+ it "should create bulk data files from master document" do
13
+ set_state('test_db_storage' => @data)
14
+ docname = bulk_data_docname(@a.id,@u.id)
15
+ expected = { @s_fields[:name] => @data,
16
+ 'FixedSchemaAdapter' => @data
17
+ }
18
+ data = BulkData.create(:name => docname,
19
+ :state => :inprogress,
20
+ :app_id => @a.id,
21
+ :user_id => @u.id,
22
+ :partition_sources => [@s_fields[:name],'FixedSchemaAdapter'],
23
+ :sources => [@s_fields[:name], 'FixedSchemaAdapter'])
24
+ do_bulk_data_job("data_name" => data.name)
25
+ data = BulkData.load(docname)
26
+ data.completed?.should == true
27
+ verify_doc_result(@s, {:md => @data,
28
+ :md_copy => @data})
29
+ validate_db(data,expected).should == true
30
+ File.exists?(data.dbfile+'.rzip').should == true
31
+ File.exists?(data.dbfile+'.gzip').should == true
32
+ path = File.join(File.dirname(data.dbfile),'tmp')
33
+ FileUtils.mkdir_p path
34
+ unzip_file("#{data.dbfile}.rzip",path)
35
+ data.dbfile = File.join(path,File.basename(data.dbfile))
36
+ validate_db(data,expected).should == true
37
+ end
11
38
 
12
- it "should create bulk data files from master document" do
13
- set_state('test_db_storage' => @data)
39
+ it "should create bulk data files from master document for specific sources" do
40
+ set_state('test_db_storage' => @data)
41
+ docname = bulk_data_docname(@a.id,@u.id)
42
+ expected = { @s_fields[:name] => {},
43
+ 'FixedSchemaAdapter' => @data
44
+ }
45
+ source_existing_data = {'my_key1' => {'my_attrib1' => 'my_val1'}}
46
+ @s.put_data(:md, source_existing_data)
47
+ data = BulkData.create(:name => docname,
48
+ :state => :inprogress,
49
+ :app_id => @a.id,
50
+ :user_id => @u.id,
51
+ :partition_sources => [@s_fields[:name],'FixedSchemaAdapter'],
52
+ :sources => ['FixedSchemaAdapter'])
53
+ do_bulk_data_job("data_name" => data.name)
54
+ data = BulkData.load(docname)
55
+ data.completed?.should == true
56
+ verify_doc_result(@s, {:md => source_existing_data,
57
+ :md_copy => {}})
58
+ # skipped source should have :none in the DB - so we pass it for verification
59
+ @s.sync_type = :none
60
+ validate_db_file(data.dbfile,[@s_fields[:name], 'FixedSchemaAdapter'], expected).should == true
61
+ File.exists?(data.dbfile+'.rzip').should == true
62
+ File.exists?(data.dbfile+'.gzip').should == true
63
+ path = File.join(File.dirname(data.dbfile),'tmp')
64
+ FileUtils.mkdir_p path
65
+ unzip_file("#{data.dbfile}.rzip",path)
66
+ data.dbfile = File.join(path,File.basename(data.dbfile))
67
+ validate_db_file(data.dbfile,[@s_fields[:name], 'FixedSchemaAdapter'], expected).should == true
68
+ end
69
+
70
+ it "should create sqlite data with source metadata" do
71
+ set_state('test_db_storage' => @data)
72
+ mock_metadata_method([SampleAdapter]) do
14
73
  docname = bulk_data_docname(@a.id,@u.id)
15
- expected = { @s_fields[:name] => @data,
16
- 'FixedSchemaAdapter' => @data
17
- }
18
74
  data = BulkData.create(:name => docname,
19
75
  :state => :inprogress,
20
76
  :app_id => @a.id,
21
77
  :user_id => @u.id,
22
- :partition_sources => [@s_fields[:name],'FixedSchemaAdapter'],
23
- :sources => [@s_fields[:name], 'FixedSchemaAdapter'])
78
+ :partition_sources => [@s_fields[:name]],
79
+ :sources => [@s_fields[:name]])
24
80
  do_bulk_data_job("data_name" => data.name)
25
81
  data = BulkData.load(docname)
26
82
  data.completed?.should == true
27
83
  verify_doc_result(@s, {:md => @data,
84
+ :metadata => {'foo'=>'bar'}.to_json,
28
85
  :md_copy => @data})
29
- validate_db(data,expected).should == true
30
- File.exists?(data.dbfile+'.rzip').should == true
31
- File.exists?(data.dbfile+'.gzip').should == true
32
- path = File.join(File.dirname(data.dbfile),'tmp')
33
- FileUtils.mkdir_p path
34
- unzip_file("#{data.dbfile}.rzip",path)
35
- data.dbfile = File.join(path,File.basename(data.dbfile))
36
- validate_db(data,expected).should == true
86
+ validate_db(data,@s.name => @data).should == true
37
87
  end
38
-
39
- it "should create bulk data files from master document for specific sources" do
40
- set_state('test_db_storage' => @data)
88
+ end
89
+
90
+ it "should create sqlite data with source schema" do
91
+ set_state('test_db_storage' => @data)
92
+ mock_schema_method([SampleAdapter]) do
41
93
  docname = bulk_data_docname(@a.id,@u.id)
42
- expected = { @s_fields[:name] => {},
43
- 'FixedSchemaAdapter' => @data
44
- }
45
- source_existing_data = {'my_key1' => {'my_attrib1' => 'my_val1'}}
46
- @s.put_data(:md, source_existing_data)
47
94
  data = BulkData.create(:name => docname,
48
95
  :state => :inprogress,
49
96
  :app_id => @a.id,
50
97
  :user_id => @u.id,
51
- :partition_sources => [@s_fields[:name],'FixedSchemaAdapter'],
52
- :sources => ['FixedSchemaAdapter'])
98
+ :partition_sources => [@s_fields[:name]],
99
+ :sources => [@s_fields[:name]])
53
100
  do_bulk_data_job("data_name" => data.name)
54
101
  data = BulkData.load(docname)
55
102
  data.completed?.should == true
56
- verify_doc_result(@s, {:md => source_existing_data,
57
- :md_copy => {}})
58
- # skipped source should have :none in the DB - so we pass it for verification
59
- @s.sync_type = :none
60
- validate_db_file(data.dbfile,[@s_fields[:name], 'FixedSchemaAdapter'], expected).should == true
61
- File.exists?(data.dbfile+'.rzip').should == true
62
- File.exists?(data.dbfile+'.gzip').should == true
63
- path = File.join(File.dirname(data.dbfile),'tmp')
64
- FileUtils.mkdir_p path
65
- unzip_file("#{data.dbfile}.rzip",path)
66
- data.dbfile = File.join(path,File.basename(data.dbfile))
67
- validate_db_file(data.dbfile,[@s_fields[:name], 'FixedSchemaAdapter'], expected).should == true
68
- end
69
-
70
- it "should create sqlite data with source metadata" do
71
- set_state('test_db_storage' => @data)
72
- mock_metadata_method([SampleAdapter]) do
73
- docname = bulk_data_docname(@a.id,@u.id)
74
- data = BulkData.create(:name => docname,
75
- :state => :inprogress,
76
- :app_id => @a.id,
77
- :user_id => @u.id,
78
- :partition_sources => [@s_fields[:name]],
79
- :sources => [@s_fields[:name]])
80
- do_bulk_data_job("data_name" => data.name)
81
- data = BulkData.load(docname)
82
- data.completed?.should == true
83
- verify_doc_result(@s, {:md => @data,
84
- :metadata => {'foo'=>'bar'}.to_json,
85
- :md_copy => @data})
86
- validate_db(data,@s.name => @data).should == true
87
- end
88
- end
89
-
90
- it "should create sqlite data with source schema" do
91
- set_state('test_db_storage' => @data)
92
- mock_schema_method([SampleAdapter]) do
93
- docname = bulk_data_docname(@a.id,@u.id)
94
- data = BulkData.create(:name => docname,
95
- :state => :inprogress,
96
- :app_id => @a.id,
97
- :user_id => @u.id,
98
- :partition_sources => [@s_fields[:name]],
99
- :sources => [@s_fields[:name]])
100
- do_bulk_data_job("data_name" => data.name)
101
- data = BulkData.load(docname)
102
- data.completed?.should == true
103
- verify_doc_result(@s, {:md => @data,
104
- :md_copy => @data})
105
- JSON.parse(@s.get_value(:schema)).should == mock_schema
106
- validate_db(data,@s.name => @data).should == true
107
- end
103
+ verify_doc_result(@s, {:md => @data,
104
+ :md_copy => @data})
105
+ JSON.parse(@s.get_value(:schema)).should == mock_schema
106
+ validate_db(data,@s.name => @data).should == true
108
107
  end
108
+ end
109
109
 
110
- it "should delete bulk data if exception is raised" do
111
- lambda {
112
- do_bulk_data_job("data_name" => 'broken')
113
- }.should raise_error(Exception)
114
- Store.get_store(0).db.keys('bulk_data*').should == []
115
- end
110
+ it "should delete bulk data if exception is raised" do
111
+ lambda {
112
+ do_bulk_data_job("data_name" => 'broken')
113
+ }.should raise_error(Exception)
114
+ Store.get_store(0).db.keys('bulk_data*').should == []
115
+ end
116
116
 
117
- it "should delete bulk data if exception is raised" do
118
- data = BulkData.create(:name => bulk_data_docname('broken',@u.id),
119
- :state => :inprogress,
120
- :app_id => 'broken',
121
- :user_id => @u.id,
122
- :partition_sources => [@s_fields[:name]],
123
- :sources => [@s_fields[:name]])
124
- lambda {
125
- do_bulk_data_job("data_name" => data.name)
126
- }.should raise_error(Exception)
127
- Store.get_store(0).db.keys('bulk_data*').should == []
128
- end
129
- end
117
+ it "should delete bulk data if exception is raised" do
118
+ data = BulkData.create(:name => bulk_data_docname('broken',@u.id),
119
+ :state => :inprogress,
120
+ :app_id => 'broken',
121
+ :user_id => @u.id,
122
+ :partition_sources => [@s_fields[:name]],
123
+ :sources => [@s_fields[:name]])
124
+ lambda {
125
+ do_bulk_data_job("data_name" => data.name)
126
+ }.should raise_error(Exception)
127
+ Store.get_store(0).db.keys('bulk_data*').should == []
128
+ end
130
129
  end