FIX: cannot show email for pending/inactive users

This commit is contained in:
Régis Hanol 2014-10-29 01:06:59 +01:00
parent 3dcccb5dee
commit 865194f409
2 changed files with 12 additions and 2 deletions

View file

@ -94,7 +94,7 @@ class UsersController < ApplicationController
end
def check_emails
user = fetch_user_from_params
user = fetch_user_from_params(include_inactive: true)
guardian.ensure_can_check_emails!(user)
StaffActionLogger.new(current_user).log_check_email(user, context: params[:context])

View file

@ -1411,6 +1411,16 @@ describe UsersController do
json["associated_accounts"].should be_present
end
it "works on inactive users" do
inactive_user = Fabricate(:user, active: false)
Guardian.any_instance.expects(:can_check_emails?).returns(true)
xhr :put, :check_emails, username: inactive_user.username
response.should be_success
json = JSON.parse(response.body)
json["email"].should be_present
json["associated_accounts"].should be_present
end
end
end