t2_airtime 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -0
- data/README.md +413 -31
- data/Rakefile +23 -3
- data/app/controllers/t2_airtime/airtime_controller.rb +102 -102
- data/config/routes.rb +8 -8
- data/lib/t2_airtime/engine.rb +6 -0
- data/lib/t2_airtime/version.rb +1 -1
- data/lib/t2_airtime.rb +1 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +27 -0
- data/spec/dummy/bin/update +26 -0
- data/spec/dummy/config/application.rb +31 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +44 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cors.rb +16 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +56 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/secrets.yml +32 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/log/development.log +118 -0
- data/spec/dummy/log/test.log +0 -0
- data/spec/dummy/tmp/restart.txt +0 -0
- data/spec/rails_helper.rb +60 -0
- data/spec/spec_helper.rb +96 -0
- data/spec/t2_airtime_spec.rb +181 -0
- metadata +92 -73
- data/.gitignore +0 -14
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -6
- data/LICENSE.txt +0 -21
- data/doc/T2Airtime/API.html +0 -1152
- data/doc/T2Airtime/Account.html +0 -260
- data/doc/T2Airtime/AirtimeController.html +0 -491
- data/doc/T2Airtime/Base.html +0 -346
- data/doc/T2Airtime/ConfigurationError.html +0 -124
- data/doc/T2Airtime/Country.html +0 -448
- data/doc/T2Airtime/Engine.html +0 -124
- data/doc/T2Airtime/Error.html +0 -290
- data/doc/T2Airtime/Operator.html +0 -272
- data/doc/T2Airtime/Product.html +0 -294
- data/doc/T2Airtime/Reply.html +0 -775
- data/doc/T2Airtime/Request.html +0 -664
- data/doc/T2Airtime/Test.html +0 -221
- data/doc/T2Airtime/Transaction.html +0 -426
- data/doc/T2Airtime/Util.html +0 -338
- data/doc/T2Airtime.html +0 -147
- data/doc/_index.html +0 -265
- data/doc/class_list.html +0 -51
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -58
- data/doc/css/style.css +0 -492
- data/doc/file.README.html +0 -172
- data/doc/file_list.html +0 -56
- data/doc/frames.html +0 -17
- data/doc/index.html +0 -172
- data/doc/js/app.js +0 -248
- data/doc/js/full_list.js +0 -216
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -491
- data/doc/top-level-namespace.html +0 -110
- data/release +0 -7
- data/t2_airtime.gemspec +0 -33
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Avoid CORS issues when API is called from the frontend app.
|
4
|
+
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
|
5
|
+
|
6
|
+
# Read more: https://github.com/cyu/rack-cors
|
7
|
+
|
8
|
+
# Rails.application.config.middleware.insert_before 0, Rack::Cors do
|
9
|
+
# allow do
|
10
|
+
# origins 'example.com'
|
11
|
+
#
|
12
|
+
# resource '*',
|
13
|
+
# headers: :any,
|
14
|
+
# methods: [:get, :post, :put, :patch, :delete, :options, :head]
|
15
|
+
# end
|
16
|
+
# end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
9
|
+
# inflect.irregular 'person', 'people'
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym 'RESTful'
|
16
|
+
# end
|
@@ -0,0 +1,9 @@
|
|
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
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# The following keys must be escaped otherwise they will not be retrieved by
|
20
|
+
# the default I18n backend:
|
21
|
+
#
|
22
|
+
# true, false, on, off, yes, no
|
23
|
+
#
|
24
|
+
# Instead, surround them with single quotes.
|
25
|
+
#
|
26
|
+
# en:
|
27
|
+
# 'true': 'foo'
|
28
|
+
#
|
29
|
+
# To learn more, please read the Rails Internationalization guide
|
30
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
31
|
+
|
32
|
+
en:
|
33
|
+
hello: "Hello world"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
2
|
+
# The `threads` method setting takes two numbers: a minimum and maximum.
|
3
|
+
# Any libraries that use thread pools should be configured to match
|
4
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
5
|
+
# and maximum; this matches the default thread size of Active Record.
|
6
|
+
#
|
7
|
+
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
8
|
+
threads threads_count, threads_count
|
9
|
+
|
10
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
11
|
+
#
|
12
|
+
port ENV.fetch("PORT") { 3000 }
|
13
|
+
|
14
|
+
# Specifies the `environment` that Puma will run in.
|
15
|
+
#
|
16
|
+
environment ENV.fetch("RAILS_ENV") { "development" }
|
17
|
+
|
18
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
19
|
+
# Workers are forked webserver processes. If using threads and workers together
|
20
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
21
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
22
|
+
# processes).
|
23
|
+
#
|
24
|
+
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
25
|
+
|
26
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
27
|
+
# This directive tells Puma to first boot the application and load code
|
28
|
+
# before forking the application. This takes advantage of Copy On Write
|
29
|
+
# process behavior so workers use less memory. If you use this option
|
30
|
+
# you need to make sure to reconnect any threads in the `on_worker_boot`
|
31
|
+
# block.
|
32
|
+
#
|
33
|
+
# preload_app!
|
34
|
+
|
35
|
+
# If you are preloading your application and using Active Record, it's
|
36
|
+
# recommended that you close any connections to the database before workers
|
37
|
+
# are forked to prevent connection leakage.
|
38
|
+
#
|
39
|
+
# before_fork do
|
40
|
+
# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
|
41
|
+
# end
|
42
|
+
|
43
|
+
# The code in the `on_worker_boot` will be called if you are using
|
44
|
+
# clustered mode by specifying a number of `workers`. After each worker
|
45
|
+
# process is booted, this block will be run. If you are using the `preload_app!`
|
46
|
+
# option, you will want to use this block to reconnect to any threads
|
47
|
+
# or connections that may have been created at application boot, as Ruby
|
48
|
+
# cannot share connections between processes.
|
49
|
+
#
|
50
|
+
# on_worker_boot do
|
51
|
+
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
|
55
|
+
# Allow puma to be restarted by `rails restart` command.
|
56
|
+
plugin :tmp_restart
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rails secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
# Shared secrets are available across all environments.
|
14
|
+
|
15
|
+
# shared:
|
16
|
+
# api_key: a1B2c3D4e5F6
|
17
|
+
|
18
|
+
# Environmental secrets are only available for that specific environment.
|
19
|
+
|
20
|
+
development:
|
21
|
+
secret_key_base: bb93504dd7a7461dc1358e02b76598a18fd6ef38063f4ee7b733f6a6668714b0ddc1b1da7a7792ee13bec8f2f6bc8be49fc9ed273edace86a7766b29e7465230
|
22
|
+
|
23
|
+
test:
|
24
|
+
secret_key_base: dfa8c93161d4b84507547786ac12fd60832723ecc07cb15098de2e4376a60b969865dcfa89dabb56b71182ae70845fff7855704f0e302ac635b696a798510ca2
|
25
|
+
|
26
|
+
# Do not keep production secrets in the unencrypted secrets file.
|
27
|
+
# Instead, either read values from the environment.
|
28
|
+
# Or, use `bin/rails secrets:setup` to configure encrypted secrets
|
29
|
+
# and move the `production:` environment over there.
|
30
|
+
|
31
|
+
production:
|
32
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -0,0 +1,118 @@
|
|
1
|
+
---------------------------
|
2
|
+
T2Airtime::Test: test_truth
|
3
|
+
---------------------------
|
4
|
+
Started GET "/" for 192.168.18.1 at 2017-09-13 13:25:16 +0200
|
5
|
+
Processing by Rails::WelcomeController#index as HTML
|
6
|
+
Rendering /usr/local/rvm/gems/ruby-2.3.3/gems/railties-5.1.3/lib/rails/templates/rails/welcome/index.html.erb
|
7
|
+
Rendered /usr/local/rvm/gems/ruby-2.3.3/gems/railties-5.1.3/lib/rails/templates/rails/welcome/index.html.erb (7.9ms)
|
8
|
+
Completed 200 OK in 23ms (Views: 18.3ms)
|
9
|
+
|
10
|
+
|
11
|
+
Started GET "/favicon.ico" for 192.168.18.1 at 2017-09-13 13:25:17 +0200
|
12
|
+
|
13
|
+
ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
|
14
|
+
|
15
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
|
16
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
|
17
|
+
railties (5.1.3) lib/rails/rack/logger.rb:36:in `call_app'
|
18
|
+
railties (5.1.3) lib/rails/rack/logger.rb:24:in `block in call'
|
19
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged'
|
20
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged'
|
21
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged'
|
22
|
+
railties (5.1.3) lib/rails/rack/logger.rb:24:in `call'
|
23
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
|
24
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call'
|
25
|
+
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
|
26
|
+
activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
|
27
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call'
|
28
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call'
|
29
|
+
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
|
30
|
+
railties (5.1.3) lib/rails/engine.rb:522:in `call'
|
31
|
+
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
|
32
|
+
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
|
33
|
+
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
|
34
|
+
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
|
35
|
+
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
|
36
|
+
Started GET "/t2_airtime" for 192.168.18.1 at 2017-09-13 13:25:24 +0200
|
37
|
+
|
38
|
+
ActionController::RoutingError (No route matches [GET] "/t2_airtime"):
|
39
|
+
|
40
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
|
41
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
|
42
|
+
railties (5.1.3) lib/rails/rack/logger.rb:36:in `call_app'
|
43
|
+
railties (5.1.3) lib/rails/rack/logger.rb:24:in `block in call'
|
44
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged'
|
45
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged'
|
46
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged'
|
47
|
+
railties (5.1.3) lib/rails/rack/logger.rb:24:in `call'
|
48
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
|
49
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call'
|
50
|
+
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
|
51
|
+
activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
|
52
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call'
|
53
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call'
|
54
|
+
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
|
55
|
+
railties (5.1.3) lib/rails/engine.rb:522:in `call'
|
56
|
+
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
|
57
|
+
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
|
58
|
+
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
|
59
|
+
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
|
60
|
+
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
|
61
|
+
Started GET "/airtime/countries" for 192.168.18.1 at 2017-09-13 13:25:33 +0200
|
62
|
+
|
63
|
+
ActionController::RoutingError (No route matches [GET] "/airtime/countries"):
|
64
|
+
|
65
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
|
66
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
|
67
|
+
railties (5.1.3) lib/rails/rack/logger.rb:36:in `call_app'
|
68
|
+
railties (5.1.3) lib/rails/rack/logger.rb:24:in `block in call'
|
69
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged'
|
70
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged'
|
71
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged'
|
72
|
+
railties (5.1.3) lib/rails/rack/logger.rb:24:in `call'
|
73
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
|
74
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call'
|
75
|
+
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
|
76
|
+
activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
|
77
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call'
|
78
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call'
|
79
|
+
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
|
80
|
+
railties (5.1.3) lib/rails/engine.rb:522:in `call'
|
81
|
+
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
|
82
|
+
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
|
83
|
+
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
|
84
|
+
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
|
85
|
+
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
|
86
|
+
Started GET "/countries" for 192.168.18.1 at 2017-09-13 13:26:22 +0200
|
87
|
+
|
88
|
+
ActionController::RoutingError (No route matches [GET] "/countries"):
|
89
|
+
|
90
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
|
91
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
|
92
|
+
railties (5.1.3) lib/rails/rack/logger.rb:36:in `call_app'
|
93
|
+
railties (5.1.3) lib/rails/rack/logger.rb:24:in `block in call'
|
94
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged'
|
95
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged'
|
96
|
+
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged'
|
97
|
+
railties (5.1.3) lib/rails/rack/logger.rb:24:in `call'
|
98
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
|
99
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call'
|
100
|
+
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
|
101
|
+
activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
|
102
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call'
|
103
|
+
actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call'
|
104
|
+
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
|
105
|
+
railties (5.1.3) lib/rails/engine.rb:522:in `call'
|
106
|
+
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
|
107
|
+
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
|
108
|
+
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
|
109
|
+
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
|
110
|
+
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
|
111
|
+
Started GET "/t2_airtime/countries" for 192.168.18.1 at 2017-09-13 13:27:09 +0200
|
112
|
+
Processing by T2Airtime::AirtimeController#countries as HTML
|
113
|
+
Completed 200 OK in 15436ms (Views: 59.0ms)
|
114
|
+
|
115
|
+
|
116
|
+
---------------------------
|
117
|
+
T2Airtime::Test: test_truth
|
118
|
+
---------------------------
|
File without changes
|
File without changes
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
require 'spec_helper'
|
3
|
+
ENV['RAILS_ENV'] ||= 'test'
|
4
|
+
require File.expand_path('../dummy/config/environment', __FILE__)
|
5
|
+
# Prevent database truncation if the environment is production
|
6
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
7
|
+
require 'rspec/rails'
|
8
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
9
|
+
|
10
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
11
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
12
|
+
# run as spec files by default. This means that files in spec/support that end
|
13
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
14
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
15
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
16
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
17
|
+
#
|
18
|
+
# The following line is provided for convenience purposes. It has the downside
|
19
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
20
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
21
|
+
# require only the support files necessary.
|
22
|
+
#
|
23
|
+
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
24
|
+
|
25
|
+
# ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
26
|
+
# Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
27
|
+
|
28
|
+
# Checks for pending migration and applies them before tests are run.
|
29
|
+
# If you are not using ActiveRecord, you can remove this line.
|
30
|
+
# ActiveRecord::Migration.maintain_test_schema!
|
31
|
+
|
32
|
+
RSpec.configure do |config|
|
33
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
34
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
35
|
+
|
36
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
37
|
+
# examples within a transaction, remove the following line or assign false
|
38
|
+
# instead of true.
|
39
|
+
config.use_transactional_fixtures = true
|
40
|
+
|
41
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
42
|
+
# based on their file location, for example enabling you to call `get` and
|
43
|
+
# `post` in specs under `spec/controllers`.
|
44
|
+
#
|
45
|
+
# You can disable this behaviour by removing the line below, and instead
|
46
|
+
# explicitly tag your specs with their type, e.g.:
|
47
|
+
#
|
48
|
+
# RSpec.describe UsersController, :type => :controller do
|
49
|
+
# # ...
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# The different available types are documented in the features, such as in
|
53
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
54
|
+
config.infer_spec_type_from_file_location!
|
55
|
+
|
56
|
+
# Filter lines from Rails gems in backtraces.
|
57
|
+
config.filter_rails_from_backtrace!
|
58
|
+
# arbitrary gems may also be filtered via:
|
59
|
+
# config.filter_gems_from_backtrace("gem name")
|
60
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
RSpec.configure do |config|
|
17
|
+
# rspec-expectations config goes here. You can use an alternate
|
18
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
19
|
+
# assertions if you prefer.
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
23
|
+
# defined using `chain`, e.g.:
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
26
|
+
# ...rather than:
|
27
|
+
# # => "be bigger than 2"
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
32
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
33
|
+
config.mock_with :rspec do |mocks|
|
34
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
35
|
+
# a real object. This is generally recommended, and will default to
|
36
|
+
# `true` in RSpec 4.
|
37
|
+
mocks.verify_partial_doubles = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
41
|
+
# have no way to turn it off -- the option exists only for backwards
|
42
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
43
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
44
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
45
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
46
|
+
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
49
|
+
=begin
|
50
|
+
# This allows you to limit a spec run to individual examples or groups
|
51
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
52
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
53
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
54
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
55
|
+
config.filter_run_when_matching :focus
|
56
|
+
|
57
|
+
# Allows RSpec to persist some state between runs in order to support
|
58
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
59
|
+
# you configure your source control system to ignore this file.
|
60
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
61
|
+
|
62
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
63
|
+
# recommended. For more details, see:
|
64
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
65
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
66
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
67
|
+
config.disable_monkey_patching!
|
68
|
+
|
69
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
70
|
+
# file, and it's useful to allow more verbose output when running an
|
71
|
+
# individual spec file.
|
72
|
+
if config.files_to_run.one?
|
73
|
+
# Use the documentation formatter for detailed output,
|
74
|
+
# unless a formatter has already been configured
|
75
|
+
# (e.g. via a command-line flag).
|
76
|
+
config.default_formatter = "doc"
|
77
|
+
end
|
78
|
+
|
79
|
+
# Print the 10 slowest examples and example groups at the
|
80
|
+
# end of the spec run, to help surface which specs are running
|
81
|
+
# particularly slow.
|
82
|
+
config.profile_examples = 10
|
83
|
+
|
84
|
+
# Run specs in random order to surface order dependencies. If you find an
|
85
|
+
# order dependency and want to debug it, you can fix the order by providing
|
86
|
+
# the seed, which is printed after each run.
|
87
|
+
# --seed 1234
|
88
|
+
config.order = :random
|
89
|
+
|
90
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
91
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
92
|
+
# test failures related to randomization by passing the same `--seed` value
|
93
|
+
# as the one that triggered the failure.
|
94
|
+
Kernel.srand config.seed
|
95
|
+
=end
|
96
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
require "t2_airtime"
|
3
|
+
|
4
|
+
RSpec.describe T2Airtime do
|
5
|
+
|
6
|
+
it "serializes account information" do
|
7
|
+
info = T2Airtime::Account.info
|
8
|
+
expect(info["attributes"]["type"]).to eq("Master")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "serializes at least 1 transaction" do
|
12
|
+
at_least_five_items = T2Airtime::Transaction.take
|
13
|
+
end
|
14
|
+
|
15
|
+
it "serializes at least 5 products" do
|
16
|
+
five_items = T2Airtime::Product.take
|
17
|
+
expect(five_items.count).to be > 4
|
18
|
+
end
|
19
|
+
|
20
|
+
it "serializes all countries" do
|
21
|
+
items = T2Airtime::Country.take(nil)
|
22
|
+
expect(items.count).to be > 5
|
23
|
+
end
|
24
|
+
|
25
|
+
it "serializes 5 countries" do
|
26
|
+
five_items = T2Airtime::Country.take
|
27
|
+
expect(five_items.count).to eq(5)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "serializes at least 1 up to 5 operators" do
|
31
|
+
at_least_five_items = T2Airtime::Operator.take
|
32
|
+
expect(at_least_five_items.count).to be > 1
|
33
|
+
expect(at_least_five_items.count).to be < 6
|
34
|
+
end
|
35
|
+
|
36
|
+
it "has a version number" do
|
37
|
+
expect(T2Airtime::VERSION).not_to be nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it "has the correct API URL" do
|
41
|
+
expect(T2Airtime::DOMAIN).to eq("transferto.com")
|
42
|
+
expect(T2Airtime::ENDPOINT).to eq("cgi-bin/shop/topup")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "has 7 test numbers" do
|
46
|
+
expect(T2Airtime::Util.test_numbers.length).to eq(7)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "responds to ping" do
|
50
|
+
api = T2Airtime::API.api
|
51
|
+
expect(api.ping.message).to eq("pong")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "gets account information" do
|
55
|
+
api = T2Airtime::API.api
|
56
|
+
expect(api.account_info.error_code).to eq(0)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "checks number information" do
|
60
|
+
api = T2Airtime::API.api
|
61
|
+
reply = api.msisdn_info(T2Airtime::Util.test_numbers(2))
|
62
|
+
expect(reply.success?).to eq(true)
|
63
|
+
expect(reply.data[:country]).to eq("Indonesia")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "reserves a transaction id" do
|
67
|
+
api = T2Airtime::API.api
|
68
|
+
reply = api.reserve_id
|
69
|
+
expect(reply.success?).to eq(true)
|
70
|
+
expect(reply.data[:reserved_id]).not_to be nil
|
71
|
+
end
|
72
|
+
|
73
|
+
it "returns a countries list" do
|
74
|
+
api = T2Airtime::API.api
|
75
|
+
reply = api.country_list
|
76
|
+
expect(reply.success?).to eq(true)
|
77
|
+
expect(reply.data[:country].split(",").count).to be(reply.data[:countryid].split(",").count)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "returns a country operators" do
|
81
|
+
api = T2Airtime::API.api
|
82
|
+
country_id = api.msisdn_info(T2Airtime::Util.test_numbers(2)).data[:countryid]
|
83
|
+
reply = api.operator_list(country_id)
|
84
|
+
expect(reply.success?).to eq(true)
|
85
|
+
expect(reply.data[:operator].split(",").count).to be(reply.data[:operatorid].split(",").count)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "returns an operator products" do
|
89
|
+
api = T2Airtime::API.api
|
90
|
+
operator_id = api.msisdn_info(T2Airtime::Util.test_numbers(2)).data[:operatorid]
|
91
|
+
reply = api.product_list(operator_id)
|
92
|
+
expect(reply.success?).to eq(true)
|
93
|
+
expect(reply.data[:product_list].split(",").count).to be(reply.data[:wholesale_price_list].split(",").count)
|
94
|
+
expect(reply.data[:product_list].split(",").count).to be(reply.data[:retail_price_list].split(",").count)
|
95
|
+
end
|
96
|
+
|
97
|
+
# The method simulation takes the same parameters as topup method. It does not perform a real Top-up to the destination number.
|
98
|
+
# This action will test if the destination number is in TransferTo numbering plan, and if the product specified is valid.
|
99
|
+
# • It DOES NOT verify if the destination number has expired for instance as the request is
|
100
|
+
# not submitted to the operator. Thus, a simulation can be successful, while a real top-up
|
101
|
+
# (request sent to the operator to perform both debit and Top-up) can fail.
|
102
|
+
# • For PIN Based products, API will respond basics information (PIN Less like). All parameters
|
103
|
+
# related to PIN information will not be provided in the response.
|
104
|
+
# Note that this action will provide you with some information (products available in your account) but is
|
105
|
+
# not part of the Top-up cycle. You should perform Top-up without making any simulations before.
|
106
|
+
|
107
|
+
it "returns error code 0 for PIN based Top-up (successful transaction)" do
|
108
|
+
api = T2Airtime::API.api
|
109
|
+
to_number = T2Airtime::Util.test_numbers(1)
|
110
|
+
operator_id = api.msisdn_info(to_number).data[:operatorid]
|
111
|
+
product = api.product_list(operator_id).data[:product_list].split(",")[0]
|
112
|
+
reply = api.topup("anumber", to_number, product, 'simulation')
|
113
|
+
expect(reply.success?).to eq(true)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "returns error code 0 for PIN less Top-up (successful transaction)" do
|
117
|
+
api = T2Airtime::API.api
|
118
|
+
to_number = T2Airtime::Util.test_numbers(2)
|
119
|
+
operator_id = api.msisdn_info(to_number).data[:operatorid]
|
120
|
+
product = api.product_list(operator_id).data[:product_list].split(",")[0]
|
121
|
+
reply = api.topup("anumber", to_number, product, 'simulation')
|
122
|
+
expect(reply.success?).to eq(true)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "returns error code 204 (destination number is not a valid prepaid phone number)" do
|
126
|
+
api = T2Airtime::API.api
|
127
|
+
to_number = T2Airtime::Util.test_numbers(3)
|
128
|
+
operator_id = api.msisdn_info(to_number).data[:operatorid]
|
129
|
+
product = api.product_list(operator_id).data[:product_list].split(",")[0]
|
130
|
+
reply = api.topup("anumber", to_number, product, 'simulation')
|
131
|
+
expect(reply.success?).to eq(false)
|
132
|
+
expect(reply.error_code).to eq(204)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "returns error code 301 (input value out of range or invalid product)" do
|
136
|
+
api = T2Airtime::API.api
|
137
|
+
to_number = T2Airtime::Util.test_numbers(4)
|
138
|
+
operator_id = api.msisdn_info(to_number).data[:operatorid]
|
139
|
+
product = api.product_list(operator_id).data[:product_list].split(",")[0]
|
140
|
+
reply = api.topup("anumber", to_number, product, 'simulation')
|
141
|
+
expect(reply.success?).to eq(false)
|
142
|
+
expect(reply.error_code).to eq(301)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "returns error code 214 (transaction refused by the operator)" do
|
146
|
+
api = T2Airtime::API.api
|
147
|
+
to_number = T2Airtime::Util.test_numbers(5)
|
148
|
+
operator_id = api.msisdn_info(to_number).data[:operatorid]
|
149
|
+
product = api.product_list(operator_id).data[:product_list].split(",")[0]
|
150
|
+
reply = api.topup("anumber", to_number, product, 'simulation')
|
151
|
+
expect(reply.success?).to eq(false)
|
152
|
+
expect(reply.error_code).to eq(214)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "returns error code 998 (system not available, please retry later)" do
|
156
|
+
api = T2Airtime::API.api
|
157
|
+
to_number = T2Airtime::Util.test_numbers(6)
|
158
|
+
operator_id = api.msisdn_info(to_number).data[:operatorid]
|
159
|
+
product = api.product_list(operator_id).data[:product_list].split(",")[0]
|
160
|
+
reply = api.topup("anumber", to_number, product, 'simulation')
|
161
|
+
expect(reply.success?).to eq(false)
|
162
|
+
expect(reply.error_code).to eq(998)
|
163
|
+
end
|
164
|
+
|
165
|
+
it "returns error code 999 (unknown error, please contact support)" do
|
166
|
+
api = T2Airtime::API.api
|
167
|
+
to_number = T2Airtime::Util.test_numbers(7)
|
168
|
+
operator_id = api.msisdn_info(to_number).data[:operatorid]
|
169
|
+
product = api.product_list(operator_id).data[:product_list].split(",")[0]
|
170
|
+
reply = api.topup("anumber", to_number, product, 'simulation')
|
171
|
+
expect(reply.success?).to eq(false)
|
172
|
+
expect(reply.error_code).to eq(999)
|
173
|
+
end
|
174
|
+
|
175
|
+
it "returns a transaction list" do
|
176
|
+
api = T2Airtime::API.api
|
177
|
+
reply = api.transaction_list(Time.now.beginning_of_day, Time.now.end_of_day)
|
178
|
+
expect(reply.success?).to eq(true)
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|