Skip to content
Extraits de code Groupes Projets
Valider 60c0a983 rédigé par Ilya Zhitomirskiy's avatar Ilya Zhitomirskiy
Parcourir les fichiers

added a podwide email preference

parent 0bb349ff
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -7,8 +7,10 @@ class Notifier < ActionMailer::Base
def self.admin(string, recipients, opts = {})
mails = []
recipients.each do |rec|
mail = single_admin(string, rec)
mails << mail
if !rec.user_preferences.exists?(:email_type => "podwide")
mail = single_admin(string, rec)
mails << mail
end
end
mails
end
......
......@@ -9,7 +9,8 @@ class UserPreference < ActiveRecord::Base
"private_message",
"started_sharing",
"also_commented",
"liked"]
"liked",
"podwide"]
def must_be_valid_email_type
unless VALID_EMAIL_TYPES.include?(self.email_type)
......
......@@ -105,6 +105,10 @@
= type.label t('.liked')
= type.check_box :liked, {:checked => @email_prefs['liked']}, false, true
%br
%p.checkbox_select
= type.label t('.podwide')
= type.check_box :podwide, {:checked => @email_prefs['podwide']}, false, true
%br
= f.submit t('.change')
......
......@@ -627,6 +627,7 @@ en:
started_sharing: "...someone starts sharing with you?"
private_message: "...you receive a private message?"
liked: "...someone likes your post?"
podwide: "...pod-wide news happen [new features, etc.]?"
change: "Change"
destroy: "Account successfully closed."
getting_started:
......
......@@ -12,6 +12,7 @@ describe Notifier do
before do
Notifier.deliveries = []
end
describe '.administrative' do
it 'mails a user' do
mails = Notifier.admin("Welcome to bureaucracy!", [user])
......@@ -21,6 +22,7 @@ describe Notifier do
mail.body.encoded.should match /Welcome to bureaucracy!/
mail.body.encoded.should match /#{user.username}/
end
it 'mails a bunch of users' do
users = []
5.times do
......@@ -34,6 +36,18 @@ describe Notifier do
mail.body.encoded.should match /#{this_user.username}/
}
end
it 'does not email the users who opted out of podwide emails' do
users = []
5.times do
users << Factory.create(:user)
end
2.times do |n|
users[n].user_preferences.create(:email_type => 'podwide')
end
mails = Notifier.admin("Welcome to bureaucracy!", users)
mails.length.should == 3
end
end
describe '.single_admin' do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter