Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't email user when they aren't requesting it

  • Loading branch information...
commit ba50d7601505ef2e35627bdb11e3a4ef6fb743e6 1 parent 791e3eb
@ryanb authored
View
1  .gitignore
@@ -8,5 +8,6 @@ coverage/*
config/database.yml
config/app_config.yml
config/*.sphinx.conf
+config/initializers/development_mail.rb
db/sphinx
public/assets
View
2  app/models/comment.rb
@@ -23,6 +23,6 @@ def notify_other_commenters
end
def users_to_notify
- ancestors.map(&:user).compact.select { |u| u.email.present? && u != user }
+ ancestors.map(&:user).compact.select { |u| u.email.present? && u.email_on_reply? && u != user }
end
end
View
2  app/views/users/edit.html.erb
@@ -16,8 +16,8 @@
<%= f.text_field :site_url %>
</p>
<p>
- <%= f.label :email_on_reply, "Receive email when a user replies to your comment?" %>
<%= f.check_box :email_on_reply %>
+ <%= f.label :email_on_reply, "Receive email when a user replies to your comment", :class => "check_box" %>
</p>
<p><%= f.submit "Update Profile" %></p>
<% end %>
View
9 spec/models/comment_spec.rb
@@ -34,10 +34,11 @@
last_email.to.should include(c1.user.email)
end
- it "should not notify users which don't have an email or comments which don't have user" do
+ it "should not notify user when user does not want email" do
c1 = Factory(:comment, :user => nil)
- c2 = Factory(:comment, :parent => c1, :user => Factory(:user, :email => ""))
- c3 = Factory(:comment, :parent => c2)
- c3.users_to_notify.should eq([])
+ c2 = Factory(:comment, :parent => c2, :user => Factory(:user, :email_on_reply => false))
+ c3 = Factory(:comment, :parent => c2, :user => Factory(:user, :email => ""))
+ c4 = Factory(:comment, :parent => c3)
+ c4.users_to_notify.should eq([])
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.