File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 124
124
end
125
125
end
126
126
end
127
+
128
+ it 'ensures all dojos with inactivated_at have is_active column' do
129
+ yaml_data = Dojo . load_attributes_from_yaml
130
+ dojos_with_inactivated_at = yaml_data . select { |dojo | dojo [ 'inactivated_at' ] . present? }
131
+
132
+ dojos_with_inactivated_at . each do |dojo |
133
+ # inactivated_atがあるDojoは必ずis_activeカラムを持つべき
134
+ # (再活性化されたDojoはis_active: trueの可能性があるため、値は問わない)
135
+ unless dojo . key? ( 'is_active' )
136
+ fail "ID: #{ dojo [ 'id' ] } (#{ dojo [ 'name' ] } ) はinactivated_atを持っていますが、is_activeカラムがありません"
137
+ end
138
+ end
139
+
140
+ # 統計情報として表示
141
+ if dojos_with_inactivated_at . any?
142
+ reactivated_count = dojos_with_inactivated_at . count { |d | d [ 'is_active' ] == true }
143
+ inactive_count = dojos_with_inactivated_at . count { |d | d [ 'is_active' ] == false }
144
+
145
+ # テスト出力には表示されないが、デバッグ時に有用
146
+ # puts "inactivated_atを持つDojo数: #{dojos_with_inactivated_at.count}"
147
+ # puts " - 現在非アクティブ: #{inactive_count}"
148
+ # puts " - 再活性化済み: #{reactivated_count}"
149
+
150
+ expect ( dojos_with_inactivated_at . count ) . to eq ( inactive_count + reactivated_count )
151
+ end
152
+ end
127
153
end
128
154
129
155
# inactivated_at カラムの基本的なテスト
You can’t perform that action at this time.
0 commit comments