Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emails displayed in same thread. #8521

Merged
merged 4 commits into from
Oct 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/mailers/comment_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def notify(user, comment)
@user = user
@comment = comment
@footer = feature('email-footer')
mail(to: user.email, subject: "New comment on #{comment.parent.title}" \
" (##{comment.parent.id}) - #c#{comment.id} ")
mail(to: user.email, subject: "New comment on #{comment.node.title}" \
" (##{comment.node.id}) - #c#{comment.id} ")
end

def notify_note_author(user, comment)
Expand Down
13 changes: 9 additions & 4 deletions app/mailers/subscription_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ def notify_node_creation(node)
end

def notify_note_liked(node, user)
subject = "[PublicLab] #{user.username} liked your " +
(node.has_power_tag('question') ? 'question' : 'research note') +
" (##{node.id})"
subject = '[PublicLab] ' +
(node.has_power_tag('question') ? 'Question: ' : '') +
node.title +
" (##{node.id}) "
@user = user
@node = node
@tags = node.tags.collect(&:name).join(',')
Expand All @@ -37,6 +38,10 @@ def notify_note_liked(node, user)
end

def notify_tag_added(node, tag, tagging_user)
subject = '[PublicLab] ' +
(node.has_power_tag('question') ? 'Question: ' : '') +
node.title +
" (##{node.id}) "
@tag = tag
@node = node
@tags = node.tags.collect(&:name).join(',')
Expand All @@ -62,7 +67,7 @@ def notify_tag_added(node, tag, tagging_user)
mail(
to: "notifications@#{ActionMailer::Base.default_url_options[:host]}",
bcc: recipients,
subject: "#{node.title} (##{node.id})"
subject: subject
)
end

Expand Down
4 changes: 2 additions & 2 deletions test/functional/like_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def teardown; end
assert_equal cached_likes + 1, note.cached_likes
assert ActionMailer::Base.deliveries.size, 1
assert ActionMailer::Base.deliveries.collect(&:to).include?([note.author.email])
assert ActionMailer::Base.deliveries.collect(&:subject).include?("[PublicLab] #{current_user.username} liked your " + (note.has_power_tag('question') ? 'question' : 'research note') + " (##{note.id})")
assert ActionMailer::Base.deliveries.collect(&:subject).include?("[PublicLab] " + (note.has_power_tag('question') ? 'Question: ' : '') + "#{note.title} (##{note.id}) ")
end

test 'delete like' do
Expand Down Expand Up @@ -73,7 +73,7 @@ def teardown; end
note = Node.find note.id
cached_likes = note.cached_likes

current_user = User.find 2
current_user = User.find 2
current_user.ban #banned user

note = Node.find note.id
Expand Down
6 changes: 3 additions & 3 deletions test/unit/subscription_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SubscriptionMailerTest < ActionMailer::TestCase
email = ActionMailer::Base.deliveries.last
assert_equal ["notifications@#{request_host}"], email.from
assert_equal [node.author.email], email.to
assert_equal "[PublicLab] #{user.username} liked your research note (##{node.id})", email.subject
assert_equal '[PublicLab] ' + (node.has_power_tag('question') ? 'Question: ' : '') + "#{node.title} (##{node.id}) ", email.subject
assert email.body.include?("Public Lab contributor #{user.username} (https://#{request_host}/profile/#{user.username}) just liked your research note")
end

Expand All @@ -64,7 +64,7 @@ class SubscriptionMailerTest < ActionMailer::TestCase
email = ActionMailer::Base.deliveries.last
assert_equal ["notifications@#{request_host}"], email.from
assert_equal [node.author.email], email.to
assert_equal "[PublicLab] #{user.username} liked your question (##{node.id})", email.subject
assert_equal '[PublicLab] ' + (node.has_power_tag('question') ? 'Question: ' : '') + "#{node.title} (##{node.id}) ", email.subject
assert email.body.include?("Public Lab contributor #{user.username} (https://#{request_host}/profile/#{user.username}) just liked your question")
end

Expand All @@ -86,7 +86,7 @@ class SubscriptionMailerTest < ActionMailer::TestCase
assert_equal ["notifications@#{request_host}"], email.from
assert_equal ["notifications@#{request_host}"], email.to
assert email.bcc.include?(users_to_email.last.email)
assert_equal "#{node.title} (##{node.id})", email.subject
assert_equal '[PublicLab] ' + (node.has_power_tag('question') ? 'Question: ' : '') + "#{node.title} (##{node.id}) ", email.subject
assert email.body.include?("was tagged with")
end
end