Skip to content

Commit

Permalink
add number of container using image
Browse files Browse the repository at this point in the history
some refactoring

refactored containers count

minor refactoring

minor refactoring

refactored tests

refactored tests

refactored tests

added file by mistake

removed random file
  • Loading branch information
nimrodshn committed Aug 10, 2017
1 parent 45156af commit 140d1aa
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 140d1aa

Please sign in to comment.