Sha256: 90b0046cb4d2516013befc45883331b3acfd13bbe28dfbf88c73d7d31a86059b
Contents?: true
Size: 1.14 KB
Versions: 4
Compression:
Stored size: 1.14 KB
Contents
require File.join(File.dirname(__FILE__), '..', 'spec_helper') describe Saulabs::Reportable do describe 'for inherited models' do before(:all) do User.create!(:login => 'test 1', :created_at => Time.now - 1.days, :profile_visits => 1) User.create!(:login => 'test 2', :created_at => Time.now - 2.days, :profile_visits => 2) SpecialUser.create!(:login => 'test 3', :created_at => Time.now - 2.days, :profile_visits => 3) end it 'should include all data when invoked on the base model class' do result = User.registrations_report.to_a result[9][1].should == 1.0 result[8][1].should == 2.0 end it 'should include only data for instances of the inherited model when invoked on the inherited model class' do result = SpecialUser.registrations_report.to_a result[9][1].should == 0.0 result[8][1].should == 1.0 end after(:all) do User.destroy_all SpecialUser.destroy_all end end after do Saulabs::Reportable::ReportCache.destroy_all end end class User < ActiveRecord::Base reportable :registrations, :limit => 10 end class SpecialUser < User; end
Version data entries
4 entries across 4 versions & 1 rubygems