diff --git a/test/models/answer_test.rb b/test/models/answer_test.rb index 3f1a52a4101..f9ce9acdcec 100644 --- a/test/models/answer_test.rb +++ b/test/models/answer_test.rb @@ -10,16 +10,16 @@ class AnswerTest < ActiveSupport::TestCase title: '一週間前の質問', description: 'テスト', user: questioner, - created_at: "2022-10-31", - updated_at: "2022-10-31", - published_at: "2022-10-31" + created_at: '2022-10-31', + updated_at: '2022-10-31', + published_at: '2022-10-31' ) answer = Answer.create!( description: '最後の回答', user: answerer, question: question, - created_at: "2022-10-31", - updated_at: "2022-10-31" + created_at: '2022-10-31', + updated_at: '2022-10-31' ) travel_to Time.zone.local(2022, 11, 6, 0, 0, 0) do assert_not answer.certain_period_has_passed? diff --git a/test/models/question_test.rb b/test/models/question_test.rb index 51682c1724d..280b649f6e9 100644 --- a/test/models/question_test.rb +++ b/test/models/question_test.rb @@ -10,27 +10,27 @@ class QuestionTest < ActiveSupport::TestCase title: 'テストの質問', description: 'テスト', user: questioner, - created_at: "2022-10-31", - updated_at: "2022-10-31", - published_at: "2022-10-31" + created_at: '2022-10-31', + updated_at: '2022-10-31', + published_at: '2022-10-31' ) first_answer = Answer.create!( description: '最初の回答', user: answerer, question: question, - created_at: "2022-11-01", - updated_at: "2022-11-01" + created_at: '2022-11-01', + updated_at: '2022-11-01' ) last_answer = Answer.create!( description: '最後の回答', user: answerer, question: question, - created_at: "2022-11-02", - updated_at: "2022-11-02" + created_at: '2022-11-02', + updated_at: '2022-11-02' ) - first_answer.update!(updated_at: "2022-11-03") + first_answer.update!(updated_at: '2022-11-03') travel_to Time.zone.local(2022, 11, 4, 0, 0, 0) do assert_not_equal question.last_answer, first_answer diff --git a/test/system/notification/questions_test.rb b/test/system/notification/questions_test.rb index 413a2c7c0e2..5fb97b7df26 100644 --- a/test/system/notification/questions_test.rb +++ b/test/system/notification/questions_test.rb @@ -287,25 +287,33 @@ class Notification::QuestionsTest < ApplicationSystemTestCase questioner = users(:kimura) answerer = users(:komagata) question = Question.create!( - title: '一週間前の質問', + title: 'テストの質問', description: 'テスト', user: questioner, - created_at: Time.current - 1.week, - updated_at: Time.current - 1.week, - published_at: Time.current - 1.week + created_at: '2022-10-31', + updated_at: '2022-10-31', + published_at: '2022-10-31' ) Answer.create!( description: '最後の回答', user: answerer, question: question, - created_at: Time.current - 1.week, - updated_at: Time.current - 1.week + created_at: '2022-10-31', + updated_at: '2022-10-31' ) - visit_with_auth '/scheduler/daily', 'kimura' - visit '/notifications' - within first('.card-list-item.is-unread') do - assert_text 'Q&A「一週間前の質問」のベストアンサーがまだ選ばれていません。' + travel_to Time.zone.local(2022, 11, 6, 0, 0, 0) do + visit_with_auth '/scheduler/daily', 'kimura' + visit '/notifications' + + assert_no_text 'Q&A「テストの質問」のベストアンサーがまだ選ばれていません。' + end + + travel_to Time.zone.local(2022, 11, 7, 0, 0, 0) do + visit_with_auth '/scheduler/daily', 'kimura' + visit '/notifications' + + assert_text 'Q&A「テストの質問」のベストアンサーがまだ選ばれていません。' end end end