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.
- data/CHANGELOG.md +14 -2
- data/CREDITS +151 -10
- data/Gemfile +16 -5
- data/Gemfile.lock +58 -23
- data/Rakefile +70 -50
- data/bench/bench_runner.rb +2 -2
- data/bench/benchapp/Gemfile +6 -0
- data/bench/benchapp/Gemfile.lock +5 -0
- data/bench/benchapp/config.ru +2 -0
- data/bench/lib/bench/cli.rb +2 -0
- data/bench/lib/bench/distr_runner.rb +3 -2
- data/bench/lib/bench/runner.rb +1 -1
- data/bench/lib/bench.rb +10 -1
- data/bench/run_bench.sh +1 -1
- data/bench/scripts/test_query_script.rb +2 -1
- data/bench/spec/bench_spec_helper.rb +1 -0
- data/bin/rhoconnect +9 -27
- data/bin/rhoconnect-benchmark +10 -1
- data/commands/commands/dtach_commands/dtach_about.rb +6 -0
- data/commands/commands/dtach_commands/dtach_install.rb +30 -0
- data/commands/commands/redis_commands/redis_about.rb +6 -0
- data/commands/commands/redis_commands/redis_attach.rb +6 -0
- data/commands/commands/redis_commands/redis_download.rb +33 -0
- data/commands/commands/redis_commands/redis_install.rb +26 -0
- data/commands/commands/redis_commands/redis_make.rb +9 -0
- data/commands/commands/redis_commands/redis_restart.rb +7 -0
- data/commands/commands/redis_commands/redis_runner.rb +67 -0
- data/commands/commands/redis_commands/redis_start.rb +6 -0
- data/commands/commands/redis_commands/redis_startbg.rb +6 -0
- data/commands/commands/redis_commands/redis_stop.rb +6 -0
- data/commands/commands/rhoconnect/attach.rb +7 -0
- data/commands/commands/rhoconnect/clean_start.rb +9 -0
- data/commands/commands/rhoconnect/config.rb +15 -0
- data/commands/commands/rhoconnect/console.rb +15 -0
- data/commands/commands/rhoconnect/console_helper.rb +3 -0
- data/commands/commands/rhoconnect/create_user.rb +18 -0
- data/commands/commands/rhoconnect/delete_device.rb +9 -0
- data/commands/commands/rhoconnect/delete_user.rb +8 -0
- data/commands/commands/rhoconnect/flushdb.rb +14 -0
- data/commands/commands/rhoconnect/get_token.rb +25 -0
- data/commands/commands/rhoconnect/reset.rb +16 -0
- data/commands/commands/rhoconnect/reset_refresh.rb +11 -0
- data/commands/commands/rhoconnect/restart.rb +7 -0
- data/commands/commands/rhoconnect/secret.rb +11 -0
- data/commands/commands/rhoconnect/set_admin_password.rb +26 -0
- data/commands/commands/rhoconnect/spec.rb +15 -0
- data/commands/commands/rhoconnect/start.rb +18 -0
- data/commands/commands/rhoconnect/startbg.rb +34 -0
- data/commands/commands/rhoconnect/startdebug.rb +35 -0
- data/commands/commands/rhoconnect/stop.rb +11 -0
- data/commands/commands/rhoconnect/war.rb +32 -0
- data/commands/commands/rhoconnect/web.rb +7 -0
- data/commands/execute.rb +35 -0
- data/commands/generators/app.rb +6 -0
- data/commands/generators/source.rb +6 -0
- data/commands/utilities/dtach_installed.rb +10 -0
- data/doc/benchmarks-running.txt +5 -0
- data/doc/command-line.txt +216 -27
- data/doc/heroku-addon.txt +1 -1
- data/doc/preparing-production.txt +20 -1
- data/doc/public/cli.txt +191 -0
- data/doc/push-backend-setup.txt +148 -0
- data/doc/push-client-setup.txt +61 -0
- data/doc/push-server-setup.txt +91 -0
- data/doc/push.txt +8 -137
- data/doc/rest-api.txt +96 -0
- data/doc/settings.txt +1 -1
- data/doc/supported-platforms.txt +2 -1
- data/doc/tutorial.txt +6 -4
- data/examples/simple/Gemfile +39 -0
- data/examples/simple/Rakefile +7 -12
- data/examples/simple/config.ru +16 -31
- data/examples/simple/settings/settings.yml +5 -4
- data/examples/simple/sources/product.rb +51 -0
- data/generators/templates/application/Gemfile +7 -0
- data/generators/templates/application/Rakefile +5 -18
- data/generators/templates/application/config.ru +11 -19
- data/install.sh +24 -49
- data/installer/unix-like/create_texts.rb +71 -123
- data/installer/unix-like/post_install.sh +3 -0
- data/installer/unix-like/post_uninstall.sh +2 -0
- data/installer/unix-like/pre_install.sh +5 -3
- data/installer/unix-like/pre_uninstall.sh +14 -6
- data/installer/unix-like/rho_connect_install_checkers.rb +1 -1
- data/installer/unix-like/rho_connect_install_constants.rb +6 -10
- data/installer/unix-like/rho_connect_install_debian.rb +2 -2
- data/installer/unix-like/rho_connect_install_dnd.rb +2 -5
- data/installer/unix-like/rho_connect_install_installers.rb +15 -23
- data/installer/unix-like/rho_connect_install_yum.rb +2 -2
- data/installer/utils/constants.rb +4 -4
- data/installer/utils/create_sha1.rb +1 -1
- data/installer/utils/nix_install_test.rb +32 -31
- data/installer/utils/nix_installation.rake +1 -1
- data/installer/utils/package_upload/repos.rake +34 -30
- data/installer/utils/package_upload/s3_upload.rb +3 -3
- data/lib/rhoconnect/api/source/fast_delete.rb +10 -0
- data/lib/rhoconnect/api/source/fast_insert.rb +10 -0
- data/lib/rhoconnect/api/source/fast_update.rb +10 -0
- data/lib/rhoconnect/api/source/get_source_params.rb +1 -1
- data/lib/rhoconnect/api/source/list_sources.rb +2 -2
- data/lib/rhoconnect/api/source/save_adapter.rb +1 -1
- data/lib/rhoconnect/api/source/update_source_params.rb +6 -0
- data/lib/rhoconnect/async.rb +82 -0
- data/lib/rhoconnect/bulk_data/bulk_data.rb +5 -1
- data/lib/rhoconnect/client_sync.rb +18 -3
- data/lib/rhoconnect/console/rhoconnect_api.rb +2 -2
- data/lib/rhoconnect/console/server.rb +5 -32
- data/lib/rhoconnect/console.rb +2 -2
- data/lib/rhoconnect/graph_helper.rb +225 -0
- data/lib/rhoconnect/jobs/bulk_data_job.rb +24 -2
- data/lib/rhoconnect/server.rb +31 -11
- data/lib/rhoconnect/source.rb +10 -5
- data/lib/rhoconnect/source_sync.rb +32 -2
- data/lib/rhoconnect/tasks.rb +19 -108
- data/lib/rhoconnect/test_methods.rb +20 -0
- data/lib/rhoconnect/utilities.rb +118 -0
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect/web-console/controllers/admins.js +245 -0
- data/lib/rhoconnect/web-console/models/adapter.js +53 -0
- data/lib/rhoconnect/web-console/models/client.js +105 -0
- data/lib/rhoconnect/web-console/models/doc.js +113 -0
- data/lib/rhoconnect/web-console/models/session.js +40 -0
- data/lib/rhoconnect/web-console/models/source.js +115 -0
- data/lib/rhoconnect/web-console/models/stats.js +84 -0
- data/lib/rhoconnect/web-console/models/user.js +111 -0
- data/lib/rhoconnect/web-console/public/backbone.js +1432 -0
- data/lib/rhoconnect/web-console/public/bootstrap.css +3990 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/excanvas.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.barRenderer.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasAxisLabelRenderer.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasAxisTickRenderer.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasTextRenderer.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.categoryAxisRenderer.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.cursor.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.dateAxisRenderer.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.dateAxisRenderer.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.pointLabels.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery-1.4.2.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery.jqplot.min.css +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery.jqplot.min.js +0 -0
- data/lib/rhoconnect/web-console/public/jquery-1.7.1.min.js +154 -0
- data/lib/rhoconnect/web-console/public/rhoconnect-web.js +15 -0
- data/lib/rhoconnect/web-console/public/underscore.js +999 -0
- data/lib/rhoconnect/web-console/server.rb +55 -0
- data/lib/rhoconnect/web-console/templates/index.erb +90 -0
- data/lib/rhoconnect/web-console/templates/jqplot.erb +60 -0
- data/lib/rhoconnect/web-console/views/api_token.js +16 -0
- data/lib/rhoconnect/web-console/views/doc.js +63 -0
- data/lib/rhoconnect/web-console/views/edit_user.js +43 -0
- data/lib/rhoconnect/web-console/views/home.js +56 -0
- data/lib/rhoconnect/web-console/views/index.js +63 -0
- data/lib/rhoconnect/web-console/views/new_ping.js +58 -0
- data/lib/rhoconnect/web-console/views/new_user.js +29 -0
- data/lib/rhoconnect/web-console/views/server_doc.js +103 -0
- data/lib/rhoconnect/web-console/views/set_adapter.js +38 -0
- data/lib/rhoconnect/web-console/views/settings.js +53 -0
- data/lib/rhoconnect/web-console/views/show_device.js +56 -0
- data/lib/rhoconnect/web-console/views/show_user.js +38 -0
- data/lib/rhoconnect/web-console/views/source_docs.js +30 -0
- data/lib/rhoconnect/web-console/views/stats.js +69 -0
- data/lib/rhoconnect/web-console/views/users.js +20 -0
- data/lib/rhoconnect.rb +2 -1
- data/rhoconnect.gemspec +3 -1
- data/spec/api/application/rhoconnect_api_spec.rb +3 -5
- data/spec/api/source/fast_delete_spec.rb +27 -0
- data/spec/api/source/fast_insert_spec.rb +28 -0
- data/spec/api/source/fast_update_spec.rb +51 -0
- data/spec/api/source/get_source_params_spec.rb +1 -0
- data/spec/api/source/update_source_params_spec.rb +24 -0
- data/spec/async_spec.rb +19 -0
- data/spec/client_sync_spec.rb +19 -2
- data/spec/javascripts/PlayerSpec.js +58 -0
- data/spec/javascripts/admins_routes_spec.js +117 -0
- data/spec/javascripts/admins_spec.js +27 -0
- data/spec/javascripts/doc_view_spec.js +37 -0
- data/spec/javascripts/edit_user_view_spec.js +44 -0
- data/spec/javascripts/helpers/SpecHelper.js +9 -0
- data/spec/javascripts/helpers/jasmine-jquery.js +305 -0
- data/spec/javascripts/helpers/jasmine-sinon.js +43 -0
- data/spec/javascripts/helpers/sinon-1.3.2.js +3551 -0
- data/spec/javascripts/home_view_spec.js +39 -0
- data/spec/javascripts/index_view_spec.js +42 -0
- data/spec/javascripts/new_ping_view_spec.js +48 -0
- data/spec/javascripts/new_user_view_spec.js +42 -0
- data/spec/javascripts/server_doc_view_spec.js +39 -0
- data/spec/javascripts/set_adapter_view_spec.js +32 -0
- data/spec/javascripts/show_device_view_spec.js +41 -0
- data/spec/javascripts/show_user_view_spec.js +46 -0
- data/spec/javascripts/source_docs_view_spec.js +36 -0
- data/spec/javascripts/support/jasmine.yml +79 -0
- data/spec/javascripts/support/jasmine_config.rb +23 -0
- data/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/spec/javascripts/users_view_spec.js +35 -0
- data/spec/jobs/bulk_data_job_spec.rb +10 -2
- data/spec/perf/bulk_data_perf_spec.rb +1 -0
- data/spec/server/server_spec.rb +3 -1
- data/spec/source_sync_spec.rb +14 -1
- data/spec/spec_helper.rb +51 -0
- data/spec/store_spec.rb +6 -0
- data/spec/test_methods_spec.rb +11 -0
- data/tasks/redis.rake +3 -1
- metadata +172 -64
- data/doc/contributing.txt +0 -60
- data/lib/rhoconnect/console/app/helpers/auth_helper.rb +0 -22
- data/lib/rhoconnect/console/app/helpers/extensions.rb +0 -19
- data/lib/rhoconnect/console/app/helpers/helpers.rb +0 -57
- data/lib/rhoconnect/console/app/public/ThickBox.css +0 -649
- data/lib/rhoconnect/console/app/public/home.css +0 -431
- data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
- data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
- data/lib/rhoconnect/console/app/public/main.css +0 -7
- data/lib/rhoconnect/console/app/public/reset.css +0 -76
- data/lib/rhoconnect/console/app/public/style.css +0 -2201
- data/lib/rhoconnect/console/app/public/text.txt +0 -0
- data/lib/rhoconnect/console/app/routes/adapter.rb +0 -28
- data/lib/rhoconnect/console/app/routes/auth.rb +0 -29
- data/lib/rhoconnect/console/app/routes/client.rb +0 -31
- data/lib/rhoconnect/console/app/routes/docs.rb +0 -145
- data/lib/rhoconnect/console/app/routes/heroku.rb +0 -19
- data/lib/rhoconnect/console/app/routes/home.rb +0 -63
- data/lib/rhoconnect/console/app/routes/timing.rb +0 -242
- data/lib/rhoconnect/console/app/routes/user.rb +0 -122
- data/lib/rhoconnect/console/app/views/adapter.erb +0 -16
- data/lib/rhoconnect/console/app/views/client.erb +0 -30
- data/lib/rhoconnect/console/app/views/content.erb +0 -14
- data/lib/rhoconnect/console/app/views/doc.erb +0 -8
- data/lib/rhoconnect/console/app/views/docdata.erb +0 -28
- data/lib/rhoconnect/console/app/views/docs.erb +0 -30
- data/lib/rhoconnect/console/app/views/edituser.erb +0 -13
- data/lib/rhoconnect/console/app/views/headermenu.erb +0 -40
- data/lib/rhoconnect/console/app/views/home.erb +0 -24
- data/lib/rhoconnect/console/app/views/index.erb +0 -58
- data/lib/rhoconnect/console/app/views/jqplot.erb +0 -52
- data/lib/rhoconnect/console/app/views/layout.erb +0 -153
- data/lib/rhoconnect/console/app/views/login.erb +0 -26
- data/lib/rhoconnect/console/app/views/newuser.erb +0 -17
- data/lib/rhoconnect/console/app/views/ping.erb +0 -40
- data/lib/rhoconnect/console/app/views/result.erb +0 -11
- data/lib/rhoconnect/console/app/views/rightboxlinks.erb +0 -15
- data/lib/rhoconnect/console/app/views/select_doc.erb +0 -17
- data/lib/rhoconnect/console/app/views/upload_doc.erb +0 -23
- data/lib/rhoconnect/console/app/views/user.erb +0 -29
- data/lib/rhoconnect/console/app/views/users.erb +0 -19
- data/lib/rhoconnect/server/views/index.erb +0 -13
@@ -0,0 +1,58 @@
|
|
1
|
+
// describe("Player", function() {
|
2
|
+
// var player;
|
3
|
+
// var song;
|
4
|
+
//
|
5
|
+
// beforeEach(function() {
|
6
|
+
// player = new Player();
|
7
|
+
// song = new Song();
|
8
|
+
// });
|
9
|
+
//
|
10
|
+
// it("should be able to play a Song", function() {
|
11
|
+
// player.play(song);
|
12
|
+
// expect(player.currentlyPlayingSong).toEqual(song);
|
13
|
+
//
|
14
|
+
// //demonstrates use of custom matcher
|
15
|
+
// expect(player).toBePlaying(song);
|
16
|
+
// });
|
17
|
+
//
|
18
|
+
// describe("when song has been paused", function() {
|
19
|
+
// beforeEach(function() {
|
20
|
+
// player.play(song);
|
21
|
+
// player.pause();
|
22
|
+
// });
|
23
|
+
//
|
24
|
+
// it("should indicate that the song is currently paused", function() {
|
25
|
+
// expect(player.isPlaying).toBeFalsy();
|
26
|
+
//
|
27
|
+
// // demonstrates use of 'not' with a custom matcher
|
28
|
+
// expect(player).not.toBePlaying(song);
|
29
|
+
// });
|
30
|
+
//
|
31
|
+
// it("should be possible to resume", function() {
|
32
|
+
// player.resume();
|
33
|
+
// expect(player.isPlaying).toBeTruthy();
|
34
|
+
// expect(player.currentlyPlayingSong).toEqual(song);
|
35
|
+
// });
|
36
|
+
// });
|
37
|
+
//
|
38
|
+
// // demonstrates use of spies to intercept and test method calls
|
39
|
+
// it("tells the current song if the user has made it a favorite", function() {
|
40
|
+
// spyOn(song, 'persistFavoriteStatus');
|
41
|
+
//
|
42
|
+
// player.play(song);
|
43
|
+
// player.makeFavorite();
|
44
|
+
//
|
45
|
+
// expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
|
46
|
+
// });
|
47
|
+
//
|
48
|
+
// //demonstrates use of expected exceptions
|
49
|
+
// describe("#resume", function() {
|
50
|
+
// it("should throw an exception if song is already playing", function() {
|
51
|
+
// player.play(song);
|
52
|
+
//
|
53
|
+
// expect(function() {
|
54
|
+
// player.resume();
|
55
|
+
// }).toThrow("song is already playing");
|
56
|
+
// });
|
57
|
+
// });
|
58
|
+
// });
|
@@ -0,0 +1,117 @@
|
|
1
|
+
describe("Admins routes", function() {
|
2
|
+
beforeEach(function() {
|
3
|
+
this.router = new App.Controllers.Admins();
|
4
|
+
this.routeSpy = sinon.spy();
|
5
|
+
try {
|
6
|
+
Backbone.History.start({silent:true, pushState:true});
|
7
|
+
} catch(e) {}
|
8
|
+
this.router.navigate("test");
|
9
|
+
});
|
10
|
+
|
11
|
+
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
|
+
|
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
|
+
|
116
|
+
});
|
117
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
// describe("Admins", function() {
|
2
|
+
//
|
3
|
+
// beforeEach(function() {
|
4
|
+
// this.router = new App.Controllers.Admins();
|
5
|
+
// this.session = new Session();
|
6
|
+
// this.sessionStub = sinon.stub(this.session,"getAuthenticated").returns("true")
|
7
|
+
//
|
8
|
+
// this.home = new App.Views.Home({model:new Source()});
|
9
|
+
// this.fetchStub = sinon.stub(this.model.home,'fetch').returns(null);
|
10
|
+
// this.fetchSave = sinon.stub(this.model.home,'save').returns(null);
|
11
|
+
// });
|
12
|
+
//
|
13
|
+
// afterEach(function() {
|
14
|
+
//
|
15
|
+
// });
|
16
|
+
//
|
17
|
+
// it("creats a new Index page if not logged in",function(){
|
18
|
+
//
|
19
|
+
//
|
20
|
+
// this.router.index();
|
21
|
+
//
|
22
|
+
// expect(sessionStub).toHaveBeenCalledOnce();
|
23
|
+
// //expect(this.fetchStub).toHaveBeenCalledOnce();
|
24
|
+
// //expect(this.fetchSave).toHaveBeenCalledOnce();
|
25
|
+
// });
|
26
|
+
//
|
27
|
+
// });
|
@@ -0,0 +1,37 @@
|
|
1
|
+
describe("DocView", function(){
|
2
|
+
|
3
|
+
beforeEach(function(){
|
4
|
+
var session = new Session();
|
5
|
+
session.setAuthenticated('true');
|
6
|
+
session.setApiKey('testtoken');
|
7
|
+
|
8
|
+
doc = new Doc();
|
9
|
+
doc.set("dbkey",'testkey');
|
10
|
+
|
11
|
+
sinon.stub(doc,'get_doc')
|
12
|
+
|
13
|
+
this.docView = new App.Views.Doc({model : doc});
|
14
|
+
});
|
15
|
+
|
16
|
+
afterEach(function(){
|
17
|
+
var session = new Session();
|
18
|
+
session.setAuthenticated('false');
|
19
|
+
session.setApiKey(null);
|
20
|
+
});
|
21
|
+
|
22
|
+
it("should have render initial html",function(){
|
23
|
+
this.docRenderSpy = sinon.spy(this.docView,'render');
|
24
|
+
|
25
|
+
this.docView.render();
|
26
|
+
expect(this.docRenderSpy).toHaveBeenCalledOnce();
|
27
|
+
});
|
28
|
+
|
29
|
+
it("should have correct html rendered ",function(){
|
30
|
+
var title = this.docView.el.innerHTML.search('[testkey]');
|
31
|
+
expect(title).toBeGreaterThan(0);
|
32
|
+
|
33
|
+
var change_btn = this.docView.el.innerHTML.search('Upload Token string');
|
34
|
+
expect(change_btn).toBeGreaterThan(0);
|
35
|
+
|
36
|
+
})
|
37
|
+
});
|
@@ -0,0 +1,44 @@
|
|
1
|
+
describe("EditUserView", function(){
|
2
|
+
|
3
|
+
beforeEach(function(){
|
4
|
+
var session = new Session();
|
5
|
+
session.setAuthenticated('true');
|
6
|
+
session.setApiKey('testtoken');
|
7
|
+
this.editUserView = new App.Views.EditUser();
|
8
|
+
});
|
9
|
+
|
10
|
+
afterEach(function(){
|
11
|
+
var session = new Session();
|
12
|
+
session.setAuthenticated('false');
|
13
|
+
session.setApiKey(null);
|
14
|
+
});
|
15
|
+
|
16
|
+
it("should have render initial html",function(){
|
17
|
+
this.UserRenderSpy = sinon.spy(this.editUserView,'render');
|
18
|
+
|
19
|
+
this.editUserView.render();
|
20
|
+
expect(this.UserRenderSpy).toHaveBeenCalledOnce();
|
21
|
+
});
|
22
|
+
|
23
|
+
it("should call edit",function(){
|
24
|
+
this.editUserRenderSpy = sinon.spy(this.editUserView,'edit');
|
25
|
+
sinon.stub(jQuery,'ajax').yieldsTo("success");
|
26
|
+
function myevent(){
|
27
|
+
this.preventDefault=function(){return true;}
|
28
|
+
}
|
29
|
+
e = new myevent();
|
30
|
+
|
31
|
+
this.editUserView.edit(e);
|
32
|
+
expect(this.editUserRenderSpy).toHaveBeenCalledOnce();
|
33
|
+
jQuery.ajax.restore();
|
34
|
+
});
|
35
|
+
|
36
|
+
it("should have correct html rendered ",function(){
|
37
|
+
var title = this.editUserView.el.innerHTML.search('Edit admin');
|
38
|
+
expect(title).toBeGreaterThan(0);
|
39
|
+
|
40
|
+
var password = this.editUserView.el.innerHTML.search('Password');
|
41
|
+
expect(password).toBeGreaterThan(0);
|
42
|
+
|
43
|
+
})
|
44
|
+
});
|
@@ -0,0 +1,305 @@
|
|
1
|
+
var readFixtures = function() {
|
2
|
+
return jasmine.getFixtures().proxyCallTo_('read', arguments);
|
3
|
+
};
|
4
|
+
|
5
|
+
var preloadFixtures = function() {
|
6
|
+
jasmine.getFixtures().proxyCallTo_('preload', arguments);
|
7
|
+
};
|
8
|
+
|
9
|
+
var loadFixtures = function() {
|
10
|
+
jasmine.getFixtures().proxyCallTo_('load', arguments);
|
11
|
+
};
|
12
|
+
|
13
|
+
var setFixtures = function(html) {
|
14
|
+
jasmine.getFixtures().set(html);
|
15
|
+
};
|
16
|
+
|
17
|
+
var sandbox = function(attributes) {
|
18
|
+
return jasmine.getFixtures().sandbox(attributes);
|
19
|
+
};
|
20
|
+
|
21
|
+
var spyOnEvent = function(selector, eventName) {
|
22
|
+
jasmine.JQuery.events.spyOn(selector, eventName);
|
23
|
+
};
|
24
|
+
|
25
|
+
jasmine.getFixtures = function() {
|
26
|
+
return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures();
|
27
|
+
};
|
28
|
+
|
29
|
+
jasmine.Fixtures = function() {
|
30
|
+
this.containerId = 'jasmine-fixtures';
|
31
|
+
this.fixturesCache_ = {};
|
32
|
+
this.fixturesPath = 'spec/javascripts/fixtures';
|
33
|
+
};
|
34
|
+
|
35
|
+
jasmine.Fixtures.prototype.set = function(html) {
|
36
|
+
this.cleanUp();
|
37
|
+
this.createContainer_(html);
|
38
|
+
};
|
39
|
+
|
40
|
+
jasmine.Fixtures.prototype.preload = function() {
|
41
|
+
this.read.apply(this, arguments);
|
42
|
+
};
|
43
|
+
|
44
|
+
jasmine.Fixtures.prototype.load = function() {
|
45
|
+
this.cleanUp();
|
46
|
+
this.createContainer_(this.read.apply(this, arguments));
|
47
|
+
};
|
48
|
+
|
49
|
+
jasmine.Fixtures.prototype.read = function() {
|
50
|
+
var htmlChunks = [];
|
51
|
+
|
52
|
+
var fixtureUrls = arguments;
|
53
|
+
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
|
54
|
+
htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]));
|
55
|
+
}
|
56
|
+
|
57
|
+
return htmlChunks.join('');
|
58
|
+
};
|
59
|
+
|
60
|
+
jasmine.Fixtures.prototype.clearCache = function() {
|
61
|
+
this.fixturesCache_ = {};
|
62
|
+
};
|
63
|
+
|
64
|
+
jasmine.Fixtures.prototype.cleanUp = function() {
|
65
|
+
jQuery('#' + this.containerId).remove();
|
66
|
+
};
|
67
|
+
|
68
|
+
jasmine.Fixtures.prototype.sandbox = function(attributes) {
|
69
|
+
var attributesToSet = attributes || {};
|
70
|
+
return jQuery('<div id="sandbox" />').attr(attributesToSet);
|
71
|
+
};
|
72
|
+
|
73
|
+
jasmine.Fixtures.prototype.createContainer_ = function(html) {
|
74
|
+
var container;
|
75
|
+
if(html instanceof jQuery) {
|
76
|
+
container = jQuery('<div id="' + this.containerId + '" />');
|
77
|
+
container.html(html);
|
78
|
+
} else {
|
79
|
+
container = '<div id="' + this.containerId + '">' + html + '</div>'
|
80
|
+
}
|
81
|
+
jQuery('body').append(container);
|
82
|
+
};
|
83
|
+
|
84
|
+
jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
|
85
|
+
if (typeof this.fixturesCache_[url] == 'undefined') {
|
86
|
+
this.loadFixtureIntoCache_(url);
|
87
|
+
}
|
88
|
+
return this.fixturesCache_[url];
|
89
|
+
};
|
90
|
+
|
91
|
+
jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
|
92
|
+
var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl;
|
93
|
+
var request = new XMLHttpRequest();
|
94
|
+
request.open("GET", url + "?" + new Date().getTime(), false);
|
95
|
+
request.send(null);
|
96
|
+
this.fixturesCache_[relativeUrl] = request.responseText;
|
97
|
+
};
|
98
|
+
|
99
|
+
jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
|
100
|
+
return this[methodName].apply(this, passedArguments);
|
101
|
+
};
|
102
|
+
|
103
|
+
|
104
|
+
jasmine.JQuery = function() {};
|
105
|
+
|
106
|
+
jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
|
107
|
+
return jQuery('<div/>').append(html).html();
|
108
|
+
};
|
109
|
+
|
110
|
+
jasmine.JQuery.elementToString = function(element) {
|
111
|
+
return jQuery('<div />').append($(element).clone()).html();
|
112
|
+
};
|
113
|
+
|
114
|
+
jasmine.JQuery.matchersClass = {};
|
115
|
+
|
116
|
+
(function(namespace) {
|
117
|
+
var data = {
|
118
|
+
spiedEvents: {},
|
119
|
+
handlers: []
|
120
|
+
};
|
121
|
+
|
122
|
+
namespace.events = {
|
123
|
+
spyOn: function(selector, eventName) {
|
124
|
+
var handler = function(e) {
|
125
|
+
data.spiedEvents[[selector, eventName]] = e;
|
126
|
+
};
|
127
|
+
jQuery(selector).bind(eventName, handler);
|
128
|
+
data.handlers.push(handler);
|
129
|
+
},
|
130
|
+
|
131
|
+
wasTriggered: function(selector, eventName) {
|
132
|
+
return !!(data.spiedEvents[[selector, eventName]]);
|
133
|
+
},
|
134
|
+
|
135
|
+
wasPrevented: function(selector, eventName) {
|
136
|
+
return data.spiedEvents[[selector, eventName]].isDefaultPrevented();
|
137
|
+
},
|
138
|
+
|
139
|
+
cleanUp: function() {
|
140
|
+
data.spiedEvents = {};
|
141
|
+
data.handlers = [];
|
142
|
+
}
|
143
|
+
}
|
144
|
+
})(jasmine.JQuery);
|
145
|
+
|
146
|
+
(function(){
|
147
|
+
var jQueryMatchers = {
|
148
|
+
toHaveClass: function(className) {
|
149
|
+
return this.actual.hasClass(className);
|
150
|
+
},
|
151
|
+
|
152
|
+
toBeVisible: function() {
|
153
|
+
return this.actual.is(':visible');
|
154
|
+
},
|
155
|
+
|
156
|
+
toBeHidden: function() {
|
157
|
+
return this.actual.is(':hidden');
|
158
|
+
},
|
159
|
+
|
160
|
+
toBeSelected: function() {
|
161
|
+
return this.actual.is(':selected');
|
162
|
+
},
|
163
|
+
|
164
|
+
toBeChecked: function() {
|
165
|
+
return this.actual.is(':checked');
|
166
|
+
},
|
167
|
+
|
168
|
+
toBeEmpty: function() {
|
169
|
+
return this.actual.is(':empty');
|
170
|
+
},
|
171
|
+
|
172
|
+
toExist: function() {
|
173
|
+
return this.actual.size() > 0;
|
174
|
+
},
|
175
|
+
|
176
|
+
toHaveAttr: function(attributeName, expectedAttributeValue) {
|
177
|
+
return hasProperty(this.actual.attr(attributeName), expectedAttributeValue);
|
178
|
+
},
|
179
|
+
|
180
|
+
toHaveProp: function(propertyName, expectedPropertyValue) {
|
181
|
+
return hasProperty(this.actual.prop(propertyName), expectedPropertyValue);
|
182
|
+
},
|
183
|
+
|
184
|
+
toHaveId: function(id) {
|
185
|
+
return this.actual.attr('id') == id;
|
186
|
+
},
|
187
|
+
|
188
|
+
toHaveHtml: function(html) {
|
189
|
+
return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html);
|
190
|
+
},
|
191
|
+
|
192
|
+
toHaveText: function(text) {
|
193
|
+
if (text && jQuery.isFunction(text.test)) {
|
194
|
+
return text.test(this.actual.text());
|
195
|
+
} else {
|
196
|
+
return this.actual.text() == text;
|
197
|
+
}
|
198
|
+
},
|
199
|
+
|
200
|
+
toHaveValue: function(value) {
|
201
|
+
return this.actual.val() == value;
|
202
|
+
},
|
203
|
+
|
204
|
+
toHaveData: function(key, expectedValue) {
|
205
|
+
return hasProperty(this.actual.data(key), expectedValue);
|
206
|
+
},
|
207
|
+
|
208
|
+
toBe: function(selector) {
|
209
|
+
return this.actual.is(selector);
|
210
|
+
},
|
211
|
+
|
212
|
+
toContain: function(selector) {
|
213
|
+
return this.actual.find(selector).size() > 0;
|
214
|
+
},
|
215
|
+
|
216
|
+
toBeDisabled: function(selector){
|
217
|
+
return this.actual.is(':disabled');
|
218
|
+
},
|
219
|
+
|
220
|
+
toBeFocused: function(selector) {
|
221
|
+
return this.actual.is(':focus');
|
222
|
+
},
|
223
|
+
|
224
|
+
// tests the existence of a specific event binding
|
225
|
+
toHandle: function(eventName) {
|
226
|
+
var events = this.actual.data("events");
|
227
|
+
return events && events[eventName].length > 0;
|
228
|
+
},
|
229
|
+
|
230
|
+
// tests the existence of a specific event binding + handler
|
231
|
+
toHandleWith: function(eventName, eventHandler) {
|
232
|
+
var stack = this.actual.data("events")[eventName];
|
233
|
+
var i;
|
234
|
+
for (i = 0; i < stack.length; i++) {
|
235
|
+
if (stack[i].handler == eventHandler) {
|
236
|
+
return true;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
return false;
|
240
|
+
}
|
241
|
+
};
|
242
|
+
|
243
|
+
var hasProperty = function(actualValue, expectedValue) {
|
244
|
+
if (expectedValue === undefined) {
|
245
|
+
return actualValue !== undefined;
|
246
|
+
}
|
247
|
+
return actualValue == expectedValue;
|
248
|
+
};
|
249
|
+
|
250
|
+
var bindMatcher = function(methodName) {
|
251
|
+
var builtInMatcher = jasmine.Matchers.prototype[methodName];
|
252
|
+
|
253
|
+
jasmine.JQuery.matchersClass[methodName] = function() {
|
254
|
+
if (this.actual
|
255
|
+
&& (this.actual instanceof jQuery
|
256
|
+
|| jasmine.isDomNode(this.actual))) {
|
257
|
+
this.actual = $(this.actual);
|
258
|
+
var result = jQueryMatchers[methodName].apply(this, arguments);
|
259
|
+
this.actual = jasmine.JQuery.elementToString(this.actual);
|
260
|
+
return result;
|
261
|
+
}
|
262
|
+
|
263
|
+
if (builtInMatcher) {
|
264
|
+
return builtInMatcher.apply(this, arguments);
|
265
|
+
}
|
266
|
+
|
267
|
+
return false;
|
268
|
+
};
|
269
|
+
};
|
270
|
+
|
271
|
+
for(var methodName in jQueryMatchers) {
|
272
|
+
bindMatcher(methodName);
|
273
|
+
}
|
274
|
+
})();
|
275
|
+
|
276
|
+
beforeEach(function() {
|
277
|
+
this.addMatchers(jasmine.JQuery.matchersClass);
|
278
|
+
this.addMatchers({
|
279
|
+
toHaveBeenTriggeredOn: function(selector) {
|
280
|
+
this.message = function() {
|
281
|
+
return [
|
282
|
+
"Expected event " + this.actual + " to have been triggered on " + selector,
|
283
|
+
"Expected event " + this.actual + " not to have been triggered on " + selector
|
284
|
+
];
|
285
|
+
};
|
286
|
+
return jasmine.JQuery.events.wasTriggered($(selector), this.actual);
|
287
|
+
}
|
288
|
+
});
|
289
|
+
this.addMatchers({
|
290
|
+
toHaveBeenPreventedOn: function(selector) {
|
291
|
+
this.message = function() {
|
292
|
+
return [
|
293
|
+
"Expected event " + this.actual + " to have been prevented on " + selector,
|
294
|
+
"Expected event " + this.actual + " not to have been prevented on " + selector
|
295
|
+
];
|
296
|
+
};
|
297
|
+
return jasmine.JQuery.events.wasPrevented(selector, this.actual);
|
298
|
+
}
|
299
|
+
});
|
300
|
+
});
|
301
|
+
|
302
|
+
afterEach(function() {
|
303
|
+
jasmine.getFixtures().cleanUp();
|
304
|
+
jasmine.JQuery.events.cleanUp();
|
305
|
+
});
|
@@ -0,0 +1,43 @@
|
|
1
|
+
(function(global) {
|
2
|
+
|
3
|
+
var spyMatchers = "called calledOnce calledTwice calledThrice calledBefore calledAfter calledOn alwaysCalledOn calledWith alwaysCalledWith calledWithExactly alwaysCalledWithExactly".split(" "),
|
4
|
+
i = spyMatchers.length,
|
5
|
+
spyMatcherHash = {},
|
6
|
+
unusualMatchers = {
|
7
|
+
"returned": "toHaveReturned",
|
8
|
+
"alwaysReturned": "toHaveAlwaysReturned",
|
9
|
+
"threw": "toHaveThrown",
|
10
|
+
"alwaysThrew": "toHaveAlwaysThrown"
|
11
|
+
},
|
12
|
+
|
13
|
+
getMatcherFunction = function(sinonName) {
|
14
|
+
return function() {
|
15
|
+
var sinonProperty = this.actual[sinonName];
|
16
|
+
return (typeof sinonProperty === 'function') ? sinonProperty.apply(this.actual, arguments) : sinonProperty;
|
17
|
+
};
|
18
|
+
};
|
19
|
+
|
20
|
+
while(i--) {
|
21
|
+
var sinonName = spyMatchers[i],
|
22
|
+
matcherName = "toHaveBeen" + sinonName.charAt(0).toUpperCase() + sinonName.slice(1);
|
23
|
+
|
24
|
+
spyMatcherHash[matcherName] = getMatcherFunction(sinonName);
|
25
|
+
};
|
26
|
+
|
27
|
+
for (var j in unusualMatchers) {
|
28
|
+
spyMatcherHash[unusualMatchers[j]] = getMatcherFunction(j);
|
29
|
+
}
|
30
|
+
|
31
|
+
global.sinonJasmine = {
|
32
|
+
getMatchers: function() {
|
33
|
+
return spyMatcherHash;
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
})(window);
|
38
|
+
|
39
|
+
beforeEach(function() {
|
40
|
+
|
41
|
+
this.addMatchers(sinonJasmine.getMatchers());
|
42
|
+
|
43
|
+
});
|