diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index a2490acc..7a41d091 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -34,8 +34,8 @@ class StatsController < ApplicationController @interpolated_actions_created_this_month = interpolate_avg_for_current_month(@actions_created_last12months_array) @interpolated_actions_done_this_month = interpolate_avg_for_current_month(@actions_done_last12months_array) - @created_count_array = Array.new(13, actions_last12months.created_after(@cut_off_year).count/12.0) - @done_count_array = Array.new(13, actions_last12months.completed_after(@cut_off_year).count/12.0) + @created_count_array = Array.new(13, actions_last12months.created_after(@cut_off_year).count(:all)/12.0) + @done_count_array = Array.new(13, actions_last12months.completed_after(@cut_off_year).count(:all)/12.0) render :layout => false end @@ -110,7 +110,7 @@ class StatsController < ApplicationController @max_actions = @actions_completion_time_array.max # get percentage done cumulative - @cum_percent_done = convert_to_cumulative_array(@actions_completion_time_array, @actions_completion_time.count) + @cum_percent_done = convert_to_cumulative_array(@actions_completion_time_array, @actions_completion_time.count(:all)) render :layout => false end diff --git a/app/models/user.rb b/app/models/user.rb index 90f59d16..4fb1ca29 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -56,13 +56,13 @@ class User < ActiveRecord::Base end def alphabetize(scope_conditions = {}) projects = where(scope_conditions) - projects.sort!{ |x,y| x.name.downcase <=> y.name.downcase } + projects.to_a.sort!{ |x,y| x.name.downcase <=> y.name.downcase } self.update_positions(projects.map{ |p| p.id }) return projects end def actionize(scope_conditions = {}) todos_in_project = where(scope_conditions).includes(:todos) - todos_in_project.sort!{ |x, y| -(x.todos.active.count <=> y.todos.active.count) } + todos_in_project.to_a.sort!{ |x, y| -(x.todos.active.count <=> y.todos.active.count) } todos_in_project.reject{ |p| p.todos.active.count > 0 } sorted_project_ids = todos_in_project.map {|p| p.id} diff --git a/app/views/todos/add_predecessor.js.erb b/app/views/todos/add_predecessor.js.erb index 98928bcc..82fa8cc6 100644 --- a/app/views/todos/add_predecessor.js.erb +++ b/app/views/todos/add_predecessor.js.erb @@ -29,7 +29,7 @@ function show_in_tickler_box() { function regenerate_predecessor_family() { <% - parents = @predecessors + parents = @predecessors.to_a until parents.empty? parent = parents.pop parents += parent.predecessors -%> diff --git a/app/views/todos/remove_predecessor.js.erb b/app/views/todos/remove_predecessor.js.erb index a2f49f2a..a53c505f 100644 --- a/app/views/todos/remove_predecessor.js.erb +++ b/app/views/todos/remove_predecessor.js.erb @@ -15,7 +15,7 @@ function replace_updated_predecessor() { function regenerate_predecessor_family() { <% - parents = @predecessors + parents = @predecessors.to_a until parents.empty? parent = parents.pop parents += parent.predecessors -%> diff --git a/test/models/todo_test.rb b/test/models/todo_test.rb index 100a86a6..a6ba8c92 100644 --- a/test/models/todo_test.rb +++ b/test/models/todo_test.rb @@ -9,6 +9,10 @@ class TodoTest < ActiveSupport::TestCase @completed = Todo.find(8).reload end + def next_week + 1.week.from_now.beginning_of_day.to_s(:db) + end + # Test loading a todo item def test_load assert_kind_of Todo, @not_completed1