Skip to content

Commit

Permalink
Fail explicitly when MAS creation fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooli Tayer committed Jul 6, 2017
1 parent ed6f7be commit 01626ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/miq_alert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def add_status_post_evaluate(target, result, event)
status.event_ems_ref = ems_ref unless ems_ref.blank?
status.resolved = resolved
status.evaluated_on = Time.now.utc
status.save
status.save!
miq_alert_statuses << status
end

Expand Down
9 changes: 9 additions & 0 deletions spec/models/miq_alert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@
expect(mas.severity).to eq(nil)
end

it "raises an exception when miq_alert_status creation fails" do
expect do
@alert.evaluate(
[@vm.class.base_class.name, @vm.id],
:ems_event => FactoryGirl.create(:ems_event, :full_data => {:severity => 'undefined'})
)
end.to raise_error(ActiveRecord::RecordInvalid)
end

it "miq_alert_status.url = ems_event.full_data.url if present" do
@alert.evaluate(
[@vm.class.base_class.name, @vm.id],
Expand Down

0 comments on commit 01626ae

Please sign in to comment.