From d510df52360612b01557adf44712f6fffb994012 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 15 Jun 2018 10:49:53 +1000 Subject: [PATCH] Remove obsolete goWithoutHashFragments It was introduced, because `Navigation.go` perserved hash fragments. We actually don't need that behaviour and it has been corrected. `goWithoutHashFragments` also didn't deal with absolute URLs. And it used `location.origin` which is not supported by Internet Explorer. That is fixed by our use of Modernizr though. --- .../javascripts/darkswarm/services/checkout.js.coffee | 2 +- .../javascripts/darkswarm/services/navigation.js.coffee | 4 ---- .../unit/darkswarm/services/checkout_spec.js.coffee | 6 ++++++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/darkswarm/services/checkout.js.coffee b/app/assets/javascripts/darkswarm/services/checkout.js.coffee index 67306a7faf..204c35ac66 100644 --- a/app/assets/javascripts/darkswarm/services/checkout.js.coffee +++ b/app/assets/javascripts/darkswarm/services/checkout.js.coffee @@ -13,7 +13,7 @@ Darkswarm.factory 'Checkout', ($injector, CurrentOrder, ShippingMethods, StripeE submit: => Loading.message = t 'submitting_order' $http.put('/checkout.json', {order: @preprocess()}).success (data, status)=> - Navigation.goWithoutHashFragments data.path + Navigation.go data.path .error (response, status)=> if response.path Navigation.go response.path diff --git a/app/assets/javascripts/darkswarm/services/navigation.js.coffee b/app/assets/javascripts/darkswarm/services/navigation.js.coffee index 54a2e60174..b58786e930 100644 --- a/app/assets/javascripts/darkswarm/services/navigation.js.coffee +++ b/app/assets/javascripts/darkswarm/services/navigation.js.coffee @@ -16,10 +16,6 @@ Darkswarm.factory 'Navigation', ($location, $window) -> else @navigate(path) - goWithoutHashFragments: (path) -> - # Redirects to specified path, without Angular hash fragments such as '#/login' - $window.location.href = $window.location.origin + path - go: (path)-> # The browser treats this like clicking on a link. # It works for absolute paths, relative paths and URLs alike. diff --git a/spec/javascripts/unit/darkswarm/services/checkout_spec.js.coffee b/spec/javascripts/unit/darkswarm/services/checkout_spec.js.coffee index 5ca05a344f..4ff2f0d97a 100644 --- a/spec/javascripts/unit/darkswarm/services/checkout_spec.js.coffee +++ b/spec/javascripts/unit/darkswarm/services/checkout_spec.js.coffee @@ -95,6 +95,12 @@ describe 'Checkout service', -> Checkout.submit() $httpBackend.flush() + it "Redirects to the returned path", -> + $httpBackend.expectPUT("/checkout.json", {order: Checkout.preprocess()}).respond 200, {path: "/test"} + Checkout.submit() + $httpBackend.flush() + expect(Navigation.go).toHaveBeenCalledWith '/test' + describe "when there is an error", -> it "redirects when a redirect is given", -> $httpBackend.expectPUT("/checkout.json").respond 400, {path: 'path'}