Remove dependency to Spree::TestingSupport code

This commit is contained in:
Luis Ramos
2020-08-22 17:18:46 +01:00
parent 907afe3131
commit 5cd40cb19f
2 changed files with 7 additions and 3 deletions

View File

@@ -1,7 +1,6 @@
module OpenFoodNetwork
class EnterpriseIssueValidator
include Rails.application.routes.url_helpers
include Spree::TestingSupport::UrlHelpers
def initialize(enterprise)
@enterprise = enterprise
@@ -13,14 +12,14 @@ module OpenFoodNetwork
unless shipping_methods_ok?
issues << {
description: I18n.t('admin.enterprise_issues.has_no_shipping_methods', enterprise: @enterprise.name),
link: "<a class='button fullwidth' href='#{spree.new_admin_shipping_method_path}'>#{I18n.t('admin.enterprise_issues.create_new')}</a>"
link: "<a class='button fullwidth' href='#{spree_routes_helper.new_admin_shipping_method_path}'>#{I18n.t('admin.enterprise_issues.create_new')}</a>"
}
end
unless payment_methods_ok?
issues << {
description: I18n.t('admin.enterprise_issues.has_no_payment_methods', enterprise: @enterprise.name),
link: "<a class='button fullwidth' href='#{spree.new_admin_payment_method_path}'>#{I18n.t('admin.enterprise_issues.create_new')}</a>"
link: "<a class='button fullwidth' href='#{spree_routes_helper.new_admin_payment_method_path}'>#{I18n.t('admin.enterprise_issues.create_new')}</a>"
}
end
@@ -64,5 +63,9 @@ module OpenFoodNetwork
@enterprise.payment_methods.available.any?
end
def spree_routes_helper
Spree::Core::Engine.routes.url_helpers
end
end
end

View File

@@ -1,3 +1,4 @@
require 'spec_helper'
require 'open_food_network/enterprise_issue_validator'
module OpenFoodNetwork