Remove codejunk

Extra whitespace, explicit returns, and an extra begin/end pair are all
gone.
This commit is contained in:
Matt Rogers 2013-04-29 20:38:35 -05:00
parent b1fb1dd326
commit 1c2de3fd5a
2 changed files with 15 additions and 17 deletions

View file

@ -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
end

View file

@ -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