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

Add number of container using image #15741

Merged
merged 1 commit into from
Aug 25, 2017
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
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