Skip to content

Commit

Permalink
Merge pull request #15741 from nimrodshn/add_features_container_image…
Browse files Browse the repository at this point in the history
…_view

Add number of container using image
  • Loading branch information
agrare authored Aug 25, 2017
2 parents 12e27eb + 140d1aa commit f9f8fa4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/container_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ContainerImage < ApplicationRecord

acts_as_miq_taggable
virtual_column :display_registry, :type => :string
virtual_total :total_containers, :containers

after_create :raise_creation_event

Expand Down
1 change: 1 addition & 0 deletions spec/factories/containers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FactoryGirl.define do
factory :container do
sequence(:name) { |n| "container_#{seq_padded_for_sorting(n)}" }
end

factory :kubernetes_container,
Expand Down
13 changes: 13 additions & 0 deletions spec/models/container_image/container_image_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe ContainerImage do
it "counts containers" do
group = FactoryGirl.create(
:container_group,
:name => "group",
:container_node => FactoryGirl.create(:container_node, :name => "node")
)
expect(FactoryGirl.create(
:container_image,
:containers => FactoryGirl.create_list(:container, 2, :container_group => group)
).total_containers).to eq(2)
end
end

0 comments on commit f9f8fa4

Please sign in to comment.