fix failing tests

not sure if the to_a fixes to get collections from activerecord is the right way
This commit is contained in:
Reinier Balt 2014-04-11 22:47:36 +02:00
parent 35cab99cea
commit 2430fcb906
5 changed files with 11 additions and 7 deletions

View file

@ -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

View file

@ -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}

View file

@ -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 -%>

View file

@ -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 -%>

View file

@ -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