diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4f632c3b872..521f1b61709 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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]) diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 3148c36a062..2d4b23e0ab7 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -521,7 +521,7 @@ describe UsersController do xhr :post, :create, create_params json = JSON::parse(response.body) json["success"].should_not == true - + # should not change the session session["user_created_email"].should be_blank end @@ -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