refactored Report#read_data - reportable - Unnamed repository; edit this file '… | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit d48fcc5ad3dad4227a805cfe89c586958752e355 | |
parent a52fc4fb93ca12d16bc1f019de403d141e0c63a2 | |
Author: Marco Otte-Witte <[email protected]> | |
Date: Thu, 15 Jan 2009 12:24:14 +0100 | |
refactored Report#read_data | |
Diffstat: | |
M lib/kvlr/reports_as_sparkline/repo… | 10 +++++----- | |
M spec/classes/report_spec.rb | 4 ++-- | |
2 files changed, 7 insertions(+), 7 deletions(-) | |
--- | |
diff --git a/lib/kvlr/reports_as_sparkline/report.rb b/lib/kvlr/reports_as_spar… | |
@@ -47,19 +47,19 @@ module Kvlr #:nodoc: | |
options.reverse_merge!(@options) | |
options[:grouping] = Grouping.new(options[:grouping]) unless options[:… | |
ReportCache.process(self, options, !custom_conditions) do |begin_at| | |
- read_data(begin_at, options[:grouping], options[:conditions]) | |
+ read_data(begin_at, options) | |
end | |
end | |
private | |
- def read_data(begin_at, grouping, conditions = []) #:nodoc: | |
- conditions = setup_conditions(begin_at, conditions) | |
+ def read_data(begin_at, options) #:nodoc: | |
+ conditions = setup_conditions(begin_at, options[:conditions]) | |
@klass.send(@aggregation, | |
@value_column, | |
:conditions => conditions, | |
- :group => grouping.to_sql(@date_column), | |
- :order => "#{grouping.to_sql(@date_column)} ASC" | |
+ :group => options[:grouping].to_sql(@date_column), | |
+ :order => "#{options[:grouping].to_sql(@date_column)} ASC" | |
) | |
end | |
diff --git a/spec/classes/report_spec.rb b/spec/classes/report_spec.rb | |
@@ -134,13 +134,13 @@ describe Kvlr::ReportsAsSparkline::Report do | |
@report = Kvlr::ReportsAsSparkline::Report.new(User, :registrations, :ag… | |
User.should_receive(:count).once.and_return([]) | |
- @report.send(:read_data, Time.now, @report.options[:grouping]) | |
+ @report.send(:read_data, Time.now, { :grouping => @report.options[:group… | |
end | |
it 'should setup the conditions' do | |
@report.should_receive(:setup_conditions).once.and_return([]) | |
- @report.send(:read_data, Time.now, @report.options[:grouping]) | |
+ @report.send(:read_data, Time.now, { :grouping => @report.options[:group… | |
end | |
end |