perfect_money_merchant 0.1.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +25 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +5 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +29 -0
  7. data/Rakefile +2 -0
  8. data/app/controllers/perfect_money_merchant/payments_controller.rb +39 -0
  9. data/app/models/perfect_money_merchant/account.rb +152 -0
  10. data/app/models/perfect_money_merchant/payment.rb +12 -0
  11. data/config/routes.rb +9 -0
  12. data/lib/generators/perfect_money_merchant/perfect_money_merchant_generator.rb +19 -0
  13. data/lib/generators/perfect_money_merchant/templates/migration.rb +42 -0
  14. data/lib/perfect_money_merchant/api.rb +52 -0
  15. data/lib/perfect_money_merchant/configuration.rb +46 -0
  16. data/lib/perfect_money_merchant/engine.rb +6 -0
  17. data/lib/perfect_money_merchant/error.rb +10 -0
  18. data/lib/perfect_money_merchant/railtie.rb +8 -0
  19. data/lib/perfect_money_merchant/sci.rb +121 -0
  20. data/lib/perfect_money_merchant/sci_response.rb +116 -0
  21. data/lib/perfect_money_merchant/version.rb +3 -0
  22. data/lib/perfect_money_merchant.rb +23 -0
  23. data/perfect_money_merchant.gemspec +33 -0
  24. data/spec/controllers/perfect_money_merchant/payments_controller_spec.rb +57 -0
  25. data/spec/models/perfect_money_merchant/account_spec.rb +7 -0
  26. data/spec/perfect_money_merchant/configuration_spec.rb +51 -0
  27. data/spec/perfect_money_merchant/sci_response_spec.rb +50 -0
  28. data/spec/perfect_money_merchant/sci_spec.rb +49 -0
  29. data/spec/rails_test_app/Gemfile +8 -0
  30. data/spec/rails_test_app/Rakefile +6 -0
  31. data/spec/rails_test_app/app/assets/javascripts/application.js +16 -0
  32. data/spec/rails_test_app/app/assets/stylesheets/application.css +15 -0
  33. data/spec/rails_test_app/app/controllers/application_controller.rb +5 -0
  34. data/spec/rails_test_app/app/helpers/application_helper.rb +2 -0
  35. data/spec/rails_test_app/app/views/layouts/application.html.erb +14 -0
  36. data/spec/rails_test_app/bin/bundle +3 -0
  37. data/spec/rails_test_app/bin/rails +4 -0
  38. data/spec/rails_test_app/bin/rake +4 -0
  39. data/spec/rails_test_app/config/application.rb +23 -0
  40. data/spec/rails_test_app/config/boot.rb +4 -0
  41. data/spec/rails_test_app/config/database.yml +25 -0
  42. data/spec/rails_test_app/config/environment.rb +8 -0
  43. data/spec/rails_test_app/config/environments/development.rb +42 -0
  44. data/spec/rails_test_app/config/environments/production.rb +78 -0
  45. data/spec/rails_test_app/config/environments/test.rb +39 -0
  46. data/spec/rails_test_app/config/initializers/assets.rb +8 -0
  47. data/spec/rails_test_app/config/initializers/backtrace_silencers.rb +7 -0
  48. data/spec/rails_test_app/config/initializers/cookies_serializer.rb +3 -0
  49. data/spec/rails_test_app/config/initializers/filter_parameter_logging.rb +4 -0
  50. data/spec/rails_test_app/config/initializers/inflections.rb +16 -0
  51. data/spec/rails_test_app/config/initializers/mime_types.rb +4 -0
  52. data/spec/rails_test_app/config/initializers/session_store.rb +3 -0
  53. data/spec/rails_test_app/config/initializers/wrap_parameters.rb +14 -0
  54. data/spec/rails_test_app/config/locales/en.yml +23 -0
  55. data/spec/rails_test_app/config/routes.rb +64 -0
  56. data/spec/rails_test_app/config/secrets.yml +22 -0
  57. data/spec/rails_test_app/config.ru +5 -0
  58. data/spec/rails_test_app/db/seeds.rb +0 -0
  59. data/spec/rails_test_app/public/404.html +67 -0
  60. data/spec/rails_test_app/public/422.html +67 -0
  61. data/spec/rails_test_app/public/500.html +66 -0
  62. data/spec/rails_test_app/public/favicon.ico +0 -0
  63. data/spec/rails_test_app/public/robots.txt +5 -0
  64. data/spec/spec_helper.rb +66 -0
  65. metadata +302 -0
@@ -0,0 +1,116 @@
1
+ # payee_account: U1234567
2
+ # payer_account: U7654321
3
+ # payment_amount: 100.0
4
+ # payment_units: USD
5
+ # payment_batch_num: 73550837
6
+ # payment_id: okpZKCUM9sML99Qzx1t7e
7
+ # timestampgmt: 1415801831
8
+ # suggested_memo: The New Friends Payment
9
+ # additional_field_1: xxxxxx
10
+ # verification_code: xxxxxxxxxxxxxxxxxxxx
11
+ # v2_hash: 634D048EB7583DE389AF550E519CBE4C
12
+
13
+ # secret_key = SFndfsdJNFjern2D123raFDF2
14
+
15
+ class PerfectMoneyMerchant::SCIResponse
16
+ attr_accessor :secret_key
17
+
18
+ # Initializes PerfectMoneyMerchant::SCI::Response object
19
+ # @param [Hash] params SCI-returned-params
20
+ # @option params [String] :payment_id Payment ID
21
+ # @option params [String] :payment_amount Payment amount
22
+ # @option params [String] :payment_units Payment currency
23
+ # @option params [String] :payment_batch_num Payment batch number
24
+ # @option params [String] :payee_account Payee account code number
25
+ # @option params [String] :payer_account Payer account code number
26
+ # @option params [String] :timestampgmt Payment performance date
27
+ # @option params [String] :v2_hash Payment verification hash
28
+ # @option params [String] :verification_code Payment verification code
29
+ # @option params [String] :verification_fields Payment verification fields
30
+ def initialize(params)
31
+ params.each_pair do |param_name, param_value|
32
+ singleton_class.class_eval { attr_reader param_name }
33
+ instance_variable_set("@#{param_name}", param_value)
34
+ end
35
+
36
+ # self.secret_key = PerfectMoneyMerchant::Account::Query.new.find_by_unit_code_number(payee_account).try(:secret_key)
37
+ end
38
+
39
+ def set_secret_key(secret_key)
40
+ @secret_key = secret_key
41
+ end
42
+
43
+ def verify!
44
+ check_on_secret_key!
45
+ check_on_verification_code!
46
+ check_on_v2_hash!
47
+ check_on_payment_purpose!
48
+ true
49
+ end
50
+
51
+ alias_method :process!, :verify!
52
+
53
+ private
54
+
55
+ def check_on_payment_purpose!
56
+ if respond_to?(:payment_purpose)
57
+ if payment_purpose.nil? or payment_purpose.blank?
58
+ raise StandardError.new('payment_purpose is nil')
59
+ end
60
+ else
61
+ raise StandardError.new('payment_purpose is not defined')
62
+ end
63
+
64
+ end
65
+
66
+ def check_on_secret_key!
67
+ if respond_to?(:secret_key)
68
+ if secret_key.nil?
69
+ raise StandardError.new('secret key is nil')
70
+ end
71
+ else
72
+ raise StandardError.new('secret key is not defined')
73
+ end
74
+
75
+ end
76
+
77
+ def check_on_verification_code!
78
+ if respond_to?(:verification_code) and respond_to?(:verification_fields)
79
+ verification_values = verification_fields.split(' ').map { |field| instance_variable_get("@#{field}") }
80
+ unless PerfectMoneyMerchant::SCI.generate_verification_code(verification_values) == verification_code
81
+ raise StandardError.new('verification code invalid')
82
+ end
83
+ else
84
+ raise StandardError.new('verification code or verification_fields is empty')
85
+ end
86
+ end
87
+
88
+ def check_on_v2_hash!
89
+ v2_hash = Digest::MD5.hexdigest(
90
+ [
91
+ payment_id,
92
+ payee_account,
93
+ payment_amount,
94
+ payment_units,
95
+ payment_batch_num,
96
+ payer_account,
97
+ Digest::MD5.hexdigest(secret_key).upcase,
98
+ timestampgmt
99
+ ].join(':')
100
+ ).upcase
101
+
102
+ unless self.v2_hash == v2_hash
103
+ raise StandardError.new('v2_hash invalid')
104
+ end
105
+ end
106
+
107
+ def create_payment!
108
+ PerfectMoneyMerchant::Payment.create!(
109
+ payment_batch_num: payment_batch_num,
110
+ payment_id: payment_id,
111
+ payment_amount: payment_amount,
112
+ payer_account: payer_account,
113
+ payee_account: payee_account
114
+ )
115
+ end
116
+ end # end Response
@@ -0,0 +1,3 @@
1
+ module PerfectMoneyMerchant
2
+ VERSION = '0.1.0.alpha.3'
3
+ end
@@ -0,0 +1,23 @@
1
+ require 'perfect_money_merchant/version'
2
+
3
+ require 'faraday'
4
+ require 'faraday_middleware'
5
+ require 'faraday_middleware/response_middleware'
6
+
7
+ require 'hashie/mash'
8
+
9
+ require 'nokogiri'
10
+
11
+ module PerfectMoneyMerchant
12
+ def self.config
13
+ Configuration.config
14
+ end
15
+ end
16
+
17
+ require 'perfect_money_merchant/railtie'
18
+ require 'perfect_money_merchant/engine'
19
+ require 'perfect_money_merchant/configuration'
20
+ require 'perfect_money_merchant/api'
21
+ require 'perfect_money_merchant/sci'
22
+ require 'perfect_money_merchant/sci_response'
23
+ require 'perfect_money_merchant/error'
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'perfect_money_merchant/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'perfect_money_merchant'
8
+ spec.version = PerfectMoneyMerchant::VERSION
9
+ spec.authors = ['Vladislav Pauk']
10
+ spec.email = ['vladislavpauk@gmail.com']
11
+ spec.summary = %q{blah blah}
12
+ spec.description = %q{blah blah blah blah}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'sqlite3', '~> 1.3'
24
+ spec.add_development_dependency 'rspec-rails', '~> 3.1'
25
+ spec.add_development_dependency 'pry', '~> 0.10'
26
+ spec.add_development_dependency 'pry-byebug', '~> 2.0'
27
+
28
+ spec.add_runtime_dependency 'faraday', '~> 0.9'
29
+ spec.add_runtime_dependency 'faraday_middleware', '~> 0.9'
30
+ spec.add_runtime_dependency 'nokogiri', '~> 1.6'
31
+ spec.add_runtime_dependency 'hashie', '~> 3.3'
32
+ spec.add_runtime_dependency 'rails', '~> 4.1'
33
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe PerfectMoneyMerchant::PaymentsController, :type => :controller do
4
+ context 'POST success' do
5
+ it 'with 200' do
6
+ post :success
7
+ expect(response).to have_http_status(200)
8
+ end
9
+ end
10
+
11
+ context 'POST error' do
12
+ it 'with 400' do
13
+ post :error
14
+ expect(response).to have_http_status(400)
15
+ end
16
+ end
17
+
18
+ context 'POST status' do
19
+ before(:example) do
20
+ PerfectMoneyMerchant::Account.create!(
21
+ secret_key: 'SFndfsdJNFjern2D123raFDF2'
22
+ ).tap do |account|
23
+ account.units.create!(
24
+ {
25
+ currency: 'usd',
26
+ code_number: 'U1234567'
27
+ }
28
+ )
29
+ end
30
+ end
31
+
32
+ let (:sci_params) do
33
+ {
34
+ payee_account: 'U1234567',
35
+ payer_account: 'U7654321',
36
+ payment_amount: '100.0',
37
+ payment_units: 'USD',
38
+ payment_batch_num: '73550837',
39
+ payment_id: 'okpZKCUM9sML99Qzx1t7e',
40
+ timestampgmt: '1415801831',
41
+ suggested_memo: 'The New Friends Payment',
42
+ v2_hash: '634D048EB7583DE389AF550E519CBE4C',
43
+ payment_purpose: 'test_task'
44
+ }
45
+ end
46
+
47
+ it 'with 200 status code' do
48
+ post :status, sci_params
49
+ expect(response).to have_http_status(200)
50
+ end
51
+
52
+ it 'with 400 status code' do
53
+ post :status, sci_params.tap { |hash| hash[:payment_amount] = '1.0' }
54
+ expect(response).to have_http_status(400)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe PerfectMoneyMerchant::Account do
4
+ context '#transfer' do
5
+ it 'should transfer okay'
6
+ end
7
+ end
@@ -0,0 +1,51 @@
1
+ # require 'spec_helper'
2
+ #
3
+ # PerfectMoneyMerchant::Configuration.class_eval do
4
+ # def self.reset
5
+ # @config = nil
6
+ # end
7
+ # end
8
+ #
9
+ # RSpec.describe PerfectMoneyMerchant::Configuration do
10
+ # context '.configure' do
11
+ # # it 'should yield with class instance' do
12
+ # # expect { |b| described_class.configure(&b) }.to yield_with_args(described_class)
13
+ # # end
14
+ # #
15
+ # # it 'should return class instance' do
16
+ # # expect(described_class.configure).to be_a(described_class)
17
+ # # end
18
+ #
19
+ # it 'should initialize configuration instance' do
20
+ # config = described_class.configure do |config|
21
+ # config.verification_secret = 'SEfxvsdrwer3rdsczdr3'
22
+ # config.payee_name = 'Perfect Money Spec'
23
+ # config.suggested_memo = 'Perfect Money Spec Commentary'
24
+ # config.payment_units = 'usd'
25
+ # config.status_url = ''
26
+ # config.payment_url = ''
27
+ # config.nopayment_url = ''
28
+ # config.payment_url_method = 'POST'
29
+ # config.nopayment_url_method = 'POST'
30
+ # end
31
+ #
32
+ # expect(config).to be_a(described_class)
33
+ # end
34
+ #
35
+ # it 'should raise validation fields error' do
36
+ # expect do
37
+ # described_class.configure do |config|
38
+ # config.verification_secret = 'SEfxvsdrwer3rdsczdr3'
39
+ # config.payee_name = 'Perfect Money Spec'
40
+ # config.suggested_memo = 'Perfect Money Spec Commentary'
41
+ # # config.payment_units = 'usd'
42
+ # config.status_url = ''
43
+ # config.payment_url = ''
44
+ # config.nopayment_url = ''
45
+ # config.payment_url_method = 'POST'
46
+ # config.nopayment_url_method = 'POST'
47
+ # end
48
+ # end.to raise_error
49
+ # end
50
+ # end
51
+ # end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe PerfectMoneyMerchant::SCIResponse do
4
+ SECRET_KEY = 'SFndfsdJNFjern2D123raFDF2'
5
+
6
+ let (:sci_response) do
7
+ PerfectMoneyMerchant::SCIResponse.new(
8
+ payee_account: 'U1234567',
9
+ payer_account: 'U7654321',
10
+ payment_amount: '100.0',
11
+ payment_units: 'USD',
12
+ payment_batch_num: '73550837',
13
+ payment_id: 'okpZKCUM9sML99Qzx1t7e',
14
+ timestampgmt: '1415801831',
15
+ suggested_memo: 'The New Friends Payment',
16
+ v2_hash: '634D048EB7583DE389AF550E519CBE4C'
17
+ )
18
+ end
19
+
20
+ context '#initialize' do
21
+ it 'should convert params into fields' do
22
+ expect(sci_response).to respond_to(:payee_account)
23
+ expect(sci_response).to respond_to(:payer_account)
24
+ expect(sci_response).to respond_to(:payment_amount)
25
+ expect(sci_response).to respond_to(:payment_units)
26
+ expect(sci_response).to respond_to(:payment_batch_num)
27
+ expect(sci_response).to respond_to(:payment_id)
28
+ expect(sci_response).to respond_to(:timestampgmt)
29
+ expect(sci_response).to respond_to(:suggested_memo)
30
+ expect(sci_response).to respond_to(:v2_hash)
31
+ end
32
+ end
33
+
34
+ context '#verify?' do
35
+ before(:example) do
36
+ sci_response.set_secret_key(SECRET_KEY)
37
+ end
38
+
39
+ it 'should return true' do
40
+ expect(sci_response.verify!).to be_truthy
41
+ end
42
+
43
+ context 'should raise error' do
44
+ it 'v2_hash' do
45
+ sci_response.instance_variable_set('@payee_account', 'U1234568')
46
+ expect { sci_response.verify! }.to raise_error(/v2_hash invalid/)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe PerfectMoneyMerchant::SCI do
4
+ let(:sci) do
5
+ PerfectMoneyMerchant::SCI.new(
6
+ payee: 'U1234567',
7
+ price: 10.0,
8
+ currency: 'usd',
9
+ additional: {
10
+ merchandise_name: 'oak field'
11
+ },
12
+ purpose: 'merchandise',
13
+ verification: [:merchandise_name]
14
+ )
15
+ end
16
+
17
+ context '#set_field' do
18
+ before(:example) do
19
+ sci.set_field(:some_new_field, 'some_value')
20
+ end
21
+
22
+ it 'should dynamically create attribute' do
23
+ expect(sci).to respond_to(:some_new_field)
24
+ end
25
+
26
+ it 'created attribute should has value' do
27
+ expect(sci.some_new_field).to eql('some_value')
28
+ end
29
+ end
30
+
31
+ describe '#initialize' do
32
+ it 'should has correct payment_amount' do
33
+ expect(sci.payment_amount).to eql(10.0)
34
+ end
35
+
36
+ it 'should has verification attributes' do
37
+ expect(sci.verification_code.class).to eql(String)
38
+ expect(sci.verification_fields.class).to eql(String)
39
+ end
40
+
41
+ it 'should has additional fields' do
42
+ expect(sci.merchandise_name).to eql('oak field')
43
+ end
44
+
45
+ it 'expected baggage fields contain additional fields' do
46
+ expect(sci.baggage_fields.split(' ')).to include('merchandise_name')
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+ gem 'rails', '~> 4.1.7'
3
+ gem 'sqlite3', '~> 1.3.10'
4
+ gem 'rspec-rails', '~> 3.1.0'
5
+ gem 'pry', '~> 0.10.1'
6
+ gem 'pry-byebug', '~> 2.0.0'
7
+ gem 'perfect_money_merchant', path: '../..'
8
+
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>RailsTestApp</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module RailsTestApp
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17
+ # config.time_zone = 'Central Time (US & Canada)'
18
+
19
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21
+ # config.i18n.default_locale = :de
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3
@@ -0,0 +1,8 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+ # gem_lib_path = ::File.expand_path('../../../../lib', __FILE__)
4
+ # $LOAD_PATH.unshift(gem_lib_path) unless $LOAD_PATH.include?(gem_lib_path)
5
+ # require 'perfect_money_merchant'
6
+
7
+ # Initialize the Rails application.
8
+ Rails.application.initialize!
@@ -0,0 +1,42 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations.
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+
30
+ # Adds additional error checking when serving assets at runtime.
31
+ # Checks for improperly declared sprockets dependencies.
32
+ # Raises helpful error messages.
33
+ config.assets.raise_runtime_errors = true
34
+
35
+ # Raises error for missing translations
36
+ # config.action_view.raise_on_missing_translations = true
37
+
38
+ config.after_initialize do
39
+ ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
40
+ ActiveRecord::Migrator.migrate File.expand_path('../../../db/migrate/', __FILE__)
41
+ end
42
+ end