From 7db68795a4c64dffb989ba2b00e9c23c3d0c63ab Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 16 Oct 2014 16:06:54 +1100 Subject: [PATCH] Redirect to admin root after confirmation --- .../devise/confirmations_controller_decorator.rb | 7 +++++++ .../devise/confirmation_controller_spec.rb | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 app/controllers/devise/confirmations_controller_decorator.rb create mode 100644 spec/controllers/devise/confirmation_controller_spec.rb diff --git a/app/controllers/devise/confirmations_controller_decorator.rb b/app/controllers/devise/confirmations_controller_decorator.rb new file mode 100644 index 0000000000..ef34f28445 --- /dev/null +++ b/app/controllers/devise/confirmations_controller_decorator.rb @@ -0,0 +1,7 @@ +Devise::ConfirmationsController.class_eval do + protected + # Override of devise method in Devise::ConfirmationsController + def after_confirmation_path_for(resource_name, resource) + spree.admin_path + end +end \ No newline at end of file diff --git a/spec/controllers/devise/confirmation_controller_spec.rb b/spec/controllers/devise/confirmation_controller_spec.rb new file mode 100644 index 0000000000..eda5dc4823 --- /dev/null +++ b/spec/controllers/devise/confirmation_controller_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe Devise::ConfirmationsController do + context "after confirmation" do + before do + e = create(:enterprise) + @request.env["devise.mapping"] = Devise.mappings[:enterprise] + spree_get :show, confirmation_token: e.confirmation_token + end + + it "should redirect to admin root" do + expect(response).to redirect_to spree.admin_path + end + end +end \ No newline at end of file