rhoconnect 3.2.0.beta1 → 3.2.0.beta2

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 (61) hide show
  1. data/CHANGELOG.md +14 -0
  2. data/Gemfile +2 -1
  3. data/Gemfile.lock +33 -7
  4. data/README.md +4 -0
  5. data/Rakefile +13 -11
  6. data/commands/commands/rhoconnect/create_user.rb +1 -1
  7. data/commands/commands/rhoconnect/delete_device.rb +1 -1
  8. data/commands/commands/rhoconnect/delete_user.rb +1 -1
  9. data/commands/commands/rhoconnect/get_token.rb +1 -1
  10. data/commands/commands/rhoconnect/reset.rb +1 -1
  11. data/commands/execute.rb +0 -1
  12. data/doc/bulk-sync.txt +35 -1
  13. data/doc/install.txt +7 -3
  14. data/examples/simple/config.ru +1 -1
  15. data/generators/templates/application/Gemfile +1 -1
  16. data/install.sh +4 -4
  17. data/installer/unix-like/create_texts.rb +31 -31
  18. data/installer/unix-like/pre_uninstall.sh +2 -3
  19. data/installer/unix-like/rho_connect_install_constants.rb +3 -3
  20. data/installer/unix-like/rho_connect_install_debian.rb +0 -5
  21. data/installer/unix-like/rho_connect_install_yum.rb +1 -3
  22. data/installer/utils/constants.rb +4 -4
  23. data/installer/utils/nix_install_test.rb +20 -20
  24. data/installer/utils/package_upload/repos.rake +2 -2
  25. data/installer/utils/package_upload/s3_single_file.rb +57 -0
  26. data/lib/rhoconnect/client_sync.rb +1 -1
  27. data/lib/rhoconnect/jobs/bulk_data_job.rb +30 -32
  28. data/lib/rhoconnect/jobs/ping_job.rb +15 -2
  29. data/lib/rhoconnect/server.rb +3 -0
  30. data/lib/rhoconnect/tasks.rb +5 -7
  31. data/lib/rhoconnect/user.rb +1 -0
  32. data/lib/rhoconnect/version.rb +1 -1
  33. data/lib/rhoconnect/web-console/models/adapter.js +2 -0
  34. data/lib/rhoconnect/web-console/models/client.js +0 -22
  35. data/lib/rhoconnect/web-console/models/source.js +1 -1
  36. data/lib/rhoconnect/web-console/templates/index.erb +2 -1
  37. data/lib/rhoconnect/web-console/views/home.js +22 -1
  38. data/lib/rhoconnect/web-console/views/set_adapter.js +5 -6
  39. data/rhoconnect.gemspec +2 -1
  40. data/spec/api/source/fast_insert_spec.rb +1 -1
  41. data/spec/api/user/create_user_spec.rb +11 -1
  42. data/spec/client_sync_spec.rb +32 -25
  43. data/spec/javascripts/admins_routes_spec.js +108 -103
  44. data/spec/javascripts/doc_view_spec.js +2 -3
  45. data/spec/javascripts/edit_user_view_spec.js +1 -1
  46. data/spec/javascripts/home_view_spec.js +6 -6
  47. data/spec/javascripts/server_doc_view_spec.js +4 -0
  48. data/spec/javascripts/session_spec.js +15 -0
  49. data/spec/javascripts/set_adapter_view_spec.js +2 -6
  50. data/spec/javascripts/show_device_view_spec.js +4 -1
  51. data/spec/javascripts/show_user_view_spec.js +4 -0
  52. data/spec/javascripts/source_docs_view_spec.js +2 -2
  53. data/spec/jobs/bulk_data_job_spec.rb +8 -12
  54. data/spec/jobs/ping_job_spec.rb +21 -0
  55. data/spec/perf/bulk_data_perf_spec.rb +1 -2
  56. data/spec/server/server_spec.rb +2 -4
  57. data/spec/spec_helper.rb +13 -3
  58. data/tasks/jasmine.rake +7 -0
  59. metadata +24 -7
  60. data/lib/rhoconnect/console/rhoconnect_api.rb +0 -245
  61. data/spec/api/application/rhoconnect_api_spec.rb +0 -592
@@ -6,7 +6,7 @@ describe "ClientSync" do
6
6
  lambda { ClientSync.new(@s,nil,2) }.should raise_error(ArgumentError,'Unknown client')
7
7
  end
8
8
 
9
- it "should handle receive cud for dymanic adapter" do
9
+ it "should handle receive cud for dynamic adapter" do
10
10
  params = {'create'=>{'1'=>@product1}}
11
11
  @c.source_name = 'Product2'
12
12
  @cs1 = ClientSync.new(@s2,@c,2)
@@ -48,27 +48,39 @@ describe "ClientSync" do
48
48
  it "should handle receive cud" do
49
49
  params = {'create'=>{'1'=>@product1},'update'=>{'2'=>@product2},'delete'=>{'3'=>@product3}}
50
50
  @cs.receive_cud(params)
51
- verify_result(@cs.client.docname(:create) => {},
52
- @cs.client.docname(:update) => {},
53
- @cs.client.docname(:delete) => {})
51
+ verify_zresult(@s.docname(:create) => [],
52
+ @s.docname(:update) => [],
53
+ @s.docname(:delete) => [])
54
+ end
55
+
56
+ it "should handle receive cud that triggers processing of the previously queued data" do
57
+ queued_create_data = {'1'=>@product1}
58
+ set_zstate({@s.docname(:create) => queued_create_data}, @c.id)
59
+ verify_zresult(@s.docname(:create) => [queued_create_data],
60
+ @cs.client.docname(:update) => [],
61
+ @cs.client.docname(:delete) => [])
62
+ @cs.receive_cud({:source_name => @s_fields[:name]})
63
+ verify_zresult(@s.docname(:create) => [],
64
+ @s.docname(:update) => [],
65
+ @s.docname(:delete) => [])
54
66
  end
55
67
 
56
68
  it "should handle receive cud with pass through" do
57
69
  params = {'create'=>{'1'=>@product1},'update'=>{'2'=>@product2},'delete'=>{'3'=>@product3}}
58
70
  @s.pass_through = 'true'
59
71
  @cs.receive_cud(params)
60
- verify_result(@cs.client.docname(:create) => {},
61
- @cs.client.docname(:update) => {},
62
- @cs.client.docname(:delete) => {})
72
+ verify_zresult(@s.docname(:create) => [],
73
+ @s.docname(:update) => [],
74
+ @s.docname(:delete) => [])
63
75
  end
64
76
 
65
77
  it "should handle exeptions in receive cud with pass through" do
66
78
  params = {'create'=>{'1'=>@error},'update'=>{'2'=>@product2},'delete'=>{'3'=>@product3}}
67
79
  @s.pass_through = 'true'
68
80
  @cs.receive_cud(params)
69
- verify_result(@cs.client.docname(:create) => {},
70
- @cs.client.docname(:update) => {},
71
- @cs.client.docname(:delete) => {})
81
+ verify_zresult(@s.docname(:create) => [],
82
+ @s.docname(:update) => [],
83
+ @s.docname(:delete) => [])
72
84
  end
73
85
 
74
86
  it "should handle send cud" do
@@ -225,9 +237,10 @@ describe "ClientSync" do
225
237
  params = {'create'=>{'1'=>@product1},
226
238
  'update'=>{'2'=>@product2},'delete'=>{'3'=>@product3}}
227
239
  @cs.receive_cud(params)
228
- verify_result(@cs.client.docname(:create) => {},
229
- @cs.client.docname(:update) => {},
230
- @cs.client.docname(:delete) => {},
240
+ verify_zresult(@s.docname(:create) => [],
241
+ @s.docname(:update) => [],
242
+ @s.docname(:delete) => [])
243
+ verify_result(
231
244
  @s.docname(:md) => {},
232
245
  @c.docname(:cd) => {})
233
246
  end
@@ -698,8 +711,7 @@ describe "ClientSync" do
698
711
  it "should return bulk data url for completed bulk data user partition" do
699
712
  set_state('test_db_storage' => @data)
700
713
  ClientSync.bulk_data(:user,@c)
701
- BulkDataJob.perform("data_name" => bulk_data_docname(@a.id,@u.id))
702
- BulkDataJob.after_perform_x("data_name" => bulk_data_docname(@a.id,@u.id))
714
+ do_bulk_data_job("data_name" => bulk_data_docname(@a.id,@u.id))
703
715
  ClientSync.bulk_data(:user,@c).should == {:result => :url,
704
716
  :url => BulkData.load(bulk_data_docname(@a.id,@u.id)).url}
705
717
  verify_result(
@@ -710,8 +722,7 @@ describe "ClientSync" do
710
722
 
711
723
  it "should return empty bulk data url if there are errors in query" do
712
724
  ClientSync.bulk_data(:user,@c)
713
- BulkDataJob.perform("data_name" => bulk_data_docname(@a.id,@u.id))
714
- BulkDataJob.after_perform_x("data_name" => bulk_data_docname(@a.id,@u.id))
725
+ do_bulk_data_job("data_name" => bulk_data_docname(@a.id,@u.id))
715
726
  errordoc = @s.docname(:errors) # source SampleAdapter
716
727
  operation = 'query'
717
728
  Store.lock(errordoc) do
@@ -727,8 +738,7 @@ describe "ClientSync" do
727
738
  :app_id => @a.id,
728
739
  :user_id => name,
729
740
  :sources => [@s_fields[:name]])
730
- BulkDataJob.perform("data_name" => bulk_data_docname(@a.id,name))
731
- BulkDataJob.after_perform_x("data_name" => bulk_data_docname(@a.id,name))
741
+ do_bulk_data_job("data_name" => bulk_data_docname(@a.id,name))
732
742
  data = BulkData.load(bulk_data_docname(@a.id,name))
733
743
  data.url.should match /a%20b/
734
744
  data.delete
@@ -738,8 +748,7 @@ describe "ClientSync" do
738
748
  set_state('test_db_storage' => @data)
739
749
  @s.partition = :app
740
750
  ClientSync.bulk_data(:app,@c)
741
- BulkDataJob.perform("data_name" => bulk_data_docname(@a.id,"*"))
742
- BulkDataJob.after_perform_x("data_name" => bulk_data_docname(@a.id,"*"))
751
+ do_bulk_data_job("data_name" => bulk_data_docname(@a.id,"*"))
743
752
  ClientSync.bulk_data(:app,@c).should == {:result => :url,
744
753
  :url => BulkData.load(bulk_data_docname(@a.id,"*")).url}
745
754
  verify_result(
@@ -752,8 +761,7 @@ describe "ClientSync" do
752
761
  set_state('test_db_storage' => @data)
753
762
  @s.sync_type = :bulk_sync_only
754
763
  ClientSync.bulk_data(:user,@c)
755
- BulkDataJob.perform("data_name" => bulk_data_docname(@a.id,@u.id))
756
- BulkDataJob.after_perform_x("data_name" => bulk_data_docname(@a.id,@u.id))
764
+ do_bulk_data_job("data_name" => bulk_data_docname(@a.id,@u.id))
757
765
  ClientSync.bulk_data(:user,@c).should == {:result => :url,
758
766
  :url => BulkData.load(bulk_data_docname(@a.id,@u.id)).url}
759
767
  verify_result(
@@ -766,8 +774,7 @@ describe "ClientSync" do
766
774
  set_state('test_db_storage' => @data)
767
775
  Rhoconnect.blackberry_bulk_sync = true
768
776
  ClientSync.bulk_data(:user,@c)
769
- BulkDataJob.perform("data_name" => bulk_data_docname(@a.id,@u.id))
770
- BulkDataJob.after_perform_x("data_name" => bulk_data_docname(@a.id,@u.id))
777
+ do_bulk_data_job("data_name" => bulk_data_docname(@a.id,@u.id))
771
778
  data = BulkData.load(bulk_data_docname(@a.id,@u.id))
772
779
  ClientSync.bulk_data(:user,@c).should == {:result => :url, :url => data.url}
773
780
  File.delete(data.dbfile)
@@ -2,116 +2,121 @@ describe("Admins routes", function() {
2
2
  beforeEach(function() {
3
3
  this.router = new App.Controllers.Admins();
4
4
  this.routeSpy = sinon.spy();
5
+ sinon.stub(jQuery,'ajax')
5
6
  try {
6
7
  Backbone.History.start({silent:true, pushState:true});
7
8
  } catch(e) {}
8
9
  this.router.navigate("test");
9
10
  });
11
+
12
+ afterEach(function(){
13
+ jQuery.ajax.restore();
14
+ });
10
15
 
11
16
  it("fires the index route with a blank hash", function() {
12
- this.router.bind("route:index", this.routeSpy);
13
- this.router.navigate("", true);
14
- expect(this.routeSpy).toHaveBeenCalledOnce();
15
- expect(this.routeSpy).toHaveBeenCalledWith();
16
- });
17
+ this.router.bind("route:index", this.routeSpy);
18
+ this.router.navigate("", true);
19
+ expect(this.routeSpy).toHaveBeenCalledOnce();
20
+ expect(this.routeSpy).toHaveBeenCalledWith();
21
+ });
22
+
23
+ it("fires the home route with a blank hash", function() {
24
+ this.router.bind("route:index", this.routeSpy);
25
+ this.router.navigate("home", true);
26
+ expect(this.routeSpy).toHaveBeenCalledOnce();
27
+ expect(this.routeSpy).toHaveBeenCalledWith();
28
+ });
29
+
30
+ it("fires the show_source route", function() {
31
+ this.router.bind('route:show_source', this.routeSpy);
32
+ this.router.navigate("sources/1/tuser/tdoc/tclient", true);
33
+ expect(this.routeSpy).toHaveBeenCalledOnce();
34
+ expect(this.routeSpy).toHaveBeenCalledWith("1","tuser","tdoc","tclient");
35
+ });
17
36
 
18
- it("fires the home route with a blank hash", function() {
19
- this.router.bind("route:index", this.routeSpy);
20
- this.router.navigate("home", true);
21
- expect(this.routeSpy).toHaveBeenCalledOnce();
22
- expect(this.routeSpy).toHaveBeenCalledWith();
23
- });
24
-
25
- it("fires the show_source route", function() {
26
- this.router.bind('route:show_source', this.routeSpy);
27
- this.router.navigate("sources/1", true);
28
- expect(this.routeSpy).toHaveBeenCalledOnce();
29
- expect(this.routeSpy).toHaveBeenCalledWith("1");
30
- });
31
-
32
- it("fires the login route", function() {
33
- this.router.bind('route:login', this.routeSpy);
34
- this.router.navigate("login", true);
35
- expect(this.routeSpy).toHaveBeenCalledOnce();
36
- expect(this.routeSpy).toHaveBeenCalledWith();
37
- });
38
-
39
- it("fires the logout route", function() {
40
- this.router.bind('route:logout', this.routeSpy);
41
- this.router.navigate("logout", true);
42
- expect(this.routeSpy).toHaveBeenCalledOnce();
43
- expect(this.routeSpy).toHaveBeenCalledWith();
44
- });
45
-
46
- it("fires the get_doc route", function() {
47
- this.router.bind('route:get_doc', this.routeSpy);
48
- this.router.navigate("doc/testdoc/2", true);
49
- expect(this.routeSpy).toHaveBeenCalledOnce();
50
- expect(this.routeSpy).toHaveBeenCalledWith("testdoc","2");
51
- });
52
-
53
- it("fires the server_doc route", function() {
54
- this.router.bind('route:server_doc', this.routeSpy);
55
- this.router.navigate("docselect", true);
56
- expect(this.routeSpy).toHaveBeenCalledOnce();
57
- expect(this.routeSpy).toHaveBeenCalledWith();
58
- });
59
-
60
- it("fires the adapter route", function() {
61
- this.router.bind('route:adapter', this.routeSpy);
62
- this.router.navigate("adapter", true);
63
- expect(this.routeSpy).toHaveBeenCalledOnce();
64
- expect(this.routeSpy).toHaveBeenCalledWith();
65
- });
66
-
67
- it("fires the users route", function() {
68
- this.router.bind('route:users', this.routeSpy);
69
- this.router.navigate("users", true);
70
- expect(this.routeSpy).toHaveBeenCalledOnce();
71
- expect(this.routeSpy).toHaveBeenCalledWith();
72
- });
73
-
74
- it("fires the new_user route", function() {
75
- this.router.bind('route:new_user', this.routeSpy);
76
- this.router.navigate("users/new", true);
77
- expect(this.routeSpy).toHaveBeenCalledOnce();
78
- expect(this.routeSpy).toHaveBeenCalledWith();
79
- });
80
-
81
- it("fires the show_user route", function() {
82
- this.router.bind('route:show_user', this.routeSpy);
83
- this.router.navigate("user/1", true);
84
- expect(this.routeSpy).toHaveBeenCalledOnce();
85
- expect(this.routeSpy).toHaveBeenCalledWith("1");
86
- });
87
-
88
- it("fires the new_ping route", function() {
89
- this.router.bind('route:new_ping', this.routeSpy);
90
- this.router.navigate("user/newping/1", true);
91
- expect(this.routeSpy).toHaveBeenCalledOnce();
92
- expect(this.routeSpy).toHaveBeenCalledWith("1");
93
- });
94
-
95
- it("fires the new_ping_all route", function() {
96
- this.router.bind('route:new_ping_all', this.routeSpy);
97
- this.router.navigate("users/newping", true);
98
- expect(this.routeSpy).toHaveBeenCalledOnce();
99
- expect(this.routeSpy).toHaveBeenCalledWith();
100
- });
101
-
102
- it("fires the user_device route", function() {
103
- this.router.bind('route:user_device', this.routeSpy);
104
- this.router.navigate("device/1/2", true);
105
- expect(this.routeSpy).toHaveBeenCalledOnce();
106
- expect(this.routeSpy).toHaveBeenCalledWith("1","2");
107
- });
108
-
109
- it("fires the change_admin route", function() {
110
- this.router.bind('route:change_admin', this.routeSpy);
111
- this.router.navigate("change_admin", true);
112
- expect(this.routeSpy).toHaveBeenCalledOnce();
113
- expect(this.routeSpy).toHaveBeenCalledWith();
114
- });
115
-
37
+ it("fires the login route", function() {
38
+ this.router.bind('route:login', this.routeSpy);
39
+ this.router.navigate("login", true);
40
+ expect(this.routeSpy).toHaveBeenCalledOnce();
41
+ expect(this.routeSpy).toHaveBeenCalledWith();
42
+ });
43
+
44
+ it("fires the logout route", function() {
45
+ this.router.bind('route:logout', this.routeSpy);
46
+ this.router.navigate("logout", true);
47
+ expect(this.routeSpy).toHaveBeenCalledOnce();
48
+ expect(this.routeSpy).toHaveBeenCalledWith();
49
+ });
50
+
51
+ it("fires the get_doc route", function() {
52
+ this.router.bind('route:get_doc', this.routeSpy);
53
+ this.router.navigate("doc/testdoc/2", true);
54
+ expect(this.routeSpy).toHaveBeenCalledOnce();
55
+ expect(this.routeSpy).toHaveBeenCalledWith("testdoc","2");
56
+ });
57
+
58
+ it("fires the server_doc route", function() {
59
+ this.router.bind('route:server_doc', this.routeSpy);
60
+ this.router.navigate("docselect", true);
61
+ expect(this.routeSpy).toHaveBeenCalledOnce();
62
+ expect(this.routeSpy).toHaveBeenCalledWith();
63
+ });
64
+
65
+ it("fires the adapter route", function() {
66
+ this.router.bind('route:adapter', this.routeSpy);
67
+ this.router.navigate("adapter", true);
68
+ expect(this.routeSpy).toHaveBeenCalledOnce();
69
+ expect(this.routeSpy).toHaveBeenCalledWith();
70
+ });
71
+
72
+ it("fires the users route", function() {
73
+ this.router.bind('route:users', this.routeSpy);
74
+ this.router.navigate("users", true);
75
+ expect(this.routeSpy).toHaveBeenCalledOnce();
76
+ expect(this.routeSpy).toHaveBeenCalledWith();
77
+ });
78
+
79
+ it("fires the new_user route", function() {
80
+ this.router.bind('route:new_user', this.routeSpy);
81
+ this.router.navigate("users/new", true);
82
+ expect(this.routeSpy).toHaveBeenCalledOnce();
83
+ expect(this.routeSpy).toHaveBeenCalledWith();
84
+ });
85
+
86
+ it("fires the show_user route", function() {
87
+ this.router.bind('route:show_user', this.routeSpy);
88
+ this.router.navigate("user/1", true);
89
+ expect(this.routeSpy).toHaveBeenCalledOnce();
90
+ expect(this.routeSpy).toHaveBeenCalledWith("1");
91
+ });
92
+
93
+ it("fires the new_ping route", function() {
94
+ this.router.bind('route:new_ping', this.routeSpy);
95
+ this.router.navigate("user/newping/1", true);
96
+ expect(this.routeSpy).toHaveBeenCalledOnce();
97
+ expect(this.routeSpy).toHaveBeenCalledWith("1");
98
+ });
99
+
100
+ it("fires the new_ping_all route", function() {
101
+ this.router.bind('route:new_ping_all', this.routeSpy);
102
+ this.router.navigate("users/newping", true);
103
+ expect(this.routeSpy).toHaveBeenCalledOnce();
104
+ expect(this.routeSpy).toHaveBeenCalledWith();
105
+ });
106
+
107
+ it("fires the user_device route", function() {
108
+ this.router.bind('route:user_device', this.routeSpy);
109
+ this.router.navigate("device/1/2", true);
110
+ expect(this.routeSpy).toHaveBeenCalledOnce();
111
+ expect(this.routeSpy).toHaveBeenCalledWith("1","2");
112
+ });
113
+
114
+ it("fires the change_admin route", function() {
115
+ this.router.bind('route:change_admin', this.routeSpy);
116
+ this.router.navigate("change_admin", true);
117
+ expect(this.routeSpy).toHaveBeenCalledOnce();
118
+ expect(this.routeSpy).toHaveBeenCalledWith();
119
+ });
120
+
116
121
  });
117
122
 
@@ -27,11 +27,10 @@ describe("DocView", function(){
27
27
  });
28
28
 
29
29
  it("should have correct html rendered ",function(){
30
- var title = this.docView.el.innerHTML.search('[testkey]');
30
+ var title = this.docView.el.innerHTML.search('testkey');
31
31
  expect(title).toBeGreaterThan(0);
32
32
 
33
- var change_btn = this.docView.el.innerHTML.search('Upload Token string');
33
+ var change_btn = this.docView.el.innerHTML.search('Upload token string');
34
34
  expect(change_btn).toBeGreaterThan(0);
35
-
36
35
  })
37
36
  });
@@ -34,7 +34,7 @@ describe("EditUserView", function(){
34
34
  });
35
35
 
36
36
  it("should have correct html rendered ",function(){
37
- var title = this.editUserView.el.innerHTML.search('Edit admin');
37
+ var title = this.editUserView.el.innerHTML.search('Change Admin Password');
38
38
  expect(title).toBeGreaterThan(0);
39
39
 
40
40
  var password = this.editUserView.el.innerHTML.search('Password');
@@ -8,7 +8,9 @@ describe("Home", function(){
8
8
 
9
9
  sinon.stub(source,'fetch')
10
10
  sinon.stub(source,'save');
11
-
11
+ confirmStub = sinon.stub(window, 'confirm');
12
+ confirmStub.returns(true);
13
+
12
14
  this.homeView = new App.Views.Home({model : source});
13
15
  });
14
16
 
@@ -16,6 +18,7 @@ describe("Home", function(){
16
18
  var session = new Session();
17
19
  session.setAuthenticated('false');
18
20
  session.setApiKey(null);
21
+ confirmStub.restore();
19
22
  });
20
23
 
21
24
  it("should have render initial html",function(){
@@ -26,13 +29,10 @@ describe("Home", function(){
26
29
  });
27
30
 
28
31
  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');
32
+ var change_btn = this.homeView.el.innerHTML.search('App partition sources');
33
33
  expect(change_btn).toBeGreaterThan(0);
34
34
 
35
- var reset = this.homeView.el.innerHTML.search('Reset');
35
+ var reset = this.homeView.el.innerHTML.search('Sync Server URL');
36
36
  expect(reset).toBeGreaterThan(0);
37
37
 
38
38
  })
@@ -28,6 +28,10 @@ describe("ServerDocView", function(){
28
28
  it("should clear doc",function(){
29
29
  this.serverDocClearSpy = sinon.spy(this.serverDocView,'clear');
30
30
  doc.set('dbkey','testdbkey');
31
+ function myevent(){
32
+ this.preventDefault=function(){return true;}
33
+ }
34
+ e = new myevent();
31
35
  this.serverDocView.clear(e);
32
36
  expect(this.serverDocClearSpy).toHaveBeenCalledOnce();
33
37
  });
@@ -0,0 +1,15 @@
1
+ describe("Session", function(){
2
+ beforeEach(function(){
3
+ this.session = new Session;
4
+ });
5
+
6
+ it("should have set session key",function(){
7
+ this.session.setApiKey("testkey")
8
+ expect(this.session.getApiKey()).toEqual('testkey')
9
+ });
10
+
11
+ it("should have set authentication",function(){
12
+ this.session.setAuthenticated("true")
13
+ expect(this.session.getAuthenticated()).toEqual('true')
14
+ });
15
+ })
@@ -5,9 +5,9 @@ describe("SetAdapterView", function(){
5
5
  session.setAuthenticated('true');
6
6
  session.setApiKey('testtoken');
7
7
  adapter = new Adapter();
8
-
8
+
9
9
  sinon.stub(jQuery,'ajax')
10
-
10
+ var domain = 'http://test.com'
11
11
  this.setAdapterView = new App.Views.SetAdapter({model : adapter});
12
12
  });
13
13
 
@@ -25,8 +25,4 @@ describe("SetAdapterView", function(){
25
25
  expect(this.setAdapterSpy).toHaveBeenCalledOnce();
26
26
  });
27
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
28
  });
@@ -9,7 +9,9 @@ describe("ShowDeviceView", function(){
9
9
  client.set('user_id', 'user_id');
10
10
 
11
11
  sinon.stub(jQuery,'ajax')
12
-
12
+ confirmStub = sinon.stub(window, 'confirm');
13
+ confirmStub.returns(true);
14
+
13
15
  this.setdeviceView = new App.Views.ShowDevice({model : client});
14
16
  });
15
17
 
@@ -18,6 +20,7 @@ describe("ShowDeviceView", function(){
18
20
  session.setAuthenticated('false');
19
21
  session.setApiKey(null);
20
22
  jQuery.ajax.restore();
23
+ confirmStub.restore();
21
24
  });
22
25
 
23
26
  it("should have render initial html",function(){
@@ -11,6 +11,9 @@ describe("ShowUserView", function(){
11
11
  sinon.stub(jQuery,'ajax')
12
12
  sinon.stub(source,'fetch')
13
13
 
14
+ confirmStub = sinon.stub(window, 'confirm');
15
+ confirmStub.returns(true);
16
+
14
17
  this.showUserView = new App.Views.ShowUser({model : user});
15
18
  });
16
19
 
@@ -19,6 +22,7 @@ describe("ShowUserView", function(){
19
22
  session.setAuthenticated('false');
20
23
  session.setApiKey(null);
21
24
  jQuery.ajax.restore();
25
+ confirmStub.restore();
22
26
  });
23
27
 
24
28
  it("should have render initial html",function(){
@@ -27,10 +27,10 @@ describe("SourceDocsView", function(){
27
27
  });
28
28
 
29
29
  it("should have correct html rendered ",function(){
30
- var title = this.sourceDocsView.el.innerHTML.search("Source attributes");
30
+ var title = this.sourceDocsView.el.innerHTML.search("Attributes");
31
31
  expect(title).toBeGreaterThan(0);
32
32
 
33
- var title2 = this.sourceDocsView.el.innerHTML.search("Documents for app partition");
33
+ var title2 = this.sourceDocsView.el.innerHTML.search("Documents");
34
34
  expect(title2).toBeGreaterThan(0);
35
35
  })
36
36
  });
@@ -23,8 +23,7 @@ describe "BulkDataJob" do
23
23
  :app_id => @a.id,
24
24
  :user_id => @u.id,
25
25
  :sources => [@s_fields[:name], 'FixedSchemaAdapter'])
26
- BulkDataJob.perform("data_name" => data.name)
27
- BulkDataJob.after_perform_x("data_name" => data.name)
26
+ do_bulk_data_job("data_name" => data.name)
28
27
  data = BulkData.load(docname)
29
28
  data.completed?.should == true
30
29
  verify_result(@s.docname(:md) => @data,@s.docname(:md_copy) => @data)
@@ -51,8 +50,7 @@ describe "BulkDataJob" do
51
50
  :app_id => @a.id,
52
51
  :user_id => @u.id,
53
52
  :sources => [@s_fields[:name]])
54
- BulkDataJob.perform("data_name" => data.name)
55
- BulkDataJob.after_perform_x("data_name" => data.name)
53
+ do_bulk_data_job("data_name" => data.name)
56
54
  data = BulkData.load(docname)
57
55
  data.completed?.should == true
58
56
  verify_result(@s.docname(:md) => @data,@s.docname(:md_copy) => @data)
@@ -70,8 +68,7 @@ describe "BulkDataJob" do
70
68
  :app_id => @a.id,
71
69
  :user_id => @u.id,
72
70
  :sources => [@s_fields[:name]])
73
- BulkDataJob.perform("data_name" => data.name)
74
- BulkDataJob.after_perform_x("data_name" => data.name)
71
+ do_bulk_data_job("data_name" => data.name)
75
72
  data = BulkData.load(docname)
76
73
  data.completed?.should == true
77
74
  verify_result(@s.docname(:md) => @data,
@@ -90,8 +87,7 @@ describe "BulkDataJob" do
90
87
  :app_id => @a.id,
91
88
  :user_id => @u.id,
92
89
  :sources => [@s_fields[:name]])
93
- BulkDataJob.perform("data_name" => data.name)
94
- BulkDataJob.after_perform_x("data_name" => data.name)
90
+ do_bulk_data_job("data_name" => data.name)
95
91
  data = BulkData.load(docname)
96
92
  data.completed?.should == true
97
93
  verify_result(@s.docname(:md) => @data, @s.docname(:md_copy) => @data)
@@ -112,8 +108,8 @@ describe "BulkDataJob" do
112
108
 
113
109
  it "should delete bulk data if exception is raised" do
114
110
  lambda {
115
- BulkDataJob.perform("data_name" => 'broken')
116
- BulkDataJob.after_perform_x("data_name" => data.name) }.should raise_error(Exception)
111
+ do_bulk_data_job("data_name" => 'broken')
112
+ }.should raise_error(Exception)
117
113
  Store.db.keys('bulk_data*').should == []
118
114
  end
119
115
 
@@ -124,8 +120,8 @@ describe "BulkDataJob" do
124
120
  :user_id => @u.id,
125
121
  :sources => [@s_fields[:name]])
126
122
  lambda {
127
- BulkDataJob.perform("data_name" => data.name)
128
- BulkDataJob.after_perform_x("data_name" => data.name) }.should raise_error(Exception)
123
+ do_bulk_data_job("data_name" => data.name)
124
+ }.should raise_error(Exception)
129
125
  Store.db.keys('bulk_data*').should == []
130
126
  end
131
127
  end
@@ -154,5 +154,26 @@ describe "PingJob" do
154
154
  PingJob.should_receive(:log).once.with(/Dropping ping request for client/)
155
155
  lambda { PingJob.perform(params) }.should_not raise_error
156
156
  end
157
+
158
+ it "should process all pings even if some of them are failing" do
159
+ params = {"user_id" => [ @u.id, @u1.id], "api_token" => @api_token,
160
+ "sources" => [@s.name], "message" => 'hello world',
161
+ "vibrate" => '5', "badge" => '5', "sound" => 'hello.mp3', 'phone_id' => nil }
162
+ @c.phone_id = '3'
163
+
164
+ scrubbed_params = params.dup
165
+ scrubbed_params['vibrate'] = '5'
166
+ @c1.device_type = 'blackberry'
167
+
168
+ Apple.should_receive(:ping).with(params.merge!({'device_pin' => @c.device_pin, 'phone_id' => @c.phone_id, 'device_port' => @c.device_port})).and_return { raise SocketError.new("Socket failure") }
169
+ Blackberry.should_receive(:ping).with({'device_pin' => @c1.device_pin, 'device_port' => @c1.device_port}.merge!(scrubbed_params))
170
+ exception_raised = false
171
+ begin
172
+ PingJob.perform(params)
173
+ rescue Exception => e
174
+ exception_raised = true
175
+ end
176
+ exception_raised.should == true
177
+ end
157
178
  end
158
179
  end
@@ -24,8 +24,7 @@ describe "BulkData Performance" do
24
24
  :app_id => @a.id,
25
25
  :user_id => @u.id,
26
26
  :sources => [@s_fields[:name]])
27
- BulkDataJob.perform("data_name" => data.name)
28
- BulkDataJob.after_perform_x("data_name" => data.name)
27
+ do_bulk_data_job("data_name" => data.name)
29
28
  lap_timer('BulkDataJob.perform duration',start)
30
29
  end
31
30
  end
@@ -426,8 +426,7 @@ describe "Server" do
426
426
  it "should receive url when bulk data is available" do
427
427
  set_state('test_db_storage' => @data)
428
428
  get "/api/application/bulk_data", :partition => :user, :client_id => @c.id
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))
429
+ do_bulk_data_job("data_name" => bulk_data_docname(@a.id,@u.id))
431
430
  get "/api/application/bulk_data", :partition => :user, :client_id => @c.id
432
431
  last_response.should be_ok
433
432
  data = BulkData.load(bulk_data_docname(@a.id,@u.id))
@@ -439,8 +438,7 @@ describe "Server" do
439
438
  it "should download bulk data file" do
440
439
  set_state('test_db_storage' => @data)
441
440
  get "/api/application/bulk_data", :partition => :user, :client_id => @c.id
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))
441
+ do_bulk_data_job("data_name" => bulk_data_docname(@a.id,@u.id))
444
442
  get "/api/application/bulk_data", :partition => :user, :client_id => @c.id
445
443
  get JSON.parse(last_response.body)["url"]
446
444
  last_response.should be_ok