mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-22 15:14:07 +01:00
Merge branch 'master' into new-gui
This commit is contained in:
commit
41ff0e20ae
2 changed files with 23 additions and 1 deletions
|
|
@ -377,7 +377,7 @@ class StatsController < ApplicationController
|
||||||
# the block should return an array of indexes each is added to the hash and summed
|
# the block should return an array of indexes each is added to the hash and summed
|
||||||
def convert_to_array(records, upper_bound)
|
def convert_to_array(records, upper_bound)
|
||||||
a = Array.new(upper_bound, 0)
|
a = Array.new(upper_bound, 0)
|
||||||
records.each { |r| (yield r).each { |i| a[i] += 1 } }
|
records.each { |r| (yield r).each { |i| a[i] += 1 if a[i] } }
|
||||||
a
|
a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,28 @@ class StatsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_empty_last12months_data
|
||||||
|
Timecop.travel(Time.local(2013, 1, 15)) do
|
||||||
|
login_as(:admin_user)
|
||||||
|
@current_user = User.find(users(:admin_user).id)
|
||||||
|
@current_user.todos.delete_all
|
||||||
|
given_todos_for_stats
|
||||||
|
get :actions_done_last12months_data
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_out_of_bounds_events_for_last12months_data
|
||||||
|
login_as(:admin_user)
|
||||||
|
@current_user = User.find(users(:admin_user).id)
|
||||||
|
@current_user.todos.delete_all
|
||||||
|
create_todo_in_past(2.years)
|
||||||
|
create_todo_in_past(15.months)
|
||||||
|
|
||||||
|
get :actions_done_last12months_data
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
def test_actions_done_last30days_data
|
def test_actions_done_last30days_data
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
@current_user = User.find(users(:admin_user).id)
|
@current_user = User.find(users(:admin_user).id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue