Add email specs for Topic

This commit is contained in:
Angel Perez
2017-11-13 08:46:56 -04:00
parent 3605a43947
commit 4c110e8100
5 changed files with 46 additions and 2 deletions

View File

@@ -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

View File

@@ -88,6 +88,9 @@ en:
images:
one: "Image"
other: "Images"
topic:
one: "Topic"
other: "Topics"
attributes:
budget:
name: "Name"

View File

@@ -88,6 +88,9 @@ es:
images:
one: "Imagen"
other: "Imágenes"
topic:
one: "Tema"
other: "Temas"
attributes:
budget:
name: "Nombre"

View File

@@ -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)

View File

@@ -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