Skip to content

Commit

Permalink
Merge pull request #1496 from Shopify/nelsonwittwer/reorg_errors
Browse files Browse the repository at this point in the history
Fix webhook error throwing
  • Loading branch information
nelsonwittwer committed Sep 1, 2022
2 parents 0352f6a + 34af622 commit 77307bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/shopify_app/managers/webhooks_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def path(webhook_attributes)
elsif uri&.path&.present?
uri.path
else
raise ShopifyApp::MissingWebhookJobError("The :path attribute is required for webhook registration.")
raise ShopifyApp::MissingWebhookJobError, "The :path attribute is required for webhook registration."
end
end

Expand Down
14 changes: 14 additions & 0 deletions test/shopify_app/managers/webhooks_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ class ShopifyApp::WebhooksManagerTest < ActiveSupport::TestCase
ShopifyApp::WebhooksManager.add_registrations
end

test "#add_registrations raises an error when missing path and address" do
ShopifyApp.configure do |config|
config.webhooks = [
{
topic: "orders/updated",
},
]
end

assert_raises ShopifyApp::MissingWebhookJobError do
ShopifyApp::WebhooksManager.add_registrations
end
end

test "#add_registrations does not makes calls to library's add_registration when there are no webhooks" do
ShopifyAPI::Webhooks::Registry.expects(:add_registration).never
ShopifyApp.configure do |config|
Expand Down

0 comments on commit 77307bd

Please sign in to comment.