Skip to content

Commit

Permalink
Merge pull request ManageIQ#18225 from kbrock/virtual_attribute_reports
Browse files Browse the repository at this point in the history
Virtual attribute reports
  • Loading branch information
Fryguy authored Dec 14, 2018
2 parents 096dcc5 + ab722e3 commit 4591309
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/models/miq_ae_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class MiqAeClass < ApplicationRecord
validates_format_of :name, :with => /\A[\w.-]+\z/i,
:message => N_("may contain only alphanumeric and _ . - characters")

virtual_attribute :fqname, :string

def self.find_by_fqname(fqname, args = {})
ns, name = parse_fqname(fqname)
find_by_namespace_and_name(ns, name, args)
Expand Down
1 change: 1 addition & 0 deletions app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Provider < ApplicationRecord
:url,
:to => :default_endpoint

virtual_column :url, :type => :string, :uses => :endpoints
virtual_column :verify_ssl, :type => :integer
virtual_column :security_protocol, :type => :string

Expand Down
27 changes: 20 additions & 7 deletions spec/models/container_image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,26 @@
expect(image.full_name).to eq("registry/repo/name@id")
end

it "#display_registry" do
image = ContainerImage.new(:name => "fedora")
expect(image.display_registry).to eq("Unknown image source")

reg = ContainerImageRegistry.new(:name => "docker.io", :host => "docker.io", :port => "1234")
image.container_image_registry = reg
expect(image.display_registry).to eq("docker.io:1234")
context "#display_registry" do
it "finds unknown with unknown name" do
image = ContainerImage.new(:name => "fedora")
expect(image.display_registry).to eq("Unknown image source")
end

it "localizes for unknown" do
I18n.with_locale(:es) do
image = ContainerImage.new(:name => "fedora")
reg = image.display_registry
expect(reg).to eq("Fuente de imagen desconocida")
end
end

it "finds name with valid name" do
image = ContainerImage.new(:name => "fedora")
reg = ContainerImageRegistry.new(:name => "docker.io", :host => "docker.io", :port => "1234")
image.container_image_registry = reg
expect(image.display_registry).to eq("docker.io:1234")
end
end

it "#docker_id" do
Expand Down
7 changes: 7 additions & 0 deletions spec/models/manageiq/providers/base_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
expect(described_class.default_blacklisted_event_names).to eq(%w(ev1 ev2))
end
end

context ".url" do
it 'delegates to the provider' do
mgr = FactoryGirl.create(:configuration_manager_foreman, :provider => FactoryGirl.create(:provider_foreman, :url => 'example.com'))
expect(mgr.url).to eq('example.com')
end
end
end

0 comments on commit 4591309

Please sign in to comment.