| Empty conditions should serialize to an emtpy string, not to to '[]'. - reporta… | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit 32488a35a713dbd7e83777333f856ff0744185e5 | |
| parent b1a65f43cd95f6d4b7dd56e1deb25214dc21c071 | |
| Author: Dieter Komendera <[email protected]> | |
| Date: Wed, 1 Feb 2012 11:22:13 +0100 | |
| Empty conditions should serialize to an emtpy string, not to to '[]'. | |
| Diffstat: | |
| M lib/saulabs/reportable/report_cach… | 2 +- | |
| M spec/classes/report_cache_spec.rb | 11 ++++++++--- | |
| 2 files changed, 9 insertions(+), 4 deletions(-) | |
| --- | |
| diff --git a/lib/saulabs/reportable/report_cache.rb b/lib/saulabs/reportable/re… | |
| @@ -123,7 +123,7 @@ module Saulabs | |
| elsif conditions.is_a?(Hash) && conditions.any? | |
| conditions.map.sort{|x,y|x.to_s<=>y.to_s}.flatten.join | |
| else | |
| - conditions.to_s | |
| + conditions.empty? ? '' : conditions.to_s | |
| end | |
| end | |
| diff --git a/spec/classes/report_cache_spec.rb b/spec/classes/report_cache_spec… | |
| @@ -214,7 +214,7 @@ describe Saulabs::Reportable::ReportCache do | |
| @report.name.to_s, | |
| @report.options[:grouping].identifier.to_s, | |
| @report.aggregation.to_s, | |
| - @report.options[:conditions].to_s, | |
| + '', | |
| Saulabs::Reportable::ReportingPeriod.first(@report.options[:grouping… | |
| ], | |
| :limit => 10, | |
| @@ -235,7 +235,7 @@ describe Saulabs::Reportable::ReportCache do | |
| @report.name.to_s, | |
| @report.options[:grouping].identifier.to_s, | |
| @report.aggregation.to_s, | |
| - @report.options[:conditions].to_s, | |
| + '', | |
| Saulabs::Reportable::ReportingPeriod.first(@report.options[:grouping… | |
| Saulabs::Reportable::ReportingPeriod.new(@report.options[:grouping],… | |
| ], | |
| @@ -258,7 +258,7 @@ describe Saulabs::Reportable::ReportCache do | |
| @report.name.to_s, | |
| grouping.identifier.to_s, | |
| @report.aggregation.to_s, | |
| - @report.options[:conditions].to_s, | |
| + '', | |
| Saulabs::Reportable::ReportingPeriod.first(grouping, 10).date_time | |
| ], | |
| :limit => 10, | |
| @@ -279,6 +279,11 @@ describe Saulabs::Reportable::ReportCache do | |
| describe '.serialize_conditions' do | |
| + it 'should serialize empty conditions correctly' do | |
| + result = Saulabs::Reportable::ReportCache.send(:serialize_conditions, []) | |
| + result.should eql('') | |
| + end | |
| + | |
| it 'should serialize a conditions array correctly' do | |
| result = Saulabs::Reportable::ReportCache.send(:serialize_conditions, ['… | |
| result.should eql('active = ? AND gender = ?truemale') |