1010 @dojo1 = Dojo . create! (
1111 name : 'CoderDojo テスト1' ,
1212 email : 'test1@example.com' ,
13+ description : 'テスト用Dojo1の説明' ,
14+ tags : [ 'Scratch' , 'Python' ] ,
15+ url : 'https://test1.coderdojo.jp' ,
1316 created_at : Time . zone . local ( 2020 , 3 , 1 ) ,
1417 prefecture_id : 13 ,
1518 is_active : false ,
1922 # 2021年から活動開始、現在も活動中
2023 @dojo2 = Dojo . create! (
2124 name : 'CoderDojo テスト2' ,
22- email : 'test2@example.com' ,
25+ email : 'test2@example.com' ,
26+ description : 'テスト用Dojo2の説明' ,
27+ tags : [ 'Scratch' ] ,
28+ url : 'https://test2.coderdojo.jp' ,
2329 created_at : Time . zone . local ( 2021 , 1 , 1 ) ,
2430 prefecture_id : 13 ,
2531 is_active : true ,
3036 @dojo3 = Dojo . create! (
3137 name : 'CoderDojo テスト3' ,
3238 email : 'test3@example.com' ,
39+ description : 'テスト用Dojo3の説明' ,
40+ tags : [ 'JavaScript' ] ,
41+ url : 'https://test3.coderdojo.jp' ,
3342 created_at : Time . zone . local ( 2019 , 1 , 1 ) ,
3443 prefecture_id : 13 ,
3544 is_active : false ,
5867 let ( :period ) { Date . new ( 2020 , 1 , 1 ) ..Date . new ( 2023 , 12 , 31 ) }
5968 let ( :stat ) { Stat . new ( period ) }
6069
61- context 'inactivated_at カラムが存在する場合' do
62- it '過去の活動履歴を含めた統計を生成する' do
63- allow ( Dojo ) . to receive ( :column_names ) . and_return ( [ 'id' , 'name' , 'inactivated_at' ] )
64- expect ( stat ) . to receive ( :annual_dojos_with_historical_data )
65-
66- stat . annual_dojos_chart
67- end
68- end
69-
70- context 'inactivated_at カラムが存在しない場合' do
71- it '従来通りアクティブなDojoのみを集計する' do
72- allow ( Dojo ) . to receive ( :column_names ) . and_return ( [ 'id' , 'name' ] )
73- expect ( Dojo . active ) . to receive ( :annual_count ) . with ( period )
74-
75- stat . annual_dojos_chart
76- end
70+ it '過去の活動履歴を含めた統計グラフを生成する' do
71+ # annual_dojos_with_historical_dataが呼ばれることを確認し、ダミーデータを返す
72+ expect ( stat ) . to receive ( :annual_dojos_with_historical_data ) . and_return ( {
73+ '2020' => 1 ,
74+ '2021' => 2 ,
75+ '2022' => 1 ,
76+ '2023' => 1
77+ } )
78+
79+ result = stat . annual_dojos_chart
80+ expect ( result ) . to be_a ( LazyHighCharts ::HighChart )
7781 end
7882 end
7983end
0 commit comments