Add a test
This commit is contained in:
parent
9a27983313
commit
1eea034844
5 changed files with 42 additions and 5 deletions
|
|
@ -36,6 +36,7 @@ If so, please delete it since it will prevent the federation from working proper
|
||||||
* Render mentions as links in comments [#7327](https://github.com/diaspora/diaspora/pull/7327)
|
* Render mentions as links in comments [#7327](https://github.com/diaspora/diaspora/pull/7327)
|
||||||
* Add support for mentions in comments to the front-end [#7386](https://github.com/diaspora/diaspora/pull/7386)
|
* Add support for mentions in comments to the front-end [#7386](https://github.com/diaspora/diaspora/pull/7386)
|
||||||
* Support direct links to comments on mobile [#7508](https://github.com/diaspora/diaspora/pull/7508)
|
* Support direct links to comments on mobile [#7508](https://github.com/diaspora/diaspora/pull/7508)
|
||||||
|
* Add inviter first and last name in the invitation e-mail [#7484](https://github.com/diaspora/diaspora/pull/7484)
|
||||||
|
|
||||||
# 0.6.8.0
|
# 0.6.8.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@ class Notifier < ActionMailer::Base
|
||||||
@invitation_code = invitation_code
|
@invitation_code = invitation_code
|
||||||
|
|
||||||
I18n.with_locale(locale) do
|
I18n.with_locale(locale) do
|
||||||
mail_opts = {:to => email, :from => AppConfig.mail.sender_address,
|
mail_opts = {to: email, from: "\"#{AppConfig.settings.pod_name}\" <#{AppConfig.mail.sender_address}>",
|
||||||
:subject => I18n.t('notifier.invited_you', :name => @inviter.name),
|
subject: I18n.t("notifier.invited_you", name: @inviter.name),
|
||||||
:host => AppConfig.pod_uri.host}
|
host: AppConfig.pod_uri.host}
|
||||||
|
|
||||||
mail(mail_opts) do |format|
|
mail(mail_opts) do |format|
|
||||||
format.text { render :layout => nil }
|
format.text { render :layout => nil }
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ Feature: Invitations
|
||||||
And I press "Send an invitation"
|
And I press "Send an invitation"
|
||||||
Then I should see a flash message indicating success
|
Then I should see a flash message indicating success
|
||||||
And I should have 1 Devise email delivery
|
And I should have 1 Devise email delivery
|
||||||
|
And I should see "You have been invited to join diaspora* by Alice Smith" in the last sent email
|
||||||
And I should not see "change your notification settings" in the last sent email
|
And I should not see "change your notification settings" in the last sent email
|
||||||
|
|
||||||
Scenario: sends an invitation from the people search page
|
Scenario: sends an invitation from the people search page
|
||||||
|
|
|
||||||
|
|
@ -168,10 +168,14 @@ Then /^I should have (\d+) email delivery$/ do |n|
|
||||||
ActionMailer::Base.deliveries.length.should == n.to_i
|
ActionMailer::Base.deliveries.length.should == n.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see "([^\"]*)" in the last sent email$/ do |text|
|
Then /^I should( not)? see "([^\"]*)" in the last sent email$/ do |negate, text|
|
||||||
email_text = Devise.mailer.deliveries.first.body.to_s
|
email_text = Devise.mailer.deliveries.first.body.to_s
|
||||||
email_text = Devise.mailer.deliveries.first.html_part.body.raw_source if email_text.blank?
|
email_text = Devise.mailer.deliveries.first.html_part.body.raw_source if email_text.blank?
|
||||||
email_text.should_not match(text)
|
if negate
|
||||||
|
expect(email_text).to_not have_content(text)
|
||||||
|
else
|
||||||
|
expect(email_text).to have_content(text)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^"([^\"]+)" has posted a (public )?status message with a photo$/ do |email, public_status|
|
When /^"([^\"]+)" has posted a (public )?status message with a photo$/ do |email, public_status|
|
||||||
|
|
|
||||||
|
|
@ -501,6 +501,37 @@ describe Notifier, type: :mailer do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe ".invite" do
|
||||||
|
let(:email) { Notifier.invite(alice.email, nil, bob, "1234", "en") }
|
||||||
|
|
||||||
|
it "goes to the right person" do
|
||||||
|
expect(email.to).to eq([alice.email])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "FROM: header should be the pod name + default sender address" do
|
||||||
|
expect(email["From"].to_s).to eq("#{pod_name} <#{AppConfig.mail.sender_address}>")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "has the correct subject" do
|
||||||
|
expect(email.subject).to eq(I18n.translate("notifier.invited_you", name: bob.name))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "has the inviter name in the body" do
|
||||||
|
expect(email.body.encoded).to include("#{bob.name} (#{bob.diaspora_handle})")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "has the inviter id if the name is nil" do
|
||||||
|
bob.person.profile.update_attributes(first_name: "", last_name: "")
|
||||||
|
mail = Notifier.invite(alice.email, nil, bob, "1234", "en")
|
||||||
|
expect(email.body.encoded).to_not include("#{bob.name} (#{bob.diaspora_handle})")
|
||||||
|
expect(mail.body.encoded).to include(bob.person.diaspora_handle)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "has the invitation code in the body" do
|
||||||
|
expect(email.body.encoded).to include("/i/1234")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe ".csrf_token_fail" do
|
describe ".csrf_token_fail" do
|
||||||
let(:email) { Notifier.send_notification("csrf_token_fail", alice.id) }
|
let(:email) { Notifier.send_notification("csrf_token_fail", alice.id) }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue