Skip to content

Commit

Permalink
Refactor ensure_nondefault method for chargeback rate
Browse files Browse the repository at this point in the history
https://bugzilla.redhat.com/show_bug.cgi?id=1552260

Refactor ensure_nondefault method so that a
new default? method is created and improved.
  • Loading branch information
Hilda Stastna committed Mar 22, 2018
1 parent d885f8c commit f2349af
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/chargeback_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def assigned_tags?
get_assigned_tos[:tags].present?
end

def default?
super || description == 'Default Container Image Rate'
end

###########################################################

private
Expand All @@ -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
Expand Down

0 comments on commit f2349af

Please sign in to comment.