A platform for community discussion. Free, open, simple.
FIX: include error message if the "accept invite" process fails
Arpit Jalan381793243e0a
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rbindex a178e401dac..884f67ec8f7 100644--- a/app/controllers/invites_controller.rb+++ b/app/controllers/invites_controller.rb@@ -63,7 +63,8 @@ class InvitesController < ApplicationControllerrescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved => erender json: {success: false,- errors: e.record&.errors&.to_hash || {}+ errors: e.record&.errors&.to_hash || {},+ message: I18n.t('invite.error_message')}endelsediff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 286a8f25531..c525fe1f901 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -208,6 +208,7 @@ en:<p>If you remember your password you can <a href="%{base_url}/login">Login</a>.</p><p>Otherwise please <a href="%{base_url}/password-reset">Reset Password</a>.</p>+ error_message: "There was an error accepting invite. Please contact the site's administrator."user_exists: "There's no need to invite <b>%{email}</b>, they <a href='%{base_path}/u/%{username}/summary'>already have an account!</a>"confirm_email: "<p>You’re almost done! We sent an activation mail to your email address. Please follow the instructions in the mail to activate your account.</p><p>If it doesn’t arrive, check your spam folder.</p>"diff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rbindex 037d2aa0476..b2b7f4152ca 100644--- a/spec/requests/invites_controller_spec.rb+++ b/spec/requests/invites_controller_spec.rb@@ -213,6 +213,18 @@ describe InvitesController doendend+ context 'with an invalid invite record' do+ let(:invite) { Fabricate(:invite, email: "John Doe <[email protected]>") }+ it "responds with error message" do+ put "/invites/show/#{invite.invite_key}.json"+ expect(response.status).to eq(200)+ json = JSON.parse(response.body)+ expect(json["success"]).to eq(false)+ expect(json["message"]).to eq(I18n.t('invite.error_message'))+ expect(session[:current_user_id]).to be_blank+ end+ end+context 'with a deleted invite' dolet(:topic) { Fabricate(:topic) }