-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
「近日開催のイベント」で、当日の開催時間を過ぎたイベントは非表示にする #8280
base: main
Are you sure you want to change the base?
Changes from all commits
8541147
1572fde
9c86dc2
7a5cc91
ed505b9
2b33e0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
class EventTest < ActiveSupport::TestCase | ||
test '.scheduled_on(date)' do | ||
travel_to Time.zone.local(2017, 4, 3, 10, 0, 0) do | ||
travel_to Time.zone.local(2017, 4, 3, 8, 0, 0) do | ||
today_date = Time.zone.today | ||
today_events_count = 2 | ||
today_events = Event.scheduled_on(today_date) | ||
|
@@ -135,4 +135,20 @@ class EventTest < ActiveSupport::TestCase | |
assert 994_018_171, ids | ||
assert 205_042_674, ids | ||
end | ||
|
||
test 'Events in progress today should be displayed' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. modelテストなので、メソッドのみをテストした方がよさそうです🙆 test '.scheduled_on_without_ended' do
# テストを記述する
end のような形になりそうですかね👀
は、システムテストで確認した方がまとまりがよいかと思います〜 システムテストが非常に重いため増やしたくない意図からmodelテストに書かれたかもしれないのですが、他のテストもメソッドをテストする書き方をしているので整合性の面でもシステムテストで書いた方が良い気がします🧐(折角fixtureでイベントも作成しているので) また、実際にシステムテストを書く際の補足ですが、私が過去にこのように指摘されたことがあるので、「表示されるorされない」のどちらかを確認するテストだけで十分だと思います👌 |
||
travel_to Time.zone.local(2024, 12, 1, 10, 0, 0) do | ||
today_date = Time.zone.today | ||
events = Event.scheduled_on_without_ended(today_date) | ||
assert_includes events, events(:event35) | ||
end | ||
end | ||
|
||
test 'Events that have already ended today should not be displayed' do | ||
travel_to Time.zone.local(2024, 12, 1, 10, 0, 0) do | ||
today_date = Time.zone.today | ||
events = Event.scheduled_on_without_ended(today_date) | ||
assert_not_includes events, events(:event36) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,4 +154,20 @@ class RegularEventTest < ActiveSupport::TestCase | |
assert_equal 157, participated_regular_events.count | ||
end | ||
end | ||
|
||
test 'Regular event in progress today should be displayed' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここのモデルテストもevent_testのコメントと同様です🙆 |
||
travel_to Time.zone.local(2024, 12, 1, 10, 0, 0) do | ||
today_date = Time.zone.today | ||
regular_event = RegularEvent.scheduled_on_without_ended(today_date) | ||
assert_includes regular_event, regular_events(:regular_event36) | ||
end | ||
end | ||
|
||
test 'Regular event that have already ended today should not be displayed' do | ||
travel_to Time.zone.local(2024, 12, 1, 10, 0, 0) do | ||
today_date = Time.zone.today | ||
regular_event = RegularEvent.scheduled_on_without_ended(today_date) | ||
assert_not_includes regular_event, regular_events(:regular_event37) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
レビューのために質問させてください🙏
scheduled_on_without_ended
をEvent
クラスとRegularEvent
クラスの両方で定義している意図って何でしょうか?👀それぞれのイベント(特別イベント・定期イベント)の違いで混乱しており、補足があればご教示いただけると幸いです🙇