diff --git a/app/controllers/admin/enterprises_controller.rb b/app/controllers/admin/enterprises_controller.rb index 9bbe0e57ea..5ccc9b9c92 100644 --- a/app/controllers/admin/enterprises_controller.rb +++ b/app/controllers/admin/enterprises_controller.rb @@ -241,7 +241,7 @@ module Admin # Overriding method on Spree's resource controller def location_after_save referer_path = OpenFoodNetwork::RefererParser::path(request.referer) - refered_from_edit = referer_path == main_app.edit_admin_enterprise_path(@enterprise) + refered_from_edit = referer_path =~ /\/edit$/ if params[:enterprise].key?(:producer_properties_attributes) && !refered_from_edit main_app.admin_enterprises_path else diff --git a/config/routes.rb b/config/routes.rb index a2e08e36a3..8ff703e2ba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,6 @@ Openfoodnetwork::Application.routes.draw do # Redirects from old URLs avoid server errors and helps search engines get "/enterprises", to: redirect("/") - get "/enterprises/:permalink", to: redirect("/") get "/products", to: redirect("/") get "/t/products/:id", to: redirect("/") get "/about_us", to: redirect(ContentConfig.footer_about_url) @@ -55,6 +54,7 @@ Openfoodnetwork::Application.routes.draw do end end get '/:id/shop', to: 'enterprises#shop', as: 'enterprise_shop' + get "/enterprises/:permalink", to: redirect("/") # Legacy enterprise URL devise_for :enterprise, controllers: { confirmations: 'enterprise_confirmations' } diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 4c0cf6d836..43c6942bcf 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -78,6 +78,8 @@ feature %q{ end fill_in 'enterprise_name', :with => 'Eaterprises' + fill_in 'enterprise_permalink', with: 'eaterprises-permalink' + page.should have_selector '.available' choose 'Own' within (".side_menu") { click_link "Users" }