Skip to content

Instantly share code, notes, and snippets.

@creich
Created October 29, 2012 13:58
Show Gist options
  • Save creich/3973709 to your computer and use it in GitHub Desktop.
Save creich/3973709 to your computer and use it in GitHub Desktop.
def update(tl)
time_log = TimeLog.where(:id => tl[:id]).first
start = Time.parse(tl[:tt_log_date] + " " + tl[:start_time])
hours = time_string2hour(tl[:spent_time])
stop = start + hours.hours
time_log.update_attributes!(:started_on => start, :stopped_at => stop, :comments => tl[:comments])
flash[:notice] = l(:tt_update_log_success)
rescue StandardError => e
flash[:error] = e.message
end
should "update only TL -comments on own logs" do
post :actions, {:time_log_edit => {1 => {:id => 1, :comments => "new comment", :tt_log_date => "2012-10-25",
:start_time => "11:47:23", :stop_time => "11:53:42",
:spent_time => "6m 19s"}}}
assert_response 302, "on update TL"
tl = TimeLog.where(:id => 1).first
assert_equal("new comment", tl.comments, "updated TL-comment")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment