spec/mongoid/report/set_spec.rb in mongoid-report-0.1.7 vs spec/mongoid/report/set_spec.rb in mongoid-report-0.1.9
- old
+ new
@@ -9,20 +9,22 @@
Report = Class.new do
include Mongoid::Report
report 'example' do
attach_to Model do
- columns :'new-field' => ->(context, row, options) { row[context.mapping('example-models')['field3'].to_s] }
+ columns :'new-field' => ->(context, row, options) { row[options[:mapping]['field3'].to_s] }
mapping :'field3' => :field1
column :field1, :'new-field'
end
end
end
- example = Report.new
- rows = example.aggregate_for('example-models')
- rows = rows.all
+ report = Report.new
+ report = report.aggregate_for('example-models')
+ report = report.all
+
+ rows = report.rows
expect(rows.size).to eq(1)
expect(rows[0]['field1']).to eq(2)
expect(rows[0]['new-field']).to eq(2)
end