Add email specs for Topic
This commit is contained in:
@@ -3,6 +3,7 @@ module MailerHelper
|
||||
def commentable_url(commentable)
|
||||
return debate_url(commentable) if commentable.is_a?(Debate)
|
||||
return proposal_url(commentable) if commentable.is_a?(Proposal)
|
||||
return community_topic_url(commentable.community_id, commentable) if commentable.is_a?(Topic)
|
||||
return budget_investment_url(commentable.budget_id, commentable) if commentable.is_a?(Budget::Investment)
|
||||
end
|
||||
|
||||
|
||||
@@ -88,6 +88,9 @@ en:
|
||||
images:
|
||||
one: "Image"
|
||||
other: "Images"
|
||||
topic:
|
||||
one: "Topic"
|
||||
other: "Topics"
|
||||
attributes:
|
||||
budget:
|
||||
name: "Name"
|
||||
|
||||
@@ -88,6 +88,9 @@ es:
|
||||
images:
|
||||
one: "Imagen"
|
||||
other: "Imágenes"
|
||||
topic:
|
||||
one: "Tema"
|
||||
other: "Temas"
|
||||
attributes:
|
||||
budget:
|
||||
name: "Nombre"
|
||||
|
||||
@@ -115,6 +115,41 @@ feature 'Emails' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'Topic comments' do
|
||||
before(:each) do
|
||||
@proposal = create(:proposal)
|
||||
end
|
||||
|
||||
scenario 'Send email on topic comment', :js do
|
||||
user = create(:user, email_on_comment: true)
|
||||
topic = create(:topic, author: user, community: @proposal.community)
|
||||
comment_on(topic)
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Someone has commented on your topic')
|
||||
expect(email).to deliver_to(topic.author)
|
||||
expect(email).to have_body_text(community_topic_path(topic, community_id: topic.community_id))
|
||||
expect(email).to have_body_text(I18n.t('mailers.config.manage_email_subscriptions'))
|
||||
expect(email).to have_body_text(account_path)
|
||||
end
|
||||
|
||||
scenario 'Do not send email about own topic comments', :js do
|
||||
user = create(:user, email_on_comment: true)
|
||||
topic = create(:topic, author: user, community: @proposal.community)
|
||||
comment_on(topic, user)
|
||||
|
||||
expect { open_last_email }.to raise_error 'No email has been sent!'
|
||||
end
|
||||
|
||||
scenario 'Do not send email about topic comment unless set in preferences', :js do
|
||||
user = create(:user, email_on_comment: false)
|
||||
topic = create(:topic, author: user, community: @proposal.community)
|
||||
comment_on(topic)
|
||||
|
||||
expect { open_last_email }.to raise_error 'No email has been sent!'
|
||||
end
|
||||
end
|
||||
|
||||
context 'Comment replies' do
|
||||
scenario "Send email on comment reply", :js do
|
||||
user = create(:user, email_on_comment_reply: true)
|
||||
|
||||
@@ -81,6 +81,8 @@ module CommonActions
|
||||
proposal_path(commentable)
|
||||
elsif commentable.is_a?(Debate)
|
||||
debate_path(commentable)
|
||||
elsif commentable.is_a?(Topic)
|
||||
community_topic_path(commentable, community_id: commentable.community_id)
|
||||
else
|
||||
budget_investment_path(commentable, budget_id: commentable.budget_id)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user