Skip to content

Commit

Permalink
Merge pull request #802 from Shopify/config-host
Browse files Browse the repository at this point in the history
adds config host for ngrok url
  • Loading branch information
Katie Davis authored Oct 16, 2019
2 parents 8bc6cc8 + ec5ab81 commit 07df4c0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/generators/shopify_app/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ def mount_engine
route "mount ShopifyApp::Engine, at: '/'"
end

def insert_hosts_into_development_config
inject_into_file(
'config/environments/development.rb',
" config.hosts << /\\h+.ngrok.io/\n",
after: "Rails.application.configure do\n"
)
end

private

def embedded_app?
Expand Down
2 changes: 2 additions & 0 deletions test/app_templates/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Rails.application.configure do
end
8 changes: 8 additions & 0 deletions test/generators/install_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase
provide_existing_application_file
provide_existing_routes_file
provide_existing_application_controller
provide_development_config_file
end

teardown do
Expand Down Expand Up @@ -90,4 +91,11 @@ class InstallGeneratorTest < Rails::Generators::TestCase
assert_match "gem 'dotenv-rails', group: [:test, :development]", gemfile
end
end

test "adds host config to development.rb" do
run_generator
assert_file "config/environments/development.rb" do |config|
assert_match "config.hosts << /\\h+.ngrok.io/", config
end
end
end
4 changes: 4 additions & 0 deletions test/support/generator_test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def provide_existing_initializer_file_with_webhooks
copy_to_generator_root("config/initializers", "shopify_app_with_webhooks.rb", rename: 'shopify_app.rb')
end

def provide_development_config_file
copy_to_generator_root("config/environments", "development.rb")
end

private

def copy_to_generator_root(destination, template, rename: nil)
Expand Down

0 comments on commit 07df4c0

Please sign in to comment.