From d784b1a5ebd63ec6971241c6e7b1e0fdcc8ac2f0 Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Tue, 21 May 2019 15:17:50 +0300 Subject: [PATCH 1/4] #1929: Fix the actions query breaking when querying actions with a non-existent tag --- app/models/todos/undone_todos_query.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/todos/undone_todos_query.rb b/app/models/todos/undone_todos_query.rb index b4980870..18a630ac 100644 --- a/app/models/todos/undone_todos_query.rb +++ b/app/models/todos/undone_todos_query.rb @@ -27,6 +27,9 @@ module Todos if params[:tag] tag = Tag.where(:name => params[:tag]).first + if not tag + return [] + end not_done_todos = not_done_todos.joins(:taggings).where('taggings.tag_id = ?', tag.id) end From 7fc1f1bf9f72c9472e8931e022e4d00090e82a8e Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Tue, 21 May 2019 22:28:37 +0300 Subject: [PATCH 2/4] Update app/models/todos/undone_todos_query.rb Co-Authored-By: Matt Rogers --- app/models/todos/undone_todos_query.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/todos/undone_todos_query.rb b/app/models/todos/undone_todos_query.rb index 18a630ac..2ba2571c 100644 --- a/app/models/todos/undone_todos_query.rb +++ b/app/models/todos/undone_todos_query.rb @@ -27,7 +27,7 @@ module Todos if params[:tag] tag = Tag.where(:name => params[:tag]).first - if not tag + return [] if !tag return [] end not_done_todos = not_done_todos.joins(:taggings).where('taggings.tag_id = ?', tag.id) From 644cf0d9e76d62414e8d2b18b992ab54a770a98c Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Tue, 21 May 2019 22:33:21 +0300 Subject: [PATCH 3/4] Fix the syntax --- app/models/todos/undone_todos_query.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/todos/undone_todos_query.rb b/app/models/todos/undone_todos_query.rb index 2ba2571c..c6d107ab 100644 --- a/app/models/todos/undone_todos_query.rb +++ b/app/models/todos/undone_todos_query.rb @@ -27,9 +27,7 @@ module Todos if params[:tag] tag = Tag.where(:name => params[:tag]).first - return [] if !tag - return [] - end + return [] if !tag not_done_todos = not_done_todos.joins(:taggings).where('taggings.tag_id = ?', tag.id) end From 43523d819153402189d79b569efff17e6638b9ef Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Wed, 22 May 2019 00:40:58 +0300 Subject: [PATCH 4/4] Test the RSS feed of starred, active todos --- test/integration/feed_smoke_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/integration/feed_smoke_test.rb b/test/integration/feed_smoke_test.rb index 6eb762bd..d172cdbd 100644 --- a/test/integration/feed_smoke_test.rb +++ b/test/integration/feed_smoke_test.rb @@ -84,6 +84,10 @@ class FeedSmokeTest < ActionDispatch::IntegrationTest assert_success "/todos.rss?token=#{ users(:admin_user).token }&done=7" end + def test_all_starred_active_actions_rss + assert_success "/todos.rss?token=#{ users(:admin_user).token }&tag=starred" + end + def test_all_actions_completed_in_last_7_days_txt assert_success "/todos.txt?token=#{ users(:admin_user).token }&done=7" end