Sha256: e743a4f41f323b6d8a34b16e6a89afc169c7dbb828b41a87cd48af8a9541ea7a
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
require 'spec_helper' describe Mongoid::Report::Collection do let(:klass) { Model } describe '.rows' do it 'use returns aggregated rows' do report_klass = Class.new do include Mongoid::Report def self.name ; 'report-klass' ; end attach_to Model do column :field1 end end 3.times { klass.create!(field1: 1) } example = report_klass.new report = example .aggregate_for('report-klass', 'models') .all rows = report.rows expect(rows.size).to eq(1) expect(rows[0]['field1']).to eq(3) end end describe '.headers' do it 'returns columns for showing in the reports' do report_klass = Class.new do include Mongoid::Report def self.name ; 'report-klass' ; end attach_to Model do column :field1, :field3, :field2 end end report = report_klass.new report = report .aggregate_for('report-klass', 'models') .all expect(report.headers).to eq(["field1", "field3", "field2"]) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongoid-report-0.2.2 | spec/mongoid/report/collection_spec.rb |
mongoid-report-0.2.1 | spec/mongoid/report/collection_spec.rb |
mongoid-report-0.2.0 | spec/mongoid/report/collection_spec.rb |