Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miq server zone description #17662

Merged
merged 2 commits into from
Jul 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/models/miq_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class MiqServer < ApplicationRecord
acts_as_miq_taggable
include RelationshipMixin

alias_attribute :description, :name

belongs_to :vm, :inverse_of => :miq_server
belongs_to :zone
has_many :messages, :as => :handler, :class_name => 'MiqQueue'
Expand All @@ -29,14 +31,12 @@ class MiqServer < ApplicationRecord
before_destroy :validate_is_deleteable
after_destroy :destroy_linked_events_queue

virtual_column :zone_description, :type => :string

default_value_for(:name, "EVM")
default_value_for(:zone) { Zone.default_zone }

scope :active_miq_servers, -> { where(:status => STATUSES_ACTIVE) }
scope :with_zone_id, ->(zone_id) { where(:zone_id => zone_id) }
delegate :description, :to => :zone, :prefix => true
virtual_delegate :description, :to => :zone, :prefix => true

STATUS_STARTING = 'starting'.freeze
STATUS_STARTED = 'started'.freeze
Expand Down
14 changes: 14 additions & 0 deletions spec/models/miq_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,18 @@
expect(described_class.new(:status => "stopped").active?).to be_falsey
end
end

describe "#zone_description" do
it "delegates to zone" do
_, miq_server, zone = EvmSpecHelper.create_guid_miq_server_zone
expect(miq_server.zone_description).to eq(zone.description)
end
end

describe "#description" do
it "doesnt blowup" do
s = described_class.new(:name => "name")
expect(s.description).to eq(s.name)
end
end
end