File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ def index
9
9
# 有効な年の範囲をチェック
10
10
unless year . between? ( 2012 , Date . current . year )
11
11
flash [ :alert ] = "指定された年(#{ year } )は無効です。2012年から#{ Date . current . year } 年の間で指定してください。"
12
- return redirect_to dojos_path
12
+ return redirect_to dojos_path ( anchor : 'table' )
13
13
end
14
14
15
15
@selected_year = year
@@ -20,7 +20,7 @@ def index
20
20
@page_title = "#{ @selected_year } 年末時点のCoderDojo一覧"
21
21
rescue ArgumentError
22
22
flash [ :alert ] = "無効な年が指定されました"
23
- return redirect_to dojos_path
23
+ return redirect_to dojos_path ( anchor : 'table' )
24
24
end
25
25
else
26
26
# yearパラメータなしの場合(既存の実装そのまま)
Original file line number Diff line number Diff line change 33
33
年次データのフィルタリング
34
34
</ h3 >
35
35
36
- <% if @selected_year %>
36
+ <% if flash [ :alert ] %>
37
+ < div style ="padding: 10px; background: #f8d7da; border: 1px solid #f5c6cb; border-radius: 4px; margin-bottom: 15px; color: #721c24; ">
38
+ <%= flash [ :alert ] %>
39
+ </ div >
40
+ <% elsif @selected_year %>
37
41
< div style ="padding: 10px; background: #d1ecf1; border: 1px solid #bee5eb; border-radius: 4px; margin-bottom: 15px; ">
38
42
< strong > <%= @selected_year %> 年末時点</ strong > のアクティブな道場を表示中
39
43
</ div >
Original file line number Diff line number Diff line change 54
54
55
55
it "rejects years before 2012" do
56
56
get dojos_path ( year : 2011 , format : :json )
57
- expect ( response ) . to redirect_to ( dojos_path )
57
+ expect ( response ) . to redirect_to ( dojos_path ( anchor : 'table' ) )
58
58
expect ( flash [ :alert ] ) . to include ( "2012年から" )
59
59
end
60
60
61
61
it "rejects years after current year" do
62
62
future_year = Date . current . year + 1
63
63
get dojos_path ( year : future_year , format : :json )
64
- expect ( response ) . to redirect_to ( dojos_path )
64
+ expect ( response ) . to redirect_to ( dojos_path ( anchor : 'table' ) )
65
65
expect ( flash [ :alert ] ) . to include ( "無効です" )
66
66
end
67
67
68
68
it "handles invalid year strings" do
69
69
get dojos_path ( year : "invalid" , format : :json )
70
- expect ( response ) . to redirect_to ( dojos_path )
70
+ expect ( response ) . to redirect_to ( dojos_path ( anchor : 'table' ) )
71
71
expect ( flash [ :alert ] ) . to include ( "無効" )
72
72
end
73
73
end
You can’t perform that action at this time.
0 commit comments