Added failing spec for duplicate key sql error I'm getting. - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 8791b1e44c216af03bcf53805cdfb642d49b20e0
(DIR) parent 1bee300b16dc0dcad74c6a22ec01f5946856a4ed
(HTM) Author: Myron Marston <myron.marston@gmail.com>
Date: Mon, 4 May 2009 10:34:23 +0800
Added failing spec for duplicate key sql error I'm getting.
Signed-off-by: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Diffstat:
M spec/boot.rb | 3 +++
M spec/classes/report_spec.rb | 14 ++++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/spec/boot.rb b/spec/boot.rb
@@ -12,6 +12,9 @@ $:.unshift "#{plugin_root}/lib"
RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + '/../')
Rails::Initializer.run(:set_load_path)
Rails::Initializer.run(:set_autoload_paths)
+Rails::Initializer.run(:initialize_time_zone) do |config|
+ config.time_zone = 'Pacific Time (US & Canada)'
+end
require File.join(File.dirname(__FILE__), '/../init.rb')
(DIR) diff --git a/spec/classes/report_spec.rb b/spec/classes/report_spec.rb
@@ -81,6 +81,16 @@ describe Simplabs::ReportsAsSparkline::Report do
describe 'when :end_date is specified' do
+ it 'should not raise a SQL duplicate key error after multiple runs' do
+ @report = Simplabs::ReportsAsSparkline::Report.new(User, :registrations,
+ :limit => 2,
+ :grouping => grouping,
+ :end_date => Date.yesterday.to_datetime
+ )
+ @report.run
+ lambda { @report.run }.should_not raise_error
+ end
+
describe 'the returned result' do
before do
@@ -428,11 +438,11 @@ describe Simplabs::ReportsAsSparkline::Report do
it 'should return conditions for date_column >= begin_at when no custom conditions and a begin_at are specified' do
@report.send(:setup_conditions, @begin_at, nil).should == ["#{@created_at_column_clause} >= ?", @begin_at]
end
-
+
it 'should return conditions for date_column <= end_at when no custom conditions and a end_at are specified' do
@report.send(:setup_conditions, nil, @end_at).should == ["#{@created_at_column_clause} <= ?", @end_at]
end
-
+
it 'should raise an argument error when neither begin_at or end_at are specified' do
lambda {@report.send(:setup_conditions, nil, nil)}.should raise_error(ArgumentError)
end