Permalink
Browse files

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

  • Loading branch information...
1 parent 791e3eb commit ba50d7601505ef2e35627bdb11e3a4ef6fb743e6 @ryanb committed Jul 25, 2011
Showing with 8 additions and 6 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 app/models/comment.rb
  3. +1 −1 app/views/users/edit.html.erb
  4. +5 −4 spec/models/comment_spec.rb
View
@@ -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
@@ -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
@@ -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 %>
@@ -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

0 comments on commit ba50d76

Please sign in to comment.