From 394a569d5fa330eed8e542b71a705f6a2537b07c Mon Sep 17 00:00:00 2001 From: keiz1213 Date: Fri, 18 Nov 2022 02:21:04 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B7=E3=82=B9=E3=83=86=E3=83=A0=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92=E6=97=A5=E6=99=82=E3=82=92=E5=9B=BA?= =?UTF-8?q?=E5=AE=9A=E3=81=99=E3=82=8B=E6=96=B9=E6=B3=95=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/answer_test.rb | 10 ++++---- test/models/question_test.rb | 16 ++++++------- test/system/notification/questions_test.rb | 28 ++++++++++++++-------- 3 files changed, 31 insertions(+), 23 deletions(-) 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