public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Search Repo:
Added per-person email notifications, with test for 
connection_notifications
Michael Hartl (author)
Mon May 12 12:02:06 -0700 2008
commit  048c1c82ce760761b301cd01a709602dca96a9c8
tree    7a964ef44c67b6d4135512309871929d36fb9f6c
parent  1efbdbdc65dae14a8038d01813136225903cf0ae
...
49
50
51
52
 
 
53
54
55
...
49
50
51
 
52
53
54
55
56
0
@@ -49,7 +49,8 @@
0
     # Make a pending connection request.
0
     def request(person, contact, mail = nil)
0
       if mail.nil?
0
- mail = global_prefs.email_notifications?
0
+ mail = global_prefs.email_notifications? &&
0
+ contact.connection_notifications?
0
       end
0
       if person == contact or Connection.exists?(person, contact)
0
         nil
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
@@ -1 +1,16 @@
0
+class AddEmailNotificationPreferences < ActiveRecord::Migration
0
+ def self.up
0
+ add_column :people, :connection_notifications, :boolean, :default => true
0
+ add_column :people, :message_notifications, :boolean, :default => true
0
+ add_column :people, :wall_comment_notifications, :boolean, :default => true
0
+ add_column :people, :blog_comment_notifications, :boolean, :default => true
0
+ end
0
+
0
+ def self.down
0
+ remove_column :people, :blog_comment_notifications
0
+ remove_column :people, :wall_comment_notifications
0
+ remove_column :people, :message_notifications
0
+ remove_column :people, :connection_notifications
0
+ end
0
+end
...
9
10
11
 
 
 
 
12
13
14
...
17
18
19
 
 
 
 
20
21
22
...
25
26
27
 
 
 
 
28
29
30
...
34
35
36
 
 
 
 
...
9
10
11
12
13
14
15
16
17
18
...
21
22
23
24
25
26
27
28
29
30
...
33
34
35
36
37
38
39
40
41
42
...
46
47
48
49
50
51
52
0
@@ -9,6 +9,10 @@
0
   created_at: <%= 5.days.ago.to_s :db %>
0
   last_logged_in_at: <%= 1.day.ago.to_s :db %>
0
   deactivated: false
0
+ connection_notifications: true
0
+ message_notifications: true
0
+ wall_comment_notifications: true
0
+ blog_comment_notifications: true
0
 
0
 aaron:
0
   email: aaron@example.com
0
@@ -17,6 +21,10 @@
0
   crypted_password: <%= password %>
0
   created_at: <%= 1.day.ago.to_s :db %>
0
   deactivated: false
0
+ connection_notifications: true
0
+ message_notifications: true
0
+ wall_comment_notifications: true
0
+ blog_comment_notifications: true
0
 
0
 kelly:
0
   email: kelly@example.com
0
@@ -25,6 +33,10 @@
0
   crypted_password: <%= password %>
0
   created_at: <%= 1.day.ago.to_s :db %>
0
   deactivated: false
0
+ connection_notifications: true
0
+ message_notifications: true
0
+ wall_comment_notifications: true
0
+ blog_comment_notifications: true
0
   
0
 admin:
0
   email: admin@example.com
0
@@ -34,4 +46,8 @@
0
   crypted_password: <%= password %>
0
   created_at: <%= 5.days.ago.to_s :db %>
0
   deactivated: false
0
+ connection_notifications: true
0
+ message_notifications: true
0
+ wall_comment_notifications: true
0
+ blog_comment_notifications: true
...
19
20
21
22
 
23
24
25
26
27
28
29
 
 
 
 
 
 
 
 
 
30
31
32
...
19
20
21
 
22
23
24
25
26
27
28
 
29
30
31
32
33
34
35
36
37
38
39
40
0
@@ -19,14 +19,22 @@
0
       status(@contact, @person).should == Connection::REQUESTED
0
     end
0
   
0
- it "should send a request notification when notifications are on" do
0
+ it "should send an email when global and notifications are on" do
0
       @global_prefs.update_attributes(:email_notifications => true)
0
       lambda do
0
         Connection.request(@person, @contact)
0
       end.should change(@emails, :length).by(1)
0
     end
0
     
0
- it "should not send a request notification when notifications are off" do
0
+ it "should not send an email when contact's notifications are off" do
0
+ @global_prefs.update_attributes(:email_notifications => true)
0
+ @contact.toggle!(:connection_notifications)
0
+ lambda do
0
+ Connection.request(@person, @contact)
0
+ end.should_not change(@emails, :length).by(1)
0
+ end
0
+
0
+ it "should not send an email when global notifications are off" do
0
       @global_prefs.update_attributes(:email_notifications => false)
0
       lambda do
0
         Connection.request(@person, @contact)

Comments

    No one has commented yet.