-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't run app config initializer for generator #1144
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d7a1f0c
Don't run app config for generator
andyw8 10c8941
Improve error message
andyw8 8f95799
Fix tests
andyw8 bb2cb0d
Update README
andyw8 b5fe5f7
Update CHANGELOG
andyw8 c7a8daf
Update README
andyw8 a563c79
Fix URL
andyw8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
28 changes: 15 additions & 13 deletions
28
lib/generators/shopify_app/install/templates/shopify_app.rb.tt
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
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 |
---|---|---|
|
@@ -23,10 +23,8 @@ class InstallGeneratorTest < Rails::Generators::TestCase | |
run_generator | ||
assert_file "config/initializers/shopify_app.rb" do |shopify_app| | ||
assert_match 'config.application_name = "My Shopify App"', shopify_app | ||
assert_match "config.api_key = ENV.fetch('SHOPIFY_API_KEY', '').presence " \ | ||
"|| raise('Missing SHOPIFY_API_KEY')", shopify_app | ||
assert_match "config.secret = ENV.fetch('SHOPIFY_API_SECRET', '').presence " \ | ||
"|| raise('Missing SHOPIFY_API_SECRET')", shopify_app | ||
assert_match "config.api_key = ENV.fetch('SHOPIFY_API_KEY', '')", shopify_app | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than copy the exact updated template code into the test, I've simplified this to check for just the 'essential' part. Verifying the template code doesn't prove that the generator works – ideally we should generate an app as part of the test suite. |
||
assert_match "config.secret = ENV.fetch('SHOPIFY_API_SECRET', '')", shopify_app | ||
assert_match 'config.scope = "read_products"', shopify_app | ||
assert_match "config.embedded_app = true", shopify_app | ||
assert_match 'config.api_version = "2019-10"', shopify_app | ||
|
@@ -41,10 +39,8 @@ class InstallGeneratorTest < Rails::Generators::TestCase | |
--api_version unstable --scope read_orders write_products) | ||
assert_file "config/initializers/shopify_app.rb" do |shopify_app| | ||
assert_match 'config.application_name = "Test Name"', shopify_app | ||
assert_match "config.api_key = ENV.fetch('SHOPIFY_API_KEY', '').presence " \ | ||
"|| raise('Missing SHOPIFY_API_KEY')", shopify_app | ||
assert_match "config.secret = ENV.fetch('SHOPIFY_API_SECRET', '').presence " \ | ||
"|| raise('Missing SHOPIFY_API_SECRET')", shopify_app | ||
assert_match "config.api_key = ENV.fetch('SHOPIFY_API_KEY', '')", shopify_app | ||
assert_match "config.secret = ENV.fetch('SHOPIFY_API_SECRET', '')", shopify_app | ||
assert_match 'config.scope = "read_orders write_products"', shopify_app | ||
assert_match 'config.embedded_app = true', shopify_app | ||
assert_match 'config.api_version = "unstable"', shopify_app | ||
|
@@ -56,10 +52,8 @@ class InstallGeneratorTest < Rails::Generators::TestCase | |
run_generator %w(--application_name Test Name --scope read_orders write_products) | ||
assert_file "config/initializers/shopify_app.rb" do |shopify_app| | ||
assert_match 'config.application_name = "Test Name"', shopify_app | ||
assert_match "config.api_key = ENV.fetch('SHOPIFY_API_KEY', '').presence " \ | ||
"|| raise('Missing SHOPIFY_API_KEY')", shopify_app | ||
assert_match "config.secret = ENV.fetch('SHOPIFY_API_SECRET', '').presence " \ | ||
"|| raise('Missing SHOPIFY_API_SECRET')", shopify_app | ||
assert_match "config.api_key = ENV.fetch('SHOPIFY_API_KEY', '')", shopify_app | ||
assert_match "config.secret = ENV.fetch('SHOPIFY_API_SECRET', '')", shopify_app | ||
assert_match 'config.scope = "read_orders write_products"', shopify_app | ||
assert_match 'config.embedded_app = true', shopify_app | ||
assert_match "config.shop_session_repository = 'Shop'", shopify_app | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andyw8 with this change, the reference of
ShopifyApp.configuration
in generator code(not template code) should also be removed, there is one at home_controller_generator.rbthe method
embedded_app?
is no longer needed any more.Otherwise the generated code of
HomeController
by default will be an authenticated home_controller instead of the unauthenticated home_controller, which is conflict with the README.mdThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point @xiaoboa, I'm actually investigating that myself. We still need need the method if we're creating non-embedded apps but I'll make sure that home_controller is not authenticated.
Thanks!