Skip to content

Commit 2708091

Browse files
committed
test: published_atバリデーションの有効ケースを追加
1 parent 76202d8 commit 2708091

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

spec/models/news_spec.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@
4848

4949
describe 'published_at' do
5050
it '公開日時が空の場合は無効になる' do
51-
news.published_at = nil
52-
expect(news).not_to be_valid
53-
expect(news.errors[:published_at]).not_to be_empty
51+
news.published_at = nil
52+
expect(news).not_to be_valid
53+
expect(news.errors[:published_at]).not_to be_empty
54+
end
55+
56+
it '公開日時が正しく設定されている場合は有効になる' do
57+
news.published_at = Time.current
58+
expect(news).to be_valid
5459
end
5560
end
5661
end

0 commit comments

Comments
 (0)