fix: Account seeder error on staging (#5371)
- Fix for Account seeding error on staging environments
This commit is contained in:
parent
4a74ab59d2
commit
7f3f6f7129
7 changed files with 17 additions and 10 deletions
8
Gemfile
8
Gemfile
|
@ -131,6 +131,10 @@ gem 'pg_search'
|
||||||
# Subscriptions, Billing
|
# Subscriptions, Billing
|
||||||
gem 'stripe'
|
gem 'stripe'
|
||||||
|
|
||||||
|
## - helper gems --##
|
||||||
|
## to populate db with sample data
|
||||||
|
gem 'faker'
|
||||||
|
|
||||||
group :production, :staging do
|
group :production, :staging do
|
||||||
# we dont want request timing out in development while using byebug
|
# we dont want request timing out in development while using byebug
|
||||||
gem 'rack-timeout'
|
gem 'rack-timeout'
|
||||||
|
@ -158,10 +162,6 @@ group :test do
|
||||||
gem 'webmock'
|
gem 'webmock'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test, :staging do
|
|
||||||
gem 'faker'
|
|
||||||
end
|
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'active_record_query_trace'
|
gem 'active_record_query_trace'
|
||||||
##--- gems for debugging and error reporting ---##
|
##--- gems for debugging and error reporting ---##
|
||||||
|
|
|
@ -43,7 +43,7 @@ class SuperAdmin::AccountsController < SuperAdmin::ApplicationController
|
||||||
# for more information
|
# for more information
|
||||||
|
|
||||||
def seed
|
def seed
|
||||||
Seeders::AccountSeeder.new(account: requested_resource).perform!
|
Internal::SeedAccountJob.perform_later(requested_resource)
|
||||||
redirect_back(fallback_location: [namespace, requested_resource], notice: 'Account seeding triggered')
|
redirect_back(fallback_location: [namespace, requested_resource], notice: 'Account seeding triggered')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
7
app/jobs/internal/seed_account_job.rb
Normal file
7
app/jobs/internal/seed_account_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class Internal::SeedAccountJob < ApplicationJob
|
||||||
|
queue_as :low
|
||||||
|
|
||||||
|
def perform(account)
|
||||||
|
Seeders::AccountSeeder.new(account: account).perform!
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,4 +1,4 @@
|
||||||
<% if !Rails.env.production? || ENV.fetch('ENABLE_ACCOUNT_SEEDING', nil) %>
|
<% if ENV.fetch('ENABLE_ACCOUNT_SEEDING', !Rails.env.production?) %>
|
||||||
<section class="main-content__body">
|
<section class="main-content__body">
|
||||||
<hr/>
|
<hr/>
|
||||||
<%= form_for([:seed, namespace, page.resource], method: :post, html: { class: "form" }) do |f| %>
|
<%= form_for([:seed, namespace, page.resource], method: :post, html: { class: "form" }) do |f| %>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
class Seeders::AccountSeeder
|
class Seeders::AccountSeeder
|
||||||
def initialize(account:)
|
def initialize(account:)
|
||||||
raise 'Account Seeding is not allowed in production.' if Rails.env.production?
|
raise 'Account Seeding is not allowed.' unless ENV.fetch('ENABLE_ACCOUNT_SEEDING', !Rails.env.production?)
|
||||||
|
|
||||||
@account_data = HashWithIndifferentAccess.new(YAML.safe_load(File.read(Rails.root.join('lib/seeders/seed_data.yml'))))
|
@account_data = HashWithIndifferentAccess.new(YAML.safe_load(File.read(Rails.root.join('lib/seeders/seed_data.yml'))))
|
||||||
@account = account
|
@account = account
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
class Seeders::InboxSeeder
|
class Seeders::InboxSeeder
|
||||||
def initialize(account:, company_data:)
|
def initialize(account:, company_data:)
|
||||||
raise 'Inbox Seeding is not allowed in production.' if Rails.env.production?
|
raise 'Inbox Seeding is not allowed in production.' unless ENV.fetch('ENABLE_ACCOUNT_SEEDING', !Rails.env.production?)
|
||||||
|
|
||||||
@account = account
|
@account = account
|
||||||
@company_data = company_data
|
@company_data = company_data
|
||||||
|
|
|
@ -351,11 +351,11 @@ contacts:
|
||||||
- message_type: incoming
|
- message_type: incoming
|
||||||
content: "Hey, \n My card is not working on your website. Please help"
|
content: "Hey, \n My card is not working on your website. Please help"
|
||||||
- name: "Candice Matherson"
|
- name: "Candice Matherson"
|
||||||
email: "cmathersonj@va.gov"
|
email: "cmathersonj@va.test"
|
||||||
gender: 'female'
|
gender: 'female'
|
||||||
conversations:
|
conversations:
|
||||||
- channel: Channel::Email
|
- channel: Channel::Email
|
||||||
source_id: "cmathersonj@va.gov"
|
source_id: "cmathersonj@va.test"
|
||||||
assignee: michael_scott@paperlayer.test
|
assignee: michael_scott@paperlayer.test
|
||||||
messages:
|
messages:
|
||||||
- message_type: incoming
|
- message_type: incoming
|
||||||
|
|
Loading…
Reference in a new issue