diff --git a/app/views/users/mailer/invitation_instructions.html.erb b/app/views/users/mailer/invitation_instructions.html.erb index 7d959b4882..87c7f64cc8 100644 --- a/app/views/users/mailer/invitation_instructions.html.erb +++ b/app/views/users/mailer/invitation_instructions.html.erb @@ -374,7 +374,6 @@ <% if @resource.invitation_due_at %>

<%= t("devise.mailer.invitation_instructions.accept_until", due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format')) %>

<% end %> -

For security reasons these invitations expire. This invitation will expire in 8 hours or if a new password reset is triggered.

If your invitation has an expired message, go <%= link_to "here", new_user_password_url %> and enter your email address to reset your password.

Feel free to ignore this email if you are not interested or if you feel it was sent by mistake.

diff --git a/app/views/users/mailer/reset_password_instructions.html.erb b/app/views/users/mailer/reset_password_instructions.html.erb index 6656a60751..1352deb8fa 100644 --- a/app/views/users/mailer/reset_password_instructions.html.erb +++ b/app/views/users/mailer/reset_password_instructions.html.erb @@ -6,7 +6,7 @@

<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

-

For security reasons these invitations expire. This invitation will expire in 8 hours or if a new password reset is triggered.

+

For security reasons these invitations expire. This invitation will expire in 6 hours or if a new password reset is triggered.

If your invitation has an expired message, go <%= link_to "here", new_user_password_url %> and enter your email address to reset your password.

If you didn't request this, please ignore this email.

Your password won't change until you access the link above and create a new one.

diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 3951cd3f08..f18cde16ff 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -120,7 +120,7 @@ # The period the generated invitation token is valid, after # this period, the invited resource won't be able to accept the invitation. # When invite_for is 0 (the default), the invitation won't expire. - # config.invite_for = 2.weeks + config.invite_for = 2.weeks # Number of invitations users can send. # - If invitation_limit is nil, there is no limit for invitations, users can diff --git a/config/locales/devise_invitable.en.yml b/config/locales/devise_invitable.en.yml index 7d5fc7c09c..ba47068d82 100644 --- a/config/locales/devise_invitable.en.yml +++ b/config/locales/devise_invitable.en.yml @@ -21,7 +21,7 @@ en: hello: "Hello %{email}" someone_invited_you: "Someone has invited you to %{url}, you can accept it through the link below." accept: "Accept invitation" - accept_until: "This invitation will be due in %{due_date}." + accept_until: "This invitation will expire at %{due_date} GMT or if a new password reset is triggered." ignore: "If you don't want to accept the invitation, please ignore this email.
\nYour account won't be created until you access the link above and set your password." time: formats: diff --git a/spec/mailers/custom_devise_mailer_spec.rb b/spec/mailers/custom_devise_mailer_spec.rb index 842c9d7541..4943481cd8 100644 --- a/spec/mailers/custom_devise_mailer_spec.rb +++ b/spec/mailers/custom_devise_mailer_spec.rb @@ -34,15 +34,21 @@ end context "when user is invited" do - let(:user) { create(:user) } + let(:invitation_sent_at) { Time.zone.now } + let(:user) { create(:user, invitation_sent_at: invitation_sent_at) } it "invites to user" do expect(mail.subject).to eq("Your Human Essentials App Account Approval") expect(mail.html_part.body).to include("Your request has been approved and you're invited to become an user of the Human Essentials inventory management system!") end - it "has invite expiration message" do - expect(mail.html_part.body).to include("For security reasons these invitations expire. This invitation will expire in 8 hours or if a new password reset is triggered.") + it "has invite expiration message and reset instructions" do + expect(mail.html_part.body).to include("This invitation will expire at #{user.invitation_due_at.strftime("%B %d, %Y %I:%M %p")} GMT or if a new password reset is triggered.") + end + + it "has reset instructions" do + expect(mail.html_part.body).to match(%r{

If your invitation has an expired message, go here and enter your email address to reset your password.

}) + expect(mail.html_part.body).to include("Feel free to ignore this email if you are not interested or if you feel it was sent by mistake.") end end end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 236ecd1147..a01a01971e 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -22,7 +22,7 @@ let(:mail) { ActionMailer::Base.deliveries.last } it "sends an email with instructions" do - expect(mail.body.encoded).to include("For security reasons these invitations expire. This invitation will expire in 8 hours or if a new password reset is triggered.") + expect(mail.body.encoded).to include("For security reasons these invitations expire. This invitation will expire in 6 hours or if a new password reset is triggered.") end end end