From f2349afab08e41ecfdd9ccbed01d85c0b073ed88 Mon Sep 17 00:00:00 2001 From: Hilda Stastna Date: Thu, 22 Mar 2018 17:53:33 +0100 Subject: [PATCH] Refactor ensure_nondefault method for chargeback rate https://bugzilla.redhat.com/show_bug.cgi?id=1552260 Refactor ensure_nondefault method so that a new default? method is created and improved. --- app/models/chargeback_rate.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/chargeback_rate.rb b/app/models/chargeback_rate.rb index f327fe760f5..2c2d9ef6097 100644 --- a/app/models/chargeback_rate.rb +++ b/app/models/chargeback_rate.rb @@ -132,6 +132,10 @@ def assigned_tags? get_assigned_tos[:tags].present? end + def default? + super || description == 'Default Container Image Rate' + end + ########################################################### private @@ -150,7 +154,7 @@ def ensure_unassigned end def ensure_nondefault - if default? || description == 'Default Container Image Rate' + if default? errors.add(:rate, "default rate cannot be deleted") throw :abort end