diff --git a/app/controllers/todos/todo_create_params_helper.rb b/app/controllers/todos/todo_create_params_helper.rb index fc3c6f10..89f4e322 100644 --- a/app/controllers/todos/todo_create_params_helper.rb +++ b/app/controllers/todos/todo_create_params_helper.rb @@ -1,7 +1,7 @@ module Todos class TodoCreateParamsHelper - attr_reader :new_project_created, :new_context_created + attr_reader :new_project_created, :new_context_created def initialize(params, user) @params = params['request'] || params @@ -76,7 +76,7 @@ module Todos def specified_by_id?(group_type) group_id = send("#{group_type}_id") - return !group_id.blank? + !group_id.blank? end def project_specified_by_name? @@ -93,7 +93,7 @@ module Todos end def add_errors(model) - @errors.each {|e| model.errors[ e[:attribute] ] = e[:message] } + @errors.each {|e| model.errors[ e[:attribute] ] = e[:message] } end private @@ -107,17 +107,15 @@ module Todos group = set.where(:name => name).first_or_create @attributes["#{group_type}_id"] = group.id return group.new_record_before_save? - end + end - def set_id_by_id_string(group_type, set, id) - begin - # be aware, this will replace the project_id/context_id (string) in @attributes with the new found id (int) - @attributes["#{group_type}_id"] = set.find(id).id - return false - rescue - @errors << { :attribute => group_type, :message => "unknown"} - end - end + def set_id_by_id_string(group_type, set, id) + # be aware, this will replace the project_id/context_id (string) in @attributes with the new found id (int) + @attributes["#{group_type}_id"] = set.find(id).id + return false + rescue + @errors << { :attribute => group_type, :message => "unknown"} + end end -end \ No newline at end of file +end diff --git a/test/unit/todo_create_params_helper_test.rb b/test/unit/todo_create_params_helper_test.rb index 812eda84..b5ce5ccd 100644 --- a/test/unit/todo_create_params_helper_test.rb +++ b/test/unit/todo_create_params_helper_test.rb @@ -37,11 +37,11 @@ class TodoCreateParamsHelperTest < ActiveSupport::TestCase def test_parse_dates_parses_show_from_date_based_on_prefs params = { 'todo' => { 'show_from' => '20/05/07', 'due' => '23/5/07'}} - + user = users(:admin_user) prefs = user.prefs prefs.date_format = "%d/%m/%y" # make sure the format matches the above - + params_helper = Todos::TodoCreateParamsHelper.new(params, user) params_helper.parse_dates() assert_equal Date.new(2007, 5, 20), params_helper.show_from.to_date @@ -49,7 +49,7 @@ class TodoCreateParamsHelperTest < ActiveSupport::TestCase def test_parse_dates_parses_due_date_based_on_prefs params = { 'todo' => { 'show_from' => '20/5/07', 'due' => '23/5/07'}} - + user = users(:admin_user) prefs = user.prefs prefs.date_format = "%d/%m/%y" # make sure the format matches the above