-
-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce
suspenders:production_environment
generator
- Loading branch information
1 parent
fe5fc93
commit acb443f
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
lib/generators/suspenders/production_environment_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Suspenders | ||
module Generators | ||
class ProductionEnvironmentGenerator < Rails::Generators::Base | ||
end | ||
end | ||
end |
35 changes: 35 additions & 0 deletions
35
test/generators/suspenders/production_environment_generator_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require "test_helper" | ||
require "generators/suspenders/production_environment_generator" | ||
|
||
module Suspenders | ||
module Generators | ||
class ProductionEnvironmentGenerator::DefaultTest < Rails::Generators::TestCase | ||
include Suspenders::TestHelpers | ||
|
||
tests Suspenders::Generators::ProductionEnvironmentGenerator | ||
destination Rails.root | ||
setup :prepare_destination | ||
teardown :restore_destination | ||
|
||
test "configures the asset host" do | ||
run_generator | ||
assert_file app_root("config/environments/production.rb") do |file| | ||
assert_match( | ||
/^ +config.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))$/, | ||
file | ||
) | ||
end | ||
end | ||
|
||
private | ||
|
||
def prepare_destination | ||
backup_file "config/environments/produciton.rb" | ||
end | ||
|
||
def restore_destination | ||
restore_file "config/environments/produciton.rb" | ||
end | ||
end | ||
end | ||
end |