From 95f9b72351888ce47f32fa02f31ec9588a9ee8fc Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 31 May 2018 12:15:28 +0800 Subject: [PATCH] FIX: Update activation email route was returning a generic json error. --- app/controllers/users_controller.rb | 2 +- spec/requests/users_controller_spec.rb | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3032c9b539e..548ce754c65 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -749,7 +749,7 @@ class UsersController < ApplicationController enqueue_activation_email render json: success_json else - render_json_error(@user) + render_json_error(primary_email) end end end diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index d47c726564b..6712de39ac5 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -2200,7 +2200,7 @@ describe UsersController do email: 'updatedemail@example.com' } - expect(response).to be_success + expect(response.status).to eq(200) user.reload expect(user.email).to eq('updatedemail@example.com') @@ -2219,7 +2219,7 @@ describe UsersController do email: 'updatedemail@example.com' } - expect(response).to_not be_success + expect(response.status).to eq(403) end it "raises an error with an invalid password" do @@ -2229,7 +2229,7 @@ describe UsersController do email: 'updatedemail@example.com' } - expect(response).to_not be_success + expect(response.status).to eq(403) end it "raises an error for an active user" do @@ -2239,7 +2239,7 @@ describe UsersController do email: 'updatedemail@example.com' } - expect(response).to_not be_success + expect(response.status).to eq(403) end it "raises an error when logged in" do @@ -2251,7 +2251,7 @@ describe UsersController do email: 'updatedemail@example.com' } - expect(response).to_not be_success + expect(response.status).to eq(403) end it "raises an error when the new email is taken" do @@ -2263,7 +2263,7 @@ describe UsersController do email: user.email } - expect(response).to_not be_success + expect(response.status).to eq(422) end it "can be updated" do @@ -2276,7 +2276,7 @@ describe UsersController do email: 'updatedemail@example.com' } - expect(response).to be_success + expect(response.status).to eq(200) user.reload expect(user.email).to eq('updatedemail@example.com')