rhoconnect 3.1.2 → 3.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. data/CHANGELOG.md +14 -2
  2. data/CREDITS +151 -10
  3. data/Gemfile +16 -5
  4. data/Gemfile.lock +58 -23
  5. data/Rakefile +70 -50
  6. data/bench/bench_runner.rb +2 -2
  7. data/bench/benchapp/Gemfile +6 -0
  8. data/bench/benchapp/Gemfile.lock +5 -0
  9. data/bench/benchapp/config.ru +2 -0
  10. data/bench/lib/bench/cli.rb +2 -0
  11. data/bench/lib/bench/distr_runner.rb +3 -2
  12. data/bench/lib/bench/runner.rb +1 -1
  13. data/bench/lib/bench.rb +10 -1
  14. data/bench/run_bench.sh +1 -1
  15. data/bench/scripts/test_query_script.rb +2 -1
  16. data/bench/spec/bench_spec_helper.rb +1 -0
  17. data/bin/rhoconnect +9 -27
  18. data/bin/rhoconnect-benchmark +10 -1
  19. data/commands/commands/dtach_commands/dtach_about.rb +6 -0
  20. data/commands/commands/dtach_commands/dtach_install.rb +30 -0
  21. data/commands/commands/redis_commands/redis_about.rb +6 -0
  22. data/commands/commands/redis_commands/redis_attach.rb +6 -0
  23. data/commands/commands/redis_commands/redis_download.rb +33 -0
  24. data/commands/commands/redis_commands/redis_install.rb +26 -0
  25. data/commands/commands/redis_commands/redis_make.rb +9 -0
  26. data/commands/commands/redis_commands/redis_restart.rb +7 -0
  27. data/commands/commands/redis_commands/redis_runner.rb +67 -0
  28. data/commands/commands/redis_commands/redis_start.rb +6 -0
  29. data/commands/commands/redis_commands/redis_startbg.rb +6 -0
  30. data/commands/commands/redis_commands/redis_stop.rb +6 -0
  31. data/commands/commands/rhoconnect/attach.rb +7 -0
  32. data/commands/commands/rhoconnect/clean_start.rb +9 -0
  33. data/commands/commands/rhoconnect/config.rb +15 -0
  34. data/commands/commands/rhoconnect/console.rb +15 -0
  35. data/commands/commands/rhoconnect/console_helper.rb +3 -0
  36. data/commands/commands/rhoconnect/create_user.rb +18 -0
  37. data/commands/commands/rhoconnect/delete_device.rb +9 -0
  38. data/commands/commands/rhoconnect/delete_user.rb +8 -0
  39. data/commands/commands/rhoconnect/flushdb.rb +14 -0
  40. data/commands/commands/rhoconnect/get_token.rb +25 -0
  41. data/commands/commands/rhoconnect/reset.rb +16 -0
  42. data/commands/commands/rhoconnect/reset_refresh.rb +11 -0
  43. data/commands/commands/rhoconnect/restart.rb +7 -0
  44. data/commands/commands/rhoconnect/secret.rb +11 -0
  45. data/commands/commands/rhoconnect/set_admin_password.rb +26 -0
  46. data/commands/commands/rhoconnect/spec.rb +15 -0
  47. data/commands/commands/rhoconnect/start.rb +18 -0
  48. data/commands/commands/rhoconnect/startbg.rb +34 -0
  49. data/commands/commands/rhoconnect/startdebug.rb +35 -0
  50. data/commands/commands/rhoconnect/stop.rb +11 -0
  51. data/commands/commands/rhoconnect/war.rb +32 -0
  52. data/commands/commands/rhoconnect/web.rb +7 -0
  53. data/commands/execute.rb +35 -0
  54. data/commands/generators/app.rb +6 -0
  55. data/commands/generators/source.rb +6 -0
  56. data/commands/utilities/dtach_installed.rb +10 -0
  57. data/doc/benchmarks-running.txt +5 -0
  58. data/doc/command-line.txt +216 -27
  59. data/doc/heroku-addon.txt +1 -1
  60. data/doc/preparing-production.txt +20 -1
  61. data/doc/public/cli.txt +191 -0
  62. data/doc/push-backend-setup.txt +148 -0
  63. data/doc/push-client-setup.txt +61 -0
  64. data/doc/push-server-setup.txt +91 -0
  65. data/doc/push.txt +8 -137
  66. data/doc/rest-api.txt +96 -0
  67. data/doc/settings.txt +1 -1
  68. data/doc/supported-platforms.txt +2 -1
  69. data/doc/tutorial.txt +6 -4
  70. data/examples/simple/Gemfile +39 -0
  71. data/examples/simple/Rakefile +7 -12
  72. data/examples/simple/config.ru +16 -31
  73. data/examples/simple/settings/settings.yml +5 -4
  74. data/examples/simple/sources/product.rb +51 -0
  75. data/generators/templates/application/Gemfile +7 -0
  76. data/generators/templates/application/Rakefile +5 -18
  77. data/generators/templates/application/config.ru +11 -19
  78. data/install.sh +24 -49
  79. data/installer/unix-like/create_texts.rb +71 -123
  80. data/installer/unix-like/post_install.sh +3 -0
  81. data/installer/unix-like/post_uninstall.sh +2 -0
  82. data/installer/unix-like/pre_install.sh +5 -3
  83. data/installer/unix-like/pre_uninstall.sh +14 -6
  84. data/installer/unix-like/rho_connect_install_checkers.rb +1 -1
  85. data/installer/unix-like/rho_connect_install_constants.rb +6 -10
  86. data/installer/unix-like/rho_connect_install_debian.rb +2 -2
  87. data/installer/unix-like/rho_connect_install_dnd.rb +2 -5
  88. data/installer/unix-like/rho_connect_install_installers.rb +15 -23
  89. data/installer/unix-like/rho_connect_install_yum.rb +2 -2
  90. data/installer/utils/constants.rb +4 -4
  91. data/installer/utils/create_sha1.rb +1 -1
  92. data/installer/utils/nix_install_test.rb +32 -31
  93. data/installer/utils/nix_installation.rake +1 -1
  94. data/installer/utils/package_upload/repos.rake +34 -30
  95. data/installer/utils/package_upload/s3_upload.rb +3 -3
  96. data/lib/rhoconnect/api/source/fast_delete.rb +10 -0
  97. data/lib/rhoconnect/api/source/fast_insert.rb +10 -0
  98. data/lib/rhoconnect/api/source/fast_update.rb +10 -0
  99. data/lib/rhoconnect/api/source/get_source_params.rb +1 -1
  100. data/lib/rhoconnect/api/source/list_sources.rb +2 -2
  101. data/lib/rhoconnect/api/source/save_adapter.rb +1 -1
  102. data/lib/rhoconnect/api/source/update_source_params.rb +6 -0
  103. data/lib/rhoconnect/async.rb +82 -0
  104. data/lib/rhoconnect/bulk_data/bulk_data.rb +5 -1
  105. data/lib/rhoconnect/client_sync.rb +18 -3
  106. data/lib/rhoconnect/console/rhoconnect_api.rb +2 -2
  107. data/lib/rhoconnect/console/server.rb +5 -32
  108. data/lib/rhoconnect/console.rb +2 -2
  109. data/lib/rhoconnect/graph_helper.rb +225 -0
  110. data/lib/rhoconnect/jobs/bulk_data_job.rb +24 -2
  111. data/lib/rhoconnect/server.rb +31 -11
  112. data/lib/rhoconnect/source.rb +10 -5
  113. data/lib/rhoconnect/source_sync.rb +32 -2
  114. data/lib/rhoconnect/tasks.rb +19 -108
  115. data/lib/rhoconnect/test_methods.rb +20 -0
  116. data/lib/rhoconnect/utilities.rb +118 -0
  117. data/lib/rhoconnect/version.rb +1 -1
  118. data/lib/rhoconnect/web-console/controllers/admins.js +245 -0
  119. data/lib/rhoconnect/web-console/models/adapter.js +53 -0
  120. data/lib/rhoconnect/web-console/models/client.js +105 -0
  121. data/lib/rhoconnect/web-console/models/doc.js +113 -0
  122. data/lib/rhoconnect/web-console/models/session.js +40 -0
  123. data/lib/rhoconnect/web-console/models/source.js +115 -0
  124. data/lib/rhoconnect/web-console/models/stats.js +84 -0
  125. data/lib/rhoconnect/web-console/models/user.js +111 -0
  126. data/lib/rhoconnect/web-console/public/backbone.js +1432 -0
  127. data/lib/rhoconnect/web-console/public/bootstrap.css +3990 -0
  128. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/excanvas.min.js +0 -0
  129. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.barRenderer.min.js +0 -0
  130. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasAxisLabelRenderer.js +0 -0
  131. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasAxisTickRenderer.js +0 -0
  132. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasTextRenderer.js +0 -0
  133. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.categoryAxisRenderer.min.js +0 -0
  134. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.cursor.js +0 -0
  135. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.dateAxisRenderer.js +0 -0
  136. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.dateAxisRenderer.min.js +0 -0
  137. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.pointLabels.min.js +0 -0
  138. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery-1.4.2.min.js +0 -0
  139. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery.jqplot.min.css +0 -0
  140. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery.jqplot.min.js +0 -0
  141. data/lib/rhoconnect/web-console/public/jquery-1.7.1.min.js +154 -0
  142. data/lib/rhoconnect/web-console/public/rhoconnect-web.js +15 -0
  143. data/lib/rhoconnect/web-console/public/underscore.js +999 -0
  144. data/lib/rhoconnect/web-console/server.rb +55 -0
  145. data/lib/rhoconnect/web-console/templates/index.erb +90 -0
  146. data/lib/rhoconnect/web-console/templates/jqplot.erb +60 -0
  147. data/lib/rhoconnect/web-console/views/api_token.js +16 -0
  148. data/lib/rhoconnect/web-console/views/doc.js +63 -0
  149. data/lib/rhoconnect/web-console/views/edit_user.js +43 -0
  150. data/lib/rhoconnect/web-console/views/home.js +56 -0
  151. data/lib/rhoconnect/web-console/views/index.js +63 -0
  152. data/lib/rhoconnect/web-console/views/new_ping.js +58 -0
  153. data/lib/rhoconnect/web-console/views/new_user.js +29 -0
  154. data/lib/rhoconnect/web-console/views/server_doc.js +103 -0
  155. data/lib/rhoconnect/web-console/views/set_adapter.js +38 -0
  156. data/lib/rhoconnect/web-console/views/settings.js +53 -0
  157. data/lib/rhoconnect/web-console/views/show_device.js +56 -0
  158. data/lib/rhoconnect/web-console/views/show_user.js +38 -0
  159. data/lib/rhoconnect/web-console/views/source_docs.js +30 -0
  160. data/lib/rhoconnect/web-console/views/stats.js +69 -0
  161. data/lib/rhoconnect/web-console/views/users.js +20 -0
  162. data/lib/rhoconnect.rb +2 -1
  163. data/rhoconnect.gemspec +3 -1
  164. data/spec/api/application/rhoconnect_api_spec.rb +3 -5
  165. data/spec/api/source/fast_delete_spec.rb +27 -0
  166. data/spec/api/source/fast_insert_spec.rb +28 -0
  167. data/spec/api/source/fast_update_spec.rb +51 -0
  168. data/spec/api/source/get_source_params_spec.rb +1 -0
  169. data/spec/api/source/update_source_params_spec.rb +24 -0
  170. data/spec/async_spec.rb +19 -0
  171. data/spec/client_sync_spec.rb +19 -2
  172. data/spec/javascripts/PlayerSpec.js +58 -0
  173. data/spec/javascripts/admins_routes_spec.js +117 -0
  174. data/spec/javascripts/admins_spec.js +27 -0
  175. data/spec/javascripts/doc_view_spec.js +37 -0
  176. data/spec/javascripts/edit_user_view_spec.js +44 -0
  177. data/spec/javascripts/helpers/SpecHelper.js +9 -0
  178. data/spec/javascripts/helpers/jasmine-jquery.js +305 -0
  179. data/spec/javascripts/helpers/jasmine-sinon.js +43 -0
  180. data/spec/javascripts/helpers/sinon-1.3.2.js +3551 -0
  181. data/spec/javascripts/home_view_spec.js +39 -0
  182. data/spec/javascripts/index_view_spec.js +42 -0
  183. data/spec/javascripts/new_ping_view_spec.js +48 -0
  184. data/spec/javascripts/new_user_view_spec.js +42 -0
  185. data/spec/javascripts/server_doc_view_spec.js +39 -0
  186. data/spec/javascripts/set_adapter_view_spec.js +32 -0
  187. data/spec/javascripts/show_device_view_spec.js +41 -0
  188. data/spec/javascripts/show_user_view_spec.js +46 -0
  189. data/spec/javascripts/source_docs_view_spec.js +36 -0
  190. data/spec/javascripts/support/jasmine.yml +79 -0
  191. data/spec/javascripts/support/jasmine_config.rb +23 -0
  192. data/spec/javascripts/support/jasmine_runner.rb +32 -0
  193. data/spec/javascripts/users_view_spec.js +35 -0
  194. data/spec/jobs/bulk_data_job_spec.rb +10 -2
  195. data/spec/perf/bulk_data_perf_spec.rb +1 -0
  196. data/spec/server/server_spec.rb +3 -1
  197. data/spec/source_sync_spec.rb +14 -1
  198. data/spec/spec_helper.rb +51 -0
  199. data/spec/store_spec.rb +6 -0
  200. data/spec/test_methods_spec.rb +11 -0
  201. data/tasks/redis.rake +3 -1
  202. metadata +172 -64
  203. data/doc/contributing.txt +0 -60
  204. data/lib/rhoconnect/console/app/helpers/auth_helper.rb +0 -22
  205. data/lib/rhoconnect/console/app/helpers/extensions.rb +0 -19
  206. data/lib/rhoconnect/console/app/helpers/helpers.rb +0 -57
  207. data/lib/rhoconnect/console/app/public/ThickBox.css +0 -649
  208. data/lib/rhoconnect/console/app/public/home.css +0 -431
  209. data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
  210. data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
  211. data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
  212. data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
  213. data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
  214. data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
  215. data/lib/rhoconnect/console/app/public/main.css +0 -7
  216. data/lib/rhoconnect/console/app/public/reset.css +0 -76
  217. data/lib/rhoconnect/console/app/public/style.css +0 -2201
  218. data/lib/rhoconnect/console/app/public/text.txt +0 -0
  219. data/lib/rhoconnect/console/app/routes/adapter.rb +0 -28
  220. data/lib/rhoconnect/console/app/routes/auth.rb +0 -29
  221. data/lib/rhoconnect/console/app/routes/client.rb +0 -31
  222. data/lib/rhoconnect/console/app/routes/docs.rb +0 -145
  223. data/lib/rhoconnect/console/app/routes/heroku.rb +0 -19
  224. data/lib/rhoconnect/console/app/routes/home.rb +0 -63
  225. data/lib/rhoconnect/console/app/routes/timing.rb +0 -242
  226. data/lib/rhoconnect/console/app/routes/user.rb +0 -122
  227. data/lib/rhoconnect/console/app/views/adapter.erb +0 -16
  228. data/lib/rhoconnect/console/app/views/client.erb +0 -30
  229. data/lib/rhoconnect/console/app/views/content.erb +0 -14
  230. data/lib/rhoconnect/console/app/views/doc.erb +0 -8
  231. data/lib/rhoconnect/console/app/views/docdata.erb +0 -28
  232. data/lib/rhoconnect/console/app/views/docs.erb +0 -30
  233. data/lib/rhoconnect/console/app/views/edituser.erb +0 -13
  234. data/lib/rhoconnect/console/app/views/headermenu.erb +0 -40
  235. data/lib/rhoconnect/console/app/views/home.erb +0 -24
  236. data/lib/rhoconnect/console/app/views/index.erb +0 -58
  237. data/lib/rhoconnect/console/app/views/jqplot.erb +0 -52
  238. data/lib/rhoconnect/console/app/views/layout.erb +0 -153
  239. data/lib/rhoconnect/console/app/views/login.erb +0 -26
  240. data/lib/rhoconnect/console/app/views/newuser.erb +0 -17
  241. data/lib/rhoconnect/console/app/views/ping.erb +0 -40
  242. data/lib/rhoconnect/console/app/views/result.erb +0 -11
  243. data/lib/rhoconnect/console/app/views/rightboxlinks.erb +0 -15
  244. data/lib/rhoconnect/console/app/views/select_doc.erb +0 -17
  245. data/lib/rhoconnect/console/app/views/upload_doc.erb +0 -23
  246. data/lib/rhoconnect/console/app/views/user.erb +0 -29
  247. data/lib/rhoconnect/console/app/views/users.erb +0 -19
  248. data/lib/rhoconnect/server/views/index.erb +0 -13
@@ -0,0 +1,39 @@
1
+ describe("Home", function(){
2
+
3
+ beforeEach(function(){
4
+ var session = new Session();
5
+ session.setAuthenticated('true');
6
+ session.setApiKey('testtoken');
7
+ source = new Source();
8
+
9
+ sinon.stub(source,'fetch')
10
+ sinon.stub(source,'save');
11
+
12
+ this.homeView = new App.Views.Home({model : source});
13
+ });
14
+
15
+ afterEach(function(){
16
+ var session = new Session();
17
+ session.setAuthenticated('false');
18
+ session.setApiKey(null);
19
+ });
20
+
21
+ it("should have render initial html",function(){
22
+ this.indexRenderSpy = sinon.spy(this.homeView,'render');
23
+
24
+ this.homeView.render();
25
+ expect(this.indexRenderSpy).toHaveBeenCalledOnce();
26
+ });
27
+
28
+ it("should have correct html rendered ",function(){
29
+ var title = this.homeView.el.innerHTML.search('Home');
30
+ expect(title).toBeGreaterThan(0);
31
+
32
+ var change_btn = this.homeView.el.innerHTML.search('Change Admin Password');
33
+ expect(change_btn).toBeGreaterThan(0);
34
+
35
+ var reset = this.homeView.el.innerHTML.search('Reset');
36
+ expect(reset).toBeGreaterThan(0);
37
+
38
+ })
39
+ });
@@ -0,0 +1,42 @@
1
+ describe("Index", function(){
2
+
3
+ beforeEach(function(){
4
+ this.indexView = new App.Views.Index;
5
+ });
6
+
7
+ afterEach(function(){
8
+ var session = new Session();
9
+ session.setAuthenticated('false');
10
+ session.setApiKey(null);
11
+ })
12
+
13
+ it("should have render initial html",function(){
14
+ this.indexRenderSpy = sinon.spy(this.indexView,'render');
15
+ this.indexView.render();
16
+ expect(this.indexRenderSpy).toHaveBeenCalledOnce();
17
+ });
18
+
19
+ it("should call login and set auth",function(){
20
+ this.indexLoginSpy = sinon.spy(this.indexView,'login')
21
+ var stub = sinon.stub(jQuery,'ajax').yieldsTo("success","testtoken");
22
+ function myevent(){
23
+ this.preventDefault=function(){return true;}
24
+ }
25
+ e = new myevent();
26
+ this.indexView.login(e);
27
+
28
+ var session = new Session();
29
+ expect(session.getAuthenticated()).toEqual('true')
30
+ expect(session.getApiKey()).toEqual('testtoken')
31
+ jQuery.ajax.restore();
32
+ });
33
+
34
+ it("should have correct html rendered",function(){
35
+ var login = this.indexView.el.innerHTML.search('Login');
36
+ expect(login).toBeGreaterThan(0);
37
+
38
+ var password = this.indexView.el.innerHTML.search('Password');
39
+ expect(password).toBeGreaterThan(0);
40
+ })
41
+
42
+ });
@@ -0,0 +1,48 @@
1
+ describe("NewPingView", function(){
2
+
3
+ beforeEach(function(){
4
+ var session = new Session();
5
+ session.setAuthenticated('true');
6
+ session.setApiKey('testtoken');
7
+ });
8
+
9
+ afterEach(function(){
10
+ var session = new Session();
11
+ session.setAuthenticated('false');
12
+ session.setApiKey(null);
13
+ });
14
+
15
+ it("should have render initial html with name",function(){
16
+ sinon.stub(jQuery,'ajax');
17
+
18
+ var user = new User();
19
+ user.set('name','testname');
20
+ this.newPingView = new App.Views.NewPing({model : user});
21
+ this.PingRenderSpy = sinon.spy(this.newPingView,'render');
22
+ this.newPingView.render();
23
+ expect(this.PingRenderSpy).toHaveBeenCalledOnce();
24
+ jQuery.ajax.restore();
25
+ });
26
+
27
+ it("should have render initial html with no name",function(){
28
+ sinon.stub(jQuery,'ajax');
29
+ var user = new User();
30
+ sinon.stub(user,'get_users');
31
+ this.newPingView = new App.Views.NewPing({model : user});
32
+ this.PingRenderSpy = sinon.spy(this.newPingView,'render');
33
+ this.newPingView.render();
34
+ expect(this.PingRenderSpy).toHaveBeenCalledOnce();
35
+
36
+ user.get_users.restore();
37
+ jQuery.ajax.restore();
38
+ });
39
+
40
+ it("should have correct html rendered ",function(){
41
+ sinon.stub(jQuery,'ajax');
42
+ var user = new User();
43
+ this.newPingView = new App.Views.NewPing({model : user});
44
+ var title = this.newPingView.el.innerHTML.search('Ping User/s');
45
+ expect(title).toBeGreaterThan(0);
46
+ jQuery.ajax.restore();
47
+ })
48
+ });
@@ -0,0 +1,42 @@
1
+ describe("NewUserView", function(){
2
+
3
+ beforeEach(function(){
4
+ var session = new Session();
5
+ session.setAuthenticated('true');
6
+ session.setApiKey('testtoken');
7
+ user = new User();
8
+
9
+ sinon.stub(user,'create_user')
10
+
11
+ this.newUserView = new App.Views.NewUser({model : user});
12
+ });
13
+
14
+ afterEach(function(){
15
+ var session = new Session();
16
+ session.setAuthenticated('false');
17
+ session.setApiKey(null);
18
+ user.create_user.restore()
19
+ });
20
+
21
+ it("should have render initial html",function(){
22
+ this.newUserRenderSpy = sinon.spy(this.newUserView,'render');
23
+
24
+ this.newUserView.render();
25
+ expect(this.newUserRenderSpy).toHaveBeenCalledOnce();
26
+ });
27
+
28
+ it("should call create user",function(){
29
+ this.createUserRenderSpy = sinon.spy(this.newUserView,'create_user');
30
+ function myevent(){
31
+ this.preventDefault=function(){return true;}
32
+ }
33
+ e = new myevent();
34
+ this.newUserView.create_user(e);
35
+ expect(this.createUserRenderSpy).toHaveBeenCalledOnce();
36
+ });
37
+
38
+ it("should have correct html rendered ",function(){
39
+ var title = this.newUserView.el.innerHTML.search('New user');
40
+ expect(title).toBeGreaterThan(0);
41
+ })
42
+ });
@@ -0,0 +1,39 @@
1
+ describe("ServerDocView", function(){
2
+
3
+ beforeEach(function(){
4
+ var session = new Session();
5
+ session.setAuthenticated('true');
6
+ session.setApiKey('testtoken');
7
+ doc = new Doc();
8
+
9
+ sinon.stub(jQuery,'ajax')
10
+
11
+ this.serverDocView = new App.Views.ServerDoc({model : doc});
12
+ });
13
+
14
+ afterEach(function(){
15
+ var session = new Session();
16
+ session.setAuthenticated('false');
17
+ session.setApiKey(null);
18
+ jQuery.ajax.restore();
19
+ });
20
+
21
+ it("should have render initial html",function(){
22
+ this.serverDocRenderSpy = sinon.spy(this.serverDocView,'render');
23
+
24
+ this.serverDocView.render();
25
+ expect(this.serverDocRenderSpy).toHaveBeenCalledOnce();
26
+ });
27
+
28
+ it("should clear doc",function(){
29
+ this.serverDocClearSpy = sinon.spy(this.serverDocView,'clear');
30
+ doc.set('dbkey','testdbkey');
31
+ this.serverDocView.clear(e);
32
+ expect(this.serverDocClearSpy).toHaveBeenCalledOnce();
33
+ });
34
+
35
+ it("should have correct html rendered ",function(){
36
+ var title = this.serverDocView.el.innerHTML.search('Document ');
37
+ expect(title).toBeGreaterThan(0);
38
+ })
39
+ });
@@ -0,0 +1,32 @@
1
+ describe("SetAdapterView", function(){
2
+
3
+ beforeEach(function(){
4
+ var session = new Session();
5
+ session.setAuthenticated('true');
6
+ session.setApiKey('testtoken');
7
+ adapter = new Adapter();
8
+
9
+ sinon.stub(jQuery,'ajax')
10
+
11
+ this.setAdapterView = new App.Views.SetAdapter({model : adapter});
12
+ });
13
+
14
+ afterEach(function(){
15
+ var session = new Session();
16
+ session.setAuthenticated('false');
17
+ session.setApiKey(null);
18
+ jQuery.ajax.restore();
19
+ });
20
+
21
+ it("should have render initial html",function(){
22
+ this.setAdapterSpy = sinon.spy(this.setAdapterView,'render');
23
+
24
+ this.setAdapterView.render();
25
+ expect(this.setAdapterSpy).toHaveBeenCalledOnce();
26
+ });
27
+
28
+ it("should have correct html rendered ",function(){
29
+ var title = this.setAdapterView.el.innerHTML.search('Set Backend App URL');
30
+ expect(title).toBeGreaterThan(0);
31
+ })
32
+ });
@@ -0,0 +1,41 @@
1
+ describe("ShowDeviceView", function(){
2
+
3
+ beforeEach(function(){
4
+ var session = new Session();
5
+ session.setAuthenticated('true');
6
+ session.setApiKey('testtoken');
7
+ client = new Client();
8
+ client.set('device_id', 'testdeviceid');
9
+ client.set('user_id', 'user_id');
10
+
11
+ sinon.stub(jQuery,'ajax')
12
+
13
+ this.setdeviceView = new App.Views.ShowDevice({model : client});
14
+ });
15
+
16
+ afterEach(function(){
17
+ var session = new Session();
18
+ session.setAuthenticated('false');
19
+ session.setApiKey(null);
20
+ jQuery.ajax.restore();
21
+ });
22
+
23
+ it("should have render initial html",function(){
24
+ this.setDeviceSpy = sinon.spy(this.setdeviceView,'render');
25
+
26
+ this.setdeviceView.render();
27
+ expect(this.setDeviceSpy).toHaveBeenCalledOnce();
28
+ });
29
+
30
+ it("should delete device",function(){
31
+ this.setDeviceDeleteSpy = sinon.spy(this.setdeviceView,'delete_device');
32
+
33
+ this.setdeviceView.delete_device();
34
+ expect(this.setDeviceDeleteSpy).toHaveBeenCalledOnce();
35
+ });
36
+
37
+ it("should have correct html rendered ",function(){
38
+ var title = this.setdeviceView.el.innerHTML.search("Device: testdeviceid");
39
+ expect(title).toBeGreaterThan(0);
40
+ })
41
+ });
@@ -0,0 +1,46 @@
1
+ describe("ShowUserView", function(){
2
+
3
+ beforeEach(function(){
4
+ var session = new Session();
5
+ session.setAuthenticated('true');
6
+ session.setApiKey('testtoken');
7
+ user = new User();
8
+ user.set('name','testname');
9
+ source = new Source();
10
+
11
+ sinon.stub(jQuery,'ajax')
12
+ sinon.stub(source,'fetch')
13
+
14
+ this.showUserView = new App.Views.ShowUser({model : user});
15
+ });
16
+
17
+ afterEach(function(){
18
+ var session = new Session();
19
+ session.setAuthenticated('false');
20
+ session.setApiKey(null);
21
+ jQuery.ajax.restore();
22
+ });
23
+
24
+ it("should have render initial html",function(){
25
+ this.showUserSpy = sinon.spy(this.showUserView,'render');
26
+
27
+ this.showUserView.render();
28
+ expect(this.showUserSpy).toHaveBeenCalledOnce();
29
+ });
30
+
31
+ it("should delete user",function(){
32
+ this.deleteUserDeleteSpy = sinon.spy(this.showUserView,'delete_user');
33
+ function myevent(){
34
+ this.preventDefault=function(){return true;}
35
+ }
36
+ e = new myevent();
37
+
38
+ this.showUserView.delete_user(e);
39
+ expect(this.deleteUserDeleteSpy).toHaveBeenCalledOnce();
40
+ });
41
+
42
+ it("should have correct html rendered ",function(){
43
+ var title = this.showUserView.el.innerHTML.search("User: testname");
44
+ expect(title).toBeGreaterThan(0);
45
+ })
46
+ });
@@ -0,0 +1,36 @@
1
+ describe("SourceDocsView", function(){
2
+
3
+ beforeEach(function(){
4
+ var session = new Session();
5
+ session.setAuthenticated('true');
6
+ session.setApiKey('testtoken');
7
+ source = new Source();
8
+ source.set("source_id",'source_id');
9
+
10
+ sinon.stub(jQuery,'ajax')
11
+
12
+ this.sourceDocsView = new App.Views.SourceDocs({model : source});
13
+ });
14
+
15
+ afterEach(function(){
16
+ var session = new Session();
17
+ session.setAuthenticated('false');
18
+ session.setApiKey(null);
19
+ jQuery.ajax.restore();
20
+ });
21
+
22
+ it("should have render initial html",function(){
23
+ this.sourceDocsSpy = sinon.spy(this.sourceDocsView,'render');
24
+
25
+ this.sourceDocsView.render('source_id');
26
+ expect(this.sourceDocsSpy).toHaveBeenCalledOnce();
27
+ });
28
+
29
+ it("should have correct html rendered ",function(){
30
+ var title = this.sourceDocsView.el.innerHTML.search("Source attributes");
31
+ expect(title).toBeGreaterThan(0);
32
+
33
+ var title2 = this.sourceDocsView.el.innerHTML.search("Documents for app partition");
34
+ expect(title2).toBeGreaterThan(0);
35
+ })
36
+ });
@@ -0,0 +1,79 @@
1
+ # src_files
2
+ #
3
+ # Return an array of filepaths relative to src_dir to include before jasmine specs.
4
+ # Default: []
5
+ #
6
+ # EXAMPLE:
7
+ #
8
+ # src_files:
9
+ # - lib/source1.js
10
+ # - lib/source2.js
11
+ # - dist/**/*.js
12
+ #
13
+ src_files:
14
+ # - lib/rhoconnect/web-console/**/*.js
15
+ - lib/rhoconnect/web-console/public/jquery-1.7.1.min.js
16
+ - lib/rhoconnect/web-console/public/underscore.js
17
+ - lib/rhoconnect/web-console/public/backbone.js
18
+ - lib/rhoconnect/web-console/public/rhoconnect-web.js
19
+ - lib/rhoconnect/web-console/models/*.js
20
+ - lib/rhoconnect/web-console/controllers/*.js
21
+ - lib/rhoconnect/web-console/views/*.js
22
+ # stylesheets
23
+ #
24
+ # Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
25
+ # Default: []
26
+ #
27
+ # EXAMPLE:
28
+ #
29
+ # stylesheets:
30
+ # - css/style.css
31
+ # - stylesheets/*.css
32
+ #
33
+ stylesheets:
34
+ - lib/rhoconnect/web-console/**/*.css
35
+ # helpers
36
+ #
37
+ # Return an array of filepaths relative to spec_dir to include before jasmine specs.
38
+ # Default: ["helpers/**/*.js"]
39
+ #
40
+ # EXAMPLE:
41
+ #
42
+ # helpers:
43
+ # - helpers/**/*.js
44
+ #
45
+ helpers:
46
+
47
+ # spec_files
48
+ #
49
+ # Return an array of filepaths relative to spec_dir to include.
50
+ # Default: ["**/*[sS]pec.js"]
51
+ #
52
+ # EXAMPLE:
53
+ #
54
+ # spec_files:
55
+ # - **/*[sS]pec.js
56
+ #
57
+ spec_files:
58
+
59
+ # src_dir
60
+ #
61
+ # Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
62
+ # Default: project root
63
+ #
64
+ # EXAMPLE:
65
+ #
66
+ # src_dir: public
67
+ #
68
+ src_dir:
69
+
70
+ # spec_dir
71
+ #
72
+ # Spec directory path. Your spec_files must be returned relative to this path.
73
+ # Default: spec/javascripts
74
+ #
75
+ # EXAMPLE:
76
+ #
77
+ # spec_dir: spec/javascripts
78
+ #
79
+ spec_dir:
@@ -0,0 +1,23 @@
1
+ module Jasmine
2
+ class Config
3
+
4
+ # Add your overrides or custom config code here
5
+
6
+ end
7
+ end
8
+
9
+
10
+ # Note - this is necessary for rspec2, which has removed the backtrace
11
+ module Jasmine
12
+ class SpecBuilder
13
+ def declare_spec(parent, spec)
14
+ me = self
15
+ example_name = spec["name"]
16
+ @spec_ids << spec["id"]
17
+ backtrace = @example_locations[parent.description + " " + example_name]
18
+ parent.it example_name, {} do
19
+ me.report_spec(spec["id"])
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,32 @@
1
+ $:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
2
+
3
+ require 'rubygems'
4
+ require 'jasmine'
5
+ jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
6
+ require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
7
+ if Jasmine::Dependencies.rspec2?
8
+ require 'rspec'
9
+ else
10
+ require 'spec'
11
+ end
12
+
13
+ jasmine_config = Jasmine::Config.new
14
+ spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
15
+
16
+ should_stop = false
17
+
18
+ if Jasmine::Dependencies.rspec2?
19
+ RSpec.configuration.after(:suite) do
20
+ spec_builder.stop if should_stop
21
+ end
22
+ else
23
+ Spec::Runner.configure do |config|
24
+ config.after(:suite) do
25
+ spec_builder.stop if should_stop
26
+ end
27
+ end
28
+ end
29
+
30
+ spec_builder.start
31
+ should_stop = true
32
+ spec_builder.declare_suites
@@ -0,0 +1,35 @@
1
+ describe("UsersView", function(){
2
+
3
+ beforeEach(function(){
4
+ var session = new Session();
5
+ session.setAuthenticated('true');
6
+ session.setApiKey('testtoken');
7
+ users = new User();
8
+
9
+ sinon.stub(jQuery,'ajax')
10
+
11
+ this.usersView = new App.Views.Users({model : users});
12
+ });
13
+
14
+ afterEach(function(){
15
+ var session = new Session();
16
+ session.setAuthenticated('false');
17
+ session.setApiKey(null);
18
+ jQuery.ajax.restore();
19
+ });
20
+
21
+ it("should have render initial html",function(){
22
+ this.usersDocsSpy = sinon.spy(this.usersView,'render');
23
+
24
+ this.usersView.render('source_id');
25
+ expect(this.usersDocsSpy).toHaveBeenCalledOnce();
26
+ });
27
+
28
+ it("should have correct html rendered ",function(){
29
+ var title = this.usersView.el.innerHTML.search("Users");
30
+ expect(title).toBeGreaterThan(0);
31
+
32
+ var title2 = this.usersView.el.innerHTML.search("Create User");
33
+ expect(title2).toBeGreaterThan(0);
34
+ })
35
+ });
@@ -24,6 +24,7 @@ describe "BulkDataJob" do
24
24
  :user_id => @u.id,
25
25
  :sources => [@s_fields[:name], 'FixedSchemaAdapter'])
26
26
  BulkDataJob.perform("data_name" => data.name)
27
+ BulkDataJob.after_perform_x("data_name" => data.name)
27
28
  data = BulkData.load(docname)
28
29
  data.completed?.should == true
29
30
  verify_result(@s.docname(:md) => @data,@s.docname(:md_copy) => @data)
@@ -51,6 +52,7 @@ describe "BulkDataJob" do
51
52
  :user_id => @u.id,
52
53
  :sources => [@s_fields[:name]])
53
54
  BulkDataJob.perform("data_name" => data.name)
55
+ BulkDataJob.after_perform_x("data_name" => data.name)
54
56
  data = BulkData.load(docname)
55
57
  data.completed?.should == true
56
58
  verify_result(@s.docname(:md) => @data,@s.docname(:md_copy) => @data)
@@ -69,6 +71,7 @@ describe "BulkDataJob" do
69
71
  :user_id => @u.id,
70
72
  :sources => [@s_fields[:name]])
71
73
  BulkDataJob.perform("data_name" => data.name)
74
+ BulkDataJob.after_perform_x("data_name" => data.name)
72
75
  data = BulkData.load(docname)
73
76
  data.completed?.should == true
74
77
  verify_result(@s.docname(:md) => @data,
@@ -88,6 +91,7 @@ describe "BulkDataJob" do
88
91
  :user_id => @u.id,
89
92
  :sources => [@s_fields[:name]])
90
93
  BulkDataJob.perform("data_name" => data.name)
94
+ BulkDataJob.after_perform_x("data_name" => data.name)
91
95
  data = BulkData.load(docname)
92
96
  data.completed?.should == true
93
97
  verify_result(@s.docname(:md) => @data, @s.docname(:md_copy) => @data)
@@ -107,7 +111,9 @@ describe "BulkDataJob" do
107
111
  end
108
112
 
109
113
  it "should delete bulk data if exception is raised" do
110
- lambda { BulkDataJob.perform("data_name" => 'broken') }.should raise_error(Exception)
114
+ lambda {
115
+ BulkDataJob.perform("data_name" => 'broken')
116
+ BulkDataJob.after_perform_x("data_name" => data.name) }.should raise_error(Exception)
111
117
  Store.db.keys('bulk_data*').should == []
112
118
  end
113
119
 
@@ -117,7 +123,9 @@ describe "BulkDataJob" do
117
123
  :app_id => 'broken',
118
124
  :user_id => @u.id,
119
125
  :sources => [@s_fields[:name]])
120
- lambda { BulkDataJob.perform("data_name" => data.name) }.should raise_error(Exception)
126
+ lambda {
127
+ BulkDataJob.perform("data_name" => data.name)
128
+ BulkDataJob.after_perform_x("data_name" => data.name) }.should raise_error(Exception)
121
129
  Store.db.keys('bulk_data*').should == []
122
130
  end
123
131
  end
@@ -25,6 +25,7 @@ describe "BulkData Performance" do
25
25
  :user_id => @u.id,
26
26
  :sources => [@s_fields[:name]])
27
27
  BulkDataJob.perform("data_name" => data.name)
28
+ BulkDataJob.after_perform_x("data_name" => data.name)
28
29
  lap_timer('BulkDataJob.perform duration',start)
29
30
  end
30
31
  end
@@ -27,7 +27,7 @@ describe "Server" do
27
27
 
28
28
  it "should show status page" do
29
29
  get '/'
30
- last_response.body.match(Rhoconnect::VERSION)[0].should == Rhoconnect::VERSION
30
+ last_response.status.should == 302
31
31
  end
32
32
 
33
33
  it "should login if content-type contains extra parameters" do
@@ -427,6 +427,7 @@ describe "Server" do
427
427
  set_state('test_db_storage' => @data)
428
428
  get "/api/application/bulk_data", :partition => :user, :client_id => @c.id
429
429
  BulkDataJob.perform("data_name" => bulk_data_docname(@a.id,@u.id))
430
+ BulkDataJob.after_perform_x("data_name" => bulk_data_docname(@a.id,@u.id))
430
431
  get "/api/application/bulk_data", :partition => :user, :client_id => @c.id
431
432
  last_response.should be_ok
432
433
  data = BulkData.load(bulk_data_docname(@a.id,@u.id))
@@ -439,6 +440,7 @@ describe "Server" do
439
440
  set_state('test_db_storage' => @data)
440
441
  get "/api/application/bulk_data", :partition => :user, :client_id => @c.id
441
442
  BulkDataJob.perform("data_name" => bulk_data_docname(@a.id,@u.id))
443
+ BulkDataJob.after_perform_x("data_name" => bulk_data_docname(@a.id,@u.id))
442
444
  get "/api/application/bulk_data", :partition => :user, :client_id => @c.id
443
445
  get JSON.parse(last_response.body)["url"]
444
446
  last_response.should be_ok
@@ -82,7 +82,20 @@ describe "SourceSync" do
82
82
  @ss.process_query
83
83
  verify_result(@s.docname(:md) => expected)
84
84
  JSON.parse(Store.get_value(@s.docname(:schema))).should == mock_schema
85
- Store.get_value(@s.docname(:schema_sha1)) == get_sha1(mock_schema.to_json)
85
+ Store.get_value(@s.docname(:schema_sha1)).should == get_sha1(mock_schema['version'])
86
+ end
87
+ end
88
+
89
+ it "should raise exception if source adapter schema has no version key/value pair" do
90
+ mock_schema_no_version_method([SampleAdapter]) do
91
+ expected = {'1'=>@product1,'2'=>@product2}
92
+ set_state('test_db_storage' => expected)
93
+ @ss.process_query
94
+ errordoc = @s.docname(:errors)
95
+ errors = {}
96
+ Store.lock(errordoc) { errors = Store.get_data(errordoc) }
97
+ errors.empty?().should == false
98
+ errors["query-error"]["message"].should == "Mandatory version key is not defined in source adapter schema method"
86
99
  end
87
100
  end
88
101