Skip to content

Commit

Permalink
Specs:tagged cloud volumes as datastores
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Dec 12, 2017
1 parent 14213fa commit 2db33a4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/models/mixins/assignment_mixin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@
# too ingrained in AR - has many, acts_as_miq_taggable, ...
let(:test_class) { MiqAlertSet }

describe '#get_assigned_for_target' do
context 'searching for ChargebackRate' do
let(:test_class) { ChargebackRate }
let(:vm) { FactoryGirl.create(:vm_openstack) }
let(:hardware) { FactoryGirl.create(:hardware, :vm_or_template_id => vm.id) }
let(:cloud_volume) { FactoryGirl.create(:cloud_volume, :hardwares => [hardware]) }
let(:chargeback_rate) { FactoryGirl.create(:chargeback_rate, :rate_type => 'Storage') }

before do
ct1 = ctag("environment", "test1")
chargeback_rate.assign_to_tags([ct1], "storage")
cloud_volume.tag_add('environment/test1', :ns => '/managed')
end

it 'returns rates based on tagged cloud volume' do
result = test_class.get_assigned_for_target(vm, :parents => [cloud_volume])
expect(result).to match_array([chargeback_rate])
end
end
end

describe '#assignments' do
it "finds no assignments" do
expect(test_class.assignments).to eq({})
Expand Down

0 comments on commit 2db33a4

Please sign in to comment.