esendex 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/esendex/application_controller.rb +4 -4
  3. data/app/controllers/esendex/inbound_messages_controller.rb +11 -11
  4. data/app/controllers/esendex/message_delivered_events_controller.rb +11 -11
  5. data/app/controllers/esendex/message_failed_events_controller.rb +11 -11
  6. data/app/controllers/esendex/push_notification_handler.rb +41 -41
  7. data/config/routes.rb +5 -5
  8. data/lib/esendex.rb +63 -62
  9. data/lib/esendex/account.rb +44 -44
  10. data/lib/esendex/api_connection.rb +29 -29
  11. data/lib/esendex/dispatcher_result.rb +25 -25
  12. data/lib/esendex/engine.rb +4 -4
  13. data/lib/esendex/exceptions.rb +25 -25
  14. data/lib/esendex/hash_serialisation.rb +23 -23
  15. data/lib/esendex/inbound_message.rb +30 -30
  16. data/lib/esendex/message.rb +38 -38
  17. data/lib/esendex/message_batch_submission.rb +50 -50
  18. data/lib/esendex/message_delivered_event.rb +29 -29
  19. data/lib/esendex/message_failed_event.rb +29 -29
  20. data/lib/esendex/railtie.rb +11 -11
  21. data/lib/esendex/version.rb +3 -3
  22. data/lib/esendex/voice_message.rb +25 -0
  23. data/lib/tasks/esendex.rake +29 -29
  24. data/licence.txt +23 -23
  25. data/readme.md +186 -186
  26. data/spec/account_spec.rb +211 -211
  27. data/spec/api_connection_spec.rb +78 -78
  28. data/spec/controllers/message_delivered_events_controller_spec.rb +29 -29
  29. data/spec/controllers/push_notification_handler_spec.rb +96 -96
  30. data/spec/dummy/README.rdoc +261 -261
  31. data/spec/dummy/Rakefile +7 -7
  32. data/spec/dummy/app/assets/javascripts/application.js +15 -15
  33. data/spec/dummy/app/assets/stylesheets/application.css +13 -13
  34. data/spec/dummy/app/controllers/application_controller.rb +3 -3
  35. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  36. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  37. data/spec/dummy/config.ru +4 -4
  38. data/spec/dummy/config/application.rb +66 -66
  39. data/spec/dummy/config/boot.rb +9 -9
  40. data/spec/dummy/config/environment.rb +5 -5
  41. data/spec/dummy/config/environments/development.rb +37 -37
  42. data/spec/dummy/config/environments/production.rb +67 -67
  43. data/spec/dummy/config/environments/test.rb +39 -39
  44. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  45. data/spec/dummy/config/initializers/inflections.rb +15 -15
  46. data/spec/dummy/config/initializers/mime_types.rb +5 -5
  47. data/spec/dummy/config/initializers/secret_token.rb +7 -7
  48. data/spec/dummy/config/initializers/session_store.rb +8 -8
  49. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  50. data/spec/dummy/config/locales/en.yml +5 -5
  51. data/spec/dummy/config/routes.rb +4 -4
  52. data/spec/dummy/public/404.html +26 -26
  53. data/spec/dummy/public/422.html +26 -26
  54. data/spec/dummy/public/500.html +25 -25
  55. data/spec/dummy/script/rails +6 -6
  56. data/spec/hash_serialisation_spec.rb +52 -52
  57. data/spec/inbound_message_spec.rb +42 -42
  58. data/spec/message_batch_submission_spec.rb +54 -54
  59. data/spec/message_delivered_event_spec.rb +32 -32
  60. data/spec/message_failed_event_spec.rb +32 -32
  61. data/spec/message_spec.rb +49 -49
  62. data/spec/spec_helper.rb +41 -41
  63. data/spec/voice_message_spec.rb +29 -0
  64. metadata +12 -9
@@ -1,39 +1,39 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
9
-
10
- # Configure static asset server for tests with Cache-Control for performance
11
- # config.serve_static_assets = true
12
- # config.static_cache_control = "public, max-age=3600"
13
-
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
16
-
17
- # Show full error reports and disable caching
18
- config.consider_all_requests_local = true
19
- config.action_controller.perform_caching = false
20
-
21
- # Raise exceptions instead of rendering exception templates
22
- config.action_dispatch.show_exceptions = false
23
-
24
- # Disable request forgery protection in test environment
25
- config.action_controller.allow_forgery_protection = false
26
-
27
- # Tell Action Mailer not to deliver emails to the real world.
28
- # The :test delivery method accumulates sent emails in the
29
- # ActionMailer::Base.deliveries array.
30
- # config.action_mailer.delivery_method = :test
31
-
32
- # Raise exception on mass assignment protection for Active Record models
33
- # config.active_record.mass_assignment_sanitizer = :strict
34
-
35
- # Print deprecation notices to the stderr
36
- config.active_support.deprecation = :stderr
37
-
38
- config.log_level = :debug
39
- end
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ # config.serve_static_assets = true
12
+ # config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ # config.action_mailer.delivery_method = :test
31
+
32
+ # Raise exception on mass assignment protection for Active Record models
33
+ # config.active_record.mass_assignment_sanitizer = :strict
34
+
35
+ # Print deprecation notices to the stderr
36
+ config.active_support.deprecation = :stderr
37
+
38
+ config.log_level = :debug
39
+ end
@@ -1,7 +1,7 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
- # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
-
6
- # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
- # Rails.backtrace_cleaner.remove_silencers!
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -1,15 +1,15 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format
4
- # (all these examples are active by default):
5
- # ActiveSupport::Inflector.inflections do |inflect|
6
- # inflect.plural /^(ox)$/i, '\1en'
7
- # inflect.singular /^(ox)en/i, '\1'
8
- # inflect.irregular 'person', 'people'
9
- # inflect.uncountable %w( fish sheep )
10
- # end
11
- #
12
- # These inflection rules are supported but not enabled by default:
13
- # ActiveSupport::Inflector.inflections do |inflect|
14
- # inflect.acronym 'RESTful'
15
- # end
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
11
+ #
12
+ # These inflection rules are supported but not enabled by default:
13
+ # ActiveSupport::Inflector.inflections do |inflect|
14
+ # inflect.acronym 'RESTful'
15
+ # end
@@ -1,5 +1,5 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new mime types for use in respond_to blocks:
4
- # Mime::Type.register "text/richtext", :rtf
5
- # Mime::Type.register_alias "text/html", :iphone
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -1,7 +1,7 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = 'c64d49877bf3e6cc8319313f320e049418bda2e2492b5780acec4f4245bee53b25d0c18539c13583c6a5653f329a60e8ab57358dd7e411081a0dbe0ce28e8a53'
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = 'c64d49877bf3e6cc8319313f320e049418bda2e2492b5780acec4f4245bee53b25d0c18539c13583c6a5653f329a60e8ab57358dd7e411081a0dbe0ce28e8a53'
@@ -1,8 +1,8 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
-
5
- # Use the database for sessions instead of the cookie-based default,
6
- # which shouldn't be used to store highly confidential information
7
- # (create the session table with "rails generate session_migration")
8
- # Dummy::Application.config.session_store :active_record_store
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -1,14 +1,14 @@
1
- # Be sure to restart your server when you modify this file.
2
- #
3
- # This file contains settings for ActionController::ParamsWrapper which
4
- # is enabled by default.
5
-
6
- # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
- ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json]
9
- end
10
-
11
- # Disable root element in JSON by default.
12
- ActiveSupport.on_load(:active_record) do
13
- self.include_root_in_json = false
14
- end
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -1,5 +1,5 @@
1
- # Sample localization file for English. Add more files in this directory for other locales.
2
- # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
-
4
- en:
5
- hello: "Hello world"
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -1,4 +1,4 @@
1
- Rails.application.routes.draw do
2
-
3
- mount Esendex::Engine => "/esendex"
4
- end
1
+ Rails.application.routes.draw do
2
+
3
+ mount Esendex::Engine => "/esendex"
4
+ end
@@ -1,26 +1,26 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -1,26 +1,26 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -1,25 +1,25 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- </div>
24
- </body>
25
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
@@ -1,6 +1,6 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -1,53 +1,53 @@
1
- require 'spec_helper'
2
-
3
- module Esendex
4
- class DummyHashSerialisation
5
- include HashSerialisation
6
-
7
- attr_accessor :name, :time, :notes
8
-
9
- end
10
-
11
- describe HashSerialisation do
12
- let(:name) { random_string }
13
- let(:time) { random_time }
14
- let(:notes) { random_string }
15
-
16
- before(:each) do
17
- @attrs = { name: name, time: time, notes: notes }
18
- end
19
-
20
- describe "#initialize" do
21
-
22
- subject { DummyHashSerialisation.new @attrs }
23
-
24
- it "sets the name" do
25
- subject.name.should eq(name)
26
- end
27
- it "sets the time" do
28
- subject.time.should eq(time)
29
- end
30
- it "sets the notes" do
31
- subject.notes.should eq(notes)
32
- end
33
-
34
- context "when invalid attribute passed" do
35
- before(:each) do
36
- @attrs[random_string] = random_string
37
- end
38
- it "should raise and argument error" do
39
- expect { subject }.to raise_error(ArgumentError)
40
- end
41
- end
42
- end
43
-
44
- describe "#to_hash" do
45
- subject { DummyHashSerialisation.new(@attrs).to_hash }
46
-
47
- it "should match the init hash" do
48
- subject.should eq(@attrs)
49
- end
50
- end
51
-
52
- end
1
+ require 'spec_helper'
2
+
3
+ module Esendex
4
+ class DummyHashSerialisation
5
+ include HashSerialisation
6
+
7
+ attr_accessor :name, :time, :notes
8
+
9
+ end
10
+
11
+ describe HashSerialisation do
12
+ let(:name) { random_string }
13
+ let(:time) { random_time }
14
+ let(:notes) { random_string }
15
+
16
+ before(:each) do
17
+ @attrs = { name: name, time: time, notes: notes }
18
+ end
19
+
20
+ describe "#initialize" do
21
+
22
+ subject { DummyHashSerialisation.new @attrs }
23
+
24
+ it "sets the name" do
25
+ subject.name.should eq(name)
26
+ end
27
+ it "sets the time" do
28
+ subject.time.should eq(time)
29
+ end
30
+ it "sets the notes" do
31
+ subject.notes.should eq(notes)
32
+ end
33
+
34
+ context "when invalid attribute passed" do
35
+ before(:each) do
36
+ @attrs[random_string] = random_string
37
+ end
38
+ it "should raise and argument error" do
39
+ expect { subject }.to raise_error(ArgumentError)
40
+ end
41
+ end
42
+ end
43
+
44
+ describe "#to_hash" do
45
+ subject { DummyHashSerialisation.new(@attrs).to_hash }
46
+
47
+ it "should match the init hash" do
48
+ subject.should eq(@attrs)
49
+ end
50
+ end
51
+
52
+ end
53
53
  end