Skip to content

Commit

Permalink
Merge pull request #16350 from lpichler/add_custom_attributes_back_to…
Browse files Browse the repository at this point in the history
…_chargeback

Add back listing of custom attributes in chargeback
  • Loading branch information
gtanzillo authored Nov 7, 2017
2 parents 380b878 + 86f1048 commit 6f1588d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/miq_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,11 @@ def self.reporting_available_fields(model, interval = nil)
c.last.ends_with?(*allowed_suffixes)
end
td = if TAG_CLASSES.include?(cb_model)
tag_details(model, {}) + _custom_details_for(cb_model, {})
tag_details(model, {})
else
[]
end
md + td
md + td + _custom_details_for(cb_model, {})
else
model_details(model, :include_model => false, :include_tags => true)
end
Expand Down
27 changes: 27 additions & 0 deletions spec/lib/miq_expression_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
describe MiqExpression do
describe '#reporting_available_fields' do
let(:vm) { FactoryGirl.create(:vm) }
let!(:custom_attribute) { FactoryGirl.create(:custom_attribute, :name => 'my_attribute_1', :resource => vm) }
let(:extra_fields) do
%w(start_date
end_date
interval_name
display_range
entity
tag_name
label_name
id
vm_id
vm_name)
end

it 'lists custom attributes in ChargebackVm' do
displayed_columms = described_class.reporting_available_fields('ChargebackVm').map(&:second)
expected_columns = (ChargebackVm.attribute_names - extra_fields).map { |x| "ChargebackVm-#{x}" }

CustomAttribute.all.each do |custom_attribute|
expected_columns.push("#{vm.class}-#{CustomAttributeMixin::CUSTOM_ATTRIBUTES_PREFIX}#{custom_attribute.name}")
end
expect(displayed_columms).to match_array(expected_columns)
end
end

describe "#valid?" do
it "returns true for a valid flat expression" do
expression = described_class.new("=" => {"field" => "Vm-name", "value" => "foo"})
Expand Down

0 comments on commit 6f1588d

Please sign in to comment.