From dd56e03be13d0c01253b85aa0f64893a9c7a7dfd Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 6 Jul 2017 12:43:38 +1000 Subject: [PATCH] Stop setting host for url helpers in specs --- config/environments/test.rb | 2 +- spec/controllers/spree/admin/products_controller_spec.rb | 2 +- spec/controllers/user_passwords_controller_spec.rb | 1 - spec/features/admin/orders_spec.rb | 1 - spec/spec_helper.rb | 3 +++ 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index f0ef05acaa..3a33fd53d7 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -45,7 +45,6 @@ Openfoodnetwork::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr - config.action_mailer.default_url_options = { :host => "test.host" } # To block requests before running the database cleaner require 'open_food_network/rack_request_blocker' @@ -55,3 +54,4 @@ end # Allows us to use _url helpers in Rspec Rails.application.routes.default_url_options[:host] = 'test.host' +Spree::Core::Engine.routes.default_url_options[:host] = 'test.host' diff --git a/spec/controllers/spree/admin/products_controller_spec.rb b/spec/controllers/spree/admin/products_controller_spec.rb index b8d76abd9c..02a5d6bced 100644 --- a/spec/controllers/spree/admin/products_controller_spec.rb +++ b/spec/controllers/spree/admin/products_controller_spec.rb @@ -12,7 +12,7 @@ describe Spree::Admin::ProductsController do end it "denies access" do - response.should redirect_to "http://test.host/unauthorized" + response.should redirect_to spree.unauthorized_url end it "does not update any product" do diff --git a/spec/controllers/user_passwords_controller_spec.rb b/spec/controllers/user_passwords_controller_spec.rb index 59fadf8e99..26584a8619 100644 --- a/spec/controllers/user_passwords_controller_spec.rb +++ b/spec/controllers/user_passwords_controller_spec.rb @@ -6,7 +6,6 @@ describe UserPasswordsController do before do @request.env["devise.mapping"] = Devise.mappings[:spree_user] - ActionMailer::Base.default_url_options[:host] = "test.host" end describe "create" do diff --git a/spec/features/admin/orders_spec.rb b/spec/features/admin/orders_spec.rb index 5b0a215dd8..4b5df630f1 100644 --- a/spec/features/admin/orders_spec.rb +++ b/spec/features/admin/orders_spec.rb @@ -204,7 +204,6 @@ feature %q{ end context "viewing the edit page" do - before { Rails.application.routes.default_url_options[:host] = "test.host" } it "shows the dropdown menu" do distributor1.update_attribute(:abn, '12345678') order = create(:completed_order_with_totals, distributor: distributor1) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e24d2a7cf7..4ef7c63b40 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -47,6 +47,9 @@ Capybara.default_max_wait_time = 30 require "paperclip/matchers" +# Override setting in Spree engine: Spree::Core::MailSettings +ActionMailer::Base.default_url_options[:host] = 'test.host' + RSpec.configure do |config| # ## Mock Framework #