質問編集履歴
5
ミス
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
describe "#create" do
|
34
34
|
|
35
|
-
let(:params) { { comment:
|
35
|
+
let(:params) { { comment: build(:comment).attributes } }
|
36
36
|
|
37
37
|
subject {
|
38
38
|
|
4
アソシエーションの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -94,9 +94,9 @@
|
|
94
94
|
|
95
95
|
factory :comment do
|
96
96
|
|
97
|
-
profile
|
97
|
+
profile
|
98
98
|
|
99
|
-
post
|
99
|
+
post{ create(:post, profile: profile) }
|
100
100
|
|
101
101
|
text "hogehoge"
|
102
102
|
|
@@ -110,7 +110,37 @@
|
|
110
110
|
|
111
111
|
|
112
112
|
|
113
|
+
###アソシエーション
|
113
114
|
|
115
|
+
```
|
116
|
+
|
117
|
+
class Comment < ApplicationRecord
|
118
|
+
|
119
|
+
belongs_to :post
|
120
|
+
|
121
|
+
belongs_to :profile
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
class Post < ApplicationRecord
|
128
|
+
|
129
|
+
belongs_to :profile
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
class Profile < ApplicationRecord
|
136
|
+
|
137
|
+
has_many :posts, dependent: :destroy
|
138
|
+
|
139
|
+
has_many :comments, dependent: :destroy
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
```
|
114
144
|
|
115
145
|
|
116
146
|
|
3
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,25 +30,27 @@
|
|
30
30
|
|
31
31
|
```
|
32
32
|
|
33
|
-
|
33
|
+
describe "#create" do
|
34
34
|
|
35
|
-
|
35
|
+
let(:params) { { comment: {build(:comment).attributes} } }
|
36
36
|
|
37
|
-
|
37
|
+
subject {
|
38
38
|
|
39
|
-
|
39
|
+
post :create,
|
40
40
|
|
41
|
-
|
41
|
+
params: params
|
42
42
|
|
43
|
-
|
43
|
+
}
|
44
44
|
|
45
|
-
it "データベースに新しいコメントが登録されること" do
|
46
45
|
|
47
|
-
expect{ subject }.to change(Comment, :count).by(1)
|
48
46
|
|
49
|
-
|
47
|
+
it "データベースに新しいコメントが登録されること" do
|
50
48
|
|
49
|
+
expect{ subject }.to change(Comment, :count).by(1)
|
50
|
+
|
51
|
-
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
52
54
|
|
53
55
|
```
|
54
56
|
|
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -96,7 +96,7 @@
|
|
96
96
|
|
97
97
|
post_id "1"
|
98
98
|
|
99
|
-
text
|
99
|
+
text "hogehoge"
|
100
100
|
|
101
101
|
end
|
102
102
|
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -47,6 +47,8 @@
|
|
47
47
|
expect{ subject }.to change(Comment, :count).by(1)
|
48
48
|
|
49
49
|
end
|
50
|
+
|
51
|
+
end
|
50
52
|
|
51
53
|
```
|
52
54
|
|