diff --git a/libraries/drivers_framework_rails.rb b/libraries/drivers_framework_rails.rb index 51500c2a..8de4fdae 100644 --- a/libraries/drivers_framework_rails.rb +++ b/libraries/drivers_framework_rails.rb @@ -16,15 +16,20 @@ def raw_out def after_deploy(context) output = out deploy_to = deploy_dir(app) + env = environment context.execute 'assets:precompile' do command output[:assets_precompilation_command] user node['deployer']['user'] cwd File.join(deploy_to, 'current') group www_group - environment output[:deploy_environment] + environment env end if out[:assets_precompile] end + + def environment + app['environment'].merge(out[:deploy_environment]) + end end end end diff --git a/spec/unit/recipes/deploy_spec.rb b/spec/unit/recipes/deploy_spec.rb index 5d0c927a..80ce3baf 100644 --- a/spec/unit/recipes/deploy_spec.rb +++ b/spec/unit/recipes/deploy_spec.rb @@ -61,7 +61,7 @@ expect(chef_run).to run_execute('start unicorn') expect(chef_run).to run_execute('assets:precompile').with( command: '/usr/local/bin/bundle exec rake assets:precompile', - environment: { 'RAILS_ENV' => 'production' }, + environment: { 'ENV_VAR1' => 'test', 'ENV_VAR2' => 'some data', 'RAILS_ENV' => 'production' }, cwd: "/srv/www/#{aws_opsworks_app['shortname']}/current" ) expect(deploy).to notify('service[nginx]').to(:reload).delayed