From 63ac90ebb264ea4c0289e5f10ca87562903d7415 Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Thu, 11 Apr 2019 11:28:43 -0500 Subject: [PATCH] Convert to using symbols everywhere --- app/models/todos/undone_todos_query.rb | 4 +-- test/models/todos/undone_todos_query_test.rb | 27 ++++++++------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/app/models/todos/undone_todos_query.rb b/app/models/todos/undone_todos_query.rb index e9bc1cc2..b4980870 100644 --- a/app/models/todos/undone_todos_query.rb +++ b/app/models/todos/undone_todos_query.rb @@ -21,12 +21,12 @@ module Todos not_done_todos = not_done_todos.limit(sanitize(params[:limit])) if params[:limit] if params[:due] - due_within_when = Time.zone.now + params['due'].to_i.days + due_within_when = Time.zone.now + params[:due].to_i.days not_done_todos = not_done_todos.where('todos.due <= ?', due_within_when) end if params[:tag] - tag = Tag.where(:name => params['tag']).first + tag = Tag.where(:name => params[:tag]).first not_done_todos = not_done_todos.joins(:taggings).where('taggings.tag_id = ?', tag.id) end diff --git a/test/models/todos/undone_todos_query_test.rb b/test/models/todos/undone_todos_query_test.rb index 15af079c..13515c06 100644 --- a/test/models/todos/undone_todos_query_test.rb +++ b/test/models/todos/undone_todos_query_test.rb @@ -32,17 +32,15 @@ module Todos def test_filtering_by_due_date user = users(:other_user) - # FIXME normalize HashWithIndifferentHash usage # Only gets todos that are due today or are past their due date. - undone_todos = UndoneTodosQuery.new(user).query(due: '0', 'due' => '0') + undone_todos = UndoneTodosQuery.new(user).query(due: '0') expected = [todos(:package_delivered)] assert_equal expected, undone_todos.to_a end def test_filtering_by_tag user = users(:other_user) - # FIXME normalize HashWithIndifferentHash usage - undone_todos = UndoneTodosQuery.new(user).query(tag: 'bar', "tag" => "bar") + undone_todos = UndoneTodosQuery.new(user).query(tag: 'bar') expected = [todos(:package_delivered), todos(:buy_tix)] assert_equal expected, undone_todos.to_a @@ -50,8 +48,7 @@ module Todos def test_filtering_by_context user = users(:other_user) - # FIXME normalize HashWithIndifferentHash usage - undone_todos = UndoneTodosQuery.new(user).query(context_id: '11', 'context_id' => '11') + undone_todos = UndoneTodosQuery.new(user).query(context_id: '11') expected = [todos(:package_delivered), todos(:pal_confirmation)] assert_equal expected, undone_todos.to_a @@ -59,37 +56,33 @@ module Todos def test_using_a_non_existant_context_raises_an_exception user = users(:other_user) - # FIXME normalize HashWithIndifferentHash usage assert_raises(ActiveRecord::RecordNotFound) do - undone_todos = UndoneTodosQuery.new(user).query(context_id: '110', 'context_id' => '110') + undone_todos = UndoneTodosQuery.new(user).query(context_id: '110') end end def test_filtering_by_project user = users(:other_user) - # FIXME normalize HashWithIndifferentHash usage - undone_todos = UndoneTodosQuery.new(user).query(project_id: '5', 'project_id' => '5') + undone_todos = UndoneTodosQuery.new(user).query(project_id: '5') expected = [todos(:package_delivered)] assert_equal expected, undone_todos.to_a end def test_using_a_non_existant_project_raises_an_exception user = users(:other_user) - # FIXME normalize HashWithIndifferentHash usage assert_raises(ActiveRecord::RecordNotFound) do - undone_todos = UndoneTodosQuery.new(user).query(project_id: '110', 'project_id' => '110') + undone_todos = UndoneTodosQuery.new(user).query(project_id: '110') end end def test_combination_of_all_params user = users(:other_user) - # FIXME normalize HashWithIndifferentHash usage undone_todos = UndoneTodosQuery.new(user).query({ limit: "1", - project_id: "5", "project_id" => "5", - context_id: "11", "context_id" => "11", - tag: "bar", "tag" => "bar", - due: "0", "due" => "0"}) + project_id: "5", + context_id: "11", + tag: "bar", + due: "0"}) expected = [todos(:package_delivered)] assert_equal expected, undone_todos.to_a end