workarea-forter 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.editorconfig +20 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.gitignore +17 -0
- data/CHANGELOG.md +63 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +25 -0
- data/LICENSE +52 -0
- data/LICENSE.md +3 -0
- data/README.md +113 -0
- data/Rakefile +60 -0
- data/app/controllers/workarea/admin/orders_controller.decorator +6 -0
- data/app/controllers/workarea/storefront/application_controller.decorator +10 -0
- data/app/models/search/admin/order.decorator +7 -0
- data/app/models/workarea/checkout/collect_payment.decorator +75 -0
- data/app/models/workarea/forter/decision.rb +18 -0
- data/app/models/workarea/forter/response.rb +15 -0
- data/app/models/workarea/fulfillment.decorator +77 -0
- data/app/models/workarea/order/status/suspected_fraud.rb +13 -0
- data/app/models/workarea/order.decorator +14 -0
- data/app/models/workarea/payment/saved_credit_card.decorator +14 -0
- data/app/models/workarea/payment/status/suspected_fraud.rb +13 -0
- data/app/models/workarea/payment/tender/credit_card.decorator +25 -0
- data/app/models/workarea/payment.decorator +13 -0
- data/app/services/workarea/forter/account.rb +42 -0
- data/app/services/workarea/forter/order.rb +145 -0
- data/app/services/workarea/forter/payment.rb +80 -0
- data/app/services/workarea/forter/tender/credit_card.rb +73 -0
- data/app/services/workarea/forter/tender/general.rb +29 -0
- data/app/services/workarea/forter/tender/gift_card.rb +23 -0
- data/app/services/workarea/forter/tender/paypal.rb +38 -0
- data/app/services/workarea/forter/tender/store_credit.rb +23 -0
- data/app/view_models/workarea/admin/order_view_model.decorator +7 -0
- data/app/views/workarea/admin/orders/_forter.html.haml +18 -0
- data/app/views/workarea/admin/orders/forter.html.haml +57 -0
- data/app/views/workarea/storefront/_forter_tracking.html.haml +4 -0
- data/app/workers/forter/update_status.rb +21 -0
- data/app/workers/workarea/save_user_order_details.decorator +34 -0
- data/bin/rails +20 -0
- data/config/initializers/appends.rb +9 -0
- data/config/initializers/workarea.rb +22 -0
- data/config/locales/en.yml +26 -0
- data/config/routes.rb +7 -0
- data/lib/workarea/forter/bogus_gateway.rb +62 -0
- data/lib/workarea/forter/decision_response.rb +60 -0
- data/lib/workarea/forter/engine.rb +8 -0
- data/lib/workarea/forter/gateway.rb +66 -0
- data/lib/workarea/forter/version.rb +5 -0
- data/lib/workarea/forter.rb +50 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +30 -0
- data/test/dummy/bin/update +26 -0
- data/test/dummy/bin/yarn +11 -0
- data/test/dummy/config/application.rb +30 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +51 -0
- data/test/dummy/config/environments/production.rb +88 -0
- data/test/dummy/config/environments/test.rb +44 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/assets.rb +14 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/workarea.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/test/dummy/config/locales/en.yml +33 -0
- data/test/dummy/config/puma.rb +56 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +32 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/log/.keep +0 -0
- data/test/factories/forter.rb +132 -0
- data/test/integration/workarea/admin/forter_order_integration_test.rb +36 -0
- data/test/integration/workarea/forter_authorize_cim_response_code_integration_test.rb +69 -0
- data/test/integration/workarea/forter_braintree_response_code_integration_test.rb +69 -0
- data/test/integration/workarea/forter_checkoutdotcom_integration_test.rb +71 -0
- data/test/integration/workarea/forter_cybersource_response_code_integration_test.rb +69 -0
- data/test/integration/workarea/forter_moneris_response_code_integration_test.rb +69 -0
- data/test/integration/workarea/forter_payflow_pro_response_code_test.rb +69 -0
- data/test/integration/workarea/storefront/forter_integration_test.rb +138 -0
- data/test/lib/workarea/forter/gateway_test.rb +47 -0
- data/test/models/workarea/checkout/forter_collect_payment_test.rb +60 -0
- data/test/models/workarea/forter_payment_test.rb +58 -0
- data/test/models/workarea/payment/forter_credit_card_test.rb +19 -0
- data/test/models/workarea/payment/forter_saved_credit_card_test.rb +32 -0
- data/test/services/workarea/forter/order_test.rb +82 -0
- data/test/support/workarea/forter_api_config.rb +27 -0
- data/test/system/workarea/admin/forter_system_test.rb +31 -0
- data/test/system/workarea/storefront/forter_braintree_checkout_system_test.rb +79 -0
- data/test/system/workarea/storefront/forter_tracking_system_test.rb +20 -0
- data/test/system/workarea/storefront/guest_checkout_system_test.decorator +43 -0
- data/test/teaspoon_env.rb +6 -0
- data/test/test_helper.rb +11 -0
- data/test/vcr_cassettes/forter/get_decision.yml +66 -0
- data/test/vcr_cassettes/forter/integration/authorize_net_response_code.yml +410 -0
- data/test/vcr_cassettes/forter/integration/braintree_response_code.yml +231 -0
- data/test/vcr_cassettes/forter/integration/checkoutdotcom_response_code.yml +129 -0
- data/test/vcr_cassettes/forter/integration/cyber_response_code.yml +199 -0
- data/test/vcr_cassettes/forter/integration/moneris_response_code.yml +84 -0
- data/test/vcr_cassettes/forter/integration/payflow_pro_response_code.yml +60 -0
- data/test/vcr_cassettes/forter/system/braintree_approved.yml +293 -0
- data/test/vcr_cassettes/forter/system/braintree_declined.yml +485 -0
- data/test/vcr_cassettes/forter/system/braintree_not_reviewed.yml +293 -0
- data/test/vcr_cassettes/forter/update_status.yml +182 -0
- data/test/view_models/workarea/storefront/order_view_model_test.decorator +10 -0
- data/test/workers/forter/update_status_test.rb +22 -0
- data/workarea-forter.gemspec +18 -0
- 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,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,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,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,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
|
data/test/dummy/Rakefile
ADDED
data/test/dummy/bin/rake
ADDED
|
@@ -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
|
data/test/dummy/bin/yarn
ADDED
|
@@ -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,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
|