social_connections 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -5,5 +5,6 @@ db/social_connections_plugin.sqlite3
5
5
  test/debug.log
6
6
  tmp/
7
7
  .*.swp
8
+ .*.swo
8
9
  social_connections*.gem
9
10
  .rvmrc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- social_connections (0.0.7)
4
+ social_connections (0.0.13)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -33,6 +33,7 @@ GEM
33
33
  ansi (1.3.0)
34
34
  arel (2.0.10)
35
35
  builder (2.1.2)
36
+ coderay (1.0.6)
36
37
  diff-lcs (1.1.3)
37
38
  erubis (2.6.6)
38
39
  abstract (>= 1.0.0)
@@ -46,8 +47,13 @@ GEM
46
47
  i18n (>= 0.4.0)
47
48
  mime-types (~> 1.16)
48
49
  treetop (~> 1.4.8)
50
+ method_source (0.7.1)
49
51
  mime-types (1.16)
50
52
  polyglot (0.3.2)
53
+ pry (0.9.9.3)
54
+ coderay (~> 1.0.5)
55
+ method_source (~> 0.7.1)
56
+ slop (>= 2.4.4, < 3)
51
57
  rack (1.2.3)
52
58
  rack-mount (0.6.14)
53
59
  rack (>= 1.0.0)
@@ -72,6 +78,7 @@ GEM
72
78
  activesupport (~> 3.0)
73
79
  railties (~> 3.0)
74
80
  rspec (~> 2.6.0)
81
+ slop (2.4.4)
75
82
  sqlite3 (1.3.4)
76
83
  thor (0.14.6)
77
84
  treetop (1.4.10)
@@ -89,6 +96,7 @@ DEPENDENCIES
89
96
  activerecord
90
97
  factory_girl_rails
91
98
  i18n
99
+ pry
92
100
  rspec
93
101
  rspec-rails
94
102
  social_connections!
data/README.md CHANGED
@@ -64,7 +64,7 @@ is the subject and book `b` is the object. A user `v` can connect to user `u` by
64
64
 
65
65
  v.connect_to(u)
66
66
 
67
- . If this is issued before invoking `likes` and `comments` as above, user `v`
67
+ . If this is issued before invoking `likes` and `comments` as above, user `v`
68
68
  receives 2 activities.
69
69
 
70
70
  These activities can be queried:
@@ -103,7 +103,7 @@ The view (e.g. `app/views/books/show.html.erb`) may then contain the following '
103
103
  Views
104
104
  -----
105
105
 
106
- A list of social activities can be rendered by
106
+ A list of social activities can be rendered by
107
107
 
108
108
  <%= render @social_activities %>
109
109
 
@@ -134,12 +134,8 @@ For this, provide a partial at 'app/views/social_activities/_user_comments_user.
134
134
  How to run the Tests (in the gem itself, not in your Rails app)
135
135
  --------------------
136
136
 
137
- Run test in ./test:
138
-
139
- rake
140
-
141
137
  Run specs in ./spec:
142
138
 
143
- rspec spec
139
+ rspec --color spec
144
140
 
145
- Copyright (c) 2011 Chris Oloff, released under the MIT license
141
+ Copyright (c) 2011, 2012 Chris Oloff, released under the MIT license
@@ -27,7 +27,9 @@ class SocialActivity < ActiveRecord::Base
27
27
  def self.create_activities(subject, verb, object, options = {})
28
28
  # TODO: we may want to delay this
29
29
  activities = []
30
- [ subject, object ].uniq.each do |owner| # one activity for the subject, and one for the object
30
+ owners = [ subject, object ]
31
+ owners.concat(options[:additional_recipients]) if options[:additional_recipients]
32
+ owners.uniq.each do |owner|
31
33
  activities << SocialActivity.create(:owner => owner,
32
34
  :subject => subject,
33
35
  :verb => verb,
@@ -47,7 +49,7 @@ class SocialActivity < ActiveRecord::Base
47
49
  :options_as_json => options.to_json)
48
50
  end
49
51
  activities
50
- end
52
+ end
51
53
 
52
54
  def self.unseen_activities(for_whom)
53
55
  SocialActivity.where('owner_id = ? and owner_type = ? and unseen = ?',
@@ -1,3 +1,3 @@
1
1
  module SocialConnections
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + '/../test/test_helper'
2
+
3
+ describe "acts_as_connectable" do
4
+ before(:each) do
5
+ @c1 = Connectable.create(:name => 'Anne')
6
+ @c2 = Connectable.create(:name => 'Bob')
7
+ end
8
+ it "defines collection accessors" do
9
+ c = Connectable.create(:name => 'Tim', :email => '2@test.com')
10
+ c.should respond_to(:outgoing_social_connections)
11
+ c.should respond_to(:incoming_social_connections)
12
+ end
13
+ it "fails when connecting to 'nil'" do
14
+ expect { @c1.connect_to(nil) }.to raise_error(ArgumentError)
15
+ end
16
+ it "allows adding connections" do
17
+ @c1.connected_to?(@c2).should be(false)
18
+ @c1.connect_to(@c2)
19
+ @c1.connected_to?(@c2).should be(true)
20
+ @c1.outgoing_social_connections.count.should be(1)
21
+ @c1.outgoing_social_connections[0].should be_kind_of(SocialConnection)
22
+ @c1.incoming_social_connections.count.should be(0)
23
+ @c2.outgoing_social_connections.count.should be(0)
24
+ @c2.incoming_social_connections.count.should be(1)
25
+ @c2.incoming_social_connections[0].should be_kind_of(SocialConnection)
26
+ end
27
+ end
@@ -13,7 +13,7 @@ describe "Social Activities" do
13
13
  activities = @sub.likes(@obj) # what about the 'owner'? everybody 'connected' to the subject *and*
14
14
  # the object becomes an owner!
15
15
  activities.should_not be_nil
16
- activities[0].verb.should eql(:likes)
16
+ activities[0].verb.should eql(:likes)
17
17
  end
18
18
 
19
19
  it "allow the verbs given, but no other verbs" do
@@ -81,6 +81,12 @@ describe "Social Activities" do
81
81
  activities.select {|a| a.owner == mary}.should_not be_empty # Mary gets an activity, because she's connected to Tim
82
82
  end
83
83
 
84
+ it "creates activities for 'additional_recipients'" do
85
+ mary = Connectable.create(:name => 'Mary')
86
+ activities = @sub.likes(@obj, :additional_recipients => [ mary ])
87
+ activities.select {|a| a.owner == mary }.should_not be_empty # Mary gets an activity, because she's in 'addition_recipients'
88
+ end
89
+
84
90
  it "do *not* create activities for those the subject is connected to" do
85
91
  mary = Connectable.create(:name => 'Mary')
86
92
  @sub.connect_to(mary) # Tim is now connected to Mary
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_connections
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-03 00:00:00.000000000Z
12
+ date: 2012-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2157131000 !ruby/object:Gem::Requirement
16
+ requirement: &70324070772740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2157131000
24
+ version_requirements: *70324070772740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sqlite3
27
- requirement: &2157130420 !ruby/object:Gem::Requirement
27
+ requirement: &70324070770780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2157130420
35
+ version_requirements: *70324070770780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec-rails
38
- requirement: &2152641060 !ruby/object:Gem::Requirement
38
+ requirement: &70324070769620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2152641060
46
+ version_requirements: *70324070769620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: turn
49
- requirement: &2152640660 !ruby/object:Gem::Requirement
49
+ requirement: &70324070767520 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2152640660
57
+ version_requirements: *70324070767520
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: factory_girl_rails
60
- requirement: &2152640260 !ruby/object:Gem::Requirement
60
+ requirement: &70324070764120 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2152640260
68
+ version_requirements: *70324070764120
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activerecord
71
- requirement: &2152639860 !ruby/object:Gem::Requirement
71
+ requirement: &70324070761020 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2152639860
79
+ version_requirements: *70324070761020
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: actionmailer
82
- requirement: &2152639460 !ruby/object:Gem::Requirement
82
+ requirement: &70324070760180 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2152639460
90
+ version_requirements: *70324070760180
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: i18n
93
- requirement: &2152639060 !ruby/object:Gem::Requirement
93
+ requirement: &70324070759120 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2152639060
101
+ version_requirements: *70324070759120
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: pry
104
- requirement: &2152638660 !ruby/object:Gem::Requirement
104
+ requirement: &70324070755780 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2152638660
112
+ version_requirements: *70324070755780
113
113
  description: The idea is to provide pluggable social connections, activities and a
114
114
  method to digest those activities (e.g. in daily emails).
115
115
  email:
@@ -147,13 +147,11 @@ files:
147
147
  - run-tests.sh
148
148
  - social_connections.gemspec
149
149
  - spec/activities_aggregator_spec.rb
150
+ - spec/acts_as_connectable_spec.rb
150
151
  - spec/mute_and_curious_guest_spec.rb
151
152
  - spec/social_activities_spec.rb
152
- - test/activities_test.rb
153
- - test/acts_as_connectable_test.rb
154
153
  - test/database.yml
155
154
  - test/schema.rb
156
- - test/social_connection_test.rb
157
155
  - test/test_helper.rb
158
156
  - uninstall.rb
159
157
  homepage: https://sites.google.com/site/socialconnections7/
@@ -176,17 +174,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
174
  version: '0'
177
175
  requirements: []
178
176
  rubyforge_project: social_connections
179
- rubygems_version: 1.8.6
177
+ rubygems_version: 1.8.17
180
178
  signing_key:
181
179
  specification_version: 3
182
180
  summary: Social connections for ActiveRecord.
183
181
  test_files:
184
182
  - spec/activities_aggregator_spec.rb
183
+ - spec/acts_as_connectable_spec.rb
185
184
  - spec/mute_and_curious_guest_spec.rb
186
185
  - spec/social_activities_spec.rb
187
- - test/activities_test.rb
188
- - test/acts_as_connectable_test.rb
189
186
  - test/database.yml
190
187
  - test/schema.rb
191
- - test/social_connection_test.rb
192
188
  - test/test_helper.rb
@@ -1,9 +0,0 @@
1
- # subject, verb, object
2
- # both subject and object are 'acts_as_connectable'
3
- # examples:
4
- # - tim likes idea x
5
- # - tom comments "this is awesome" on idea y
6
- # - ben bought deal "25% off on xyz"
7
- #
8
- # how to indicate that someone has seen an activity already?
9
- # by having "owner, subject, verb, object", there could be a flag on the activity?
@@ -1,35 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- class ActsAsConnectableTest < ActiveSupport::TestCase
4
-
5
- load_schema
6
-
7
- def setup
8
- @connectable1 = Connectable.create(:name => 'Anne')
9
- @connectable2 = Connectable.create(:name => 'Bob')
10
- end
11
-
12
- test "should define collection accessors" do
13
- c = Connectable.create(:name => 'Tim', :email => '2@test.com')
14
- assert c.respond_to?(:outgoing_social_connections) == true, "does not respond to outgoing connections getter."
15
- assert c.respond_to?(:incoming_social_connections) == true, "does not respond to incoming connections getter."
16
- # etc.
17
- end
18
-
19
- test "should not allow nil as 'other'" do
20
- assert_raise ArgumentError do
21
- @connectable1.connect_to(nil)
22
- end
23
- end
24
-
25
- test "should allow adding connections" do
26
- assert @connectable1.connected_to?(@connectable2) == false
27
- @connectable1.connect_to(@connectable2)
28
- assert @connectable1.connected_to?(@connectable2) == true
29
- assert @connectable1.outgoing_social_connections.count == 1
30
- assert @connectable1.incoming_social_connections.count == 0
31
- assert @connectable2.outgoing_social_connections.count == 0
32
- assert @connectable2.incoming_social_connections.count == 1
33
- end
34
-
35
- end
@@ -1,10 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SocialConnectionTest < ActiveSupport::TestCase
4
- load_schema
5
-
6
- test "SocialConnection can be instantiated" do
7
- assert_kind_of SocialConnection, SocialConnection.new
8
- end
9
- end
10
-