質問編集履歴
2
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,11 +46,11 @@
|
|
46
46
|
|
47
47
|
test "should get home" do
|
48
48
|
|
49
|
-
get
|
49
|
+
get root_path
|
50
|
-
|
50
|
+
|
51
|
-
assert_response :success
|
51
|
+
assert_response :success
|
52
|
-
|
52
|
+
|
53
|
-
assert_select "title", "
|
53
|
+
assert_select "title", "Ruby on Rails Tutorial Sample App"
|
54
54
|
|
55
55
|
end
|
56
56
|
|
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
test "should get help" do
|
60
60
|
|
61
|
-
get
|
61
|
+
get help_path
|
62
62
|
|
63
63
|
assert_response :success
|
64
64
|
|
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
test "should get about" do
|
72
72
|
|
73
|
-
get
|
73
|
+
get about_path
|
74
74
|
|
75
75
|
assert_response :success
|
76
76
|
|
@@ -78,11 +78,11 @@
|
|
78
78
|
|
79
79
|
end
|
80
80
|
|
81
|
-
|
81
|
+
|
82
82
|
|
83
83
|
test "should get contact" do
|
84
84
|
|
85
|
-
get
|
85
|
+
get contact_path
|
86
86
|
|
87
87
|
assert_response :success
|
88
88
|
|
@@ -98,15 +98,15 @@
|
|
98
98
|
|
99
99
|
Rails.application.routes.draw do
|
100
100
|
|
101
|
-
root'static_pages#home'
|
101
|
+
root 'static_pages#home'
|
102
|
-
|
103
|
-
|
102
|
+
|
104
|
-
|
105
|
-
get 'static_pages
|
103
|
+
get '/help', to: 'static_pages#help'
|
106
|
-
|
104
|
+
|
107
|
-
get 'static_pages
|
105
|
+
get '/about', to: 'static_pages#about'
|
108
|
-
|
106
|
+
|
109
|
-
get 'static_pages
|
107
|
+
get '/contact', to: 'static_pages#contact'
|
108
|
+
|
109
|
+
get '/signup', to: 'users#new'
|
110
110
|
|
111
111
|
end
|
112
112
|
|
@@ -166,20 +166,6 @@
|
|
166
166
|
|
167
167
|
[home.html.erb]
|
168
168
|
|
169
|
-
<h1>Sample App</h1>
|
170
|
-
|
171
|
-
<p>
|
172
|
-
|
173
|
-
This is the home page for the
|
174
|
-
|
175
|
-
<a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
|
176
|
-
|
177
|
-
sample application.
|
178
|
-
|
179
|
-
</p>
|
180
|
-
|
181
|
-
|
182
|
-
|
183
169
|
<div class="center jumbotron">
|
184
170
|
|
185
171
|
<h1>Welcome to the Sample App</h1>
|
@@ -198,7 +184,7 @@
|
|
198
184
|
|
199
185
|
|
200
186
|
|
201
|
-
<%= link_to "Sign up now!",signup_path, class: "btn btn-lg btn-primary" %>
|
187
|
+
<%= link_to "Sign up now!", signup_path, class: "btn btn-lg btn-primary" %>
|
202
188
|
|
203
189
|
</div>
|
204
190
|
|
@@ -210,4 +196,156 @@
|
|
210
196
|
|
211
197
|
|
212
198
|
|
199
|
+
[user_test.rb]
|
200
|
+
|
201
|
+
require 'test_helper'
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
class UserTest < ActiveSupport::TestCase
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
def setup
|
210
|
+
|
211
|
+
@user = User.new(name: "Example User", email: "user@example.com",
|
212
|
+
|
213
|
+
password: "foobar", password_confirmation: "foobar")
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
test "should be valid" do
|
218
|
+
|
219
|
+
assert @user.valid?
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
test "name should be present" do
|
226
|
+
|
227
|
+
@user.name = " "
|
228
|
+
|
229
|
+
assert_not @user.valid?
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
test "email should be present" do
|
236
|
+
|
237
|
+
@user.email = " "
|
238
|
+
|
239
|
+
assert_not @user.valid?
|
240
|
+
|
241
|
+
end
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
test "name should not be too long" do
|
246
|
+
|
247
|
+
@user.name = "a" * 51
|
248
|
+
|
249
|
+
assert_not @user.valid?
|
250
|
+
|
251
|
+
end
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
test "email should not be too long" do
|
256
|
+
|
257
|
+
@user.email = "a" * 244 + "@example.com"
|
258
|
+
|
259
|
+
assert_not @user.valid?
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
test "email validation should accept valid addresses" do
|
266
|
+
|
267
|
+
valid_addresses = %w[user@example.com USER@foo.COM A_US-ER@foo.bar.org
|
268
|
+
|
269
|
+
first.last@foo.jp alice+bob@baz.cn]
|
270
|
+
|
271
|
+
valid_addresses.each do |valid_address|
|
272
|
+
|
273
|
+
@user.email = valid_address
|
274
|
+
|
275
|
+
assert @user.valid?, "#{valid_address.inspect} should be valid"
|
276
|
+
|
277
|
+
end
|
278
|
+
|
279
|
+
end
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
test "email validation should reject invalid addresses" do
|
284
|
+
|
285
|
+
invalid_addresses = %w[user@example,com user_at_foo.org user.name@example.
|
286
|
+
|
287
|
+
foo@bar_baz.com foo@bar+baz.com]
|
288
|
+
|
289
|
+
invalid_addresses.each do |invalid_address|
|
290
|
+
|
291
|
+
@user.email = invalid_address
|
292
|
+
|
293
|
+
assert_not @user.valid?, "#{invalid_address.inspect} should be invalid"
|
294
|
+
|
295
|
+
end
|
296
|
+
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
test "email addresses should be unique" do
|
302
|
+
|
303
|
+
duplicate_user = @user.dup
|
304
|
+
|
305
|
+
duplicate_user.email = @user.email.upcase
|
306
|
+
|
307
|
+
@user.save
|
308
|
+
|
309
|
+
assert_not duplicate_user.valid?
|
310
|
+
|
311
|
+
end
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
test "email addresses should be saved as lower-case" do
|
316
|
+
|
317
|
+
mixed_case_email = "Foo@ExAMPle.CoM"
|
318
|
+
|
319
|
+
@user.email = mixed_case_email
|
320
|
+
|
321
|
+
@user.save
|
322
|
+
|
323
|
+
assert_equal mixed_case_email.downcase, @user.reload.email
|
324
|
+
|
325
|
+
end
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
test "password should be present (nonblank)" do
|
330
|
+
|
331
|
+
@user.password = @user.password_confirmation = " " * 6
|
332
|
+
|
333
|
+
assert_not @user.valid?
|
334
|
+
|
335
|
+
end
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
test "password should have a minimum length" do
|
340
|
+
|
341
|
+
@user.password = @user.password_confirmation = "a" * 5
|
342
|
+
|
343
|
+
assert_not @user.valid?
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
end
|
348
|
+
|
349
|
+
|
350
|
+
|
213
351
|
お手数ですが、ご回答よろしくお願い致します。
|
1
home.html.erbのソースコードを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -164,4 +164,50 @@
|
|
164
164
|
|
165
165
|
|
166
166
|
|
167
|
+
[home.html.erb]
|
168
|
+
|
169
|
+
<h1>Sample App</h1>
|
170
|
+
|
171
|
+
<p>
|
172
|
+
|
173
|
+
This is the home page for the
|
174
|
+
|
175
|
+
<a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
|
176
|
+
|
177
|
+
sample application.
|
178
|
+
|
179
|
+
</p>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
<div class="center jumbotron">
|
184
|
+
|
185
|
+
<h1>Welcome to the Sample App</h1>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
<h2>
|
190
|
+
|
191
|
+
This is the home page for the
|
192
|
+
|
193
|
+
<a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a>
|
194
|
+
|
195
|
+
sample application.
|
196
|
+
|
197
|
+
</h2>
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
<%= link_to "Sign up now!",signup_path, class: "btn btn-lg btn-primary" %>
|
202
|
+
|
203
|
+
</div>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
<%= link_to image_tag("rails.png", alt: "Rails logo"),
|
208
|
+
|
209
|
+
'http://rubyonrails.org/' %>
|
210
|
+
|
211
|
+
|
212
|
+
|
167
213
|
お手数ですが、ご回答よろしくお願い致します。
|