removed some specs that put expectation on internel stuff, making every minor change to the code break the specs - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit bbec0de4cda48704427b6978a4d8080edf5d3a2d
(DIR) parent 1d937aa19e87ee6eaa80c8683bc8cf98df0d008b
(HTM) Author: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Date: Wed, 29 Apr 2009 10:35:17 +0200
removed some specs that put expectation on internel stuff, making every minor change to the code break the specs
Diffstat:
M spec/classes/cumulated_report_spec… | 35 -------------------------------
M spec/classes/report_cache_spec.rb | 16 ----------------
M spec/classes/report_spec.rb | 43 ------------------------------
3 files changed, 0 insertions(+), 94 deletions(-)
---
(DIR) diff --git a/spec/classes/cumulated_report_spec.rb b/spec/classes/cumulated_report_spec.rb
@@ -26,41 +26,6 @@ describe Simplabs::ReportsAsSparkline::CumulatedReport do
@report.run.length.should == 11
end
- describe "a month report with a limit of 2" do
- before(:all) do
- User.delete_all
- User.create!(:login => 'test 1', :created_at => Time.now, :profile_visits => 2)
- User.create!(:login => 'test 2', :created_at => Time.now - 1.month, :profile_visits => 1)
- User.create!(:login => 'test 3', :created_at => Time.now - 3.month, :profile_visits => 2)
- User.create!(:login => 'test 4', :created_at => Time.now - 3.month, :profile_visits => 3)
- User.create!(:login => 'test 5', :created_at => Time.now - 4.month, :profile_visits => 4)
-
- @report2 = Simplabs::ReportsAsSparkline::CumulatedReport.new(User, :cumulated_registrations,
- :grouping => :month,
- :limit => 2
- )
-
- @one_month_ago = Date.new(DateTime.now.year, DateTime.now.month, 1) - 1.month
- @two_months_ago = Date.new(DateTime.now.year, DateTime.now.month, 1) - 2.months
- @three_months_ago = Date.new(DateTime.now.year, DateTime.now.month, 1) - 3.months
- end
-
- it 'should include the counts from before the first period in the cumulated totals' do
- @report2.run.should == [[@two_months_ago, 3.0], [@one_month_ago, 4.0]]
- end
-
- it 'should return the initial count for initial_cumulative_value' do
- options = @report2.send(:options_for_run, {})
- tomorrow = 1.day.from_now
- @report2.send(:initial_cumulative_value, tomorrow, options).should == 5
- @report2.send(:initial_cumulative_value, tomorrow - 1.month, options).should == 4
- @report2.send(:initial_cumulative_value, tomorrow - 2.months, options).should == 3
- @report2.send(:initial_cumulative_value, tomorrow - 3.months, options).should == 3
- @report2.send(:initial_cumulative_value, tomorrow - 4.months, options).should == 1
- @report2.send(:initial_cumulative_value, tomorrow - 5.months, options).should == 0
- end
- end
-
for grouping in [:hour, :day, :week, :month] do
describe "for grouping #{grouping.to_s}" do
(DIR) diff --git a/spec/classes/report_cache_spec.rb b/spec/classes/report_cache_spec.rb
@@ -155,16 +155,6 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
Simplabs::ReportsAsSparkline::ReportCache.process(@report, { :limit => 10, :grouping => grouping }) { [] }
end
- it 'should prepare the results before it returns them' do
- new_after_cache_data = []
- new_before_cache_data = []
- cached_data = []
- Simplabs::ReportsAsSparkline::ReportCache.stub!(:find).and_return(cached_data)
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:prepare_result).once.with(new_before_cache_data, new_after_cache_data, cached_data, @report, @report.options, true)
-
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @report.options) { new_after_cache_data }
- end
-
it 'should yield the first reporting period if the cache is empty' do
Simplabs::ReportsAsSparkline::ReportCache.process(@report, @report.options) do |begin_at, end_at|
begin_at.should == Simplabs::ReportsAsSparkline::ReportingPeriod.first(@report.options[:grouping], 10).date_time
@@ -204,12 +194,6 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
Simplabs::ReportsAsSparkline::ReportCache.stub!(:build_cached_data).and_return(@cached)
end
- it 'should convert the date strings from the newly read data to reporting periods' do
- Simplabs::ReportsAsSparkline::ReportingPeriod.should_receive(:from_db_string).once.with(@report.options[:grouping], @new_after_cache_data[0][0]).and_return(Simplabs::ReportsAsSparkline::ReportingPeriod.new(@report.options[:grouping]))
-
- Simplabs::ReportsAsSparkline::ReportCache.send(:prepare_result, [], @new_after_cache_data, [], @report, @report.options)
- end
-
it 'should create :limit instances of Simplabs::ReportsAsSparkline::ReportCache with value 0.0 if no new data has been read and nothing was cached' do
Simplabs::ReportsAsSparkline::ReportCache.should_receive(:build_cached_data).exactly(10).times.with(
@report,
(DIR) diff --git a/spec/classes/report_spec.rb b/spec/classes/report_spec.rb
@@ -68,49 +68,6 @@ describe Simplabs::ReportsAsSparkline::Report do
@report.run.length.should == 11
end
- describe "a month report with a limit of 2" do
- before(:all) do
- User.create!(:login => 'test 1', :created_at => Time.now, :profile_visits => 2)
- User.create!(:login => 'test 2', :created_at => Time.now - 1.month, :profile_visits => 1)
- User.create!(:login => 'test 3', :created_at => Time.now - 3.month, :profile_visits => 2)
- User.create!(:login => 'test 4', :created_at => Time.now - 3.month, :profile_visits => 3)
-
- @report2 = Simplabs::ReportsAsSparkline::Report.new(User, :registrations,
- :grouping => :month,
- :limit => 2
- )
-
- @one_month_ago = Date.new(DateTime.now.year, DateTime.now.month, 1) - 1.month
- @two_months_ago = Date.new(DateTime.now.year, DateTime.now.month, 1) - 2.months
- @three_months_ago = Date.new(DateTime.now.year, DateTime.now.month, 1) - 3.months
- end
-
- it "should return data for the last two months when there is no end date" do
- @report2.run.should == [[@two_months_ago, 0.0], [@one_month_ago, 1.0]]
- end
-
- it "should go back further into history on a second report run if the limit is higher" do
- @report2.run(:limit => 2)
- @report2.run(:limit => 3).should == [[@three_months_ago, 2.0], [@two_months_ago.to_time, 0.0], [@one_month_ago.to_time, 1.0]]
- end
-
- it "should return data for two months prior to the end date" do
- @report2.run(:end_date => 1.month.ago).should == [[@three_months_ago, 2.0], [@two_months_ago, 0.0]]
- end
-
- it "should return data for the two months prior to the end date, and also the end date's month when live_date = true" do
- @report2.run(:end_date => 1.month.ago, :live_data => true).should == [[@three_months_ago, 2.0], [@two_months_ago, 0.0], [@one_month_ago, 1.0]]
- end
-
- it "should return data for the two months prior to the end date, and also the end date's month when live_date = true, when getting the data from the cache" do
- # run it once to get from the database...
- @report2.run(:end_date => 1.month.ago, :live_data => true)
-
- # and then again from the cache...
- @report2.run(:end_date => 1.month.ago, :live_data => true).should == [[@three_months_ago.to_time, 2.0], [@two_months_ago.to_time, 0.0], [@one_month_ago, 1.0]]
- end
- end
-
for grouping in [:hour, :day, :week, :month] do
describe "for grouping #{grouping.to_s}" do