diff --git a/lib/suspenders/app_builder.rb b/lib/suspenders/app_builder.rb index 0d86f8a5c..3d8f424be 100644 --- a/lib/suspenders/app_builder.rb +++ b/lib/suspenders/app_builder.rb @@ -280,10 +280,9 @@ def init_git end def create_heroku_apps - path_addition = override_path_for_tests - run "#{path_addition} heroku create #{app_name}-production --remote=production" - run "#{path_addition} heroku create #{app_name}-staging --remote=staging" - run "#{path_addition} heroku config:add RACK_ENV=staging RAILS_ENV=staging --remote=staging" + run_heroku "create #{app_name}-production", "production" + run_heroku "create #{app_name}-staging", "staging" + run_heroku "config:add RACK_ENV=staging RAILS_ENV=staging", "staging" end def set_heroku_remotes @@ -310,9 +309,15 @@ def join_heroku_app(environment) end def set_heroku_rails_secrets - path_addition = override_path_for_tests - run "#{path_addition} heroku config:add SECRET_KEY_BASE=#{generate_secret} --remote=staging" - run "#{path_addition} heroku config:add SECRET_KEY_BASE=#{generate_secret} --remote=production" + %w(staging production).each do |environment| + run_heroku "config:add SECRET_KEY_BASE=#{generate_secret}", environment + end + end + + def set_memory_management_variable + %w(staging production).each do |environment| + run_heroku "config:add NEW_RELIC_AGGRESSIVE_KEEPALIVE=1", environment + end end def create_github_repo(repo_name) @@ -383,6 +388,11 @@ def override_path_for_tests end end + def run_heroku(command, environment) + path_addition = override_path_for_tests + run "#{path_addition} heroku #{command} --remote #{environment}" + end + def factories_spec_rake_task IO.read find_in_source_paths('factories_spec_rake_task.rb') end diff --git a/lib/suspenders/generators/app_generator.rb b/lib/suspenders/generators/app_generator.rb index d71d0bfbc..9f99fabb2 100644 --- a/lib/suspenders/generators/app_generator.rb +++ b/lib/suspenders/generators/app_generator.rb @@ -156,6 +156,7 @@ def create_heroku_apps build :create_heroku_apps build :set_heroku_remotes build :set_heroku_rails_secrets + build :set_memory_management_variable end end diff --git a/spec/support/fake_heroku.rb b/spec/support/fake_heroku.rb index 3fa9fe4d9..aaafb7bfc 100644 --- a/spec/support/fake_heroku.rb +++ b/spec/support/fake_heroku.rb @@ -25,14 +25,14 @@ def self.has_gem_included?(project_path, gem_name) def self.has_created_app_for?(remote_name) app_name = "#{SuspendersTestHelpers::APP_NAME}-#{remote_name}" - expected_line = "create #{app_name} --remote=#{remote_name}\n" + expected_line = "create #{app_name} --remote #{remote_name}\n" File.foreach(RECORDER).any? { |line| line == expected_line } end def self.has_configured_vars?(remote_name, var) File.foreach(RECORDER).any? do |line| - line =~ /^config:add #{var}=.+ --remote=#{remote_name}\n$/ + line =~ /^config:add #{var}=.+ --remote #{remote_name}\n$/ end end end