mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-01 18:40:15 +01:00
fix case when there are no tags places on todos, the stats page would fail. Fixes #822.
Thanks Walter for finding this one
This commit is contained in:
parent
278c7310c1
commit
8cdae83014
2 changed files with 18 additions and 1 deletions
|
|
@ -652,6 +652,7 @@ class StatsController < ApplicationController
|
||||||
"AND tags.id = taggings.tag_id " +
|
"AND tags.id = taggings.tag_id " +
|
||||||
"AND taggings.taggable_id = todos.id ", current_user.id])
|
"AND taggings.taggable_id = todos.id ", current_user.id])
|
||||||
tags_ids_s = tag_ids.map(&:id).sort.join(",")
|
tags_ids_s = tag_ids.map(&:id).sort.join(",")
|
||||||
|
return {} if tags_ids_s.blank? # return empty array for .size to work
|
||||||
return Tag.find(:all, :conditions => "id in (" + tags_ids_s + ")")
|
return Tag.find(:all, :conditions => "id in (" + tags_ids_s + ")")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,4 +91,20 @@ class StatsControllerTest < Test::Unit::TestCase
|
||||||
assert_template "stats/show_selection_from_chart"
|
assert_template "stats/show_selection_from_chart"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_stats_render_when_tasks_have_no_taggings
|
||||||
|
login_as(:admin_user)
|
||||||
|
|
||||||
|
# using the default fixtures, todos have tags
|
||||||
|
get :index
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
# clear taggings table and render again
|
||||||
|
taggings = Tagging.find(:all)
|
||||||
|
taggings.each do |t|
|
||||||
|
t.delete
|
||||||
|
end
|
||||||
|
get :index
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue