workarea-forter 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.gitignore +17 -0
  7. data/CHANGELOG.md +63 -0
  8. data/CODE_OF_CONDUCT.md +3 -0
  9. data/CONTRIBUTING.md +3 -0
  10. data/Gemfile +25 -0
  11. data/LICENSE +52 -0
  12. data/LICENSE.md +3 -0
  13. data/README.md +113 -0
  14. data/Rakefile +60 -0
  15. data/app/controllers/workarea/admin/orders_controller.decorator +6 -0
  16. data/app/controllers/workarea/storefront/application_controller.decorator +10 -0
  17. data/app/models/search/admin/order.decorator +7 -0
  18. data/app/models/workarea/checkout/collect_payment.decorator +75 -0
  19. data/app/models/workarea/forter/decision.rb +18 -0
  20. data/app/models/workarea/forter/response.rb +15 -0
  21. data/app/models/workarea/fulfillment.decorator +77 -0
  22. data/app/models/workarea/order/status/suspected_fraud.rb +13 -0
  23. data/app/models/workarea/order.decorator +14 -0
  24. data/app/models/workarea/payment/saved_credit_card.decorator +14 -0
  25. data/app/models/workarea/payment/status/suspected_fraud.rb +13 -0
  26. data/app/models/workarea/payment/tender/credit_card.decorator +25 -0
  27. data/app/models/workarea/payment.decorator +13 -0
  28. data/app/services/workarea/forter/account.rb +42 -0
  29. data/app/services/workarea/forter/order.rb +145 -0
  30. data/app/services/workarea/forter/payment.rb +80 -0
  31. data/app/services/workarea/forter/tender/credit_card.rb +73 -0
  32. data/app/services/workarea/forter/tender/general.rb +29 -0
  33. data/app/services/workarea/forter/tender/gift_card.rb +23 -0
  34. data/app/services/workarea/forter/tender/paypal.rb +38 -0
  35. data/app/services/workarea/forter/tender/store_credit.rb +23 -0
  36. data/app/view_models/workarea/admin/order_view_model.decorator +7 -0
  37. data/app/views/workarea/admin/orders/_forter.html.haml +18 -0
  38. data/app/views/workarea/admin/orders/forter.html.haml +57 -0
  39. data/app/views/workarea/storefront/_forter_tracking.html.haml +4 -0
  40. data/app/workers/forter/update_status.rb +21 -0
  41. data/app/workers/workarea/save_user_order_details.decorator +34 -0
  42. data/bin/rails +20 -0
  43. data/config/initializers/appends.rb +9 -0
  44. data/config/initializers/workarea.rb +22 -0
  45. data/config/locales/en.yml +26 -0
  46. data/config/routes.rb +7 -0
  47. data/lib/workarea/forter/bogus_gateway.rb +62 -0
  48. data/lib/workarea/forter/decision_response.rb +60 -0
  49. data/lib/workarea/forter/engine.rb +8 -0
  50. data/lib/workarea/forter/gateway.rb +66 -0
  51. data/lib/workarea/forter/version.rb +5 -0
  52. data/lib/workarea/forter.rb +50 -0
  53. data/test/dummy/Rakefile +6 -0
  54. data/test/dummy/bin/bundle +3 -0
  55. data/test/dummy/bin/rails +4 -0
  56. data/test/dummy/bin/rake +4 -0
  57. data/test/dummy/bin/setup +30 -0
  58. data/test/dummy/bin/update +26 -0
  59. data/test/dummy/bin/yarn +11 -0
  60. data/test/dummy/config/application.rb +30 -0
  61. data/test/dummy/config/boot.rb +5 -0
  62. data/test/dummy/config/cable.yml +10 -0
  63. data/test/dummy/config/environment.rb +5 -0
  64. data/test/dummy/config/environments/development.rb +51 -0
  65. data/test/dummy/config/environments/production.rb +88 -0
  66. data/test/dummy/config/environments/test.rb +44 -0
  67. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  68. data/test/dummy/config/initializers/assets.rb +14 -0
  69. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  70. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  71. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  72. data/test/dummy/config/initializers/inflections.rb +16 -0
  73. data/test/dummy/config/initializers/mime_types.rb +4 -0
  74. data/test/dummy/config/initializers/workarea.rb +5 -0
  75. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  76. data/test/dummy/config/locales/en.yml +33 -0
  77. data/test/dummy/config/puma.rb +56 -0
  78. data/test/dummy/config/routes.rb +5 -0
  79. data/test/dummy/config/secrets.yml +32 -0
  80. data/test/dummy/config/spring.rb +6 -0
  81. data/test/dummy/config.ru +5 -0
  82. data/test/dummy/db/seeds.rb +2 -0
  83. data/test/dummy/log/.keep +0 -0
  84. data/test/factories/forter.rb +132 -0
  85. data/test/integration/workarea/admin/forter_order_integration_test.rb +36 -0
  86. data/test/integration/workarea/forter_authorize_cim_response_code_integration_test.rb +69 -0
  87. data/test/integration/workarea/forter_braintree_response_code_integration_test.rb +69 -0
  88. data/test/integration/workarea/forter_checkoutdotcom_integration_test.rb +71 -0
  89. data/test/integration/workarea/forter_cybersource_response_code_integration_test.rb +69 -0
  90. data/test/integration/workarea/forter_moneris_response_code_integration_test.rb +69 -0
  91. data/test/integration/workarea/forter_payflow_pro_response_code_test.rb +69 -0
  92. data/test/integration/workarea/storefront/forter_integration_test.rb +138 -0
  93. data/test/lib/workarea/forter/gateway_test.rb +47 -0
  94. data/test/models/workarea/checkout/forter_collect_payment_test.rb +60 -0
  95. data/test/models/workarea/forter_payment_test.rb +58 -0
  96. data/test/models/workarea/payment/forter_credit_card_test.rb +19 -0
  97. data/test/models/workarea/payment/forter_saved_credit_card_test.rb +32 -0
  98. data/test/services/workarea/forter/order_test.rb +82 -0
  99. data/test/support/workarea/forter_api_config.rb +27 -0
  100. data/test/system/workarea/admin/forter_system_test.rb +31 -0
  101. data/test/system/workarea/storefront/forter_braintree_checkout_system_test.rb +79 -0
  102. data/test/system/workarea/storefront/forter_tracking_system_test.rb +20 -0
  103. data/test/system/workarea/storefront/guest_checkout_system_test.decorator +43 -0
  104. data/test/teaspoon_env.rb +6 -0
  105. data/test/test_helper.rb +11 -0
  106. data/test/vcr_cassettes/forter/get_decision.yml +66 -0
  107. data/test/vcr_cassettes/forter/integration/authorize_net_response_code.yml +410 -0
  108. data/test/vcr_cassettes/forter/integration/braintree_response_code.yml +231 -0
  109. data/test/vcr_cassettes/forter/integration/checkoutdotcom_response_code.yml +129 -0
  110. data/test/vcr_cassettes/forter/integration/cyber_response_code.yml +199 -0
  111. data/test/vcr_cassettes/forter/integration/moneris_response_code.yml +84 -0
  112. data/test/vcr_cassettes/forter/integration/payflow_pro_response_code.yml +60 -0
  113. data/test/vcr_cassettes/forter/system/braintree_approved.yml +293 -0
  114. data/test/vcr_cassettes/forter/system/braintree_declined.yml +485 -0
  115. data/test/vcr_cassettes/forter/system/braintree_not_reviewed.yml +293 -0
  116. data/test/vcr_cassettes/forter/update_status.yml +182 -0
  117. data/test/view_models/workarea/storefront/order_view_model_test.decorator +10 -0
  118. data/test/workers/forter/update_status_test.rb +22 -0
  119. data/workarea-forter.gemspec +18 -0
  120. metadata +195 -0
@@ -0,0 +1,34 @@
1
+ module Workarea
2
+ decorate SaveUserOrderDetails, with: :forter do
3
+ def save_payment_details(order, user)
4
+ payment = Payment.find_or_initialize_by(id: order.id)
5
+ payment_profile = Payment::Profile.lookup(PaymentReference.new(user))
6
+ billing_address = extract_address_attributes(payment.address)
7
+
8
+ if billing_address.present?
9
+ user.auto_save_billing_address(billing_address)
10
+
11
+ if user.public_info.blank?
12
+ user.update_attributes!(
13
+ first_name: billing_address[:first_name],
14
+ last_name: billing_address[:last_name]
15
+ )
16
+ end
17
+ end
18
+
19
+ if payment.credit_card? && !payment.credit_card.saved?
20
+ payment_profile.credit_cards.create(
21
+ first_name: payment.credit_card.first_name,
22
+ last_name: payment.credit_card.last_name,
23
+ display_number: payment.credit_card.display_number,
24
+ issuer: payment.credit_card.issuer,
25
+ month: payment.credit_card.month,
26
+ year: payment.credit_card.year,
27
+ token: payment.credit_card.token,
28
+ default: payment_profile.credit_cards.none?,
29
+ bin: payment.credit_card.bin
30
+ )
31
+ end
32
+ end
33
+ end
34
+ end
data/bin/rails ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
6
+ ENGINE_PATH = File.expand_path('../../lib/workarea/forter/engine', __FILE__)
7
+ APP_PATH = File.expand_path('../../test/dummy/config/application', __FILE__)
8
+
9
+ # Set up gems listed in the Gemfile.
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
11
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
12
+
13
+ require "action_controller/railtie"
14
+ require "action_view/railtie"
15
+ require "action_mailer/railtie"
16
+ require "rails/test_unit/railtie"
17
+ require "sprockets/railtie"
18
+ require 'teaspoon-mocha'
19
+
20
+ require 'rails/engine/commands'
@@ -0,0 +1,9 @@
1
+ Workarea.append_partials(
2
+ 'storefront.javascript',
3
+ 'workarea/storefront/forter_tracking'
4
+ )
5
+
6
+ Workarea.append_partials(
7
+ 'admin.order_cards',
8
+ 'workarea/admin/orders/forter'
9
+ )
@@ -0,0 +1,22 @@
1
+ Workarea.configure do |config|
2
+ config.order_status_calculators.insert(0, 'Workarea::Order::Status::SuspectedFraud')
3
+ config.payment_status_calculators.insert(0, 'Workarea::Payment::Status::SuspectedFraud')
4
+
5
+ config.forter = ActiveSupport::Configurable::Configuration.new
6
+ config.forter.site_id = nil
7
+
8
+ config.forter.api_version = "2.2"
9
+
10
+ config.forter.api_timeout = 2
11
+ config.forter.open_timeout = 2
12
+
13
+ config.forter.response_code = {
14
+ 'ActiveMerchant::Billing::StripeGateway' => -> (transaction) { transaction.params['failure_code'] },
15
+ 'ActiveMerchant::Billing::BraintreeBlueGateway' => -> (transaction) { transaction.response.params["braintree_transaction"]["processor_response_code"] },
16
+ 'ActiveMerchant::Billing::MonerisGateway' => -> (transaction) { transaction.response.params["response_code"] },
17
+ 'ActiveMerchant::Billing::AuthorizeNetCimGateway' => -> (transaction) { transaction.response.params["direct_response"]["response_code"] },
18
+ 'ActiveMerchant::Billing::PayflowGateway' => -> (transaction) { transaction.response.params["result"] },
19
+ 'ActiveMerchant::Billing::CyberSourceGateway' => -> (transaction) { transaction.response.params["reasonCode"] },
20
+ 'ActiveMerchant::Billing::CheckoutV2Gateway' => -> (transaction) { transaction.response.params["responseCode"] || transaction.response.params["response_code"] }
21
+ }
22
+ end
@@ -0,0 +1,26 @@
1
+ en:
2
+ workarea:
3
+ admin:
4
+ orders:
5
+ forter:
6
+ page_title: "%{id} Forter Fraud Decision"
7
+ title: Fraud Decision
8
+ review_reason: Decision Action
9
+ reason_code: Reason
10
+ status: Forter Order Status
11
+ console: View in Forter Admin
12
+ details_heading: Details
13
+ details_description: A list of decision responses returned from Forter
14
+ decision_error: No decision made, check response
15
+ error: Error
16
+ details:
17
+ action: Action
18
+ message: Message
19
+ reason_code: Reason Code
20
+ errors: Errors
21
+ cards:
22
+ forter:
23
+ title: 'Fraud Decision:'
24
+ decision: 'Decision Action:'
25
+ reason_code: 'Reason:'
26
+ status: 'Forter Order Status:'
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Workarea::Admin::Engine.routes.draw do
2
+ resources :orders, only: [] do
3
+ member do
4
+ get :forter
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,62 @@
1
+ module Workarea
2
+ module Forter
3
+ class BogusGateway
4
+ attr_reader :options
5
+
6
+ def initialize(options = {})
7
+ @options = options
8
+ end
9
+
10
+ def create_decision(order_id, hsh = {})
11
+ response_json = if hsh[:accountOwner][:email] == "decline@workarea.com"
12
+ response_body(order_id, "decline")
13
+ elsif hsh[:accountOwner][:email] == "notreviewed@workarea.com"
14
+ response_body(order_id, "not reviewed")
15
+ elsif hsh[:accountOwner][:email] == "error@workarea.com"
16
+ error_body(order_id)
17
+ else
18
+ response_body(order_id, "approve")
19
+ end
20
+
21
+ response = Faraday.new do |builder|
22
+ builder.adapter :test do |stub|
23
+ stub.get('/rest/bogus.json') { |env| [ 200, {}, response_json ] }
24
+ end
25
+ end
26
+ response.get('/rest/bogus.json')
27
+ end
28
+
29
+ def method_missing(method, *args)
30
+ generic_response
31
+ end
32
+
33
+ private
34
+
35
+ def generic_response
36
+ response = Faraday.new do |builder|
37
+ builder.adapter :test do |stub|
38
+ stub.get('/rest/bogus.json') { |env| [ 200, {}, nil ] }
39
+ end
40
+ end
41
+ response.get('/rest/bogus.json')
42
+ end
43
+
44
+ def response_body(id, action)
45
+ {
46
+ status: "success",
47
+ transaction: "#{id}",
48
+ action: "#{action}",
49
+ message: "Transaction #{id}"
50
+ }.to_json
51
+ end
52
+
53
+ def error_body(id)
54
+ {
55
+ status: "failure",
56
+ action: "",
57
+ errors: [{ "path" => "#/payment/", "message" => "Forced Gateway Error" }]
58
+ }.to_json
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,60 @@
1
+ module Workarea
2
+ module Forter
3
+ class DecisionResponse
4
+ def initialize(body)
5
+ @body = body
6
+ end
7
+
8
+ def success?
9
+ @body["status"] == "success"
10
+ end
11
+
12
+ def suspected_fraud?
13
+ @body["action"] == "decline"
14
+ end
15
+
16
+ def action
17
+ @body["action"]
18
+ end
19
+
20
+ def body_message
21
+ @body["message"]
22
+ end
23
+
24
+ def reason_code
25
+ @body["reasonCode"]
26
+ end
27
+
28
+ def errors
29
+ @body["errors"]
30
+ end
31
+
32
+ def status
33
+ @body["status"]
34
+ end
35
+
36
+ def mongoize
37
+ @body
38
+ end
39
+
40
+ class << self
41
+ def demongoize(object)
42
+ return nil if object.blank?
43
+
44
+ DecisionResponse.new(object)
45
+ end
46
+
47
+ def mongoize(object)
48
+ case object
49
+ when DecisionResponse then object.mongoize
50
+ else object
51
+ end
52
+ end
53
+
54
+ def evolve(object)
55
+ raise 'querying on an Workarea::Forter::DecisionResponse is unsupported at this time'
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,8 @@
1
+ module Workarea
2
+ module Forter
3
+ class Engine < ::Rails::Engine
4
+ include Workarea::Plugin
5
+ isolate_namespace Workarea::Forter
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,66 @@
1
+ module Workarea
2
+ module Forter
3
+ class Gateway
4
+
5
+ attr_reader :options
6
+
7
+ def initialize(options = {})
8
+ @options = options
9
+ end
10
+
11
+ def create_decision(order_id, order_details)
12
+ body = order_details.to_json
13
+
14
+ connection.post do |req|
15
+ req.url "v2/orders/#{order_id}", {}
16
+ req.body = body
17
+ end
18
+ end
19
+
20
+ def update_order_status(order_id, order_details)
21
+ body = order_details.to_json
22
+
23
+ connection.put do |req|
24
+ req.url "v2/status/#{order_id}", {}
25
+ req.body = body
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def rest_endpoint
32
+ "https://api.forter-secure.com"
33
+ end
34
+
35
+ def connection
36
+ headers = {
37
+ "Content-Type" => "application/json",
38
+ "x-forter-siteid" => site_id,
39
+ "api-version" => api_version
40
+ }
41
+
42
+ request_timeouts = {
43
+ timeout: Workarea.config.forter[:api_timeout],
44
+ open_timeout: Workarea.config.forter[:open_timeout]
45
+ }
46
+
47
+ conn = Faraday.new(url: rest_endpoint, headers: headers, request: request_timeouts)
48
+ conn.basic_auth(secret_key, nil)
49
+
50
+ conn
51
+ end
52
+
53
+ def api_version
54
+ options[:api_version] || "2.2"
55
+ end
56
+
57
+ def secret_key
58
+ options[:secret_key]
59
+ end
60
+
61
+ def site_id
62
+ options[:site_id]
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,5 @@
1
+ module Workarea
2
+ module Forter
3
+ VERSION = "1.2.2"
4
+ end
5
+ end
@@ -0,0 +1,50 @@
1
+ require 'workarea'
2
+ require 'workarea/storefront'
3
+ require 'workarea/admin'
4
+
5
+ require 'workarea/forter/gateway'
6
+ require 'workarea/forter/bogus_gateway'
7
+ require 'workarea/forter/decision_response'
8
+
9
+ require 'workarea/forter/engine'
10
+ require 'workarea/forter/version'
11
+
12
+ module Workarea
13
+ module Forter
14
+ def self.credentials
15
+ (Rails.application.secrets.forter || {}).deep_symbolize_keys
16
+ end
17
+
18
+ def self.secret_key
19
+ credentials[:secret_key]
20
+ end
21
+
22
+ def self.config
23
+ Workarea.config.forter
24
+ end
25
+
26
+ def self.site_id
27
+ config.site_id
28
+ end
29
+
30
+ def self.api_version
31
+ config.api_version
32
+ end
33
+
34
+ def self.gateway
35
+ if credentials.present?
36
+ Forter::Gateway.new(site_id: site_id, secret_key: secret_key, api_version: api_version)
37
+ else
38
+ Forter::BogusGateway.new
39
+ end
40
+ end
41
+
42
+ def self.log_error(error)
43
+ if defined?(::Raven)
44
+ Raven.capture_exception error
45
+ else
46
+ Rails.logger.warn error
47
+ end
48
+ end
49
+ end
50
+ end
@@ -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_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -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', __dir__)
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,30 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a starting point to setup your application.
15
+ # Add necessary setup steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ # Install JavaScript dependencies if using Yarn
22
+ # system('bin/yarn')
23
+
24
+
25
+ puts "\n== Removing old logs and tempfiles =="
26
+ system! 'bin/rails log:clear tmp:clear'
27
+
28
+ puts "\n== Restarting application server =="
29
+ system! 'bin/rails restart'
30
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a way to update your development environment automatically.
15
+ # Add necessary update steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ puts "\n== Removing old logs and tempfiles =="
22
+ system! 'bin/rails log:clear tmp:clear'
23
+
24
+ puts "\n== Restarting application server =="
25
+ system! 'bin/rails restart'
26
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ VENDOR_PATH = File.expand_path('..', __dir__)
3
+ Dir.chdir(VENDOR_PATH) do
4
+ begin
5
+ exec "yarnpkg #{ARGV.join(" ")}"
6
+ rescue Errno::ENOENT
7
+ $stderr.puts "Yarn executable was not detected in the system."
8
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9
+ exit 1
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'boot'
2
+
3
+ # Pick the frameworks you want:
4
+ # require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_view/railtie"
7
+ require "action_mailer/railtie"
8
+ require "active_job/railtie"
9
+ # require "action_cable/engine"
10
+ require "rails/test_unit/railtie"
11
+ require "sprockets/railtie"
12
+
13
+ # Workarea must be required before other gems to ensure control over Rails.env
14
+ # for running tests
15
+ require 'workarea/core'
16
+ require 'workarea/admin'
17
+ require 'workarea/storefront'
18
+ Bundler.require(*Rails.groups)
19
+ require "workarea/forter"
20
+
21
+ module Dummy
22
+ class Application < Rails::Application
23
+ # Initialize configuration defaults for originally generated Rails version.
24
+ config.load_defaults 5.1
25
+
26
+ # Settings in config/environments/* take precedence over those specified here.
27
+ # Application configuration should go into files in config/initializers
28
+ # -- all .rb files in that directory are automatically loaded.
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ production:
8
+ adapter: redis
9
+ url: redis://localhost:6379/1
10
+ channel_prefix: dummy_production
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative 'application'
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,51 @@
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.
13
+ config.consider_all_requests_local = true
14
+
15
+ # Enable/disable caching. By default caching is disabled.
16
+ if Rails.root.join('tmp/caching-dev.txt').exist?
17
+ config.action_controller.perform_caching = true
18
+
19
+ config.cache_store = :memory_store
20
+ config.public_file_server.headers = {
21
+ 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
22
+ }
23
+ else
24
+ config.action_controller.perform_caching = false
25
+
26
+ config.cache_store = :null_store
27
+ end
28
+
29
+ # Don't care if the mailer can't send.
30
+ config.action_mailer.raise_delivery_errors = false
31
+
32
+ config.action_mailer.perform_caching = false
33
+
34
+ # Print deprecation notices to the Rails logger.
35
+ config.active_support.deprecation = :log
36
+
37
+ # Debug mode disables concatenation and preprocessing of assets.
38
+ # This option may cause significant delays in view rendering with a large
39
+ # number of complex assets.
40
+ config.assets.debug = true
41
+
42
+ # Suppress logger output for asset requests.
43
+ config.assets.quiet = true
44
+
45
+ # Raises error for missing translations
46
+ # config.action_view.raise_on_missing_translations = true
47
+
48
+ # Use an evented file watcher to asynchronously detect changes in source code,
49
+ # routes, locales, etc. This feature depends on the listen gem.
50
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
51
+ end
@@ -0,0 +1,88 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
18
+ # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
19
+ # `config/secrets.yml.key`.
20
+ config.read_encrypted_secrets = true
21
+
22
+ # Disable serving static files from the `/public` folder by default since
23
+ # Apache or NGINX already handles this.
24
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
25
+
26
+ # Compress JavaScripts and CSS.
27
+ config.assets.js_compressor = :uglifier
28
+ # config.assets.css_compressor = :sass
29
+
30
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
31
+ config.assets.compile = false
32
+
33
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
34
+
35
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
36
+ # config.action_controller.asset_host = 'http://assets.example.com'
37
+
38
+ # Specifies the header that your server uses for sending files.
39
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
40
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
41
+
42
+ # Mount Action Cable outside main process or domain
43
+ # config.action_cable.mount_path = nil
44
+ # config.action_cable.url = 'wss://example.com/cable'
45
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
46
+
47
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
48
+ # config.force_ssl = true
49
+
50
+ # Use the lowest log level to ensure availability of diagnostic information
51
+ # when problems arise.
52
+ config.log_level = :debug
53
+
54
+ # Prepend all log lines with the following tags.
55
+ config.log_tags = [ :request_id ]
56
+
57
+ # Use a different cache store in production.
58
+ # config.cache_store = :mem_cache_store
59
+
60
+ # Use a real queuing backend for Active Job (and separate queues per environment)
61
+ # config.active_job.queue_adapter = :resque
62
+ # config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
63
+ config.action_mailer.perform_caching = false
64
+
65
+ # Ignore bad email addresses and do not raise email delivery errors.
66
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
67
+ # config.action_mailer.raise_delivery_errors = false
68
+
69
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
70
+ # the I18n.default_locale when a translation cannot be found).
71
+ config.i18n.fallbacks = true
72
+
73
+ # Send deprecation notices to registered listeners.
74
+ config.active_support.deprecation = :notify
75
+
76
+ # Use default logging formatter so that PID and timestamp are not suppressed.
77
+ config.log_formatter = ::Logger::Formatter.new
78
+
79
+ # Use a different logger for distributed setups.
80
+ # require 'syslog/logger'
81
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
82
+
83
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
84
+ logger = ActiveSupport::Logger.new(STDOUT)
85
+ logger.formatter = config.log_formatter
86
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
87
+ end
88
+ end