crusade_rails 0.8.0 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/crusade_rails/abstract_notification.js.coffee +38 -0
  3. data/app/assets/javascripts/crusade_rails/configuration.js.coffee.erb +2 -1
  4. data/app/assets/javascripts/crusade_rails/local_notification.js.coffee +23 -0
  5. data/app/assets/javascripts/crusade_rails/notification_permission.js.coffee +3 -1
  6. data/app/assets/javascripts/crusade_rails/push_notification.coffee +42 -0
  7. data/app/controllers/crusade_rails/apns/v1/push_package_controller.rb +34 -3
  8. data/app/controllers/crusade_rails/apns/v1/subscription_controller.rb +5 -1
  9. data/app/controllers/crusade_rails/application_controller.rb +2 -2
  10. data/app/services/crusade_rails/user_subscription_service.rb +41 -7
  11. data/config/routes.rb +2 -0
  12. data/db/migrate/20130917203302_create_crusade_rails_user_subscriptions.rb +1 -0
  13. data/lib/crusade_rails.rb +1 -0
  14. data/lib/crusade_rails/configuration.rb +45 -0
  15. data/lib/crusade_rails/version.rb +1 -1
  16. data/lib/generators/crusade/install/templates/initializer.rb +3 -3
  17. data/test/controllers/apns/v1/push_package_controller_test.rb +39 -7
  18. data/test/controllers/apns/v1/subscription_controller_test.rb +3 -1
  19. data/test/dummy/config/initializers/crusade.rb +3 -3
  20. data/test/dummy/db/development.sqlite3 +0 -0
  21. data/test/dummy/db/migrate/{20130922190000_create_crusade_rails_user_subscriptions.crusade_rails.rb → 20130925062705_create_crusade_rails_user_subscriptions.crusade_rails.rb} +1 -0
  22. data/test/dummy/db/schema.rb +2 -1
  23. data/test/dummy/db/test.sqlite3 +0 -0
  24. data/test/dummy/log/development.log +7 -470
  25. data/test/dummy/log/test.log +36862 -3832
  26. data/test/integration/configuration_test.rb +29 -0
  27. data/test/integration/push_package_integration_test.rb +9 -2
  28. data/test/javascripts/support/configuration.js.coffee +4 -4
  29. data/test/javascripts/support/disable_logger.coffee +1 -0
  30. data/test/javascripts/support/fake_notification.js.coffee +4 -0
  31. data/test/javascripts/support/jquery.mockajax.js +587 -0
  32. data/test/javascripts/support/safari.js.coffee +6 -1
  33. data/test/javascripts/unit/configuration_test.js.coffee +5 -4
  34. data/test/javascripts/unit/local_notification_test.js.coffee +130 -0
  35. data/test/javascripts/unit/notification_permission_test.js.coffee +5 -5
  36. data/test/javascripts/unit/push_notification_test.js.coffee +180 -0
  37. data/test/routes/apns_routes_test.rb +6 -0
  38. data/test/services/user_subscription_service_test.rb +126 -19
  39. metadata +22 -93
  40. data/app/assets/javascripts/crusade_rails/crusade.js.coffee +0 -46
  41. data/test/dummy/tmp/cache/assets/development/sprockets/07be86ef00416c18f2f7dd96f4603129 +0 -0
  42. data/test/dummy/tmp/cache/assets/development/sprockets/116d0ea1f1fccbc5f17329e738b48f32 +0 -0
  43. data/test/dummy/tmp/cache/assets/development/sprockets/1c6cab9972997baaf0f7fd1599e62590 +0 -0
  44. data/test/dummy/tmp/cache/assets/development/sprockets/2a4f82e222d708931c0b88831e1bb864 +0 -0
  45. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  46. data/test/dummy/tmp/cache/assets/development/sprockets/2fe1114a6234d617f0bb5e464a840942 +0 -0
  47. data/test/dummy/tmp/cache/assets/development/sprockets/39b9141911bd7b575b7e782b8c405a0d +0 -0
  48. data/test/dummy/tmp/cache/assets/development/sprockets/3c9d7a4a4511e1418a3f5e9beaac8d0a +0 -0
  49. data/test/dummy/tmp/cache/assets/development/sprockets/45a685d3bc33555e456c32424fd838e8 +0 -0
  50. data/test/dummy/tmp/cache/assets/development/sprockets/576608e546507cd114398639d7f7bd5d +0 -0
  51. data/test/dummy/tmp/cache/assets/development/sprockets/57adfe7d0eeb4aca9491ffb75157956e +0 -0
  52. data/test/dummy/tmp/cache/assets/development/sprockets/5c7b888c11190fa68628e8fd3212e8fd +0 -0
  53. data/test/dummy/tmp/cache/assets/development/sprockets/5ded1a08ed08028fbe21471a88881d28 +0 -0
  54. data/test/dummy/tmp/cache/assets/development/sprockets/5e40cea3d1e28179f2a2ad998d1f26f7 +0 -0
  55. data/test/dummy/tmp/cache/assets/development/sprockets/618327f5ca738fb1d560cdf13c073bf3 +0 -0
  56. data/test/dummy/tmp/cache/assets/development/sprockets/6e6652fce2d9f8b871274ccb2af329c7 +0 -0
  57. data/test/dummy/tmp/cache/assets/development/sprockets/6f5e75e28ef2f140b52beb6f1b6609b9 +0 -0
  58. data/test/dummy/tmp/cache/assets/development/sprockets/7161340e0502d24611730dd49b15e115 +0 -0
  59. data/test/dummy/tmp/cache/assets/development/sprockets/7d4e507c01e7ef7a4dc9d7f9c5478ca4 +0 -0
  60. data/test/dummy/tmp/cache/assets/development/sprockets/803bc12cb782253e6b4191a7346991c5 +0 -0
  61. data/test/dummy/tmp/cache/assets/development/sprockets/8b3d3f72f349b54596b95558be73d55d +0 -0
  62. data/test/dummy/tmp/cache/assets/development/sprockets/97ba61a3e4a7ec32873e08c29a7a6f94 +0 -0
  63. data/test/dummy/tmp/cache/assets/development/sprockets/9ccfcc3c008514fb5c35aa7b3d7bbc78 +0 -0
  64. data/test/dummy/tmp/cache/assets/development/sprockets/a82b6a43a4be516353a2ac1d89f6b610 +0 -0
  65. data/test/dummy/tmp/cache/assets/development/sprockets/a92311b92483c1f9472df2622e658768 +0 -0
  66. data/test/dummy/tmp/cache/assets/development/sprockets/aba15ac42f92b66ff70b0a3e26184263 +0 -0
  67. data/test/dummy/tmp/cache/assets/development/sprockets/b75702adcae93ffe045a33824fc40f12 +0 -0
  68. data/test/dummy/tmp/cache/assets/development/sprockets/be89d70eb8f19e72ed6ad9481a7c1b9a +0 -0
  69. data/test/dummy/tmp/cache/assets/development/sprockets/c1d4b2d589a2dc7649e075ffea2d2566 +0 -0
  70. data/test/dummy/tmp/cache/assets/development/sprockets/cd0a1473787729a36454fd789dd86195 +0 -0
  71. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  72. data/test/dummy/tmp/cache/assets/development/sprockets/d03fd0d3629c94a744a70d063d15eb6f +0 -0
  73. data/test/dummy/tmp/cache/assets/development/sprockets/d572f7956c1b132aba30f71dfb1334d9 +0 -0
  74. data/test/dummy/tmp/cache/assets/development/sprockets/dc8639471867248d3cfc41c6dad35a43 +0 -0
  75. data/test/dummy/tmp/cache/assets/development/sprockets/e113ed0ed8564e75067a161599ed7fc9 +0 -0
  76. data/test/dummy/tmp/cache/assets/development/sprockets/e2bd66166c81c25a6fea7aab23cf58cf +0 -0
  77. data/test/dummy/tmp/cache/assets/development/sprockets/e653b1d89bb66ba5ee551887655e02da +0 -0
  78. data/test/dummy/tmp/cache/assets/development/sprockets/eb5bc1e85d69a5ec7063b599c7f6acf1 +0 -0
  79. data/test/dummy/tmp/cache/assets/development/sprockets/f084f98622288fc6a4d8fdbc755bcb48 +0 -0
  80. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  81. data/test/dummy/tmp/cache/assets/development/sprockets/f99eb680da1b65060a9388e0b41f19b0 +0 -0
  82. data/test/dummy/tmp/cache/assets/development/sprockets/fa3e415ce51e582faa842454baced5a3 +0 -0
  83. data/test/javascripts/unit/crusade_spec.js.coffee +0 -102
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crusade_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rouchy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-22 00:00:00.000000000 Z
11
+ date: 2013-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 0.8.0
61
+ version: 0.8.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 0.8.0
68
+ version: 0.8.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdoc
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -158,9 +158,11 @@ extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
160
  - app/assets/javascripts/crusade.js
161
+ - app/assets/javascripts/crusade_rails/abstract_notification.js.coffee
161
162
  - app/assets/javascripts/crusade_rails/configuration.js.coffee.erb
162
- - app/assets/javascripts/crusade_rails/crusade.js.coffee
163
+ - app/assets/javascripts/crusade_rails/local_notification.js.coffee
163
164
  - app/assets/javascripts/crusade_rails/notification_permission.js.coffee
165
+ - app/assets/javascripts/crusade_rails/push_notification.coffee
164
166
  - app/assets/stylesheets/crusade_rails/application.css
165
167
  - app/controllers/crusade_rails/apns/v1/log_controller.rb
166
168
  - app/controllers/crusade_rails/apns/v1/push_package_controller.rb
@@ -173,6 +175,7 @@ files:
173
175
  - app/views/layouts/crusade_rails/application.html.erb
174
176
  - config/routes.rb
175
177
  - db/migrate/20130917203302_create_crusade_rails_user_subscriptions.rb
178
+ - lib/crusade_rails/configuration.rb
176
179
  - lib/crusade_rails/engine.rb
177
180
  - lib/crusade_rails/version.rb
178
181
  - lib/crusade_rails.rb
@@ -218,7 +221,7 @@ files:
218
221
  - test/dummy/config/routes.rb
219
222
  - test/dummy/config.ru
220
223
  - test/dummy/db/development.sqlite3
221
- - test/dummy/db/migrate/20130922190000_create_crusade_rails_user_subscriptions.crusade_rails.rb
224
+ - test/dummy/db/migrate/20130925062705_create_crusade_rails_user_subscriptions.crusade_rails.rb
222
225
  - test/dummy/db/schema.rb
223
226
  - test/dummy/db/test.sqlite3
224
227
  - test/dummy/lib/icon.iconset/icon_128x128.png
@@ -235,58 +238,21 @@ files:
235
238
  - test/dummy/public/favicon.ico
236
239
  - test/dummy/Rakefile
237
240
  - test/dummy/README.rdoc
238
- - test/dummy/tmp/cache/assets/development/sprockets/07be86ef00416c18f2f7dd96f4603129
239
- - test/dummy/tmp/cache/assets/development/sprockets/116d0ea1f1fccbc5f17329e738b48f32
240
- - test/dummy/tmp/cache/assets/development/sprockets/1c6cab9972997baaf0f7fd1599e62590
241
- - test/dummy/tmp/cache/assets/development/sprockets/2a4f82e222d708931c0b88831e1bb864
242
- - test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af
243
- - test/dummy/tmp/cache/assets/development/sprockets/2fe1114a6234d617f0bb5e464a840942
244
- - test/dummy/tmp/cache/assets/development/sprockets/39b9141911bd7b575b7e782b8c405a0d
245
- - test/dummy/tmp/cache/assets/development/sprockets/3c9d7a4a4511e1418a3f5e9beaac8d0a
246
- - test/dummy/tmp/cache/assets/development/sprockets/45a685d3bc33555e456c32424fd838e8
247
- - test/dummy/tmp/cache/assets/development/sprockets/576608e546507cd114398639d7f7bd5d
248
- - test/dummy/tmp/cache/assets/development/sprockets/57adfe7d0eeb4aca9491ffb75157956e
249
- - test/dummy/tmp/cache/assets/development/sprockets/5c7b888c11190fa68628e8fd3212e8fd
250
- - test/dummy/tmp/cache/assets/development/sprockets/5ded1a08ed08028fbe21471a88881d28
251
- - test/dummy/tmp/cache/assets/development/sprockets/5e40cea3d1e28179f2a2ad998d1f26f7
252
- - test/dummy/tmp/cache/assets/development/sprockets/618327f5ca738fb1d560cdf13c073bf3
253
- - test/dummy/tmp/cache/assets/development/sprockets/6e6652fce2d9f8b871274ccb2af329c7
254
- - test/dummy/tmp/cache/assets/development/sprockets/6f5e75e28ef2f140b52beb6f1b6609b9
255
- - test/dummy/tmp/cache/assets/development/sprockets/7161340e0502d24611730dd49b15e115
256
- - test/dummy/tmp/cache/assets/development/sprockets/7d4e507c01e7ef7a4dc9d7f9c5478ca4
257
- - test/dummy/tmp/cache/assets/development/sprockets/803bc12cb782253e6b4191a7346991c5
258
- - test/dummy/tmp/cache/assets/development/sprockets/8b3d3f72f349b54596b95558be73d55d
259
- - test/dummy/tmp/cache/assets/development/sprockets/97ba61a3e4a7ec32873e08c29a7a6f94
260
- - test/dummy/tmp/cache/assets/development/sprockets/9ccfcc3c008514fb5c35aa7b3d7bbc78
261
- - test/dummy/tmp/cache/assets/development/sprockets/a82b6a43a4be516353a2ac1d89f6b610
262
- - test/dummy/tmp/cache/assets/development/sprockets/a92311b92483c1f9472df2622e658768
263
- - test/dummy/tmp/cache/assets/development/sprockets/aba15ac42f92b66ff70b0a3e26184263
264
- - test/dummy/tmp/cache/assets/development/sprockets/b75702adcae93ffe045a33824fc40f12
265
- - test/dummy/tmp/cache/assets/development/sprockets/be89d70eb8f19e72ed6ad9481a7c1b9a
266
- - test/dummy/tmp/cache/assets/development/sprockets/c1d4b2d589a2dc7649e075ffea2d2566
267
- - test/dummy/tmp/cache/assets/development/sprockets/cd0a1473787729a36454fd789dd86195
268
- - test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994
269
- - test/dummy/tmp/cache/assets/development/sprockets/d03fd0d3629c94a744a70d063d15eb6f
270
- - test/dummy/tmp/cache/assets/development/sprockets/d572f7956c1b132aba30f71dfb1334d9
271
- - test/dummy/tmp/cache/assets/development/sprockets/dc8639471867248d3cfc41c6dad35a43
272
- - test/dummy/tmp/cache/assets/development/sprockets/e113ed0ed8564e75067a161599ed7fc9
273
- - test/dummy/tmp/cache/assets/development/sprockets/e2bd66166c81c25a6fea7aab23cf58cf
274
- - test/dummy/tmp/cache/assets/development/sprockets/e653b1d89bb66ba5ee551887655e02da
275
- - test/dummy/tmp/cache/assets/development/sprockets/eb5bc1e85d69a5ec7063b599c7f6acf1
276
- - test/dummy/tmp/cache/assets/development/sprockets/f084f98622288fc6a4d8fdbc755bcb48
277
- - test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
278
- - test/dummy/tmp/cache/assets/development/sprockets/f99eb680da1b65060a9388e0b41f19b0
279
- - test/dummy/tmp/cache/assets/development/sprockets/fa3e415ce51e582faa842454baced5a3
280
241
  - test/fixtures/crusade_rails/default_routes.rb
281
242
  - test/generators/install_generator_test.rb
243
+ - test/integration/configuration_test.rb
282
244
  - test/integration/push_package_integration_test.rb
283
245
  - test/javascripts/support/configuration.js.coffee
246
+ - test/javascripts/support/disable_logger.coffee
247
+ - test/javascripts/support/fake_notification.js.coffee
284
248
  - test/javascripts/support/jquery.js
249
+ - test/javascripts/support/jquery.mockajax.js
285
250
  - test/javascripts/support/safari.js.coffee
286
251
  - test/javascripts/test_helper.js.coffee
287
252
  - test/javascripts/unit/configuration_test.js.coffee
288
- - test/javascripts/unit/crusade_spec.js.coffee
253
+ - test/javascripts/unit/local_notification_test.js.coffee
289
254
  - test/javascripts/unit/notification_permission_test.js.coffee
255
+ - test/javascripts/unit/push_notification_test.js.coffee
290
256
  - test/routes/apns_routes_test.rb
291
257
  - test/services/notification_service_test.rb
292
258
  - test/services/user_subscription_service_test.rb
@@ -351,7 +317,7 @@ test_files:
351
317
  - test/dummy/config/routes.rb
352
318
  - test/dummy/config.ru
353
319
  - test/dummy/db/development.sqlite3
354
- - test/dummy/db/migrate/20130922190000_create_crusade_rails_user_subscriptions.crusade_rails.rb
320
+ - test/dummy/db/migrate/20130925062705_create_crusade_rails_user_subscriptions.crusade_rails.rb
355
321
  - test/dummy/db/schema.rb
356
322
  - test/dummy/db/test.sqlite3
357
323
  - test/dummy/lib/icon.iconset/icon_128x128.png
@@ -368,58 +334,21 @@ test_files:
368
334
  - test/dummy/public/favicon.ico
369
335
  - test/dummy/Rakefile
370
336
  - test/dummy/README.rdoc
371
- - test/dummy/tmp/cache/assets/development/sprockets/07be86ef00416c18f2f7dd96f4603129
372
- - test/dummy/tmp/cache/assets/development/sprockets/116d0ea1f1fccbc5f17329e738b48f32
373
- - test/dummy/tmp/cache/assets/development/sprockets/1c6cab9972997baaf0f7fd1599e62590
374
- - test/dummy/tmp/cache/assets/development/sprockets/2a4f82e222d708931c0b88831e1bb864
375
- - test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af
376
- - test/dummy/tmp/cache/assets/development/sprockets/2fe1114a6234d617f0bb5e464a840942
377
- - test/dummy/tmp/cache/assets/development/sprockets/39b9141911bd7b575b7e782b8c405a0d
378
- - test/dummy/tmp/cache/assets/development/sprockets/3c9d7a4a4511e1418a3f5e9beaac8d0a
379
- - test/dummy/tmp/cache/assets/development/sprockets/45a685d3bc33555e456c32424fd838e8
380
- - test/dummy/tmp/cache/assets/development/sprockets/576608e546507cd114398639d7f7bd5d
381
- - test/dummy/tmp/cache/assets/development/sprockets/57adfe7d0eeb4aca9491ffb75157956e
382
- - test/dummy/tmp/cache/assets/development/sprockets/5c7b888c11190fa68628e8fd3212e8fd
383
- - test/dummy/tmp/cache/assets/development/sprockets/5ded1a08ed08028fbe21471a88881d28
384
- - test/dummy/tmp/cache/assets/development/sprockets/5e40cea3d1e28179f2a2ad998d1f26f7
385
- - test/dummy/tmp/cache/assets/development/sprockets/618327f5ca738fb1d560cdf13c073bf3
386
- - test/dummy/tmp/cache/assets/development/sprockets/6e6652fce2d9f8b871274ccb2af329c7
387
- - test/dummy/tmp/cache/assets/development/sprockets/6f5e75e28ef2f140b52beb6f1b6609b9
388
- - test/dummy/tmp/cache/assets/development/sprockets/7161340e0502d24611730dd49b15e115
389
- - test/dummy/tmp/cache/assets/development/sprockets/7d4e507c01e7ef7a4dc9d7f9c5478ca4
390
- - test/dummy/tmp/cache/assets/development/sprockets/803bc12cb782253e6b4191a7346991c5
391
- - test/dummy/tmp/cache/assets/development/sprockets/8b3d3f72f349b54596b95558be73d55d
392
- - test/dummy/tmp/cache/assets/development/sprockets/97ba61a3e4a7ec32873e08c29a7a6f94
393
- - test/dummy/tmp/cache/assets/development/sprockets/9ccfcc3c008514fb5c35aa7b3d7bbc78
394
- - test/dummy/tmp/cache/assets/development/sprockets/a82b6a43a4be516353a2ac1d89f6b610
395
- - test/dummy/tmp/cache/assets/development/sprockets/a92311b92483c1f9472df2622e658768
396
- - test/dummy/tmp/cache/assets/development/sprockets/aba15ac42f92b66ff70b0a3e26184263
397
- - test/dummy/tmp/cache/assets/development/sprockets/b75702adcae93ffe045a33824fc40f12
398
- - test/dummy/tmp/cache/assets/development/sprockets/be89d70eb8f19e72ed6ad9481a7c1b9a
399
- - test/dummy/tmp/cache/assets/development/sprockets/c1d4b2d589a2dc7649e075ffea2d2566
400
- - test/dummy/tmp/cache/assets/development/sprockets/cd0a1473787729a36454fd789dd86195
401
- - test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994
402
- - test/dummy/tmp/cache/assets/development/sprockets/d03fd0d3629c94a744a70d063d15eb6f
403
- - test/dummy/tmp/cache/assets/development/sprockets/d572f7956c1b132aba30f71dfb1334d9
404
- - test/dummy/tmp/cache/assets/development/sprockets/dc8639471867248d3cfc41c6dad35a43
405
- - test/dummy/tmp/cache/assets/development/sprockets/e113ed0ed8564e75067a161599ed7fc9
406
- - test/dummy/tmp/cache/assets/development/sprockets/e2bd66166c81c25a6fea7aab23cf58cf
407
- - test/dummy/tmp/cache/assets/development/sprockets/e653b1d89bb66ba5ee551887655e02da
408
- - test/dummy/tmp/cache/assets/development/sprockets/eb5bc1e85d69a5ec7063b599c7f6acf1
409
- - test/dummy/tmp/cache/assets/development/sprockets/f084f98622288fc6a4d8fdbc755bcb48
410
- - test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
411
- - test/dummy/tmp/cache/assets/development/sprockets/f99eb680da1b65060a9388e0b41f19b0
412
- - test/dummy/tmp/cache/assets/development/sprockets/fa3e415ce51e582faa842454baced5a3
413
337
  - test/fixtures/crusade_rails/default_routes.rb
414
338
  - test/generators/install_generator_test.rb
339
+ - test/integration/configuration_test.rb
415
340
  - test/integration/push_package_integration_test.rb
416
341
  - test/javascripts/support/configuration.js.coffee
342
+ - test/javascripts/support/disable_logger.coffee
343
+ - test/javascripts/support/fake_notification.js.coffee
417
344
  - test/javascripts/support/jquery.js
345
+ - test/javascripts/support/jquery.mockajax.js
418
346
  - test/javascripts/support/safari.js.coffee
419
347
  - test/javascripts/test_helper.js.coffee
420
348
  - test/javascripts/unit/configuration_test.js.coffee
421
- - test/javascripts/unit/crusade_spec.js.coffee
349
+ - test/javascripts/unit/local_notification_test.js.coffee
422
350
  - test/javascripts/unit/notification_permission_test.js.coffee
351
+ - test/javascripts/unit/push_notification_test.js.coffee
423
352
  - test/routes/apns_routes_test.rb
424
353
  - test/services/notification_service_test.rb
425
354
  - test/services/user_subscription_service_test.rb
@@ -1,46 +0,0 @@
1
-
2
- class @Crusade
3
-
4
- requestPermission: (userId) ->
5
- promise = $.Deferred((defer) =>
6
- permission = currentPermission()
7
-
8
- resolve(permission, defer, userId)
9
-
10
- ).promise()
11
-
12
- promise.granted = promise.done
13
- promise.denied = promise.fail
14
-
15
- promise
16
-
17
- checkPermission: ->
18
- currentPermission()
19
-
20
- currentPermission = ->
21
- wrapPermission window.safari.pushNotification.permission(window.crusade.pushId)
22
-
23
- wrapPermission = (safariPermission) ->
24
- new NotificationPermission safariPermission
25
-
26
- requestNewPemission = (userId) ->
27
- $.Deferred((defer) =>
28
- window.safari.pushNotification.requestPermission(
29
- window.crusade.webserviceUrl
30
- window.crusade.pushId
31
- { userId: userId }
32
- (safariPermission) =>
33
- permission = wrapPermission safariPermission
34
-
35
- resolve(permission, defer, userId)
36
- )
37
- ).promise()
38
-
39
- resolve = (permission, defer, userId) ->
40
- switch permission.permission
41
- when 'granted' then defer.resolve(permission)
42
- when 'denied' then defer.reject(permission)
43
- when 'default'
44
- requestNewPemission(userId).
45
- done((permission) -> defer.resolve(permission)).
46
- fail((permission) -> defer.reject(permission))
@@ -1,102 +0,0 @@
1
-
2
- describe 'Crusade', ->
3
- subject = null
4
-
5
- beforeEach ->
6
- subject = new Crusade()
7
-
8
- describe 'request push notification permission', ->
9
- callback = null
10
- permissionResult = null
11
-
12
- beforeEach ->
13
- mockSafariPushNotification()
14
-
15
- callback = (permission) -> permissionResult = permission
16
-
17
- describe 'the user was already requested', ->
18
- afterEach ->
19
- expect(window.safari.pushNotification.permission).toHaveBeenCalledWith 'web.com.example.push.id'
20
-
21
-
22
- describe 'the user granted the permission', ->
23
- it 'executes the success function if the user has already granted the permission', ->
24
- spyOn(window.safari.pushNotification, 'permission').andReturn({permission: 'granted', deviceToken: 'deviceToken'})
25
-
26
- subject.requestPermission('userId').granted(callback)
27
-
28
- expect(permissionResult.permission).toEqual 'granted'
29
-
30
- it 'wraps the safari permission into a crusade permission', ->
31
- spyOn(window.safari.pushNotification, 'permission').andReturn({permission: 'granted', deviceToken: 'deviceToken'})
32
-
33
- subject.requestPermission('userId').granted(callback)
34
-
35
- expect(permissionResult).toEqual jasmine.any(NotificationPermission)
36
-
37
- describe 'the user denied the permission', ->
38
- it 'executes the error function if the user has already denied the permission', ->
39
- spyOn(window.safari.pushNotification, 'permission').andReturn({permission: 'denied'})
40
-
41
- subject.requestPermission('userId').denied(callback)
42
-
43
- expect(permissionResult.permission).toEqual 'denied'
44
-
45
- describe 'the user has never been requested', ->
46
- permissionCallback = null
47
-
48
- beforeEach ->
49
- spyOn(window.safari.pushNotification, 'permission').andReturn({permission: 'default'})
50
-
51
- permissionCallback = (permission) -> callback(permission)
52
-
53
- afterEach ->
54
- expect(window.safari.pushNotification.requestPermission).toHaveBeenCalledWith 'https://www.example.com/push',
55
- 'web.com.example.push.id'
56
- {userId: 'userId'}
57
- jasmine.any(Function)
58
-
59
- describe 'the user denies the permission', ->
60
- it 'executes the success function if the user has already granted the permission', ->
61
- window.safari.pushNotification.fakeResult = { permission: 'granted', deviceToken: 'deviceToken' }
62
- spyOn(window.safari.pushNotification, 'requestPermission').andCallThrough()
63
-
64
- subject.requestPermission('userId').granted(callback)
65
-
66
- expect(permissionResult.permission).toEqual 'granted'
67
-
68
- it 'wraps the safari permission into a crusade permission', ->
69
- window.safari.pushNotification.fakeResult = { permission: 'granted', deviceToken: 'deviceToken' }
70
- spyOn(window.safari.pushNotification, 'requestPermission').andCallThrough()
71
-
72
- subject.requestPermission('userId').granted(callback)
73
-
74
- expect(permissionResult).toEqual jasmine.any(NotificationPermission)
75
-
76
- describe 'the user grants the permission', ->
77
- it 'executes the error function if the user has already denied the permission', ->
78
- window.safari.pushNotification.fakeResult = { permission: 'denied' }
79
- spyOn(window.safari.pushNotification, 'requestPermission').andCallThrough()
80
-
81
- subject.requestPermission('userId').denied(callback)
82
-
83
- expect(permissionResult.permission).toEqual 'denied'
84
-
85
- describe 'checkPermission', ->
86
- afterEach ->
87
- expect(window.safari.pushNotification.permission).toHaveBeenCalledWith 'web.com.example.push.id'
88
-
89
-
90
- it 'returns the result of the current permission', ->
91
- spyOn(window.safari.pushNotification, 'permission').andReturn({permission: 'granted', deviceToken: 'deviceToken'})
92
-
93
- permissionResult = subject.checkPermission()
94
-
95
- expect(permissionResult.permission).toEqual 'granted'
96
-
97
- it 'wraps the safari permission into a crusade permission', ->
98
- spyOn(window.safari.pushNotification, 'permission').andReturn({permission: 'granted', deviceToken: 'deviceToken'})
99
-
100
- permissionResult = subject.checkPermission()
101
-
102
- expect(permissionResult).toEqual jasmine.any(NotificationPermission)