Skip to content

Commit

Permalink
Merge pull request #17188 from hstastna/Default_Container_Image_Rate_…
Browse files Browse the repository at this point in the history
…edit

Refactor ensure_nondefault method for chargeback rate
  • Loading branch information
martinpovolny authored Apr 6, 2018
2 parents c7d1580 + f2349af commit 60e46a2
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 60e46a2

Please sign in to comment.