Add email specs for Topic
This commit is contained in:
@@ -3,7 +3,8 @@ module MailerHelper
|
|||||||
def commentable_url(commentable)
|
def commentable_url(commentable)
|
||||||
return debate_url(commentable) if commentable.is_a?(Debate)
|
return debate_url(commentable) if commentable.is_a?(Debate)
|
||||||
return proposal_url(commentable) if commentable.is_a?(Proposal)
|
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)
|
return budget_investment_url(commentable.budget_id, commentable) if commentable.is_a?(Budget::Investment)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ en:
|
|||||||
images:
|
images:
|
||||||
one: "Image"
|
one: "Image"
|
||||||
other: "Images"
|
other: "Images"
|
||||||
|
topic:
|
||||||
|
one: "Topic"
|
||||||
|
other: "Topics"
|
||||||
attributes:
|
attributes:
|
||||||
budget:
|
budget:
|
||||||
name: "Name"
|
name: "Name"
|
||||||
@@ -281,4 +284,4 @@ en:
|
|||||||
attributes:
|
attributes:
|
||||||
image:
|
image:
|
||||||
image_width: "Width must be %{required_width}px"
|
image_width: "Width must be %{required_width}px"
|
||||||
image_height: "Height must be %{required_height}px"
|
image_height: "Height must be %{required_height}px"
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ es:
|
|||||||
images:
|
images:
|
||||||
one: "Imagen"
|
one: "Imagen"
|
||||||
other: "Imágenes"
|
other: "Imágenes"
|
||||||
|
topic:
|
||||||
|
one: "Tema"
|
||||||
|
other: "Temas"
|
||||||
attributes:
|
attributes:
|
||||||
budget:
|
budget:
|
||||||
name: "Nombre"
|
name: "Nombre"
|
||||||
|
|||||||
@@ -115,6 +115,41 @@ feature 'Emails' do
|
|||||||
end
|
end
|
||||||
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
|
context 'Comment replies' do
|
||||||
scenario "Send email on comment reply", :js do
|
scenario "Send email on comment reply", :js do
|
||||||
user = create(:user, email_on_comment_reply: true)
|
user = create(:user, email_on_comment_reply: true)
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ module CommonActions
|
|||||||
proposal_path(commentable)
|
proposal_path(commentable)
|
||||||
elsif commentable.is_a?(Debate)
|
elsif commentable.is_a?(Debate)
|
||||||
debate_path(commentable)
|
debate_path(commentable)
|
||||||
|
elsif commentable.is_a?(Topic)
|
||||||
|
community_topic_path(commentable, community_id: commentable.community_id)
|
||||||
else
|
else
|
||||||
budget_investment_path(commentable, budget_id: commentable.budget_id)
|
budget_investment_path(commentable, budget_id: commentable.budget_id)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user