Add email specs for Budget::Investment
This commit is contained in:
@@ -84,6 +84,37 @@ feature 'Emails' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'Budget investments comments' do
|
||||
scenario 'Send email on budget investment comment', :js do
|
||||
user = create(:user, email_on_comment: true)
|
||||
investment = create(:budget_investment, author: user, budget: create(:budget))
|
||||
comment_on(investment)
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Someone has commented on your investment')
|
||||
expect(email).to deliver_to(investment.author)
|
||||
expect(email).to have_body_text(budget_investment_path(investment, budget_id: investment.budget_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 budget investments comments', :js do
|
||||
user = create(:user, email_on_comment: true)
|
||||
investment = create(:budget_investment, author: user, budget: create(:budget))
|
||||
comment_on(investment, user)
|
||||
|
||||
expect { open_last_email }.to raise_error 'No email has been sent!'
|
||||
end
|
||||
|
||||
scenario 'Do not send email about budget investment comment unless set in preferences', :js do
|
||||
user = create(:user, email_on_comment: false)
|
||||
investment = create(:budget_investment, author: user, budget: create(:budget))
|
||||
comment_on(investment)
|
||||
|
||||
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)
|
||||
|
||||
@@ -77,10 +77,16 @@ module CommonActions
|
||||
user ||= create(:user)
|
||||
|
||||
login_as(user)
|
||||
commentable_path = commentable.is_a?(Proposal) ? proposal_path(commentable) : debate_path(commentable)
|
||||
commentable_path = if commentable.is_a?(Proposal)
|
||||
proposal_path(commentable)
|
||||
elsif commentable.is_a?(Debate)
|
||||
debate_path(commentable)
|
||||
else
|
||||
budget_investment_path(commentable, budget_id: commentable.budget_id)
|
||||
end
|
||||
visit commentable_path
|
||||
|
||||
fill_in "comment-body-#{commentable.class.name.underscore}_#{commentable.id}", with: 'Have you thought about...?'
|
||||
fill_in "comment-body-#{commentable.class.name.gsub(/::/, '_').downcase}_#{commentable.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish comment'
|
||||
|
||||
expect(page).to have_content 'Have you thought about...?'
|
||||
|
||||
Reference in New Issue
Block a user