mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 18:03:38 +08:00
FIX: show invite validation error message in response
This commit is contained in:
parent
009f0921dc
commit
34996b4eff
|
@ -76,7 +76,7 @@ class InvitesController < ApplicationController
|
|||
else
|
||||
render json: failed_json, status: 422
|
||||
end
|
||||
rescue Invite::UserExists => e
|
||||
rescue Invite::UserExists, ActiveRecord::RecordInvalid => e
|
||||
render json: {errors: [e.message]}, status: 422
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,6 +74,8 @@ describe InvitesController do
|
|||
invite.reload
|
||||
post :create, email: invite.email
|
||||
expect(response).not_to be_success
|
||||
json = JSON.parse(response.body)
|
||||
expect(json["failed"]).to be_present
|
||||
end
|
||||
|
||||
it "allows admins to invite to groups" do
|
||||
|
@ -91,6 +93,14 @@ describe InvitesController do
|
|||
post :create, email: invite.email
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it "responds with error message in case of validation failure" do
|
||||
log_in(:admin)
|
||||
post :create, email: "test@mailinator.com"
|
||||
expect(response).not_to be_success
|
||||
json = JSON.parse(response.body)
|
||||
expect(json["errors"]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user