disco_app 0.14.3 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/disco_app/concerns/webhooks_controller.rb +48 -0
  3. data/app/controllers/disco_app/webhooks_controller.rb +2 -46
  4. data/app/models/disco_app/concerns/renders_assets.rb +1 -1
  5. data/app/models/disco_app/concerns/taggable.rb +1 -1
  6. data/config/routes.rb +1 -1
  7. data/db/migrate/20150525000000_create_shops_if_not_existent.rb +80 -80
  8. data/db/migrate/20170315062548_create_disco_app_sources.rb +2 -0
  9. data/db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb +2 -0
  10. data/db/migrate/20170327214540_create_disco_app_users.rb +2 -1
  11. data/db/migrate/20170606160751_fix_disco_app_users_index.rb +2 -0
  12. data/lib/disco_app/version.rb +1 -1
  13. data/lib/generators/disco_app/disco_app_generator.rb +24 -7
  14. data/lib/generators/disco_app/templates/config/cable.yml.tt +11 -0
  15. data/lib/generators/disco_app/templates/config/database.yml.tt +6 -3
  16. data/lib/generators/disco_app/templates/config/environments/staging.rb +108 -0
  17. data/lib/generators/disco_app/templates/config/newrelic.yml +3 -0
  18. data/lib/generators/disco_app/templates/controllers/home_controller.rb +1 -0
  19. data/lib/generators/disco_app/templates/initializers/rollbar.rb +2 -4
  20. data/lib/generators/disco_app/templates/initializers/session_store.rb +1 -1
  21. data/lib/generators/disco_app/templates/root/.github/PULL_REQUEST_TEMPLATE.md +18 -0
  22. data/lib/generators/disco_app/templates/root/.gitignore +4 -0
  23. data/lib/generators/disco_app/templates/root/.rubocop.yml +223 -158
  24. data/test/dummy/config/database.yml +3 -0
  25. data/test/dummy/config/environments/staging.rb +85 -0
  26. data/test/dummy/config/secrets.yml +3 -0
  27. metadata +129 -123
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8061db5ad61ffe4081ab3ef7bd34f74c59638598e189e5d07a50ff33ea4d0d9f
4
- data.tar.gz: ff77b159f594e2a840fda477085f5c4500669d4628a9d39b5d642fc7aeb5fce6
3
+ metadata.gz: 4ece31304441ed10f09b9391cd7dd60e4f2ee042b8f1fb782d4a3a57508e0018
4
+ data.tar.gz: 4795ce5f7be894f915acf1b22342902495de3cff322c4c881634ff26458d6457
5
5
  SHA512:
6
- metadata.gz: 68a0031fc00e57c365802bbb9a76c5779e592e3491d39ea82d964ac6fa86fae7c6a92dcab16e5c59b2e235c92669c732034d2e3f76fc7ac8530a9e249cbc7f75
7
- data.tar.gz: cb70cd788355ac7a21a68d215588cb03fc69030b17e1d67fe6d58c87aa57999850d7c9df136b92fbf8ebe160706b03b8dd6f0641a885fb30a17a11649296f09b
6
+ metadata.gz: 67ddc280601b0dd494535991a9e217d7eeb94732e0113dffbf973a88096c81f9c31771aa4d2b260a5e586ec3ed90b8d088fe60f697034f07682c0d6f451691a9
7
+ data.tar.gz: 69f2f10799bdc2b57f904b81734af3252b1497aa64963e87b2f2201fe68e8cc9028b6127b9d99d613a9bb8b0a80f1d2e848eacd572faba9ffbd9c9d66cf517b8
@@ -0,0 +1,48 @@
1
+ module DiscoApp::Concerns::WebhooksController
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_action :verify_webhook
6
+ protect_from_forgery with: :null_session
7
+ end
8
+
9
+ def process_webhook
10
+ # Get the topic and domain for this webhook.
11
+ topic = request.headers['HTTP_X_SHOPIFY_TOPIC']
12
+ shopify_domain = request.headers['HTTP_X_SHOPIFY_SHOP_DOMAIN']
13
+
14
+ # Ensure a domain was provided in the headers.
15
+ unless shopify_domain
16
+ head :bad_request
17
+ end
18
+
19
+ # Try to find a matching background job task for the given topic using class name.
20
+ job_class = DiscoApp::WebhookService.find_job_class(topic)
21
+
22
+ # Return bad request if we couldn't match a job class.
23
+ unless job_class.present?
24
+ head :bad_request
25
+ end
26
+
27
+ # Decode the body data and enqueue the appropriate job.
28
+ data = ActiveSupport::JSON::decode(request.body.read).with_indifferent_access
29
+ job_class.perform_later(shopify_domain, data)
30
+
31
+ render body: nil
32
+ end
33
+
34
+ private
35
+
36
+ def verify_webhook
37
+ unless webhook_is_valid?
38
+ head :unauthorized
39
+ end
40
+ request.body.rewind
41
+ end
42
+
43
+ def webhook_is_valid?
44
+ return true if Rails.env.development? and DiscoApp.configuration.skip_webhook_verification?
45
+ DiscoApp::WebhookService.is_valid_hmac?(request.body.read.to_s, ShopifyApp.configuration.secret, request.headers['HTTP_X_SHOPIFY_HMAC_SHA256'])
46
+ end
47
+
48
+ end
@@ -1,47 +1,3 @@
1
- module DiscoApp
2
- class WebhooksController < ActionController::Base
3
-
4
- before_action :verify_webhook
5
- protect_from_forgery with: :null_session
6
-
7
- def process_webhook
8
- # Get the topic and domain for this webhook.
9
- topic = request.headers['HTTP_X_SHOPIFY_TOPIC']
10
- shopify_domain = request.headers['HTTP_X_SHOPIFY_SHOP_DOMAIN']
11
-
12
- # Ensure a domain was provided in the headers.
13
- unless shopify_domain
14
- head :bad_request
15
- end
16
-
17
- # Try to find a matching background job task for the given topic using class name.
18
- job_class = DiscoApp::WebhookService.find_job_class(topic)
19
-
20
- # Return bad request if we couldn't match a job class.
21
- unless job_class.present?
22
- head :bad_request
23
- end
24
-
25
- # Decode the body data and enqueue the appropriate job.
26
- data = ActiveSupport::JSON::decode(request.body.read).with_indifferent_access
27
- job_class.perform_later(shopify_domain, data)
28
-
29
- render body: nil
30
- end
31
-
32
- private
33
-
34
- def verify_webhook
35
- unless webhook_is_valid?
36
- head :unauthorized
37
- end
38
- request.body.rewind
39
- end
40
-
41
- def webhook_is_valid?
42
- return true if Rails.env.development? and DiscoApp.configuration.skip_webhook_verification?
43
- DiscoApp::WebhookService.is_valid_hmac?(request.body.read.to_s, ShopifyApp.configuration.secret, request.headers['HTTP_X_SHOPIFY_HMAC_SHA256'])
44
- end
45
-
46
- end
1
+ class DiscoApp::WebhooksController < ActionController::Base
2
+ include DiscoApp::Concerns::WebhooksController
47
3
  end
@@ -67,7 +67,7 @@ module DiscoApp::Concerns::RendersAssets
67
67
  assets: nil,
68
68
  triggered_by: nil,
69
69
  script_tags: nil,
70
- minify: Rails.env.production?
70
+ minify: Rails.env.production? || Rails.env.staging?
71
71
  }
72
72
  end
73
73
 
@@ -14,7 +14,7 @@ module DiscoApp::Concerns::Taggable
14
14
  end
15
15
 
16
16
  def has_tag?(tag_to_check)
17
- tags.any? { |tag| tag.casecmp(tag_to_check) }
17
+ tags.any? { |tag| tag.casecmp?(tag_to_check) }
18
18
  end
19
19
 
20
20
  end
data/config/routes.rb CHANGED
@@ -46,7 +46,7 @@ DiscoApp::Engine.routes.draw do
46
46
  end
47
47
 
48
48
  # Make the Sidekiq Web UI accessible using the same credentials as the admin.
49
- if Rails.env.production?
49
+ if Rails.env.production? || Rails.env.staging?
50
50
  Sidekiq::Web.use Rack::Auth::Basic do |username, password|
51
51
  [
52
52
  ENV['ADMIN_APP_USERNAME'].present?,
@@ -6,105 +6,105 @@ class CreateShopsIfNotExistent < ActiveRecord::Migration[5.1]
6
6
  def change
7
7
  return if table_exists? :disco_app_shops
8
8
 
9
- create_table "disco_app_app_settings", force: :cascade do |t|
10
- t.datetime "created_at", null: false
11
- t.datetime "updated_at", null: false
9
+ create_table :disco_app_app_settings, force: :cascade do |t|
10
+ t.datetime :created_at, null: false
11
+ t.datetime :updated_at, null: false
12
12
  end
13
13
 
14
- create_table "disco_app_application_charges", force: :cascade do |t|
15
- t.integer "shop_id", limit: 8
16
- t.integer "subscription_id", limit: 8
17
- t.integer "status", default: 0
18
- t.datetime "created_at", null: false
19
- t.datetime "updated_at", null: false
20
- t.integer "shopify_id", limit: 8
21
- t.string "confirmation_url"
14
+ create_table :disco_app_application_charges, force: :cascade do |t|
15
+ t.integer :shop_id, limit: 8
16
+ t.integer :subscription_id, limit: 8
17
+ t.integer :status, default: 0
18
+ t.datetime :created_at, null: false
19
+ t.datetime :updated_at, null: false
20
+ t.integer :shopify_id, limit: 8
21
+ t.string :confirmation_url
22
22
  end
23
23
 
24
- create_table "disco_app_plan_codes", force: :cascade do |t|
25
- t.integer "plan_id", limit: 8
26
- t.string "code"
27
- t.integer "trial_period_days"
28
- t.integer "amount"
29
- t.datetime "created_at", null: false
30
- t.datetime "updated_at", null: false
31
- t.integer "status", default: 0
24
+ create_table :disco_app_plan_codes, force: :cascade do |t|
25
+ t.integer :plan_id, limit: 8
26
+ t.string :code
27
+ t.integer :trial_period_days
28
+ t.integer :amount
29
+ t.datetime :created_at, null: false
30
+ t.datetime :updated_at, null: false
31
+ t.integer :status, default: 0
32
32
  end
33
33
 
34
- create_table "disco_app_plans", force: :cascade do |t|
35
- t.integer "status", default: 0
36
- t.string "name"
37
- t.integer "plan_type", default: 0
38
- t.integer "trial_period_days"
39
- t.datetime "created_at", null: false
40
- t.datetime "updated_at", null: false
41
- t.integer "amount", default: 0
42
- t.string "currency", default: "USD"
43
- t.integer "interval", default: 0
44
- t.integer "interval_count", default: 1
34
+ create_table :disco_app_plans, force: :cascade do |t|
35
+ t.integer :status, default: 0
36
+ t.string :name
37
+ t.integer :plan_type, default: 0
38
+ t.integer :trial_period_days
39
+ t.datetime :created_at, null: false
40
+ t.datetime :updated_at, null: false
41
+ t.integer :amount, default: 0
42
+ t.string :currency, default: 'USD'
43
+ t.integer :interval, default: 0
44
+ t.integer :interval_count, default: 1
45
45
  end
46
46
 
47
- create_table "disco_app_recurring_application_charges", force: :cascade do |t|
48
- t.integer "shop_id", limit: 8
49
- t.integer "subscription_id", limit: 8
50
- t.integer "status", default: 0
51
- t.datetime "created_at", null: false
52
- t.datetime "updated_at", null: false
53
- t.integer "shopify_id", limit: 8
54
- t.string "confirmation_url"
47
+ create_table :disco_app_recurring_application_charges, force: :cascade do |t|
48
+ t.integer :shop_id, limit: 8
49
+ t.integer :subscription_id, limit: 8
50
+ t.integer :status, default: 0
51
+ t.datetime :created_at, null: false
52
+ t.datetime :updated_at, null: false
53
+ t.integer :shopify_id, limit: 8
54
+ t.string :confirmation_url
55
55
  end
56
56
 
57
- create_table "disco_app_sessions", force: :cascade do |t|
58
- t.string "session_id", null: false
59
- t.text "data"
60
- t.datetime "created_at", null: false
61
- t.datetime "updated_at", null: false
62
- t.integer "shop_id"
57
+ create_table :disco_app_sessions, force: :cascade do |t|
58
+ t.string :session_id, null: false
59
+ t.text :data
60
+ t.datetime :created_at, null: false
61
+ t.datetime :updated_at, null: false
62
+ t.integer :shop_id
63
63
  end
64
64
 
65
- add_index "disco_app_sessions", ["session_id"], name: "index_disco_app_sessions_on_session_id", unique: true, using: :btree
66
- add_index "disco_app_sessions", ["updated_at"], name: "index_disco_app_sessions_on_updated_at", using: :btree
65
+ add_index :disco_app_sessions, [:session_id], name: 'index_disco_app_sessions_on_session_id', unique: true, using: :btree
66
+ add_index :disco_app_sessions, [:updated_at], name: 'index_disco_app_sessions_on_updated_at', using: :btree
67
67
 
68
- create_table "disco_app_shops", force: :cascade do |t|
69
- t.string "shopify_domain", null: false
70
- t.string "shopify_token", null: false
71
- t.datetime "created_at", null: false
72
- t.datetime "updated_at", null: false
73
- t.integer "status", default: 0
74
- t.string "domain"
75
- t.string "plan_name"
76
- t.string "name"
77
- t.jsonb "data", default: {}
68
+ create_table :disco_app_shops, force: :cascade do |t|
69
+ t.string :shopify_domain, null: false
70
+ t.string :shopify_token, null: false
71
+ t.datetime :created_at, null: false
72
+ t.datetime :updated_at, null: false
73
+ t.integer :status, default: 0
74
+ t.string :domain
75
+ t.string :plan_name
76
+ t.string :name
77
+ t.jsonb :data, default: {}
78
78
  end
79
79
 
80
- add_index "disco_app_shops", ["shopify_domain"], name: "index_disco_app_shops_on_shopify_domain", unique: true, using: :btree
80
+ add_index :disco_app_shops, [:shopify_domain], name: 'index_disco_app_shops_on_shopify_domain', unique: true, using: :btree
81
81
 
82
- create_table "disco_app_subscriptions", force: :cascade do |t|
83
- t.integer "shop_id"
84
- t.integer "plan_id"
85
- t.integer "status"
86
- t.integer "subscription_type"
87
- t.datetime "created_at", null: false
88
- t.datetime "updated_at", null: false
89
- t.datetime "trial_start_at"
90
- t.datetime "trial_end_at"
91
- t.datetime "cancelled_at"
92
- t.integer "amount", default: 0
93
- t.integer "plan_code_id", limit: 8
94
- t.string "source"
95
- t.integer "trial_period_days"
82
+ create_table :disco_app_subscriptions, force: :cascade do |t|
83
+ t.integer :shop_id
84
+ t.integer :plan_id
85
+ t.integer :status
86
+ t.integer :subscription_type
87
+ t.datetime :created_at, null: false
88
+ t.datetime :updated_at, null: false
89
+ t.datetime :trial_start_at
90
+ t.datetime :trial_end_at
91
+ t.datetime :cancelled_at
92
+ t.integer :amount, default: 0
93
+ t.integer :plan_code_id, limit: 8
94
+ t.string :source
95
+ t.integer :trial_period_days
96
96
  end
97
97
 
98
- add_index "disco_app_subscriptions", ["plan_id"], name: "index_disco_app_subscriptions_on_plan_id", using: :btree
99
- add_index "disco_app_subscriptions", ["shop_id"], name: "index_disco_app_subscriptions_on_shop_id", using: :btree
98
+ add_index :disco_app_subscriptions, [:plan_id], name: 'index_disco_app_subscriptions_on_plan_id', using: :btree
99
+ add_index :disco_app_subscriptions, [:shop_id], name: 'index_disco_app_subscriptions_on_shop_id', using: :btree
100
100
 
101
- add_foreign_key "disco_app_application_charges", "disco_app_shops", column: "shop_id"
102
- add_foreign_key "disco_app_application_charges", "disco_app_subscriptions", column: "subscription_id"
103
- add_foreign_key "disco_app_plan_codes", "disco_app_plans", column: "plan_id"
104
- add_foreign_key "disco_app_recurring_application_charges", "disco_app_shops", column: "shop_id"
105
- add_foreign_key "disco_app_recurring_application_charges", "disco_app_subscriptions", column: "subscription_id"
106
- add_foreign_key "disco_app_sessions", "disco_app_shops", column: "shop_id", on_delete: :cascade
107
- add_foreign_key "disco_app_subscriptions", "disco_app_plan_codes", column: "plan_code_id"
101
+ add_foreign_key :disco_app_application_charges, :disco_app_shops, column: :shop_id
102
+ add_foreign_key :disco_app_application_charges, :disco_app_subscriptions, column: :subscription_id
103
+ add_foreign_key :disco_app_plan_codes, :disco_app_plans, column: :plan_id
104
+ add_foreign_key :disco_app_recurring_application_charges, :disco_app_shops, column: :shop_id
105
+ add_foreign_key :disco_app_recurring_application_charges, :disco_app_subscriptions, column: :subscription_id
106
+ add_foreign_key :disco_app_sessions, :disco_app_shops, column: :shop_id, on_delete: :cascade
107
+ add_foreign_key :disco_app_subscriptions, :disco_app_plan_codes, column: :plan_code_id
108
108
  end
109
109
 
110
110
  end
@@ -1,4 +1,5 @@
1
1
  class CreateDiscoAppSources < ActiveRecord::Migration[5.1]
2
+
2
3
  def change
3
4
  create_table :disco_app_sources do |t|
4
5
  t.string :source, null: true
@@ -7,4 +8,5 @@ class CreateDiscoAppSources < ActiveRecord::Migration[5.1]
7
8
  end
8
9
  add_index :disco_app_sources, :source
9
10
  end
11
+
10
12
  end
@@ -1,4 +1,5 @@
1
1
  class AddSourcesToShopSubscriptions < ActiveRecord::Migration[5.1]
2
+
2
3
  def change
3
4
  add_column :disco_app_subscriptions, :source_id, :integer, limit: 8, index: true
4
5
  add_foreign_key :disco_app_subscriptions, :disco_app_sources, column: :source_id
@@ -11,4 +12,5 @@ class AddSourcesToShopSubscriptions < ActiveRecord::Migration[5.1]
11
12
 
12
13
  remove_column :disco_app_subscriptions, :source
13
14
  end
15
+
14
16
  end
@@ -1,13 +1,14 @@
1
1
  class CreateDiscoAppUsers < ActiveRecord::Migration[5.1]
2
+
2
3
  def change
3
4
  create_table :disco_app_users do |t|
4
5
  t.integer :shop_id, limit: 8
5
6
  t.string :first_name
6
7
  t.string :last_name
7
8
  t.string :email
8
-
9
9
  t.timestamps null: false
10
10
  end
11
11
  add_index :disco_app_users, :shop_id, unique: true
12
12
  end
13
+
13
14
  end
@@ -1,6 +1,8 @@
1
1
  class FixDiscoAppUsersIndex < ActiveRecord::Migration[5.1]
2
+
2
3
  def change
3
4
  remove_index :disco_app_users, :shop_id
4
5
  add_index :disco_app_users, [:id, :shop_id], unique: true
5
6
  end
7
+
6
8
  end
@@ -1,3 +1,3 @@
1
1
  module DiscoApp
2
- VERSION = '0.14.3'
2
+ VERSION = '0.16.0'
3
3
  end
@@ -8,12 +8,13 @@ class DiscoAppGenerator < Rails::Generators::Base
8
8
  # - Slightly customised version of the default Rails .gitignore;
9
9
  # - Default simple Procfile for Heroku;
10
10
  # - .editorconfig to help enforce 2-space tabs, newlines and truncated whitespace for editors that support it.
11
- # - README template
11
+ # - README/PULL REQUEST template
12
12
  #
13
13
  def copy_root_files
14
14
  %w(.editorconfig .env .env.local .gitignore .rubocop.yml .codeclimate.yml Procfile CHECKS README.md).each do |file|
15
15
  copy_file "root/#{file}", file
16
16
  end
17
+ directory 'root/.github'
17
18
  end
18
19
 
19
20
  # Remove a number of root files.
@@ -30,6 +31,7 @@ class DiscoAppGenerator < Rails::Generators::Base
30
31
 
31
32
  # Add gem requirements.
32
33
  gem 'active_link_to'
34
+ gem 'activeresource'
33
35
  gem 'acts_as_singleton'
34
36
  gem 'classnames-rails'
35
37
  gem 'newrelic_rpm'
@@ -42,10 +44,9 @@ class DiscoAppGenerator < Rails::Generators::Base
42
44
  gem 'rollbar'
43
45
  gem 'shopify_app'
44
46
  gem 'sidekiq'
45
- gem 'activeresource'
46
47
 
47
- # Indicate which gems should only be used in production.
48
- gem_group :production do
48
+ # Indicate which gems should only be used in staging and production.
49
+ gem_group :staging, :production do
49
50
  gem 'mailgun_rails'
50
51
  gem 'rails_12factor'
51
52
  end
@@ -53,9 +54,9 @@ class DiscoAppGenerator < Rails::Generators::Base
53
54
  # Indicate which gems should only be used in development and test.
54
55
  gem_group :development, :test do
55
56
  gem 'dotenv-rails'
57
+ gem 'mechanize'
56
58
  gem 'minitest-reporters'
57
59
  gem 'webmock'
58
- gem 'mechanize'
59
60
  end
60
61
  end
61
62
 
@@ -64,6 +65,10 @@ class DiscoAppGenerator < Rails::Generators::Base
64
65
  template 'config/database.yml.tt'
65
66
  end
66
67
 
68
+ def update_cable_config
69
+ template 'config/cable.yml.tt'
70
+ end
71
+
67
72
  # Run bundle install to add our new gems before running tasks.
68
73
  def bundle_install
69
74
  Bundler.with_clean_env do
@@ -71,6 +76,10 @@ class DiscoAppGenerator < Rails::Generators::Base
71
76
  end
72
77
  end
73
78
 
79
+ def support_staging_environment
80
+ copy_file 'config/environments/staging.rb', 'config/environments/staging.rb'
81
+ end
82
+
74
83
  # Make any required adjustments to the application configuration.
75
84
  def configure_application
76
85
  # The force_ssl flag is commented by default for production.
@@ -108,15 +117,23 @@ class DiscoAppGenerator < Rails::Generators::Base
108
117
  application "config.active_job.queue_adapter = :sidekiq\n", env: :production
109
118
  application "# Use Sidekiq as the active job backend", env: :production
110
119
 
120
+ # Set Sidekiq as the queue adapter in staging.
121
+ application "config.active_job.queue_adapter = :sidekiq\n", env: :staging
122
+ application "# Use Sidekiq as the active job backend", env: :staging
123
+
111
124
  # Ensure the application configuration uses the DEFAULT_HOST environment
112
125
  # variable to set up support for reverse routing absolute URLS (needed when
113
126
  # generating Webhook URLs for example).
114
127
  application "routes.default_url_options[:host] = ENV['DEFAULT_HOST']\n"
115
128
  application "# Set the default host for absolute URL routing purposes"
116
129
 
117
- # Configure React in development and production.
130
+ # Configure React in development, staging, and production.
118
131
  application "config.react.variant = :development", env: :development
119
132
  application "# Use development variant of React in development.", env: :development
133
+
134
+ application "config.react.variant = :production", env: :staging
135
+ application "# Use production variant of React in staging.", env: :staging
136
+
120
137
  application "config.react.variant = :production", env: :production
121
138
  application "# Use production variant of React in production.", env: :production
122
139
 
@@ -136,13 +153,13 @@ class DiscoAppGenerator < Rails::Generators::Base
136
153
  end
137
154
  CONFIG
138
155
  application configuration, env: :production
156
+ application configuration, env: :staging
139
157
 
140
158
  # Monitoring configuration
141
159
  copy_file 'initializers/rollbar.rb', 'config/initializers/rollbar.rb'
142
160
  copy_file 'config/newrelic.yml', 'config/newrelic.yml'
143
161
  end
144
162
 
145
-
146
163
  # Add entries to .env and .env.local
147
164
  def add_env_variables
148
165
  configuration = <<-CONFIG.strip_heredoc
@@ -0,0 +1,11 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ staging:
8
+ adapter: async
9
+
10
+ production:
11
+ adapter: async
@@ -4,18 +4,21 @@ default: &default
4
4
  pool: 5
5
5
  timeout: 5000
6
6
  prepared_statements: false
7
-
7
+
8
8
  development:
9
9
  <<: *default
10
10
  host: localhost
11
11
  port: 5432
12
12
  database: <%= Rails.application.class.parent_name.downcase %>
13
-
13
+
14
14
  test:
15
15
  <<: *default
16
16
  host: localhost
17
17
  port: 5432
18
18
  database: <%= Rails.application.class.parent_name.downcase %>_test
19
-
19
+
20
+ staging:
21
+ <<: *default
22
+
20
23
  production:
21
24
  <<: *default
@@ -0,0 +1,108 @@
1
+ Rails.application.configure do
2
+ # Configure ActionMailer to use MailGun
3
+ if ENV['MAILGUN_API_KEY']
4
+ config.action_mailer.delivery_method = :mailgun
5
+ config.action_mailer.mailgun_settings = {
6
+ api_key: ENV['MAILGUN_API_KEY'],
7
+ domain: ENV['MAILGUN_API_DOMAIN']
8
+ }
9
+ end
10
+
11
+ # Use production variant of React in staging.
12
+ config.react.variant = :production
13
+ # Use Sidekiq as the active job backend
14
+ config.active_job.queue_adapter = :sidekiq
15
+
16
+ # Allow real charges in production with an ENV variable
17
+ config.x.shopify_charges_real = false
18
+
19
+ # Settings specified here will take precedence over those in config/application.rb.
20
+
21
+ # Code is not reloaded between requests.
22
+ config.cache_classes = true
23
+
24
+ # Eager load code on boot. This eager loads most of Rails and
25
+ # your application in memory, allowing both threaded web servers
26
+ # and those relying on copy on write to perform better.
27
+ # Rake tasks automatically ignore this option for performance.
28
+ config.eager_load = true
29
+
30
+ # Full error reports are disabled and caching is turned on.
31
+ config.consider_all_requests_local = false
32
+ config.action_controller.perform_caching = true
33
+
34
+ # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
35
+ # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
36
+ # `config/secrets.yml.key`.
37
+ config.read_encrypted_secrets = true
38
+
39
+ # Disable serving static files from the `/public` folder by default since
40
+ # Apache or NGINX already handles this.
41
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
42
+
43
+ # Compress JavaScripts and CSS.
44
+ config.assets.js_compressor = :uglifier
45
+ # config.assets.css_compressor = :sass
46
+
47
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
48
+ config.assets.compile = false
49
+
50
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
51
+
52
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
53
+ # config.action_controller.asset_host = 'http://assets.example.com'
54
+
55
+ # Specifies the header that your server uses for sending files.
56
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
57
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
58
+
59
+ # Mount Action Cable outside main process or domain
60
+ # config.action_cable.mount_path = nil
61
+ # config.action_cable.url = 'wss://example.com/cable'
62
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
63
+
64
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
65
+ config.force_ssl = true
66
+
67
+ # Use the lowest log level to ensure availability of diagnostic information
68
+ # when problems arise.
69
+ config.log_level = :debug
70
+
71
+ # Prepend all log lines with the following tags.
72
+ config.log_tags = [:request_id]
73
+
74
+ # Use a different cache store in staging.
75
+ # config.cache_store = :mem_cache_store
76
+
77
+ # Use a real queuing backend for Active Job (and separate queues per environment)
78
+ # config.active_job.queue_adapter = :resque
79
+ # config.active_job.queue_name_prefix = "example_app_#{Rails.env}"
80
+ config.action_mailer.perform_caching = false
81
+
82
+ # Ignore bad email addresses and do not raise email delivery errors.
83
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
84
+ # config.action_mailer.raise_delivery_errors = false
85
+
86
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
87
+ # the I18n.default_locale when a translation cannot be found).
88
+ config.i18n.fallbacks = true
89
+
90
+ # Send deprecation notices to registered listeners.
91
+ config.active_support.deprecation = :notify
92
+
93
+ # Use default logging formatter so that PID and timestamp are not suppressed.
94
+ config.log_formatter = ::Logger::Formatter.new
95
+
96
+ # Use a different logger for distributed setups.
97
+ # require 'syslog/logger'
98
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
99
+
100
+ if ENV['RAILS_LOG_TO_STDOUT'].present?
101
+ logger = ActiveSupport::Logger.new(STDOUT)
102
+ logger.formatter = config.log_formatter
103
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
104
+ end
105
+
106
+ # Do not dump schema after migrations.
107
+ config.active_record.dump_schema_after_migration = false
108
+ end
@@ -22,5 +22,8 @@ test:
22
22
  <<: *default_settings
23
23
  monitor_mode: false
24
24
 
25
+ staging:
26
+ <<: *default_settings
27
+
25
28
  production:
26
29
  <<: *default_settings
@@ -1,4 +1,5 @@
1
1
  class HomeController < ApplicationController
2
+
2
3
  include DiscoApp::Concerns::AuthenticatedController
3
4
 
4
5
  def index