Commit c395dd2f1d62a5879e9d084c770dc35e02ee1043
Committed by
GitHub
Exists in
master
Merge pull request #78 from amoludage/ruby-hash-syntax
Update ruby hash syntax
Showing
5 changed files
with
24 additions
and
28 deletions
Show diff stats
lib/acts_as_follower/follow_scopes.rb
... | ... | @@ -3,23 +3,22 @@ module ActsAsFollower #:nodoc: |
3 | 3 | |
4 | 4 | # returns Follow records where follower is the record passed in. |
5 | 5 | def for_follower(follower) |
6 | - where(:follower_id => follower.id, | |
7 | - :follower_type => parent_class_name(follower)) | |
6 | + where(follower_id: follower.id, follower_type: parent_class_name(follower)) | |
8 | 7 | end |
9 | 8 | |
10 | 9 | # returns Follow records where followable is the record passed in. |
11 | 10 | def for_followable(followable) |
12 | - where(:followable_id => followable.id, :followable_type => parent_class_name(followable)) | |
11 | + where(followable_id: followable.id, followable_type: parent_class_name(followable)) | |
13 | 12 | end |
14 | 13 | |
15 | 14 | # returns Follow records where follower_type is the record passed in. |
16 | 15 | def for_follower_type(follower_type) |
17 | - where(:follower_type => follower_type) | |
16 | + where(follower_type: follower_type) | |
18 | 17 | end |
19 | 18 | |
20 | 19 | # returns Follow records where followeable_type is the record passed in. |
21 | 20 | def for_followable_type(followable_type) |
22 | - where(:followable_type => followable_type) | |
21 | + where(followable_type: followable_type) | |
23 | 22 | end |
24 | 23 | |
25 | 24 | # returns Follow records from past 2 weeks with default parameter. |
... | ... | @@ -34,12 +33,12 @@ module ActsAsFollower #:nodoc: |
34 | 33 | |
35 | 34 | # returns unblocked Follow records. |
36 | 35 | def unblocked |
37 | - where(:blocked => false) | |
36 | + where(blocked: false) | |
38 | 37 | end |
39 | 38 | |
40 | 39 | # returns blocked Follow records. |
41 | 40 | def blocked |
42 | - where(:blocked => true) | |
41 | + where(blocked: true) | |
43 | 42 | end |
44 | 43 | |
45 | 44 | end | ... | ... |
lib/acts_as_follower/followable.rb
... | ... | @@ -7,7 +7,7 @@ module ActsAsFollower #:nodoc: |
7 | 7 | |
8 | 8 | module ClassMethods |
9 | 9 | def acts_as_followable |
10 | - has_many :followings, :as => :followable, :dependent => :destroy, :class_name => 'Follow' | |
10 | + has_many :followings, as: :followable, dependent: :destroy, class_name: 'Follow' | |
11 | 11 | include ActsAsFollower::Followable::InstanceMethods |
12 | 12 | include ActsAsFollower::FollowerLib |
13 | 13 | end |
... | ... | @@ -101,7 +101,7 @@ module ActsAsFollower #:nodoc: |
101 | 101 | private |
102 | 102 | |
103 | 103 | def block_future_follow(follower) |
104 | - Follow.create(:followable => self, :follower => follower, :blocked => true) | |
104 | + Follow.create(followable: self, follower: follower, blocked: true) | |
105 | 105 | end |
106 | 106 | |
107 | 107 | def block_existing_follow(follower) |
... | ... | @@ -109,6 +109,5 @@ module ActsAsFollower #:nodoc: |
109 | 109 | end |
110 | 110 | |
111 | 111 | end |
112 | - | |
113 | 112 | end |
114 | 113 | end | ... | ... |
lib/acts_as_follower/follower.rb
... | ... | @@ -7,7 +7,7 @@ module ActsAsFollower #:nodoc: |
7 | 7 | |
8 | 8 | module ClassMethods |
9 | 9 | def acts_as_follower |
10 | - has_many :follows, :as => :follower, :dependent => :destroy | |
10 | + has_many :follows, as: :follower, dependent: :destroy | |
11 | 11 | include ActsAsFollower::Follower::InstanceMethods |
12 | 12 | include ActsAsFollower::FollowerLib |
13 | 13 | end |
... | ... | @@ -108,6 +108,5 @@ module ActsAsFollower #:nodoc: |
108 | 108 | end |
109 | 109 | |
110 | 110 | end |
111 | - | |
112 | 111 | end |
113 | 112 | end | ... | ... |
test/acts_as_followable_test.rb
... | ... | @@ -64,7 +64,7 @@ class ActsAsFollowableTest < ActiveSupport::TestCase |
64 | 64 | should "accept AR options" do |
65 | 65 | @bob = FactoryGirl.create(:bob) |
66 | 66 | @bob.follow(@jon) |
67 | - assert_equal 1, @jon.followers(:limit => 1).count | |
67 | + assert_equal 1, @jon.followers(limit: 1).count | |
68 | 68 | end |
69 | 69 | end |
70 | 70 | |
... | ... | @@ -80,8 +80,8 @@ class ActsAsFollowableTest < ActiveSupport::TestCase |
80 | 80 | @jon.destroy |
81 | 81 | end |
82 | 82 | |
83 | - should_change("follow count", :by => -1) { Follow.count } | |
84 | - should_change("@sam.all_following.size", :by => -1) { @sam.all_following.size } | |
83 | + should_change("follow count", by: -1) { Follow.count } | |
84 | + should_change("@sam.all_following.size", by: -1) { @sam.all_following.size } | |
85 | 85 | end |
86 | 86 | |
87 | 87 | context "get follow record" do |
... | ... | @@ -107,7 +107,7 @@ class ActsAsFollowableTest < ActiveSupport::TestCase |
107 | 107 | end |
108 | 108 | |
109 | 109 | should "accept AR options" do |
110 | - assert_equal 1, @jon.blocks(:limit => 1).count | |
110 | + assert_equal 1, @jon.blocks(limit: 1).count | |
111 | 111 | end |
112 | 112 | end |
113 | 113 | |
... | ... | @@ -264,5 +264,4 @@ class ActsAsFollowableTest < ActiveSupport::TestCase |
264 | 264 | end |
265 | 265 | |
266 | 266 | end |
267 | - | |
268 | 267 | end | ... | ... |
test/acts_as_follower_test.rb
... | ... | @@ -43,8 +43,8 @@ class ActsAsFollowerTest < ActiveSupport::TestCase |
43 | 43 | @jon.follow(@sam) |
44 | 44 | end |
45 | 45 | |
46 | - should_change("Follow count", :by => 1) { Follow.count } | |
47 | - should_change("@jon.follow_count", :by => 1) { @jon.follow_count } | |
46 | + should_change("Follow count", by: 1) { Follow.count } | |
47 | + should_change("@jon.follow_count", by: 1) { @jon.follow_count } | |
48 | 48 | |
49 | 49 | should "set the follower" do |
50 | 50 | assert_equal @jon, Follow.last.follower |
... | ... | @@ -77,8 +77,8 @@ class ActsAsFollowerTest < ActiveSupport::TestCase |
77 | 77 | @sam.stop_following(@jon) |
78 | 78 | end |
79 | 79 | |
80 | - should_change("Follow count", :by => -1) { Follow.count } | |
81 | - should_change("@sam.follow_count", :by => -1) { @sam.follow_count } | |
80 | + should_change("Follow count", by: -1) { Follow.count } | |
81 | + should_change("@sam.follow_count", by: -1) { @sam.follow_count } | |
82 | 82 | end |
83 | 83 | |
84 | 84 | context "follows" do |
... | ... | @@ -96,7 +96,7 @@ class ActsAsFollowerTest < ActiveSupport::TestCase |
96 | 96 | should "accept AR options" do |
97 | 97 | @metallica = FactoryGirl.create(:metallica) |
98 | 98 | @sam.follow(@metallica) |
99 | - assert_equal 1, @sam.follows_by_type('Band', :limit => 1).count | |
99 | + assert_equal 1, @sam.follows_by_type('Band', limit: 1).count | |
100 | 100 | end |
101 | 101 | end |
102 | 102 | |
... | ... | @@ -121,7 +121,7 @@ class ActsAsFollowerTest < ActiveSupport::TestCase |
121 | 121 | end |
122 | 122 | |
123 | 123 | should "accept AR options" do |
124 | - assert_equal 1, @sam.all_follows(:limit => 1).count | |
124 | + assert_equal 1, @sam.all_follows(limit: 1).count | |
125 | 125 | end |
126 | 126 | end |
127 | 127 | end |
... | ... | @@ -135,11 +135,11 @@ class ActsAsFollowerTest < ActiveSupport::TestCase |
135 | 135 | end |
136 | 136 | |
137 | 137 | should "accept AR limit option" do |
138 | - assert_equal 1, @sam.all_following(:limit => 1).count | |
138 | + assert_equal 1, @sam.all_following(limit: 1).count | |
139 | 139 | end |
140 | 140 | |
141 | 141 | should "accept AR where option" do |
142 | - assert_equal 1, @sam.all_following(:where => { :id => @oasis.id }).count | |
142 | + assert_equal 1, @sam.all_following(where: { id: @oasis.id }).count | |
143 | 143 | end |
144 | 144 | end |
145 | 145 | |
... | ... | @@ -152,7 +152,7 @@ class ActsAsFollowerTest < ActiveSupport::TestCase |
152 | 152 | should "accept AR options" do |
153 | 153 | @metallica = FactoryGirl.create(:metallica) |
154 | 154 | @sam.follow(@metallica) |
155 | - assert_equal 1, @sam.following_by_type('Band', :limit => 1).to_a.size | |
155 | + assert_equal 1, @sam.following_by_type('Band', limit: 1).to_a.size | |
156 | 156 | end |
157 | 157 | end |
158 | 158 | |
... | ... | @@ -193,8 +193,8 @@ class ActsAsFollowerTest < ActiveSupport::TestCase |
193 | 193 | @jon.destroy |
194 | 194 | end |
195 | 195 | |
196 | - should_change("Follow.count", :by => -1) { Follow.count } | |
197 | - should_change("@sam.follow_count", :by => -1) { @sam.follow_count } | |
196 | + should_change("Follow.count", by: -1) { Follow.count } | |
197 | + should_change("@sam.follow_count", by: -1) { @sam.follow_count } | |
198 | 198 | end |
199 | 199 | |
200 | 200 | context "blocked by followable" do | ... | ... |