Skip to content

Commit

Permalink
Join the Heroku app in bin/setup
Browse files Browse the repository at this point in the history
  • Loading branch information
gabebw authored and Dan Croak committed May 29, 2014
1 parent 64d5f1f commit 82b44cc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
26 changes: 19 additions & 7 deletions lib/suspenders/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,31 @@ def create_heroku_apps
end

def set_heroku_remotes
remotes = <<-RUBY
remotes = <<-SHELL
# Set up staging and production git remotes
git remote add staging git@heroku.com:#{app_name}-staging.git
heroku join --app #{app_name}-staging
# Set up staging and production git remotes.
git remote add staging git@heroku.com:#{app_name}-staging.git || true
git remote add production git@heroku.com:#{app_name}-production.git || true
git remote add production git@heroku.com:#{app_name}-production.git
heroku join --app #{app_name}-production
RUBY
# Join the staging and production apps.
#{join_heroku_app('staging')}
#{join_heroku_app('production')}
SHELL

append_file 'bin/setup', remotes
end

def join_heroku_app(environment)
heroku_app_name = "#{app_name}-#{environment}"
<<-SHELL
if heroku join --app #{heroku_app_name} &> /dev/null; then
echo 'You are a collaborator on the "#{heroku_app_name}" Heroku app'
else
echo 'Ask for access to the "#{heroku_app_name}" Heroku app'
fi
SHELL
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"
Expand Down
6 changes: 6 additions & 0 deletions spec/features/heroku_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@
expect(FakeHeroku).to have_created_app_for('production')
expect(FakeHeroku).to have_configured_vars('staging', 'SECRET_KEY_BASE')
expect(FakeHeroku).to have_configured_vars('production', 'SECRET_KEY_BASE')

bin_setup = IO.read("#{project_path}/bin/setup")
app_name = SuspendersTestHelpers::APP_NAME

expect(bin_setup).to include("heroku join --app #{app_name}-staging")
expect(bin_setup).to include("heroku join --app #{app_name}-production")
end
end
1 change: 0 additions & 1 deletion spec/features/new_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
expect(secrets_file).to match(/secret_key_base: <%= ENV\['SECRET_KEY_BASE'\] %>/)
end


scenario 'action mailer support file is added' do
run_suspenders

Expand Down

0 comments on commit 82b44cc

Please sign in to comment.