Thursday, 12 September 2013

How do I implement a timestamp in postgreSQL?

How do I implement a timestamp in postgreSQL?

I'm in a Dev bootcamp, this isn't homework or anything. My issue is two
fold. I am trying to implement a timestamp into my to-do list and also
wondering why my test for showing all my tasks in a given list, is
failing.
Timestamp test :
it 'lets you set a due date' do
task = Task.new('birthday',timestamp, task.id)
task.add_due_date should eq 'birthday' 1969-05-01
end
Timestamp method :
def add_due_date
DB.exec("UPDATE tasks SET timestamp = #{@due_date} WHERE id =
#{@list_id};")
end
Show all tasks test :
it 'shows all of the tasks in its list' do
list1 = List.new('home stuff')
list2 = List.new('work stuff')
task1 = Task.new('mop', list1.id)
task2 = Task.new('finish report for boss', list2.id)
list1.save
list1.tasks.should eq [task1]
end
Show all tasks method :
def show_tasks
DB.exec("SELECT * FROM tasks WHERE id = #{@list_id};")
end
My database is all good, I just don't know why my tests are failing. Maybe
I just been staring at the screen too long but I am kinda stumped. Any
insight would be greatly appreciated!

No comments:

Post a Comment