Skip to content

Commit

Permalink
fix: Account seeder error on staging (#5371)
Browse files Browse the repository at this point in the history
- Fix for Account seeding error on staging environments
  • Loading branch information
sojan-official committed Sep 1, 2022
1 parent 4a74ab5 commit 7f3f6f7
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Gemfile
Expand Up @@ -131,6 +131,10 @@ gem 'pg_search'
# Subscriptions, Billing
gem 'stripe'

## - helper gems --##
## to populate db with sample data
gem 'faker'

group :production, :staging do
# we dont want request timing out in development while using byebug
gem 'rack-timeout'
Expand Down Expand Up @@ -158,10 +162,6 @@ group :test do
gem 'webmock'
end

group :development, :test, :staging do
gem 'faker'
end

group :development, :test do
gem 'active_record_query_trace'
##--- gems for debugging and error reporting ---##
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/super_admin/accounts_controller.rb
Expand Up @@ -43,7 +43,7 @@ def resource_params
# for more information

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')
end
end
7 changes: 7 additions & 0 deletions app/jobs/internal/seed_account_job.rb
@@ -0,0 +1,7 @@
class Internal::SeedAccountJob < ApplicationJob
queue_as :low

def perform(account)
Seeders::AccountSeeder.new(account: account).perform!
end
end
2 changes: 1 addition & 1 deletion app/views/super_admin/accounts/_seed_data.html.erb
@@ -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">
<hr/>
<%= form_for([:seed, namespace, page.resource], method: :post, html: { class: "form" }) do |f| %>
Expand Down
2 changes: 1 addition & 1 deletion lib/seeders/account_seeder.rb
Expand Up @@ -10,7 +10,7 @@

class Seeders::AccountSeeder
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 = account
Expand Down
2 changes: 1 addition & 1 deletion lib/seeders/inbox_seeder.rb
Expand Up @@ -10,7 +10,7 @@

class Seeders::InboxSeeder
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
@company_data = company_data
Expand Down
4 changes: 2 additions & 2 deletions lib/seeders/seed_data.yml
Expand Up @@ -351,11 +351,11 @@ contacts:
- message_type: incoming
content: "Hey, \n My card is not working on your website. Please help"
- name: "Candice Matherson"
email: "cmathersonj@va.gov"
email: "cmathersonj@va.test"
gender: 'female'
conversations:
- channel: Channel::Email
source_id: "cmathersonj@va.gov"
source_id: "cmathersonj@va.test"
assignee: michael_scott@paperlayer.test
messages:
- message_type: incoming
Expand Down

0 comments on commit 7f3f6f7

Please sign in to comment.