Skip to content

Commit

Permalink
FIX: cannot show email for pending/inactive users
Browse files Browse the repository at this point in the history
  • Loading branch information
ZogStriP committed Oct 29, 2014
1 parent 3dcccb5 commit 865194f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Expand Up @@ -94,7 +94,7 @@ def username
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])
Expand Down
12 changes: 11 additions & 1 deletion spec/controllers/users_controller_spec.rb
Expand Up @@ -521,7 +521,7 @@ def post_user
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
Expand Down Expand Up @@ -1411,6 +1411,16 @@ def post_user
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
Expand Down

0 comments on commit 865194f

Please sign in to comment.