partisan 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +6 -13
- data/LICENSE.md +1 -1
- data/README.md +11 -1
- data/gemfiles/{Gemfile.activerecord-3.2.x → Gemfile.activerecord-4.2} +1 -1
- data/lib/generators/partisan/templates/migration.rb +3 -2
- data/lib/partisan/follow.rb +2 -2
- data/lib/partisan/followable.rb +1 -1
- data/lib/partisan/follower.rb +1 -1
- data/lib/partisan/version.rb +1 -1
- data/spec/partisan/followable_spec.rb +15 -2
- data/spec/partisan/follower_spec.rb +9 -12
- data/spec/spec_helper.rb +1 -0
- metadata +4 -5
- data/gemfiles/Gemfile.activerecord-4.0 +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d936bacfb75a4439cfa641e0dc3f021f4eeefd0d
|
4
|
+
data.tar.gz: ceba8e18ebb77675bd10d141165a31321f552c8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91469d38973cada18bb4ce7827e33b012b9fc55580b93cfafc24d8fad8be2a26e1b5c4cee53111704063a0afc7390fb313efbf41c7c6620c6e23cf510922d293
|
7
|
+
data.tar.gz: a3952e8a4e978691f966fc144bcfcb9a2c37f5056fe9e1e737b00d8893612499be3abae243fbf0399424b8c34e53a188b244660e8106e2947ca5b0809beaee40
|
data/.travis.yml
CHANGED
@@ -1,21 +1,14 @@
|
|
1
|
+
sudo: false
|
2
|
+
|
1
3
|
language: ruby
|
2
4
|
|
3
5
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 1
|
6
|
+
- 2.2
|
7
|
+
- 2.1
|
8
|
+
- 2.0
|
6
9
|
|
7
10
|
gemfile:
|
11
|
+
- gemfiles/Gemfile.activerecord-4.2
|
8
12
|
- gemfiles/Gemfile.activerecord-4.1
|
9
|
-
- gemfiles/Gemfile.activerecord-4.0
|
10
|
-
- gemfiles/Gemfile.activerecord-3.2.x
|
11
13
|
|
12
14
|
script: "echo 'DO IT' && bundle exec rake spec"
|
13
|
-
|
14
|
-
notifications:
|
15
|
-
hipchat:
|
16
|
-
rooms:
|
17
|
-
secure: "DUZC6Q2b18pEp7W7qNnGRYDgqtZGeWh44ED+hF27OIxjdM6JRx/nOmpvY46/lR6KjiH7DDM+TGPbxAzXo3rECxUZqkMPjMkqfZyfyN4JhccI/dJf1EL0GDUMogPfFUOuLWTqA49Y9GvvXTghK/irlLBhInWcrPJcTIsDG2t4nN4="
|
18
|
-
template:
|
19
|
-
- '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message} (<a href="%{build_url}">Build</a>/<a href="%{compare_url}">Changes</a>)'
|
20
|
-
format: 'html'
|
21
|
-
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -56,6 +56,10 @@ end
|
|
56
56
|
class Band < ActiveRecord::Base
|
57
57
|
acts_as_followable
|
58
58
|
end
|
59
|
+
|
60
|
+
class Follow < ActiveRecord::Base
|
61
|
+
acts_as_follow
|
62
|
+
end
|
59
63
|
```
|
60
64
|
|
61
65
|
And follow/unfollow other records!
|
@@ -140,9 +144,15 @@ The available callbacks are:
|
|
140
144
|
| `before_being_unfollowed` | `self.about_to_by_unfollowed_by` |
|
141
145
|
| `after_being_unfollowed` | `self.just_unfollowed_by` |
|
142
146
|
|
147
|
+
## Contributors
|
148
|
+
|
149
|
+
* [@simonprev](https://github.com/simonprev)
|
150
|
+
* [@remiprev](https://github.com/remiprev)
|
151
|
+
* [@jdurand](https://github.com/jdurand)
|
152
|
+
|
143
153
|
## License
|
144
154
|
|
145
|
-
`Partisan` is © 2013 [Mirego](http://www.mirego.com) and may be freely distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/partisan/blob/master/LICENSE.md) file.
|
155
|
+
`Partisan` is © 2013-2016 [Mirego](http://www.mirego.com) and may be freely distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/partisan/blob/master/LICENSE.md) file.
|
146
156
|
|
147
157
|
## About Mirego
|
148
158
|
|
@@ -4,11 +4,12 @@ class AddFollowsMigration < ActiveRecord::Migration
|
|
4
4
|
t.references :followable, polymorphic: true
|
5
5
|
t.references :follower, polymorphic: true
|
6
6
|
|
7
|
-
t.timestamps
|
7
|
+
t.timestamps null: false
|
8
8
|
end
|
9
9
|
|
10
|
-
add_index :follows, ['follower_id', 'follower_type'],
|
10
|
+
add_index :follows, ['follower_id', 'follower_type'], name: 'index_partisan_followers'
|
11
11
|
add_index :follows, ['followable_id', 'followable_type'], name: 'index_partisan_followables'
|
12
|
+
add_index :follows, ['follower_id', 'follower_type', 'followable_id', 'follower_type'], name: 'index_partisan_unique_follow', unique: true
|
12
13
|
end
|
13
14
|
|
14
15
|
def down
|
data/lib/partisan/follow.rb
CHANGED
@@ -30,8 +30,8 @@ module Partisan
|
|
30
30
|
protected
|
31
31
|
|
32
32
|
def update_follow_counter
|
33
|
-
follower.
|
34
|
-
followable.
|
33
|
+
follower.update_followings_counter
|
34
|
+
followable.update_followers_counter
|
35
35
|
end
|
36
36
|
|
37
37
|
def around_create_follower(&blk)
|
data/lib/partisan/followable.rb
CHANGED
@@ -52,7 +52,7 @@ module Partisan
|
|
52
52
|
|
53
53
|
# Update cache counter
|
54
54
|
# Called in after_create and after_destroy
|
55
|
-
def
|
55
|
+
def update_followers_counter
|
56
56
|
self.update_attribute('followers_count', self.followings.count) if self.respond_to?(:followers_count)
|
57
57
|
end
|
58
58
|
|
data/lib/partisan/follower.rb
CHANGED
@@ -96,7 +96,7 @@ module Partisan
|
|
96
96
|
|
97
97
|
# Update cache counter
|
98
98
|
# Called in after_create and after_destroy
|
99
|
-
def
|
99
|
+
def update_followings_counter
|
100
100
|
self.update_attribute('followings_count', self.follows.count) if self.respond_to?(:followings_count)
|
101
101
|
end
|
102
102
|
|
data/lib/partisan/version.rb
CHANGED
@@ -4,7 +4,10 @@ describe Partisan::Followable do
|
|
4
4
|
before do
|
5
5
|
run_migration do
|
6
6
|
create_table(:fans, force: true)
|
7
|
-
create_table(:users, force: true)
|
7
|
+
create_table(:users, force: true) do |t|
|
8
|
+
t.integer :followings_count, default: 0
|
9
|
+
t.integer :followers_count, default: 0
|
10
|
+
end
|
8
11
|
create_table(:concerts, force: true)
|
9
12
|
|
10
13
|
create_table(:bands, force: true) do |t|
|
@@ -13,13 +16,14 @@ describe Partisan::Followable do
|
|
13
16
|
end
|
14
17
|
|
15
18
|
follower 'Fan'
|
16
|
-
|
19
|
+
followable_and_follower 'User'
|
17
20
|
followable 'Band'
|
18
21
|
followable 'Concert'
|
19
22
|
end
|
20
23
|
|
21
24
|
let(:band) { Band.create }
|
22
25
|
let(:user) { User.create }
|
26
|
+
let(:user2) { User.create }
|
23
27
|
let(:concert) { Concert.create }
|
24
28
|
let(:fan) { Fan.create }
|
25
29
|
|
@@ -127,5 +131,14 @@ describe Partisan::Followable do
|
|
127
131
|
|
128
132
|
it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(user) }
|
129
133
|
end
|
134
|
+
|
135
|
+
describe :update_followings_counter do
|
136
|
+
before do
|
137
|
+
user.follow user2
|
138
|
+
user.reload
|
139
|
+
end
|
140
|
+
|
141
|
+
it { expect(user.followings_count).to eq 1 }
|
142
|
+
end
|
130
143
|
end
|
131
144
|
end
|
@@ -21,18 +21,6 @@ describe Partisan::Follower do
|
|
21
21
|
let(:user2) { User.create }
|
22
22
|
let(:concert) { Concert.create }
|
23
23
|
|
24
|
-
describe :UserToUser do
|
25
|
-
before do
|
26
|
-
user.follow user2
|
27
|
-
|
28
|
-
user.reload
|
29
|
-
user2.reload
|
30
|
-
end
|
31
|
-
|
32
|
-
it { expect(user.followings_count).to eq 1 }
|
33
|
-
it { expect(user2.followers_count).to eq 1 }
|
34
|
-
end
|
35
|
-
|
36
24
|
describe :InstanceMethods do
|
37
25
|
before do
|
38
26
|
user.follow band
|
@@ -150,6 +138,15 @@ describe Partisan::Follower do
|
|
150
138
|
|
151
139
|
it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(band) }
|
152
140
|
end
|
141
|
+
|
142
|
+
describe :update_followers_counter do
|
143
|
+
before do
|
144
|
+
user.follow user2
|
145
|
+
user2.reload
|
146
|
+
end
|
147
|
+
|
148
|
+
it { expect(user2.followers_count).to eq 1 }
|
149
|
+
end
|
153
150
|
end
|
154
151
|
|
155
152
|
describe :AliasMethods do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: partisan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Prévost
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -98,9 +98,8 @@ files:
|
|
98
98
|
- LICENSE.md
|
99
99
|
- README.md
|
100
100
|
- Rakefile
|
101
|
-
- gemfiles/Gemfile.activerecord-3.2.x
|
102
|
-
- gemfiles/Gemfile.activerecord-4.0
|
103
101
|
- gemfiles/Gemfile.activerecord-4.1
|
102
|
+
- gemfiles/Gemfile.activerecord-4.2
|
104
103
|
- lib/generators/partisan/USAGE
|
105
104
|
- lib/generators/partisan/install_generator.rb
|
106
105
|
- lib/generators/partisan/templates/migration.rb
|
@@ -139,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
138
|
version: '0'
|
140
139
|
requirements: []
|
141
140
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.4.5
|
143
142
|
signing_key:
|
144
143
|
specification_version: 4
|
145
144
|
summary: Partisan is a Ruby library that allows ActiveRecord records to be follower
|