public this repo is viewable by everyone
Description: a ruby on rails plugin to create and display a social feed
Homepage: http://upstream-berlin.com/blog/open-source/#social_feed
Clone URL: git://github.com/langalex/social_feed.git
previously the email sending required the user to have a online? method 
(no emails if user is online), this is now optional
Alexander Lang (author)
17 days ago
commit  332d458a4b144fd0c2f2219272517992c5998a3a
tree    5960f818fde3393b9e02899871ac9a955b40f339
parent  42613fb213fe912bbc1733d4b616fa9e2a0db8b9
...
1
 
2
3
4
...
 
1
2
3
4
0
@@ -1,4 +1,4 @@
0
-require 'if_not_nil'
0
+require 'object_extensions'
0
 
0
 # configuration
0
 require 'ostruct'
...
56
57
58
59
 
60
61
62
...
56
57
58
 
59
60
61
62
0
@@ -56,7 +56,7 @@ class FeedEvent < ActiveRecord::Base
0
   private
0
   def send_email
0
     FeedEventMailer.send "deliver_#{self.class.name.underscore[0..-7]}", self if self.class.can_send_email? &&
0
- (user.subscribed_to_email?(self.class) || self.class.user_cannot_subscribe_to_event?) && !user.online?
0
+ (user.subscribed_to_email?(self.class) || self.class.user_cannot_subscribe_to_event?) && !user.try(:online?)
0
   end
0
   
0
   def self.load_subclasses
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,21 +0,0 @@
0
-class Object
0
- def if_nil?
0
- self
0
- end
0
-
0
- def if_not_nil?
0
- yield self
0
- end
0
-end
0
-
0
-class NilClass
0
- def if_nil?
0
- yield self
0
- self
0
- end
0
-
0
- def if_not_nil?
0
- self
0
- end
0
-end
0
-
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
0
@@ -0,0 +1,27 @@
0
+class Object
0
+ def try(method, *params)
0
+ send method, *params if respond_to? method
0
+ end
0
+end
0
+
0
+class Object
0
+ def if_nil?
0
+ self
0
+ end
0
+
0
+ def if_not_nil?
0
+ yield self
0
+ end
0
+end
0
+
0
+class NilClass
0
+ def if_nil?
0
+ yield self
0
+ self
0
+ end
0
+
0
+ def if_not_nil?
0
+ self
0
+ end
0
+end
0
+
...
136
137
138
 
 
 
 
 
139
140
141
...
136
137
138
139
140
141
142
143
144
145
146
0
@@ -136,6 +136,11 @@ describe FeedEvent, 'check subscription before sending emails' do
0
     TestFeedEvent.create :user => @user
0
   end
0
   
0
+ it "should send an email user user subscribed to email and has no online method" do
0
+ FeedEventMailer.should_receive(:send).with('deliver_test_feed', anything)
0
+ TestFeedEvent.create :user => mock_model(User, :subscribed_to_email? => true, :subscribed_to_feed_event? => false)
0
+ end
0
+
0
   it "should check the subscription of the user" do
0
     @user.should_receive(:subscribed_to_email?).with(TestFeedEvent).and_return(false)
0
     TestFeedEvent.create :user => @user
...
29
30
31
32
 
33
34
35
...
29
30
31
 
32
33
34
35
0
@@ -29,7 +29,7 @@ class FeedEventMailer; end
0
 require File.dirname(__FILE__) + '/../generators/social_feed_migration/templates/migration'
0
 AddSocialFeed.up
0
 
0
-require PLUGIN_ROOT + '/lib/if_not_nil'
0
+require PLUGIN_ROOT + '/lib/object_extensions'
0
 
0
 
0
 # rspec rails stuff

Comments

    No one has commented yet.