Skip to content

Commit

Permalink
Validate presence of feed on middleware servers
Browse files Browse the repository at this point in the history
Hawkular's MiddlewareServer relies on feed not being nil.
Adding a `validates_presence` to be sure.

And fixing the factory to always create a feed - to remove the need to always provide `feed` when mocking to prevent errors from `CGI.unescape`.
  • Loading branch information
himdel committed Jun 16, 2017
1 parent 471de63 commit cd9b525
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/middleware_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class MiddlewareServer < ApplicationRecord
serialize :properties
acts_as_miq_taggable

validates :feed, :presence => true

def properties
super || {}
end
Expand Down
1 change: 1 addition & 0 deletions spec/factories/middleware_servers.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FactoryGirl.define do
factory :middleware_server do
sequence(:name) { |n| "middleware_server_#{seq_padded_for_sorting(n)}" }
sequence(:feed) { |n| "feed_#{n}" }
end

factory :hawkular_middleware_server,
Expand Down

0 comments on commit cd9b525

Please sign in to comment.