muck-friends 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -2
- data/Rakefile +3 -27
- data/VERSION +1 -1
- data/app/controllers/muck/friends_controller.rb +28 -11
- data/app/helpers/muck_friends_helper.rb +110 -48
- data/app/views/activity_templates/_follow.html.erb +3 -0
- data/app/views/activity_templates/_friends_with.html.erb +3 -0
- data/app/views/friends/_all_friends.html.erb +1 -1
- data/app/views/friends/_friend_icon.html.erb +1 -0
- data/config/muck_friends_routes.rb +3 -1
- data/lib/active_record/acts/muck_friend.rb +14 -22
- data/lib/active_record/acts/muck_friend_user.rb +7 -2
- data/locales/en.yml +14 -7
- data/muck-friends.gemspec +41 -5
- data/test/rails_root/Rakefile +15 -0
- data/test/rails_root/app/views/default/friend_link.html.erb +1 -0
- data/test/rails_root/config/database.yml +4 -1
- data/test/rails_root/config/environments/cucumber.rb +22 -0
- data/test/rails_root/config/global_config.yml +1 -1
- data/test/rails_root/db/migrate/20090402234137_create_languages.rb +18 -0
- data/test/rails_root/db/migrate/20090426041056_create_countries.rb +15 -0
- data/test/rails_root/db/migrate/20090426041103_create_states.rb +18 -0
- data/test/rails_root/db/migrate/20090730044139_add_comment_cache.rb +9 -0
- data/test/rails_root/features/step_definitions/webrat_steps.rb +57 -23
- data/test/rails_root/features/support/env.rb +14 -3
- data/test/rails_root/features/support/paths.rb +27 -0
- data/test/rails_root/lib/tasks/cucumber.rake +32 -0
- data/test/rails_root/public/images/fancybox/fancy_closebox.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_left.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_progress.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_right.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_e.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_n.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_ne.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_nw.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_s.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_se.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_sw.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_w.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_title_left.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_title_main.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_title_right.png +0 -0
- data/test/rails_root/public/images/nothing.png +0 -0
- data/test/rails_root/public/javascripts/jquery/jquery.easing.js +1 -0
- data/test/rails_root/public/javascripts/jquery/jquery.fancybox.js +9 -0
- data/test/rails_root/public/javascripts/muck.js +7 -3
- data/test/rails_root/public/javascripts/muck_activities.js +1 -1
- data/test/rails_root/public/stylesheets/jquery/jquery.fancybox.css +44 -0
- data/test/rails_root/public/stylesheets/styles.css +8 -3
- data/test/rails_root/script/cucumber +5 -3
- data/test/rails_root/test/functional/default_controller_test.rb +177 -4
- data/test/rails_root/test/functional/friends_controller_test.rb +8 -8
- data/test/rails_root/test/unit/user_test.rb +164 -127
- metadata +38 -5
- data/app/views/activity_templates/follow.html.erb +0 -1
- data/app/views/activity_templates/friends_with.html.erb +0 -1
- data/test/rails_root/db/schema.rb +0 -153
@@ -44,6 +44,179 @@ class Muck::DefaultControllerTest < ActionController::TestCase
|
|
44
44
|
@controller.stubs(:other_user).returns(@quentin)
|
45
45
|
end
|
46
46
|
|
47
|
+
context "friend link" do
|
48
|
+
setup do
|
49
|
+
@enable_following = GlobalConfig.enable_following
|
50
|
+
@enable_friending = GlobalConfig.enable_friending
|
51
|
+
end
|
52
|
+
teardown do
|
53
|
+
# Reset global config
|
54
|
+
GlobalConfig.enable_following = @enable_following
|
55
|
+
GlobalConfig.enable_friending = @enable_friending
|
56
|
+
end
|
57
|
+
|
58
|
+
context "enable_following is true and enable_friending is true" do
|
59
|
+
setup do
|
60
|
+
GlobalConfig.enable_following = true
|
61
|
+
GlobalConfig.enable_friending = true
|
62
|
+
end
|
63
|
+
context "no current user" do
|
64
|
+
setup do
|
65
|
+
@controller.stubs(:current_user).returns(nil)
|
66
|
+
get :friend_link
|
67
|
+
end
|
68
|
+
should_respond_with :success
|
69
|
+
should_render_template :friend_link
|
70
|
+
should "have login/signup in the body" do
|
71
|
+
assert @response.body.include?(I18n.t("muck.friends.muck.friends.login_or_sign_up_to_follow"), :login => link_to(I18n.t('muck.friends.login'), login_path), :signup => link_to(I18n.t('muck.friends.signup'), signup_path))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
context "current user is not friends with other user" do
|
75
|
+
setup do
|
76
|
+
@other_user = Factory(:user)
|
77
|
+
@controller.stubs(:other_user).returns(@other_user)
|
78
|
+
get :friend_link
|
79
|
+
end
|
80
|
+
should_respond_with :success
|
81
|
+
should_render_template :friend_link
|
82
|
+
should "have 'follow' in the body" do
|
83
|
+
assert @response.body.include?(I18n.t('muck.friends.start_following', :user => @other_user.display_name))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
context "current user is friends with other user" do
|
87
|
+
setup do
|
88
|
+
@controller.stubs(:other_user).returns(@friend1)
|
89
|
+
get :friend_link
|
90
|
+
end
|
91
|
+
should_respond_with :success
|
92
|
+
should_render_template :friend_link
|
93
|
+
should "have 'stop being friends' in the body" do
|
94
|
+
assert @response.body.include?(I18n.t('muck.friends.stop_being_friends_with', :user => @friend1.display_name))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
context "current user is not friend with other user, but other user follows current user" do
|
98
|
+
setup do
|
99
|
+
@controller.stubs(:other_user).returns(@follower1)
|
100
|
+
get :friend_link
|
101
|
+
end
|
102
|
+
should_respond_with :success
|
103
|
+
should_render_template :friend_link
|
104
|
+
should "have 'accept friend request' in the body" do
|
105
|
+
assert @response.body.include?(I18n.t('muck.friends.acccept_friend_request', :user => @follower1.display_name))
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "enable_following is true and enable_friending is false" do
|
111
|
+
setup do
|
112
|
+
GlobalConfig.enable_following = true
|
113
|
+
GlobalConfig.enable_friending = false
|
114
|
+
end
|
115
|
+
context "no current user" do
|
116
|
+
setup do
|
117
|
+
@controller.stubs(:current_user).returns(nil)
|
118
|
+
get :friend_link
|
119
|
+
end
|
120
|
+
should_respond_with :success
|
121
|
+
should_render_template :friend_link
|
122
|
+
should "have login/signup in the body" do
|
123
|
+
assert @response.body.include?(I18n.t("muck.friends.muck.friends.login_or_sign_up_to_follow"), :login => link_to(I18n.t('muck.friends.login'), login_path), :signup => link_to(I18n.t('muck.friends.signup'), signup_path))
|
124
|
+
end
|
125
|
+
end
|
126
|
+
context "current user is not following other user" do
|
127
|
+
setup do
|
128
|
+
@other_user = Factory(:user)
|
129
|
+
@controller.stubs(:other_user).returns(@other_user)
|
130
|
+
get :friend_link
|
131
|
+
end
|
132
|
+
should_respond_with :success
|
133
|
+
should_render_template :friend_link
|
134
|
+
should "have 'follow' in the body" do
|
135
|
+
assert @response.body.include?(I18n.t('muck.friends.start_following', :user => @other_user.display_name))
|
136
|
+
end
|
137
|
+
end
|
138
|
+
context "current user is following the other user" do
|
139
|
+
setup do
|
140
|
+
@being_followed = Factory(:user)
|
141
|
+
@aaron.follow(@being_followed)
|
142
|
+
@controller.stubs(:other_user).returns(@being_followed)
|
143
|
+
get :friend_link
|
144
|
+
end
|
145
|
+
should_respond_with :success
|
146
|
+
should_render_template :friend_link
|
147
|
+
should "have 'stop following' in the body" do
|
148
|
+
assert @response.body.include?(I18n.t('muck.friends.stop_following', :user => @being_followed.display_name))
|
149
|
+
end
|
150
|
+
end
|
151
|
+
context "current user is not friend with other user, but other user follows current user" do
|
152
|
+
setup do
|
153
|
+
@controller.stubs(:other_user).returns(@follower1)
|
154
|
+
get :friend_link
|
155
|
+
end
|
156
|
+
should_respond_with :success
|
157
|
+
should_render_template :friend_link
|
158
|
+
should "have 'follow' in the body" do
|
159
|
+
assert @response.body.include?(I18n.t('muck.friends.start_following', :user => @follower1.display_name))
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context "enable_following is false and enable_friending is true" do
|
165
|
+
setup do
|
166
|
+
GlobalConfig.enable_following = false
|
167
|
+
GlobalConfig.enable_friending = true
|
168
|
+
end
|
169
|
+
context "no current user" do
|
170
|
+
setup do
|
171
|
+
@controller.stubs(:current_user).returns(nil)
|
172
|
+
get :friend_link
|
173
|
+
end
|
174
|
+
should_respond_with :success
|
175
|
+
should_render_template :friend_link
|
176
|
+
should "have login/signup in the body" do
|
177
|
+
assert @response.body.include?(I18n.t("muck.friends.muck.friends.login_or_sign_up_to_friend"), :login => link_to(I18n.t('muck.friends.login'), login_path), :signup => link_to(I18n.t('muck.friends.signup'), signup_path))
|
178
|
+
end
|
179
|
+
end
|
180
|
+
context "current user is not friends with the other user" do
|
181
|
+
setup do
|
182
|
+
@other_user = Factory(:user)
|
183
|
+
@controller.stubs(:other_user).returns(@other_user)
|
184
|
+
get :friend_link
|
185
|
+
end
|
186
|
+
should_respond_with :success
|
187
|
+
should_render_template :friend_link
|
188
|
+
should "have 'friend request' in the body" do
|
189
|
+
assert @response.body.include?(I18n.t('muck.friends.friend_request_prompt', :user => @other_user.display_name))
|
190
|
+
end
|
191
|
+
end
|
192
|
+
context "current user has sent a friend request to the other user" do
|
193
|
+
setup do
|
194
|
+
@being_followed = Factory(:user)
|
195
|
+
@aaron.follow(@being_followed)
|
196
|
+
@controller.stubs(:other_user).returns(@being_followed)
|
197
|
+
get :friend_link
|
198
|
+
end
|
199
|
+
should_respond_with :success
|
200
|
+
should_render_template :friend_link
|
201
|
+
should "have 'friend request pending' in the body" do
|
202
|
+
assert @response.body.include?(I18n.t('muck.friends.friend_request_pending', :link => ''))
|
203
|
+
end
|
204
|
+
end
|
205
|
+
context "current user is not friend with other user, but other user has sent a friend request" do
|
206
|
+
setup do
|
207
|
+
@controller.stubs(:other_user).returns(@follower1)
|
208
|
+
get :friend_link
|
209
|
+
end
|
210
|
+
should_respond_with :success
|
211
|
+
should_render_template :friend_link
|
212
|
+
should "have 'accept friend request' in the body" do
|
213
|
+
assert @response.body.include?(I18n.t('muck.friends.acccept_friend_request', :user => @follower1.display_name))
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
|
47
220
|
context 'all friends' do
|
48
221
|
setup do
|
49
222
|
get :all_friends
|
@@ -51,7 +224,7 @@ class Muck::DefaultControllerTest < ActionController::TestCase
|
|
51
224
|
should_respond_with :success
|
52
225
|
should_render_template :all_friends
|
53
226
|
end
|
54
|
-
|
227
|
+
|
55
228
|
context 'mutual friends' do
|
56
229
|
setup do
|
57
230
|
get :mutual_friends
|
@@ -86,12 +259,12 @@ class Muck::DefaultControllerTest < ActionController::TestCase
|
|
86
259
|
|
87
260
|
context 'friend requests' do
|
88
261
|
setup do
|
89
|
-
@
|
90
|
-
GlobalConfig.
|
262
|
+
@enable_following = GlobalConfig.enable_following
|
263
|
+
GlobalConfig.enable_following = false
|
91
264
|
get :friend_requests
|
92
265
|
end
|
93
266
|
teardown do
|
94
|
-
GlobalConfig.
|
267
|
+
GlobalConfig.enable_following = @enable_following
|
95
268
|
end
|
96
269
|
should_respond_with :success
|
97
270
|
should_render_template :friend_requests
|
@@ -107,16 +107,16 @@ class Muck::FriendsControllerTest < ActionController::TestCase
|
|
107
107
|
|
108
108
|
context "Following allowed" do
|
109
109
|
setup do
|
110
|
-
@
|
111
|
-
GlobalConfig.
|
110
|
+
@temp_enable_following = GlobalConfig.enable_following
|
111
|
+
GlobalConfig.enable_following = true
|
112
112
|
Friend.destroy_all
|
113
113
|
@aaron.follow(@quentin)
|
114
114
|
@quentin.become_friends_with(@aaron)
|
115
115
|
end
|
116
116
|
teardown do
|
117
|
-
GlobalConfig.
|
117
|
+
GlobalConfig.enable_following = @temp_enable_following
|
118
118
|
end
|
119
|
-
context 'js request' do
|
119
|
+
context 'DELETE to destroy js request' do
|
120
120
|
setup do
|
121
121
|
delete :destroy, { :user_id => @quentin.to_param, :id => @aaron.to_param, :format => 'js'}
|
122
122
|
end
|
@@ -129,7 +129,7 @@ class Muck::FriendsControllerTest < ActionController::TestCase
|
|
129
129
|
assert @quentin.followed_by?(@aaron)
|
130
130
|
end
|
131
131
|
end
|
132
|
-
context 'html request' do
|
132
|
+
context 'DELETE to destroy html request' do
|
133
133
|
setup do
|
134
134
|
delete :destroy, { :user_id => @quentin.to_param, :id => @aaron.to_param}
|
135
135
|
end
|
@@ -139,14 +139,14 @@ class Muck::FriendsControllerTest < ActionController::TestCase
|
|
139
139
|
|
140
140
|
context 'Following not allowed' do
|
141
141
|
setup do
|
142
|
-
@
|
143
|
-
GlobalConfig.
|
142
|
+
@temp_enable_following = GlobalConfig.enable_following
|
143
|
+
GlobalConfig.enable_following = false
|
144
144
|
Friend.destroy_all
|
145
145
|
@aaron.follow(@quentin)
|
146
146
|
@quentin.become_friends_with(@aaron)
|
147
147
|
end
|
148
148
|
teardown do
|
149
|
-
GlobalConfig.
|
149
|
+
GlobalConfig.enable_following = @temp_enable_following
|
150
150
|
end
|
151
151
|
context 'js request' do
|
152
152
|
setup do
|
@@ -32,139 +32,176 @@ class UserTest < ActiveSupport::TestCase
|
|
32
32
|
@follower_guy = Factory(:user)
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
35
|
+
context "following disabled" do
|
36
|
+
setup do
|
37
|
+
@temp_enable_following = GlobalConfig.enable_following
|
38
|
+
GlobalConfig.enable_following = false
|
39
|
+
end
|
40
|
+
teardown do
|
41
|
+
GlobalConfig.enable_following = @temp_enable_following
|
42
|
+
end
|
43
|
+
should "stop being friends" do
|
44
|
+
assert @quentin.follow(@aaron)
|
45
|
+
assert @aaron.become_friends_with(@quentin)
|
46
|
+
assert @quentin.drop_friend(@aaron)
|
47
|
+
@quentin.reload
|
48
|
+
@aaron.reload
|
49
|
+
assert !@quentin.friend_of?(@aaron)
|
50
|
+
assert !@quentin.following?(@aaron)
|
51
|
+
assert !@quentin.followed_by?(@aaron)
|
52
|
+
assert !@aaron.friend_of?(@quentin)
|
53
|
+
assert !@aaron.following?(@quentin)
|
54
|
+
assert !@aaron.followed_by?(@quentin)
|
55
|
+
end
|
56
|
+
context "drop_friend following not enabled" do
|
57
|
+
setup do
|
58
|
+
assert @quentin.follow(@aaron)
|
59
|
+
assert @aaron.become_friends_with(@quentin)
|
60
|
+
assert @quentin.drop_friend(@aaron)
|
61
|
+
end
|
62
|
+
should "stop being friends with the user and don't retain follow" do
|
63
|
+
assert !@quentin.followings.any?{|f| f.id == @aaron.id}
|
64
|
+
assert !@aaron.followings.any?{|f| f.id == @quentin.id}
|
65
|
+
end
|
66
|
+
end
|
58
67
|
end
|
59
68
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
assert !@quentin.followings.any?{|f| f.id == @aaron.id}
|
101
|
-
end
|
102
|
-
|
103
|
-
should "become friends" do
|
104
|
-
@quentin.follow(@aaron)
|
105
|
-
@aaron.become_friends_with(@quentin)
|
106
|
-
@quentin.reload
|
107
|
-
@aaron.reload
|
108
|
-
assert @aaron.friends.any?{|f| f.id == @quentin.id}
|
109
|
-
assert @quentin.friends.any?{|f| f.id == @aaron.id}
|
110
|
-
end
|
69
|
+
context "following enabled" do
|
70
|
+
setup do
|
71
|
+
@temp_enable_following = GlobalConfig.enable_following
|
72
|
+
GlobalConfig.enable_following = true
|
73
|
+
end
|
74
|
+
teardown do
|
75
|
+
GlobalConfig.enable_following = @temp_enable_following
|
76
|
+
end
|
77
|
+
should "stop being friends but still allow follow" do
|
78
|
+
assert @quentin.follow(@aaron)
|
79
|
+
assert @aaron.become_friends_with(@quentin)
|
80
|
+
assert @quentin.drop_friend(@aaron)
|
81
|
+
@quentin.reload
|
82
|
+
@aaron.reload
|
83
|
+
assert !@quentin.friend_of?(@aaron)
|
84
|
+
assert !@quentin.following?(@aaron)
|
85
|
+
assert @quentin.followed_by?(@aaron)
|
86
|
+
assert !@aaron.friend_of?(@quentin)
|
87
|
+
assert @aaron.following?(@quentin)
|
88
|
+
assert !@aaron.followed_by?(@quentin)
|
89
|
+
end
|
90
|
+
context "drop_friend" do
|
91
|
+
setup do
|
92
|
+
assert @quentin.follow(@aaron)
|
93
|
+
end
|
94
|
+
should "stop following the user" do
|
95
|
+
assert @aaron.become_friends_with(@quentin)
|
96
|
+
assert @quentin.drop_friend(@aaron)
|
97
|
+
assert !@quentin.followings.any?{|f| f.id == @aaron.id}
|
98
|
+
assert @aaron.followings.any?{|f| f.id == @quentin.id}
|
99
|
+
end
|
100
|
+
should "stop being friends with the user but retain follow" do
|
101
|
+
assert @quentin.drop_friend(@aaron)
|
102
|
+
assert !@quentin.followings.any?{|f| f.id == @aaron.id}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
should "become friends" do
|
106
|
+
assert @aaron.follow(@quentin)
|
107
|
+
assert @quentin.become_friends_with(@aaron)
|
108
|
+
end
|
111
109
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
GlobalConfig.allow_following = @temp_allow_following
|
125
|
-
end
|
110
|
+
should "have friends" do
|
111
|
+
assert @aaron.follow(@quentin)
|
112
|
+
assert @quentin.become_friends_with(@aaron)
|
113
|
+
assert @friend_guy.follow(@quentin)
|
114
|
+
assert @quentin.become_friends_with(@friend_guy)
|
115
|
+
@quentin.reload
|
116
|
+
@aaron.reload
|
117
|
+
@friend_guy.reload
|
118
|
+
assert @quentin.friends.any?{|f| f.id == @aaron.id || f.id == @friend_guy.id}
|
119
|
+
assert @aaron.friends.any?{|f| f.id == @quentin.id}
|
120
|
+
assert @friend_guy.friends.any?{|f| f.id == @quentin.id}
|
121
|
+
end
|
126
122
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
123
|
+
should "not have follower as friend" do
|
124
|
+
assert @follower_guy.follow(@quentin)
|
125
|
+
assert !@quentin.friends.any?{|f| f.id == @follower_guy.id}
|
126
|
+
end
|
127
|
+
|
128
|
+
should "have followers" do
|
129
|
+
assert @follower_guy.follow(@quentin)
|
130
|
+
assert @quentin.followers.any?{|f| f.id == @follower_guy.id}
|
131
|
+
end
|
132
|
+
|
133
|
+
should "have people user follows (followings)" do
|
134
|
+
assert @follower_guy.follow(@quentin)
|
135
|
+
assert @follower_guy.followings.any?{|f| f.id == @quentin.id}
|
136
|
+
end
|
137
|
+
|
138
|
+
should "be a friend" do
|
139
|
+
assert @quentin.follow(@aaron)
|
140
|
+
assert @quentin.follow(@friend_guy)
|
141
|
+
assert @aaron.become_friends_with(@quentin)
|
142
|
+
assert @friend_guy.become_friends_with(@quentin)
|
143
|
+
assert_equal @quentin.occurances_as_friend.count, 2
|
144
|
+
end
|
145
|
+
|
146
|
+
should "find friendships initiated by me" do
|
147
|
+
assert @quentin.follow(@aaron)
|
148
|
+
assert @quentin.follow(@friend_guy)
|
149
|
+
assert_equal 2, @quentin.friendships_initiated_by_me.count
|
150
|
+
assert @quentin.friendships_initiated_by_me.any?{|f| f.id == @aaron.id || f.id == @friend_guy.id}
|
151
|
+
end
|
152
|
+
|
153
|
+
should "find friendships not initiated by me" do
|
154
|
+
assert @aaron.follow(@quentin)
|
155
|
+
assert @friend_guy.follow(@quentin)
|
156
|
+
assert_equal 2, @quentin.friendships_not_initiated_by_me.count
|
157
|
+
assert @quentin.friendships_not_initiated_by_me.any?{|f| f.id == @aaron.id || f.id == @friend_guy.id}
|
158
|
+
end
|
159
|
+
|
160
|
+
should "follow the user" do
|
161
|
+
assert @quentin.follow(@aaron)
|
162
|
+
assert @quentin.followings.any?{|f| f.id == @aaron.id}
|
163
|
+
end
|
164
|
+
|
165
|
+
should "stop following the user" do
|
166
|
+
assert @quentin.follow(@aaron)
|
167
|
+
assert @quentin.stop_following(@aaron)
|
168
|
+
assert !@quentin.followings.any?{|f| f.id == @aaron.id}
|
169
|
+
end
|
170
|
+
|
171
|
+
should "become friends" do
|
172
|
+
assert @quentin.follow(@aaron)
|
173
|
+
assert @aaron.become_friends_with(@quentin)
|
174
|
+
@quentin.reload
|
175
|
+
@aaron.reload
|
176
|
+
assert @aaron.friends.any?{|f| f.id == @quentin.id}
|
177
|
+
assert @quentin.friends.any?{|f| f.id == @aaron.id}
|
178
|
+
end
|
179
|
+
should "not have a network" do
|
180
|
+
assert !@quentin.has_network?
|
181
|
+
end
|
182
|
+
|
183
|
+
should "have a network" do
|
184
|
+
assert @quentin.follow(@aaron)
|
185
|
+
assert @quentin.has_network?
|
186
|
+
end
|
187
|
+
|
188
|
+
should "block user" do
|
189
|
+
assert @quentin.follow(@aaron)
|
190
|
+
assert @aaron.block_user(@quentin)
|
191
|
+
assert !@aaron.friends.any?{|f| f.id == @quentin.id}
|
192
|
+
assert !@aaron.followers.any?{|f| f.id == @quentin.id}
|
193
|
+
assert !@quentin.followings.any?{|f| f.id == @aaron.id}
|
194
|
+
end
|
195
|
+
|
196
|
+
should "unblock user" do
|
197
|
+
assert @quentin.follow(@aaron)
|
198
|
+
assert @aaron.block_user(@quentin)
|
199
|
+
assert @aaron.unblock_user(@quentin)
|
200
|
+
assert @aaron.followers.any?{|f| f.id == @quentin.id}
|
201
|
+
assert @quentin.followings.any?{|f| f.id == @aaron.id}
|
202
|
+
end
|
159
203
|
end
|
160
204
|
|
161
|
-
should "unblock user" do
|
162
|
-
@quentin.follow(@aaron)
|
163
|
-
@aaron.block_user(@quentin)
|
164
|
-
@aaron.unblock_user(@quentin)
|
165
|
-
assert @aaron.followers.any?{|f| f.id == @quentin.id}
|
166
|
-
assert @quentin.followings.any?{|f| f.id == @aaron.id}
|
167
|
-
end
|
168
205
|
end
|
169
206
|
|
170
207
|
end
|