From 414a36184b60a30e80dc0d08bc07bfbbd9b919e1 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 9 May 2019 15:10:24 +0800 Subject: [PATCH] DEV: Prefer `create!` over `create` when not checking return value. --- db/fixtures/600_themes.rb | 12 +++++++----- lib/wizard/builder.rb | 7 ++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/db/fixtures/600_themes.rb b/db/fixtures/600_themes.rb index be8ee222a84..340f4506edc 100644 --- a/db/fixtures/600_themes.rb +++ b/db/fixtures/600_themes.rb @@ -7,13 +7,15 @@ if !Theme.exists? dark_scheme ||= ColorScheme.create_from_base(name: name, via_wizard: true, base_scheme_id: "Dark") name = I18n.t('color_schemes.dark_theme_name') - _dark_theme = Theme.create(name: name, user_id: -1, - color_scheme_id: dark_scheme.id, - user_selectable: true) + + _dark_theme = Theme.create!( + name: name, user_id: -1, + color_scheme_id: dark_scheme.id, + user_selectable: true + ) name = I18n.t('color_schemes.default_theme_name') - default_theme = Theme.create(name: name, user_id: -1, - user_selectable: true) + default_theme = Theme.create!(name: name, user_id: -1, user_selectable: true) default_theme.set_default! end diff --git a/lib/wizard/builder.rb b/lib/wizard/builder.rb index 994230f2da3..55e12bd70cd 100644 --- a/lib/wizard/builder.rb +++ b/lib/wizard/builder.rb @@ -167,7 +167,12 @@ class Wizard theme = themes.find(&:default?) theme ||= themes.first - theme ||= Theme.create(name: name, user_id: @wizard.user.id, color_scheme_id: scheme.id) + theme ||= Theme.create!( + name: name, + user_id: @wizard.user.id, + color_scheme_id: scheme.id + ) + theme.set_default! end end