From b2df032ca7f056e304307ddb9122d784943ab545 Mon Sep 17 00:00:00 2001 From: Robert Pankowecki Date: Sun, 7 Jun 2009 19:12:54 +0200 Subject: [PATCH] Resolving compatibility issues with REE 1.8.6 --- app/helpers/shadow_helper.rb | 84 ++-- app/models/graph_builder.rb | 2 +- app/views/exchanges/index.html.erb | 8 +- app/views/exchanges/list.html.erb | 10 +- .../transfers/_kind_of_transfer.html.erb | 7 +- config/environment.rb | 4 +- config/preinitializer.rb | 15 + lib/array_extensions.rb | 49 +++ lib/enumerable_extensions.rb | 18 + lib/workers/report_worker.rb | 2 +- test/test_helper.rb | 4 +- test/unit/date_test.rb | 416 +++++++++--------- test/unit/flow_report_test.rb | 4 +- test/unit/goal_test.rb | 32 +- test/unit/goal_worker_test.rb | 40 +- test/unit/multiple_category_report_test.rb | 6 +- test/unit/report_test.rb | 10 +- test/unit/share_report_test.rb | 4 +- test/unit/system_category_test.rb | 2 +- test/unit/user_test.rb | 12 +- test/unit/value_report_test.rb | 12 +- 21 files changed, 415 insertions(+), 326 deletions(-) create mode 100644 lib/array_extensions.rb create mode 100644 lib/enumerable_extensions.rb diff --git a/app/helpers/shadow_helper.rb b/app/helpers/shadow_helper.rb index 1c14105..378aa8e 100644 --- a/app/helpers/shadow_helper.rb +++ b/app/helpers/shadow_helper.rb @@ -1,6 +1,57 @@ module ShadowHelper + class ShadowOptions < Hash + def initialize + self[:top] = ShadowLmr.new + self[:middle] = ShadowLmr.new + self[:bottom] = ShadowLmr.new + end + + def top + self[:top] + end + + def middle + self[:middle] + end + + def bottom + self[:bottom] + end + end + + class ShadowLmr < Hash + def initialize + self[:left] = ShadowText.new + self[:middle] = ShadowText.new + self[:right] = ShadowText.new + end + + def left + self[:left] + end + + def middle + self[:middle] + end + def right + self[:right] + end + end + + class ShadowText < Hash + def initialize + self[:text] = String.new + end + def text + self[:text] + end + + def text=(val) + self[:text]=val + end + end # Creates a table that includes elements created in block and # surrounds them with inner shadow # @@ -77,39 +128,6 @@ def shadow(*args, &block) inner_or_outer_shadow(:outer, *args, &block) end - - # - # Helper for creating options for methods to create shadows. - # You can use it as last paramter in *shadow* methods - # - # in ERB template: - # <% opt = shadow_options do |opt| %> - # <% opt[:top][:middle].call :style => 'height:100px;' do %> - #
THIS TEXT WILL BE ON TOP MIDDLE SHADOW which will be 100px height
- # <% end %> - # <% end %> - # - # opt => {:top => {:middle => {:style => 'height:100px;', :text => "
THIS TEXT WILL BE ON TOP MIDDLE SHADOW
" } } } - def shadow_options() - raise 'No block given' unless block_given? - output_hash = {} - call_hash = {} - [:top, :middle, :bottom]. each do |vertical| - call_hash[vertical] = {} - output_hash[vertical] = {} - [:left, :middle, :right]. each do |horizontal| - output_hash[vertical][horizontal] = {:text =>nil} - call_hash[vertical][horizontal] = Proc.new do |arg, &block| - output_hash[vertical][horizontal][:text] = capture(&block) - output_hash[vertical][horizontal].merge!(arg) if arg - end - end - end - - yield call_hash - output_hash - end - private # inner_or_outer_shadow(:inner, '80grey', :left, :right ... element-options, table-shadow-boxes-content-hash do ... end diff --git a/app/models/graph_builder.rb b/app/models/graph_builder.rb index 5146dd1..3443064 100644 --- a/app/models/graph_builder.rb +++ b/app/models/graph_builder.rb @@ -192,7 +192,7 @@ def self.generate_share_report(report) OpenFlashChart::PieValue.new(val[:value].value(cur), get_label.call(val)) end graph.tooltip = "#percent#
#label#
Wartość: #val##{cur.symbol} z #{sum}#{cur.symbol}" - if values.count > 15 + if values.size > 15 graph.set_no_labels() end graph.colours = COLORS diff --git a/app/views/exchanges/index.html.erb b/app/views/exchanges/index.html.erb index 82f921b..aa9fa8a 100644 --- a/app/views/exchanges/index.html.erb +++ b/app/views/exchanges/index.html.erb @@ -14,12 +14,8 @@ -<% options = shadow_options do |opt| %> - <% opt[:top][:middle].call do %> - <%= tab [[:new, 'Nowy']], :exchange -%> - <% end %> -<% end %> - +<% options = ShadowHelper::ShadowOptions.new %> +<% options.top.middle.text = tab([[:new, 'Nowy']], :exchange) %> <% light_shadow({:class => 'long'}, {}, options) do %> <% tab_container(:exchange) do %> diff --git a/app/views/exchanges/list.html.erb b/app/views/exchanges/list.html.erb index cfdb75f..95308ef 100644 --- a/app/views/exchanges/list.html.erb +++ b/app/views/exchanges/list.html.erb @@ -57,13 +57,9 @@ - - <% options = shadow_options do |opt| %> - <% opt[:top][:middle].call do %> - <%= tab [[:new, 'Nowy']], :exchange -%> - <% end %> - <% end %> - + <% options = ShadowHelper::ShadowOptions.new %> + <% options.top.middle.text = tab([[:new, 'Nowy']], :exchange) %> + <% light_shadow({:class => 'long'}, {}, options) do %> <% tab_container(:exchange) do %> diff --git a/app/views/transfers/_kind_of_transfer.html.erb b/app/views/transfers/_kind_of_transfer.html.erb index 3214795..3f05bf1 100644 --- a/app/views/transfers/_kind_of_transfer.html.erb +++ b/app/views/transfers/_kind_of_transfer.html.erb @@ -7,11 +7,8 @@ <% all.shift if @category.nil? %> <% show = all.first %> -<% options = shadow_options do |opt| %> - <% opt[:top][:middle].call do %> - <%= tab all, :transfer %> - <% end %> -<% end %> +<% options = ShadowHelper::ShadowOptions.new %> +<% options.top.middle.text = tab(all, :transfer) %> <% light_shadow({:class => 'long'}, {}, options) do %> <% tab_container(:transfer) do %> diff --git a/config/environment.rb b/config/environment.rb index 080acc0..dac9afd 100755 --- a/config/environment.rb +++ b/config/environment.rb @@ -11,7 +11,6 @@ # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') - Rails::Configuration.class_eval do include FileSiteKeys #defined in preinitializer end @@ -113,7 +112,8 @@ config.after_initialize do class Date include DateExtensions - end + end + end end diff --git a/config/preinitializer.rb b/config/preinitializer.rb index 7f7f552..f112902 100644 --- a/config/preinitializer.rb +++ b/config/preinitializer.rb @@ -48,4 +48,19 @@ def apply_file_keys end end +end + + + +require File.join(File.dirname(__FILE__), '..', 'lib', 'array_extensions.rb') +require File.join(File.dirname(__FILE__), '..', 'lib', 'enumerable_extensions.rb') + +if RUBY_VERSION == "1.8.6" + class Array + include ArrayExtensions + include EnumerableExtensions #already includes Enumerable + end + module Enumerable + include EnumerableExtensions + end end \ No newline at end of file diff --git a/lib/array_extensions.rb b/lib/array_extensions.rb new file mode 100644 index 0000000..1f8c610 --- /dev/null +++ b/lib/array_extensions.rb @@ -0,0 +1,49 @@ +module ArrayExtensions + def shuffle + array = self.clone + n = array.size + while n > 1 do + n-=1 + k = Kernel.rand(n+1) + tmp = array[k] + array[k] = array[n] + array[n] = tmp + end + array + end #unless method_defined?(:shuffle) + + + def shuffle! + n = self.size + while n > 1 do + n-=1 + k = Kernel.rand(n+1) + tmp = self[k] + self[k] = self[n] + self[n] = tmp + end + + end #unless method_defined?(:shuffle!) + + def comb(n = size) + if size < n or n < 0 + elsif n == 0 + yield([]) + else + self[1..-1].comb(n) do |x| + yield(x) + end + self[1..-1].comb(n - 1) do |x| + yield([first] + x) + end + end + end + + + def combination(n = size) + array = [] + comb(n) {|c| array << c} + array + end + +end \ No newline at end of file diff --git a/lib/enumerable_extensions.rb b/lib/enumerable_extensions.rb new file mode 100644 index 0000000..69c6328 --- /dev/null +++ b/lib/enumerable_extensions.rb @@ -0,0 +1,18 @@ +module EnumerableExtensions + + def max_by(&proc) + max_obj = nil + max_val = nil + is_first = true + each do |obj| + val = proc.call(obj) + if is_first || val > max_val + max_obj = obj + max_val = val + end + is_first = false + end + max_obj + end + +end \ No newline at end of file diff --git a/lib/workers/report_worker.rb b/lib/workers/report_worker.rb index 748a347..b9c32b0 100644 --- a/lib/workers/report_worker.rb +++ b/lib/workers/report_worker.rb @@ -16,7 +16,7 @@ def delete_temporary_reports non_deleted_reports << r end end - if reports.count > 0 + if reports.size > 0 logger.info "Deleted #{deleted_reports} reports from #{reports.count}" logger.info "Problems deleting #{non_deleted_reports}" if deleted_reports < reports.count else diff --git a/test/test_helper.rb b/test/test_helper.rb index 4f1f6c6..5157803 100755 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -280,7 +280,7 @@ def create_share_report(user, save = true) r.user = user r.category = user.categories.first r.report_view_type = :pie - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.depth = 5 r.max_categories_values_count = 6 r.name = "Testowy raport" @@ -294,7 +294,7 @@ def create_flow_report(user) r.user = user add_category_options user, r r.report_view_type = :text - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.name = "Testowy raport" r.save! r diff --git a/test/unit/date_test.rb b/test/unit/date_test.rb index d90f1aa..c5a34fb 100644 --- a/test/unit/date_test.rb +++ b/test/unit/date_test.rb @@ -3,7 +3,7 @@ class DateTest < ActiveSupport::TestCase def test_split_into_days dates = Date.split_period(:day, 5.day.ago.to_date, Date.today) - assert_equal 6, dates.count + assert_equal 6, dates.size assert_equal [ [5.day.ago.to_date,5.day.ago.to_date], [4.day.ago.to_date,4.day.ago.to_date], @@ -15,7 +15,7 @@ def test_split_into_days dates dates = Date.split_period(:day, Date.yesterday, Date.today) - assert_equal 2, dates.count + assert_equal 2, dates.size assert_equal [ [Date.yesterday,Date.yesterday], [Date.today,Date.today] @@ -23,7 +23,7 @@ def test_split_into_days dates dates = Date.split_period(:day, Date.today, Date.today) - assert_equal 1, dates.count + assert_equal 1, dates.size assert_equal [ [Date.today,Date.today] ], @@ -32,28 +32,28 @@ def test_split_into_days end def test_split_into_weeks - dates = Date.split_period(:week, "02.02.2009".to_date, "02.02.2009".to_date) - assert_equal 1, dates.count - assert_equal [["02.02.2009".to_date,"02.02.2009".to_date]], dates + dates = Date.split_period(:week, "02-02-2009".to_date, "02-02-2009".to_date) + assert_equal 1, dates.size + assert_equal [["02-02-2009".to_date,"02-02-2009".to_date]], dates - dates = Date.split_period(:week, "02.02.2009".to_date, "27.02.2009".to_date) - assert_equal 4, dates.count + dates = Date.split_period(:week, "02-02-2009".to_date, "27-02-2009".to_date) + assert_equal 4, dates.size assert_equal [ - ["02.02.2009".to_date, "08.02.2009".to_date], - ["09.02.2009".to_date, "15.02.2009".to_date], - ["16.02.2009".to_date, "22.02.2009".to_date], - ["23.02.2009".to_date, "27.02.2009".to_date] + ["02-02-2009".to_date, "08-02-2009".to_date], + ["09-02-2009".to_date, "15-02-2009".to_date], + ["16-02-2009".to_date, "22-02-2009".to_date], + ["23-02-2009".to_date, "27-02-2009".to_date] ], dates - dates = Date.split_period(:week, "04.02.2009".to_date, "27.02.2009".to_date) - assert_equal 4, dates.count + dates = Date.split_period(:week, "04-02-2009".to_date, "27-02-2009".to_date) + assert_equal 4, dates.size assert_equal [ - ["04.02.2009".to_date, "08.02.2009".to_date], - ["09.02.2009".to_date, "15.02.2009".to_date], - ["16.02.2009".to_date, "22.02.2009".to_date], - ["23.02.2009".to_date, "27.02.2009".to_date] + ["04-02-2009".to_date, "08-02-2009".to_date], + ["09-02-2009".to_date, "15-02-2009".to_date], + ["16-02-2009".to_date, "22-02-2009".to_date], + ["23-02-2009".to_date, "27-02-2009".to_date] ], dates @@ -62,137 +62,137 @@ def test_split_into_weeks end def test_split_into_months - dates = Date.split_period(:month, "01.02.2009".to_date , "05.02.2009".to_date) - assert_equal 1, dates.count - assert_equal "01.02.2009".to_date, dates[0][0] - assert_equal "05.02.2009".to_date, dates[0][1] - - dates = Date.split_period(:month, "01.02.2009".to_date , "01.02.2009".to_date) - assert_equal 1, dates.count - assert_equal "01.02.2009".to_date, dates[0][0] - assert_equal "01.02.2009".to_date, dates[0][1] - - dates = Date.split_period(:month, "31.01.2009".to_date , "01.02.2009".to_date) - assert_equal 2, dates.count - assert_equal "31.01.2009".to_date, dates[0][0] - assert_equal "31.01.2009".to_date, dates[0][1] - assert_equal "01.02.2009".to_date, dates[1][0] - assert_equal "01.02.2009".to_date, dates[1][1] - - - dates = Date.split_period(:month, "04.02.2009".to_date , "18.02.2009".to_date) - assert_equal 1, dates.count - assert_equal "04.02.2009".to_date, dates[0][0] - assert_equal "18.02.2009".to_date, dates[0][1] - - dates = Date.split_period(:month, "13.01.2009".to_date , "18.02.2009".to_date) - assert_equal 2, dates.count - assert_equal "13.01.2009".to_date, dates[0][0] - assert_equal "31.01.2009".to_date, dates[0][1] - assert_equal "01.02.2009".to_date, dates[1][0] - assert_equal "18.02.2009".to_date, dates[1][1] - - dates = Date.split_period(:month, "01.01.2009".to_date , "28.02.2009".to_date) - assert_equal 2, dates.count - assert_equal "01.01.2009".to_date, dates[0][0] - assert_equal "31.01.2009".to_date, dates[0][1] - assert_equal "01.02.2009".to_date, dates[1][0] - assert_equal "28.02.2009".to_date, dates[1][1] - - - dates = Date.split_period(:month, "01.01.2009".to_date , "15.04.2009".to_date) - assert_equal 4, dates.count - assert_equal "01.01.2009".to_date, dates[0][0] - assert_equal "31.01.2009".to_date, dates[0][1] - assert_equal "01.02.2009".to_date, dates[1][0] - assert_equal "28.02.2009".to_date, dates[1][1] - assert_equal "01.03.2009".to_date, dates[2][0] - assert_equal "31.03.2009".to_date, dates[2][1] - assert_equal "01.04.2009".to_date, dates[3][0] - assert_equal "15.04.2009".to_date, dates[3][1] + dates = Date.split_period(:month, "01-02-2009".to_date , "05-02-2009".to_date) + assert_equal 1, dates.size + assert_equal "01-02-2009".to_date, dates[0][0] + assert_equal "05-02-2009".to_date, dates[0][1] + + dates = Date.split_period(:month, "01-02-2009".to_date , "01-02-2009".to_date) + assert_equal 1, dates.size + assert_equal "01-02-2009".to_date, dates[0][0] + assert_equal "01-02-2009".to_date, dates[0][1] + + dates = Date.split_period(:month, "31-01-2009".to_date , "01-02-2009".to_date) + assert_equal 2, dates.size + assert_equal "31-01-2009".to_date, dates[0][0] + assert_equal "31-01-2009".to_date, dates[0][1] + assert_equal "01-02-2009".to_date, dates[1][0] + assert_equal "01-02-2009".to_date, dates[1][1] + + + dates = Date.split_period(:month, "04-02-2009".to_date , "18-02-2009".to_date) + assert_equal 1, dates.size + assert_equal "04-02-2009".to_date, dates[0][0] + assert_equal "18-02-2009".to_date, dates[0][1] + + dates = Date.split_period(:month, "13-01-2009".to_date , "18-02-2009".to_date) + assert_equal 2, dates.size + assert_equal "13-01-2009".to_date, dates[0][0] + assert_equal "31-01-2009".to_date, dates[0][1] + assert_equal "01-02-2009".to_date, dates[1][0] + assert_equal "18-02-2009".to_date, dates[1][1] + + dates = Date.split_period(:month, "01-01-2009".to_date , "28-02-2009".to_date) + assert_equal 2, dates.size + assert_equal "01-01-2009".to_date, dates[0][0] + assert_equal "31-01-2009".to_date, dates[0][1] + assert_equal "01-02-2009".to_date, dates[1][0] + assert_equal "28-02-2009".to_date, dates[1][1] + + + dates = Date.split_period(:month, "01-01-2009".to_date , "15-04-2009".to_date) + assert_equal 4, dates.size + assert_equal "01-01-2009".to_date, dates[0][0] + assert_equal "31-01-2009".to_date, dates[0][1] + assert_equal "01-02-2009".to_date, dates[1][0] + assert_equal "28-02-2009".to_date, dates[1][1] + assert_equal "01-03-2009".to_date, dates[2][0] + assert_equal "31-03-2009".to_date, dates[2][1] + assert_equal "01-04-2009".to_date, dates[3][0] + assert_equal "15-04-2009".to_date, dates[3][1] end def test_split_into_quarters - dates = Date.split_period(:quarter, "01.01.2009".to_date, "31.03.2009".to_date) - assert_equal 1, dates.count - assert_equal "01.01.2009".to_date, dates[0][0] - assert_equal "31.03.2009".to_date, dates[0][1] + dates = Date.split_period(:quarter, "01-01-2009".to_date, "31-03-2009".to_date) + assert_equal 1, dates.size + assert_equal "01-01-2009".to_date, dates[0][0] + assert_equal "31-03-2009".to_date, dates[0][1] - dates = Date.split_period(:quarter, "04.01.2009".to_date, "31.03.2009".to_date) - assert_equal 1, dates.count - assert_equal "04.01.2009".to_date, dates[0][0] - assert_equal "31.03.2009".to_date, dates[0][1] + dates = Date.split_period(:quarter, "04-01-2009".to_date, "31-03-2009".to_date) + assert_equal 1, dates.size + assert_equal "04-01-2009".to_date, dates[0][0] + assert_equal "31-03-2009".to_date, dates[0][1] - dates = Date.split_period(:quarter, "01.01.2009".to_date, "25.03.2009".to_date) - assert_equal 1, dates.count - assert_equal "01.01.2009".to_date, dates[0][0] - assert_equal "25.03.2009".to_date, dates[0][1] + dates = Date.split_period(:quarter, "01-01-2009".to_date, "25-03-2009".to_date) + assert_equal 1, dates.size + assert_equal "01-01-2009".to_date, dates[0][0] + assert_equal "25-03-2009".to_date, dates[0][1] - dates = Date.split_period(:quarter, "05.02.2009".to_date, "25.03.2009".to_date) - assert_equal 1, dates.count - assert_equal "05.02.2009".to_date, dates[0][0] - assert_equal "25.03.2009".to_date, dates[0][1] + dates = Date.split_period(:quarter, "05-02-2009".to_date, "25-03-2009".to_date) + assert_equal 1, dates.size + assert_equal "05-02-2009".to_date, dates[0][0] + assert_equal "25-03-2009".to_date, dates[0][1] - dates = Date.split_period(:quarter, "05.02.2009".to_date, "05.02.2009".to_date) - assert_equal 1, dates.count - assert_equal "05.02.2009".to_date, dates[0][0] - assert_equal "05.02.2009".to_date, dates[0][1] + dates = Date.split_period(:quarter, "05-02-2009".to_date, "05-02-2009".to_date) + assert_equal 1, dates.size + assert_equal "05-02-2009".to_date, dates[0][0] + assert_equal "05-02-2009".to_date, dates[0][1] - dates = Date.split_period(:quarter, "05.02.2008".to_date, "05.02.2009".to_date) - assert_equal 5, dates.count - assert_equal "05.02.2008".to_date, dates[0][0] - assert_equal "31.03.2008".to_date, dates[0][1] + dates = Date.split_period(:quarter, "05-02-2008".to_date, "05-02-2009".to_date) + assert_equal 5, dates.size + assert_equal "05-02-2008".to_date, dates[0][0] + assert_equal "31-03-2008".to_date, dates[0][1] - assert_equal "01.04.2008".to_date, dates[1][0] - assert_equal "30.06.2008".to_date, dates[1][1] + assert_equal "01-04-2008".to_date, dates[1][0] + assert_equal "30-06-2008".to_date, dates[1][1] - assert_equal "01.07.2008".to_date, dates[2][0] - assert_equal "30.09.2008".to_date, dates[2][1] + assert_equal "01-07-2008".to_date, dates[2][0] + assert_equal "30-09-2008".to_date, dates[2][1] - assert_equal "01.10.2008".to_date, dates[3][0] - assert_equal "31.12.2008".to_date, dates[3][1] + assert_equal "01-10-2008".to_date, dates[3][0] + assert_equal "31-12-2008".to_date, dates[3][1] - assert_equal "01.01.2009".to_date, dates[4][0] - assert_equal "05.02.2009".to_date, dates[4][1] + assert_equal "01-01-2009".to_date, dates[4][0] + assert_equal "05-02-2009".to_date, dates[4][1] end def test_split_into_years - dates = Date.split_period(:year, "05.02.2009".to_date, "05.02.2009".to_date) - assert_equal 1, dates.count - assert_equal "05.02.2009".to_date, dates[0][0] - assert_equal "05.02.2009".to_date, dates[0][1] + dates = Date.split_period(:year, "05-02-2009".to_date, "05-02-2009".to_date) + assert_equal 1, dates.size + assert_equal "05-02-2009".to_date, dates[0][0] + assert_equal "05-02-2009".to_date, dates[0][1] - dates = Date.split_period(:year, "05.03.2009".to_date, "05.06.2009".to_date) - assert_equal 1, dates.count - assert_equal "05.03.2009".to_date, dates[0][0] - assert_equal "05.06.2009".to_date, dates[0][1] + dates = Date.split_period(:year, "05-03-2009".to_date, "05-06-2009".to_date) + assert_equal 1, dates.size + assert_equal "05-03-2009".to_date, dates[0][0] + assert_equal "05-06-2009".to_date, dates[0][1] - dates = Date.split_period(:year, "01.01.2009".to_date, "31.12.2009".to_date) - assert_equal 1, dates.count - assert_equal "01.01.2009".to_date, dates[0][0] - assert_equal "31.12.2009".to_date, dates[0][1] + dates = Date.split_period(:year, "01-01-2009".to_date, "31-12-2009".to_date) + assert_equal 1, dates.size + assert_equal "01-01-2009".to_date, dates[0][0] + assert_equal "31-12-2009".to_date, dates[0][1] - dates = Date.split_period(:year, "23.01.2009".to_date, "14.02.2010".to_date) - assert_equal 2, dates.count - assert_equal "23.01.2009".to_date, dates[0][0] - assert_equal "31.12.2009".to_date, dates[0][1] + dates = Date.split_period(:year, "23-01-2009".to_date, "14-02-2010".to_date) + assert_equal 2, dates.size + assert_equal "23-01-2009".to_date, dates[0][0] + assert_equal "31-12-2009".to_date, dates[0][1] - assert_equal "01.01.2010".to_date, dates[1][0] - assert_equal "14.02.2010".to_date, dates[1][1] + assert_equal "01-01-2010".to_date, dates[1][0] + assert_equal "14-02-2010".to_date, dates[1][1] - dates = Date.split_period(:year, "23.01.2008".to_date, "14.02.2010".to_date) - assert_equal 3, dates.count - assert_equal "23.01.2008".to_date, dates[0][0] - assert_equal "31.12.2008".to_date, dates[0][1] + dates = Date.split_period(:year, "23-01-2008".to_date, "14-02-2010".to_date) + assert_equal 3, dates.size + assert_equal "23-01-2008".to_date, dates[0][0] + assert_equal "31-12-2008".to_date, dates[0][1] - assert_equal "01.01.2009".to_date, dates[1][0] - assert_equal "31.12.2009".to_date, dates[1][1] + assert_equal "01-01-2009".to_date, dates[1][0] + assert_equal "31-12-2009".to_date, dates[1][1] - assert_equal "01.01.2010".to_date, dates[2][0] - assert_equal "14.02.2010".to_date, dates[2][1] + assert_equal "01-01-2010".to_date, dates[2][0] + assert_equal "14-02-2010".to_date, dates[2][1] end @@ -204,49 +204,49 @@ def test_split_into_none def test_next_quarter - assert_equal "01.04.2009".to_date, "01.01.2009".to_date.next_quarter - assert_equal "01.04.2009".to_date, "01.02.2009".to_date.next_quarter - assert_equal "01.04.2009".to_date, "11.02.2009".to_date.next_quarter - assert_equal "01.04.2009".to_date, "31.03.2009".to_date.next_quarter - assert_equal "01.07.2009".to_date, "01.04.2009".to_date.next_quarter - assert_equal "01.07.2009".to_date, "12.05.2009".to_date.next_quarter - assert_equal "01.10.2009".to_date, "12.07.2009".to_date.next_quarter - assert_equal "01.01.2010".to_date, "14.10.2009".to_date.next_quarter + assert_equal "01-04-2009".to_date, "01-01-2009".to_date.next_quarter + assert_equal "01-04-2009".to_date, "01-02-2009".to_date.next_quarter + assert_equal "01-04-2009".to_date, "11-02-2009".to_date.next_quarter + assert_equal "01-04-2009".to_date, "31-03-2009".to_date.next_quarter + assert_equal "01-07-2009".to_date, "01-04-2009".to_date.next_quarter + assert_equal "01-07-2009".to_date, "12-05-2009".to_date.next_quarter + assert_equal "01-10-2009".to_date, "12-07-2009".to_date.next_quarter + assert_equal "01-01-2010".to_date, "14-10-2009".to_date.next_quarter end def test_last_quarter - assert_equal "01.10.2008".to_date, "01.01.2009".to_date.last_quarter - assert_equal "01.10.2008".to_date, "01.02.2009".to_date.last_quarter - assert_equal "01.10.2008".to_date, "11.02.2009".to_date.last_quarter - assert_equal "01.10.2008".to_date, "31.03.2009".to_date.last_quarter - assert_equal "01.01.2009".to_date, "01.04.2009".to_date.last_quarter - assert_equal "01.01.2009".to_date, "12.05.2009".to_date.last_quarter - assert_equal "01.04.2009".to_date, "12.07.2009".to_date.last_quarter - assert_equal "01.07.2009".to_date, "14.10.2009".to_date.last_quarter + assert_equal "01-10-2008".to_date, "01-01-2009".to_date.last_quarter + assert_equal "01-10-2008".to_date, "01-02-2009".to_date.last_quarter + assert_equal "01-10-2008".to_date, "11-02-2009".to_date.last_quarter + assert_equal "01-10-2008".to_date, "31-03-2009".to_date.last_quarter + assert_equal "01-01-2009".to_date, "01-04-2009".to_date.last_quarter + assert_equal "01-01-2009".to_date, "12-05-2009".to_date.last_quarter + assert_equal "01-04-2009".to_date, "12-07-2009".to_date.last_quarter + assert_equal "01-07-2009".to_date, "14-10-2009".to_date.last_quarter end #this test doesnt test model, but rather method in test helper;) #its really important ! def test_forced_date_and_time - forced_date = '03.01.2001' + forced_date = '03-01-2001' with_dates(forced_date) do assert_equal forced_date.to_date, Date.today assert_equal forced_date.to_time, Time.now - assert_equal '02.01.2001'.to_date, Date.yesterday - assert_equal '01.01.2001'.to_time, 2.days.ago + assert_equal '02-01-2001'.to_date, Date.yesterday + assert_equal '01-01-2001'.to_time, 2.days.ago end assert_not_equal forced_date.to_date, Date.today assert_not_equal forced_date.to_time, Time.now - assert_not_equal '02.01.2001'.to_date, Date.yesterday - assert_not_equal '01.01.2001'.to_time, 2.days.ago + assert_not_equal '02-01-2001'.to_date, Date.yesterday + assert_not_equal '01-01-2001'.to_time, 2.days.ago end def test_calculate - forced_date = '16.07.2008' #sroda, 3 tydzień lipca, III kwartał, 29 tydzień 2008 + forced_date = '16-07-2008' #sroda, 3 tydzień lipca, III kwartał, 29 tydzień 2008 with_dates(forced_date) do assert_actual_periods @@ -256,18 +256,18 @@ def test_calculate end def test_shift - date = '16.07.2008'.to_date #sroda, 3 tydzień lipca, III kwartał, 29 tydzień 2008 - - assert_equal '16.07.2008'.to_date, date.shift(:DAY) - assert_equal '22.07.2008'.to_date, date.shift(:WEEK) - assert_equal '15.08.2008'.to_date, date.shift(:MONTH) - assert_equal '15.10.2008'.to_date, date.shift(:QUARTER) - assert_equal '15.07.2009'.to_date, date.shift(:YEAR) - assert_equal '22.07.2008'.to_date, date.shift(:A_7_DAYS) - assert_equal '12.08.2008'.to_date, date.shift(:A_4_WEEKS) - assert_equal '15.10.2008'.to_date, date.shift(:A_3_MONTHS) - assert_equal '13.10.2008'.to_date, date.shift(:A_90_DAYS) - assert_equal '15.07.2009'.to_date, date.shift(:A_12_MONTHS) + date = '16-07-2008'.to_date #sroda, 3 tydzień lipca, III kwartał, 29 tydzień 2008 + + assert_equal '16-07-2008'.to_date, date.shift(:DAY) + assert_equal '22-07-2008'.to_date, date.shift(:WEEK) + assert_equal '15-08-2008'.to_date, date.shift(:MONTH) + assert_equal '15-10-2008'.to_date, date.shift(:QUARTER) + assert_equal '15-07-2009'.to_date, date.shift(:YEAR) + assert_equal '22-07-2008'.to_date, date.shift(:A_7_DAYS) + assert_equal '12-08-2008'.to_date, date.shift(:A_4_WEEKS) + assert_equal '15-10-2008'.to_date, date.shift(:A_3_MONTHS) + assert_equal '13-10-2008'.to_date, date.shift(:A_90_DAYS) + assert_equal '15-07-2009'.to_date, date.shift(:A_12_MONTHS) end @@ -275,109 +275,109 @@ def test_shift private def assert_actual_periods range = Date.calculate :THIS_DAY - assert_equal '16.07.2008'.to_date, range.begin - assert_equal '16.07.2008'.to_date, range.end + assert_equal '16-07-2008'.to_date, range.begin + assert_equal '16-07-2008'.to_date, range.end range = Date.calculate :THIS_WEEK - assert_equal '14.07.2008'.to_date, range.begin - assert_equal '20.07.2008'.to_date, range.end + assert_equal '14-07-2008'.to_date, range.begin + assert_equal '20-07-2008'.to_date, range.end range = Date.calculate :THIS_MONTH - assert_equal '01.07.2008'.to_date, range.begin - assert_equal '31.07.2008'.to_date, range.end + assert_equal '01-07-2008'.to_date, range.begin + assert_equal '31-07-2008'.to_date, range.end range = Date.calculate :THIS_QUARTER - assert_equal '01.07.2008'.to_date, range.begin - assert_equal '30.09.2008'.to_date, range.end + assert_equal '01-07-2008'.to_date, range.begin + assert_equal '30-09-2008'.to_date, range.end range = Date.calculate :THIS_YEAR - assert_equal '01.01.2008'.to_date, range.begin - assert_equal '31.12.2008'.to_date, range.end + assert_equal '01-01-2008'.to_date, range.begin + assert_equal '31-12-2008'.to_date, range.end end def assert_past_periods range = Date.calculate :LAST_DAY - assert_equal '15.07.2008'.to_date, range.begin - assert_equal '15.07.2008'.to_date, range.end + assert_equal '15-07-2008'.to_date, range.begin + assert_equal '15-07-2008'.to_date, range.end range = Date.calculate :LAST_WEEK - assert_equal '07.07.2008'.to_date, range.begin - assert_equal '13.07.2008'.to_date, range.end + assert_equal '07-07-2008'.to_date, range.begin + assert_equal '13-07-2008'.to_date, range.end range = Date.calculate :LAST_7_DAYS - assert_equal '10.07.2008'.to_date, range.begin - assert_equal '16.07.2008'.to_date, range.end + assert_equal '10-07-2008'.to_date, range.begin + assert_equal '16-07-2008'.to_date, range.end range = Date.calculate :LAST_MONTH - assert_equal '01.06.2008'.to_date, range.begin - assert_equal '30.06.2008'.to_date, range.end + assert_equal '01-06-2008'.to_date, range.begin + assert_equal '30-06-2008'.to_date, range.end range = Date.calculate :LAST_4_WEEKS - assert_equal '23.06.2008'.to_date, range.begin - assert_equal '16.07.2008'.to_date, range.end + assert_equal '23-06-2008'.to_date, range.begin + assert_equal '16-07-2008'.to_date, range.end range = Date.calculate :LAST_QUARTER - assert_equal '01.04.2008'.to_date, range.begin - assert_equal '30.06.2008'.to_date, range.end + assert_equal '01-04-2008'.to_date, range.begin + assert_equal '30-06-2008'.to_date, range.end range = Date.calculate :LAST_3_MONTHS - assert_equal '01.05.2008'.to_date, range.begin - assert_equal '31.07.2008'.to_date, range.end + assert_equal '01-05-2008'.to_date, range.begin + assert_equal '31-07-2008'.to_date, range.end range = Date.calculate :LAST_90_DAYS - assert_equal '18.04.2008'.to_date, range.begin - assert_equal '16.07.2008'.to_date, range.end + assert_equal '18-04-2008'.to_date, range.begin + assert_equal '16-07-2008'.to_date, range.end range = Date.calculate :LAST_YEAR - assert_equal '01.01.2007'.to_date, range.begin - assert_equal '31.12.2007'.to_date, range.end + assert_equal '01-01-2007'.to_date, range.begin + assert_equal '31-12-2007'.to_date, range.end range = Date.calculate :LAST_12_MONTHS - assert_equal '01.08.2007'.to_date, range.begin - assert_equal '31.07.2008'.to_date, range.end + assert_equal '01-08-2007'.to_date, range.begin + assert_equal '31-07-2008'.to_date, range.end end def assert_future_periods range = Date.calculate :NEXT_DAY - assert_equal '17.07.2008'.to_date, range.begin - assert_equal '17.07.2008'.to_date, range.end + assert_equal '17-07-2008'.to_date, range.begin + assert_equal '17-07-2008'.to_date, range.end range = Date.calculate :NEXT_WEEK - assert_equal '21.07.2008'.to_date, range.begin - assert_equal '27.07.2008'.to_date, range.end + assert_equal '21-07-2008'.to_date, range.begin + assert_equal '27-07-2008'.to_date, range.end range = Date.calculate :NEXT_7_DAYS - assert_equal '16.07.2008'.to_date, range.begin - assert_equal '22.07.2008'.to_date, range.end + assert_equal '16-07-2008'.to_date, range.begin + assert_equal '22-07-2008'.to_date, range.end range = Date.calculate :NEXT_MONTH - assert_equal '01.08.2008'.to_date, range.begin - assert_equal '31.08.2008'.to_date, range.end + assert_equal '01-08-2008'.to_date, range.begin + assert_equal '31-08-2008'.to_date, range.end range = Date.calculate :NEXT_4_WEEKS - assert_equal '16.07.2008'.to_date, range.begin - assert_equal '13.08.2008'.to_date, range.end + assert_equal '16-07-2008'.to_date, range.begin + assert_equal '13-08-2008'.to_date, range.end range = Date.calculate :NEXT_QUARTER - assert_equal '01.10.2008'.to_date, range.begin - assert_equal '31.12.2008'.to_date, range.end + assert_equal '01-10-2008'.to_date, range.begin + assert_equal '31-12-2008'.to_date, range.end range = Date.calculate :NEXT_3_MONTHS - assert_equal '16.07.2008'.to_date, range.begin - assert_equal '31.10.2008'.to_date, range.end + assert_equal '16-07-2008'.to_date, range.begin + assert_equal '31-10-2008'.to_date, range.end range = Date.calculate :NEXT_90_DAYS - assert_equal '16.07.2008'.to_date, range.begin - assert_equal '13.10.2008'.to_date, range.end + assert_equal '16-07-2008'.to_date, range.begin + assert_equal '13-10-2008'.to_date, range.end range = Date.calculate :NEXT_YEAR - assert_equal '01.01.2009'.to_date, range.begin - assert_equal '31.12.2009'.to_date, range.end + assert_equal '01-01-2009'.to_date, range.begin + assert_equal '31-12-2009'.to_date, range.end range = Date.calculate :NEXT_12_MONTHS - assert_equal '16.07.2008'.to_date, range.begin - assert_equal '16.07.2009'.to_date, range.end + assert_equal '16-07-2008'.to_date, range.begin + assert_equal '16-07-2009'.to_date, range.end end diff --git a/test/unit/flow_report_test.rb b/test/unit/flow_report_test.rb index fc47b6c..21a93ed 100644 --- a/test/unit/flow_report_test.rb +++ b/test/unit/flow_report_test.rb @@ -11,7 +11,7 @@ def setup add_category_options @jarek, r r.user = @jarek r.report_view_type = :text - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.name = "Testowy raport" assert r.save! end @@ -20,7 +20,7 @@ def setup r = FlowReport.new add_category_options @jarek, r r.report_view_type = :linear - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.name = "Testowy raport" r.user = @jarek assert !r.save diff --git a/test/unit/goal_test.rb b/test/unit/goal_test.rb index 8536059..84e42a8 100644 --- a/test/unit/goal_test.rb +++ b/test/unit/goal_test.rb @@ -9,8 +9,8 @@ def setup def test_create_next_goal_in_cycle g = create_goal g.period_type = :NEXT_WEEK - g.period_start = '01.01.2008'.to_date - g.period_end = '07.01.2008'.to_date + g.period_start = '01-01-2008'.to_date + g.period_end = '07-01-2008'.to_date g.is_cyclic = true g.save! @@ -23,8 +23,8 @@ def test_create_next_goal_in_cycle assert_equal g.user, new_g.user assert_equal g.category, new_g.category assert_equal g.period_type, new_g.period_type - assert_equal '08.01.2008'.to_date, new_g.period_start - assert_equal '14.01.2008'.to_date, new_g.period_end + assert_equal '08-01-2008'.to_date, new_g.period_start + assert_equal '14-01-2008'.to_date, new_g.period_end assert_equal g.goal_type_and_currency, new_g.goal_type_and_currency assert_equal g.value, new_g.value assert_equal g.description, new_g.description @@ -41,21 +41,21 @@ def test_create_next_goal_in_cycle def test_next_goal_in_cycle_has_proper_date g = create_goal g.period_type = :NEXT_MONTH - g.period_start = '01.01.2008'.to_date - g.period_end = '31.01.2008'.to_date + g.period_start = '01-01-2008'.to_date + g.period_end = '31-01-2008'.to_date g.is_cyclic = true g.save! new_g = g.create_next_goal_in_cycle assert_not_nil new_g new_g.save! - assert_equal '01.02.2008'.to_date, new_g.period_start - assert_equal '29.02.2008'.to_date, new_g.period_end + assert_equal '01-02-2008'.to_date, new_g.period_start + assert_equal '29-02-2008'.to_date, new_g.period_end new_g = new_g.create_next_goal_in_cycle assert_not_nil new_g new_g.save! - assert_equal '01.03.2008'.to_date, new_g.period_start - assert_equal '31.03.2008'.to_date, new_g.period_end + assert_equal '01-03-2008'.to_date, new_g.period_start + assert_equal '31-03-2008'.to_date, new_g.period_end end @@ -64,8 +64,8 @@ def test_next_goal_in_cycle_has_proper_date def test_set_cycle_group_on_save g = create_goal(false) g.period_type = :NEXT_WEEK - g.period_start = '01.01.2008'.to_date - g.period_end = '07.01.2008'.to_date + g.period_start = '01-01-2008'.to_date + g.period_end = '07-01-2008'.to_date g.is_cyclic = true g.save! assert_equal g.id, g.cycle_group @@ -78,8 +78,8 @@ def test_set_cycle_group_on_save g2.save! assert_equal nil, g2.cycle_group g2.period_type = :NEXT_WEEK - g2.period_start = '01.01.2008'.to_date - g2.period_end = '07.01.2008'.to_date + g2.period_start = '01-01-2008'.to_date + g2.period_end = '07-01-2008'.to_date g2.is_cyclic = true g2.save! assert_equal g2.id, g2.cycle_group @@ -106,8 +106,8 @@ def test_validations g.user = @jarek g.category = @jarek.income g.period_type = :SELECTED - g.period_start = '12.12.2012'.to_date - g.period_end = '12.12.2012'.to_date + g.period_start = '12-12-2012'.to_date + g.period_end = '12-12-2012'.to_date assert !g.save assert_equal 2, g.errors.size diff --git a/test/unit/goal_worker_test.rb b/test/unit/goal_worker_test.rb index 3764c1f..1e9fb4e 100644 --- a/test/unit/goal_worker_test.rb +++ b/test/unit/goal_worker_test.rb @@ -43,22 +43,22 @@ def test_dont_create_goals_for_non_cyclic_goals def test_create_goals_for_one_cyclic_goal g = create_goal(false) g.period_type = :NEXT_WEEK - g.period_start = '01.01.2008'.to_date - g.period_end = '07.01.2008'.to_date + g.period_start = '01-01-2008'.to_date + g.period_end = '07-01-2008'.to_date g.is_cyclic = true g.save! goals = Goal.all assert_equal 1, goals.size - with_dates('02.01.2007', '01.01.2008', '03.01.2008', '01.05.2008') do + with_dates('02-01-2007', '01-01-2008', '03-01-2008', '01-05-2008') do @worker.create_goals_for_next_cycle end goals = Goal.all assert_equal 1, goals.size - with_dates('07.01.2008') do + with_dates('07-01-2008') do @worker.create_goals_for_next_cycle end goals = Goal.all @@ -77,44 +77,44 @@ def test_create_goals_for_many_cyclic_and_non_cyclic_goals #should be copyed g1 = create_goal(false) g1.period_type = :NEXT_YEAR - g1.period_start = '01.01.2008'.to_date - g1.period_end = '31.12.2008'.to_date + g1.period_start = '01-01-2008'.to_date + g1.period_end = '31-12-2008'.to_date g1.is_cyclic = true g1.save! g2 = create_goal(false) g2.period_type = :NEXT_WEEK - g2.period_start = '01.01.2008'.to_date - g2.period_end = '07.01.2008'.to_date + g2.period_start = '01-01-2008'.to_date + g2.period_end = '07-01-2008'.to_date g2.is_cyclic = true g2.save! #should be copyed g3 = create_goal(false) g3.period_type = :NEXT_DAY - g3.period_start = '31.12.2008'.to_date - g3.period_end = '31.12.2008'.to_date + g3.period_start = '31-12-2008'.to_date + g3.period_end = '31-12-2008'.to_date g3.is_cyclic = true g3.save! g4 = create_goal(false) g4.period_type = :NEXT_DAY - g4.period_start = '30.12.2008'.to_date - g4.period_end = '31.12.2008'.to_date + g4.period_start = '30-12-2008'.to_date + g4.period_end = '31-12-2008'.to_date g4.is_cyclic = false g4.save! goals = Goal.all assert_equal 4, goals.size - with_dates('01.01.2007') do + with_dates('01-01-2007') do @worker.create_goals_for_next_cycle end goals = Goal.all assert_equal 4, goals.size - with_dates('31.12.2008') do + with_dates('31-12-2008') do @worker.create_goals_for_next_cycle end goals = Goal.all @@ -133,8 +133,8 @@ def test_create_goals_for_many_cyclic_and_non_cyclic_goals def test_create_goals_for_goal_with_history g1 = create_goal(false) g1.period_type = :NEXT_YEAR - g1.period_start = '01.01.2008'.to_date - g1.period_end = '31.12.2008'.to_date + g1.period_start = '01-01-2008'.to_date + g1.period_end = '31-12-2008'.to_date g1.is_cyclic = true g1.save! @@ -147,7 +147,7 @@ def test_create_goals_for_goal_with_history goals = Goal.all assert_equal 3, goals.size - with_dates('31.12.2010') do + with_dates('31-12-2010') do @worker.create_goals_for_next_cycle end @@ -163,8 +163,8 @@ def test_create_goals_for_goal_with_history def test_dont_create_goals_for_already_exiting_goal_copy g1 = create_goal(false) g1.period_type = :NEXT_YEAR - g1.period_start = '01.01.2008'.to_date - g1.period_end = '31.12.2008'.to_date + g1.period_start = '01-01-2008'.to_date + g1.period_end = '31-12-2008'.to_date g1.is_cyclic = true g1.save! @@ -175,7 +175,7 @@ def test_dont_create_goals_for_already_exiting_goal_copy assert_equal 2, goals.size - with_dates('31.12.2008') do + with_dates('31-12-2008') do @worker.create_goals_for_next_cycle end diff --git a/test/unit/multiple_category_report_test.rb b/test/unit/multiple_category_report_test.rb index 61e9f92..3460f82 100644 --- a/test/unit/multiple_category_report_test.rb +++ b/test/unit/multiple_category_report_test.rb @@ -10,7 +10,7 @@ def setup r = MultipleCategoryReport.new add_category_options @jarek, r r.report_view_type = :bar - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.name = "Testowy raport" r.user = @jarek assert r.save! @@ -40,7 +40,7 @@ def setup r = MultipleCategoryReport.new r.report_view_type = :linear r.name = "Testowy raport" - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.user = @jarek assert !r.save assert r.errors.on(:base) @@ -55,7 +55,7 @@ def setup r = MultipleCategoryReport.new add_category_options @rupert, r r.report_view_type = :bar - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.name = "Testowy raport" r.user = @jarek assert !r.save diff --git a/test/unit/report_test.rb b/test/unit/report_test.rb index 67789a8..e53926a 100644 --- a/test/unit/report_test.rb +++ b/test/unit/report_test.rb @@ -10,7 +10,7 @@ def setup r = nil r = Report.new r.user = @jarek - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.name = "Testowy raport" r.report_view_type = :pie assert r.save @@ -19,7 +19,7 @@ def setup test "Should create and save Report with period" do r = Report.new r.user = @jarek - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.report_view_type = :pie r.name = "Testowy raport" assert r.save @@ -84,7 +84,7 @@ def setup #TODO find way to change Date.today value and test it! # class Date # def self.today - # '06.01.2008'.to_date + # '06-01-2008'.to_date # end # end # @@ -94,8 +94,8 @@ def setup # r.save! # # - # assert_equal '01.01.2008'.to_date, r.period_start - # assert_equal '31.01.2008'.to_date, r.period_end + # assert_equal '01-01-2008'.to_date, r.period_start + # assert_equal '31-01-2008'.to_date, r.period_end diff --git a/test/unit/share_report_test.rb b/test/unit/share_report_test.rb index a77b805..7346df1 100644 --- a/test/unit/share_report_test.rb +++ b/test/unit/share_report_test.rb @@ -11,7 +11,7 @@ def setup r.user = @jarek r.category = @jarek.categories.first r.report_view_type = :pie - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.max_categories_values_count = 1 r.name = "Testowy raport" assert r.save! @@ -41,7 +41,7 @@ def setup r.user = @jarek r.category = @rupert.income r.report_view_type = :pie - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.max_categories_values_count = 1 r.name = "Testowy raport" assert !r.save diff --git a/test/unit/system_category_test.rb b/test/unit/system_category_test.rb index 278ad30..abe5d1e 100644 --- a/test/unit/system_category_test.rb +++ b/test/unit/system_category_test.rb @@ -16,7 +16,7 @@ def setup e.save! s.save! - assert_equal 2, SystemCategory.all.count + assert_equal 2, SystemCategory.count(:all) assert e.id, s.parent.id diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 32c5606..978ee61 100755 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -177,14 +177,14 @@ def test_should_properly_list_newest_transfers end end - assert_equal 10, @rupert.newest_transfers.to_a.count + assert_equal 10, @rupert.newest_transfers.to_a.size assert_equal Date.today, @rupert.newest_transfers.map(&:day).max assert_equal Date.yesterday, @rupert.newest_transfers.map(&:day).min @rupert.transaction_amount_limit_value = 5 @rupert.save! - assert_equal 5, @rupert.newest_transfers.to_a.count + assert_equal 5, @rupert.newest_transfers.to_a.size assert_equal Date.today, @rupert.newest_transfers.map(&:day).max assert_equal Date.today, @rupert.newest_transfers.map(&:day).min @@ -201,14 +201,14 @@ def test_should_properly_list_newest_transfers end end - assert_equal 10, @rupert.newest_transfers.to_a.count + assert_equal 10, @rupert.newest_transfers.to_a.size assert_equal Date.today, @rupert.newest_transfers.map(&:day).max assert_equal 1.week.ago.to_date, @rupert.newest_transfers.map(&:day).min @rupert.transaction_amount_limit_value = 1 @rupert.save! - assert_equal 5, @rupert.newest_transfers.to_a.count + assert_equal 5, @rupert.newest_transfers.to_a.size assert_equal Date.today, @rupert.newest_transfers.map(&:day).max assert_equal Date.today, @rupert.newest_transfers.map(&:day).min @@ -228,7 +228,7 @@ def test_should_properly_list_newest_transfers transfers << save_simple_transfer(:day => a_day, :user => @rupert) end - assert_equal Date.calculate(:THIS_MONTH).count, @rupert.newest_transfers.to_a.count + assert_equal Date.calculate(:THIS_MONTH).to_a.size, @rupert.newest_transfers.to_a.size assert_equal Date.today.end_of_month, @rupert.newest_transfers.map(&:day).max assert_equal Date.today.beginning_of_month, @rupert.newest_transfers.map(&:day).min @@ -236,7 +236,7 @@ def test_should_properly_list_newest_transfers @rupert.transaction_amount_limit_value = nil @rupert.save! - assert_equal Date.calculate(:THIS_MONTH).count + Date.calculate(:LAST_MONTH).count, @rupert.newest_transfers.to_a.count + assert_equal Date.calculate(:THIS_MONTH).to_a.size + Date.calculate(:LAST_MONTH).to_a.size, @rupert.newest_transfers.to_a.size assert_equal Date.today.end_of_month, @rupert.newest_transfers.map(&:day).max assert_equal Date.today.last_month.beginning_of_month, @rupert.newest_transfers.map(&:day).min end diff --git a/test/unit/value_report_test.rb b/test/unit/value_report_test.rb index fd69083..aa7d455 100644 --- a/test/unit/value_report_test.rb +++ b/test/unit/value_report_test.rb @@ -11,7 +11,7 @@ def setup r.user = @jarek add_category_options @jarek, r r.report_view_type = :bar - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.name = "Testowy raport" assert r.save! end @@ -21,7 +21,7 @@ def setup r.user = @jarek add_category_options @jarek, r r.report_view_type = :pie - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.name = "Testowy raport" assert !r.save assert r.errors.on(:report_view_type) @@ -33,7 +33,7 @@ def setup r.user = @jarek add_category_options @jarek, r r.report_view_type = :bar - r.set_period(["10.01.2009".to_date, "17.01.2009".to_date, :LAST_WEEK]) + r.set_period(["10-01-2009".to_date, "17-01-2009".to_date, :LAST_WEEK]) r.name = "Testowy raport" r.category_report_options.each do |option| option.inclusion_type = :both @@ -58,7 +58,7 @@ def setup # assert_equal Money.new, result.first.second # # - # result = category1.calculate_values(:category_and_subcategories, :day, '26.02.2008'.to_date, '27.02.2008'.to_date) + # result = category1.calculate_values(:category_and_subcategories, :day, '26-02-2008'.to_date, '27-02-2008'.to_date) # # assert_equal 2, result.size # assert_equal 2, result.first.size @@ -68,9 +68,9 @@ def setup # assert_equal :category_and_subcategories, result.second.first # assert_equal Money.new, result.second.second # - # save_simple_transfer(:income => category1, :outcome => category2, :day => '26.02.2008'.to_date, :currency => @zloty, :value => 123, :user => @jarek) + # save_simple_transfer(:income => category1, :outcome => category2, :day => '26-02-2008'.to_date, :currency => @zloty, :value => 123, :user => @jarek) # - # result = category1.calculate_values(:category_and_subcategories, :day, '26.02.2008'.to_date, '27.02.2008'.to_date) + # result = category1.calculate_values(:category_and_subcategories, :day, '26-02-2008'.to_date, '27-02-2008'.to_date) # # assert_equal 2, result.size # assert_equal 2, result.first.size