mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Fix webhook endpoints controller spec
This commit is contained in:
@@ -11,14 +11,16 @@ RSpec.describe WebhookEndpointsController do
|
||||
describe "#create" do
|
||||
it "creates a webhook_endpoint" do
|
||||
expect {
|
||||
spree_post :create, { url: "https://url" }
|
||||
spree_post :create, { url: "https://url", webhook_type: "order_cycle_opened" }
|
||||
}.to change {
|
||||
user.webhook_endpoints.count
|
||||
}.by(1)
|
||||
|
||||
expect(flash[:success]).to be_present
|
||||
expect(flash[:error]).to be_blank
|
||||
expect(user.webhook_endpoints.first.url).to eq "https://url"
|
||||
webhook = user.webhook_endpoints.first
|
||||
expect(webhook.url).to eq "https://url"
|
||||
expect(webhook.webhook_type).to eq "order_cycle_opened"
|
||||
end
|
||||
|
||||
it "shows error if parameters not specified" do
|
||||
@@ -33,17 +35,20 @@ RSpec.describe WebhookEndpointsController do
|
||||
end
|
||||
|
||||
it "redirects back to referrer" do
|
||||
spree_post :create, { url: "https://url" }
|
||||
spree_post :create, { url: "https://url", webhook_type: "order_cycle_opened" }
|
||||
|
||||
expect(response).to redirect_to "/account#/developer_settings"
|
||||
end
|
||||
end
|
||||
|
||||
describe "#destroy" do
|
||||
let!(:webhook_endpoint) { user.webhook_endpoints.create(url: "https://url") }
|
||||
let!(:webhook_endpoint) {
|
||||
user.webhook_endpoints.create(url: "https://url", webhook_type: "order_cycle_opened")
|
||||
}
|
||||
|
||||
it "destroys a webhook_endpoint" do
|
||||
webhook_endpoint2 = user.webhook_endpoints.create!(url: "https://url2")
|
||||
webhook_endpoint2 = user.webhook_endpoints.create!(url: "https://url2",
|
||||
webhook_type: "order_cycle_opened")
|
||||
|
||||
expect {
|
||||
spree_delete :destroy, { id: webhook_endpoint.id }
|
||||
|
||||
Reference in New Issue
Block a user