mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-11 18:26:50 +00:00
Re add VINE_API_URL env variable
And add error handling if the variable is not set
This commit is contained in:
3
.env
3
.env
@@ -67,3 +67,6 @@ SMTP_PASSWORD="f00d"
|
|||||||
# ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
# ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
# ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
# ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
# ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
# ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
|
|
||||||
|
# VINE API settings
|
||||||
|
# VINE_API_URL="https://vine-staging.openfoodnetwork.org.au/api/v1"
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ module Admin
|
|||||||
rescue Faraday::Error => e
|
rescue Faraday::Error => e
|
||||||
log_and_notify_exception(e)
|
log_and_notify_exception(e)
|
||||||
handle_error(I18n.t("admin.enterprises.form.connected_apps.vine.connection_error"))
|
handle_error(I18n.t("admin.enterprises.form.connected_apps.vine.connection_error"))
|
||||||
|
rescue KeyError => e
|
||||||
|
log_and_notify_exception(e)
|
||||||
|
handle_error(I18n.t("admin.enterprises.form.connected_apps.vine.setup_error"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def enterprise
|
def enterprise
|
||||||
|
|||||||
@@ -1441,6 +1441,7 @@ en:
|
|||||||
api_parameters_empty: "Please enter an API key and a secret"
|
api_parameters_empty: "Please enter an API key and a secret"
|
||||||
api_parameters_error: "Check you entered your API key and secret correctly, contact your instance manager if the error persists"
|
api_parameters_error: "Check you entered your API key and secret correctly, contact your instance manager if the error persists"
|
||||||
connection_error: "API connection error, please try again"
|
connection_error: "API connection error, please try again"
|
||||||
|
setup_error: "VINE API is not configured, please contact your instance manager"
|
||||||
actions:
|
actions:
|
||||||
edit_profile: Settings
|
edit_profile: Settings
|
||||||
properties: Properties
|
properties: Properties
|
||||||
|
|||||||
@@ -111,6 +111,38 @@ RSpec.describe "Admin ConnectedApp" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when VINE API is not set up properly" do
|
||||||
|
before do
|
||||||
|
# VineApiService will raise a KeyError if VINE_API_URL is not set
|
||||||
|
allow(VineApiService).to receive(:new).and_raise(KeyError)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to enterprise edit page, with an error" do
|
||||||
|
params = {
|
||||||
|
type: ConnectedApps::Vine,
|
||||||
|
vine_api_key: "12345678",
|
||||||
|
vine_secret: "my_secret"
|
||||||
|
}
|
||||||
|
post("/admin/enterprises/#{enterprise.id}/connected_apps", params: )
|
||||||
|
|
||||||
|
expect(response).to redirect_to(edit_enterprise_url)
|
||||||
|
expect(flash[:error]).to eq(
|
||||||
|
"VINE API is not configured, please contact your instance manager"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "notifies Bugsnag" do
|
||||||
|
expect(Bugsnag).to receive(:notify)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
type: ConnectedApps::Vine,
|
||||||
|
vine_api_key: "12345678",
|
||||||
|
vine_secret: "my_secret"
|
||||||
|
}
|
||||||
|
post("/admin/enterprises/#{enterprise.id}/connected_apps", params: )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "when there is a connection error" do
|
context "when there is a connection error" do
|
||||||
before do
|
before do
|
||||||
allow(vine_api).to receive(:my_team).and_raise(Faraday::Error)
|
allow(vine_api).to receive(:my_team).and_raise(Faraday::Error)
|
||||||
|
|||||||
Reference in New Issue
Block a user