FIX: better error message when invited user already exists
This commit is contained in:
parent
e8fc8f0bb6
commit
295cf8839e
|
@ -2,7 +2,7 @@
|
|||
{{#if model.error}}
|
||||
<div class="alert alert-error">
|
||||
<button class="close" data-dismiss="alert">×</button>
|
||||
{{errorMessage}}
|
||||
{{{errorMessage}}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if model.finished}}
|
||||
|
|
|
@ -103,7 +103,7 @@ class Invite < ActiveRecord::Base
|
|||
|
||||
if user
|
||||
extend_permissions(topic, user, invited_by) if topic
|
||||
return nil
|
||||
raise StandardError.new I18n.t("invite.user_exists", email: lower_email, username: user.username)
|
||||
end
|
||||
|
||||
invite = Invite.with_deleted
|
||||
|
|
|
@ -138,6 +138,7 @@ en:
|
|||
|
||||
invite:
|
||||
not_found: "Your invite token is invalid. Please contact the site's administrator."
|
||||
user_exists: "There's no need to invite <b>%{email}</b>, they <a href='/users/%{username}/summary'>already have an account!</a>"
|
||||
|
||||
bulk_invite:
|
||||
file_should_be_csv: "The uploaded file should be of csv format."
|
||||
|
|
|
@ -152,11 +152,10 @@ describe Invite do
|
|||
context 'an existing user' do
|
||||
let(:topic) { Fabricate(:topic, category_id: nil, archetype: 'private_message') }
|
||||
let(:coding_horror) { Fabricate(:coding_horror) }
|
||||
let!(:invite) { topic.invite_by_email(topic.user, coding_horror.email) }
|
||||
|
||||
it "works" do
|
||||
# doesn't create an invite
|
||||
expect(invite).to be_blank
|
||||
expect { topic.invite_by_email(topic.user, coding_horror.email) }.to raise_error(StandardError)
|
||||
|
||||
# gives the user permission to access the topic
|
||||
expect(topic.allowed_users.include?(coding_horror)).to eq(true)
|
||||
|
|
|
@ -1773,8 +1773,7 @@ describe Topic do
|
|||
|
||||
it "should add user to the group" do
|
||||
expect(Guardian.new(walter).can_see?(group_private_topic)).to be_falsey
|
||||
invite = group_private_topic.invite(group_manager, walter.email)
|
||||
expect(invite).to be_nil
|
||||
expect { group_private_topic.invite(group_manager, walter.email) }.to raise_error(StandardError)
|
||||
expect(walter.groups).to include(group)
|
||||
expect(Guardian.new(walter).can_see?(group_private_topic)).to be_truthy
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue