mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Allow request to specify a return value when calling user_passwords#edit
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
class UserPasswordsController < Spree::UserPasswordsController
|
||||
layout 'darkswarm'
|
||||
|
||||
before_filter :set_admin_redirect, only: :edit
|
||||
|
||||
def create
|
||||
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
||||
|
||||
@@ -18,4 +20,10 @@ class UserPasswordsController < Spree::UserPasswordsController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_admin_redirect
|
||||
session["spree_user_return_to"] = params[:return_to] if params[:return_to]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,15 +9,26 @@ describe UserPasswordsController do
|
||||
ActionMailer::Base.default_url_options[:host] = "test.host"
|
||||
end
|
||||
|
||||
it "returns errors" do
|
||||
spree_post :create, spree_user: {}
|
||||
response.should be_success
|
||||
response.should render_template "spree/user_passwords/new"
|
||||
describe "create" do
|
||||
it "returns errors" do
|
||||
spree_post :create, spree_user: {}
|
||||
response.should be_success
|
||||
response.should render_template "spree/user_passwords/new"
|
||||
end
|
||||
|
||||
it "redirects to login when data is valid" do
|
||||
spree_post :create, spree_user: { email: user.email}
|
||||
response.should be_redirect
|
||||
end
|
||||
end
|
||||
|
||||
it "redirects to login when data is valid" do
|
||||
spree_post :create, spree_user: { email: user.email}
|
||||
response.should be_redirect
|
||||
describe "edit" do
|
||||
context "when given a redirect" do
|
||||
it "stores the redirect path in 'spree_user_return_to'" do
|
||||
spree_post :edit, reset_password_token: "token", return_to: "/return_path"
|
||||
expect(session["spree_user_return_to"]).to eq "/return_path"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "renders Darkswarm" do
|
||||
|
||||
Reference in New Issue
Block a user