Sha256: 23bc4f46b5aab4a7b5cfce3ae5f2d3daa78635d9330e92e98ec1ef58341a2d7d
Contents?: true
Size: 765 Bytes
Versions: 3
Compression:
Stored size: 765 Bytes
Contents
require 'spec_helper' describe Mongoid::Report do let(:klass) { Model } it 'allows to save options per report and attached model' do 2.times { klass.create!(field1: 1) } report_klass = Class.new do include Mongoid::Report report 'example' do attach_to Model do columns :'new-field' => ->(context, row, options) { row[options[:mapping]['field3'].to_s] } mapping :'field3' => :field1 column :field1, :'new-field' end end end report = report_klass.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 end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongoid-report-0.2.2 | spec/mongoid/report/set_spec.rb |
mongoid-report-0.2.1 | spec/mongoid/report/set_spec.rb |
mongoid-report-0.2.0 | spec/mongoid/report/set_spec.rb |