質問編集履歴
2
文字の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -85,7 +85,7 @@
|
|
85
85
|
|
86
86
|
# テストのファイル内容
|
87
87
|
|
88
|
-
|
88
|
+
念のため、記載します。
|
89
89
|
|
90
90
|
```
|
91
91
|
|
1
補足
title
CHANGED
File without changes
|
body
CHANGED
@@ -80,4 +80,63 @@
|
|
80
80
|
**どうして、better_errors削除前後でテスト結果が変わる**のかがさっぱりです。
|
81
81
|
|
82
82
|
**個別エラーの意味というより、better_errors削除前後でのテスト仕様(?)** について
|
83
|
-
もし情報をお持ちの方、ご助言頂けるとと幸いです。宜しくお願いします。
|
83
|
+
もし情報をお持ちの方、ご助言頂けるとと幸いです。宜しくお願いします。
|
84
|
+
|
85
|
+
|
86
|
+
# テストのファイル内容
|
87
|
+
|
88
|
+
一応、加えておきます。
|
89
|
+
|
90
|
+
```
|
91
|
+
|
92
|
+
require 'test_helper'
|
93
|
+
|
94
|
+
class FollowingTest < ActionDispatch::IntegrationTest
|
95
|
+
|
96
|
+
def setup
|
97
|
+
@user = users(:michael)
|
98
|
+
@host = hosts(:google)
|
99
|
+
log_in_as(@user)
|
100
|
+
end
|
101
|
+
|
102
|
+
test "フォローリストページ" do
|
103
|
+
get following_user_mypage_path
|
104
|
+
assert_not @user.following.empty?
|
105
|
+
assert_match @user.following.count.to_s,response.body
|
106
|
+
@user.following.each do |host|
|
107
|
+
assert_select "a[href=?]",user_host_path(host)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
test "フォロー" do
|
112
|
+
assert_difference '@user.following.count',1 do
|
113
|
+
post user_relationships_path, params: { followed_id: @host.id }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
test "フォロー(Ajax)" do
|
118
|
+
assert_difference '@user.following.count',1 do
|
119
|
+
post user_relationships_path, params: { followed_id: @host.id }, xhr: true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
test "フォロー解除" do
|
124
|
+
@user.follow(@host)
|
125
|
+
relationship = @user.active_relationships.find_by(followed_id: @host.id)
|
126
|
+
assert_difference '@user.following.count', -1 do
|
127
|
+
delete user_relationship_path(relationship)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
test "フォロー解除(Ajax)" do
|
132
|
+
@user.follow(@host)
|
133
|
+
relationship = @user.active_relationships.find_by(followed_id: @host.id)
|
134
|
+
assert_difference '@user.following.count', -1 do
|
135
|
+
delete user_relationship_path(relationship),xhr:true
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
```
|