mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-16 04:24:23 +00:00
Update links to n8n server
This commit is contained in:
50
spec/migrations/20240502035220_update_n8n_url_spec.rb
Normal file
50
spec/migrations/20240502035220_update_n8n_url_spec.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require_relative '../../db/migrate/20240502035220_update_n8n_url'
|
||||
|
||||
describe UpdateN8nUrl do
|
||||
# We may want to move this to a support file if this syntax is useful in
|
||||
# other places. Reference:
|
||||
# - https://stackoverflow.com/a/34969429/3377535
|
||||
RSpec::Matchers.define_negated_matcher :not_change, :change
|
||||
|
||||
let(:enterprise) { create(:enterprise) }
|
||||
let(:old_data) {
|
||||
{
|
||||
link: "https://link-to-form",
|
||||
destroy: "https://n8n.openfoodnetwork.org.uk/webhook/remove-enterprise?key=abc&id=123",
|
||||
}
|
||||
}
|
||||
let(:new_data) {
|
||||
{
|
||||
link: "https://link-to-form",
|
||||
destroy: "https://n8n.openfoodnetwork.org/webhook/remove-enterprise?key=abc&id=123",
|
||||
}
|
||||
}
|
||||
|
||||
it "updates old connected app links" do
|
||||
app = ConnectedApp.create!(enterprise:, data: old_data,)
|
||||
|
||||
expect {
|
||||
subject.up
|
||||
app.reload
|
||||
}.to change {
|
||||
app.data["destroy"]
|
||||
}.to("https://n8n.openfoodnetwork.org/webhook/remove-enterprise?key=abc&id=123")
|
||||
.and not_change {
|
||||
app.data["link"]
|
||||
}
|
||||
end
|
||||
|
||||
it "keeps new connected app links" do
|
||||
app = ConnectedApp.create!(enterprise:, data: new_data,)
|
||||
|
||||
expect {
|
||||
subject.up
|
||||
app.reload
|
||||
}.not_to change {
|
||||
app.data
|
||||
}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user