Permalink
Browse files

Add new_record? to Taskrabbit::Task

  • Loading branch information...
1 parent 45f4432 commit fb6c9e51889b9c357463295395320bcefa15d05b @jrichardlai committed Aug 2, 2012
Showing with 18 additions and 0 deletions.
  1. +4 −0 lib/taskrabbit/task.rb
  2. +14 −0 spec/taskrabbit/task_spec.rb
View
@@ -50,6 +50,10 @@ def save
end
end
+ def new_record?
+ !id
+ end
+
def delete!
reload('delete', "tasks/#{id.to_s}")
end
@@ -78,6 +78,20 @@
end
end
+ describe "#new_record?" do
+ subject { Taskrabbit::Task.new }
+
+ it "returns true if the task has no id" do
+ subject.stub(:id => nil)
+ subject.should be_new_record
+ end
+
+ it "returns false if the task has an id" do
+ subject.stub(:id => 123)
+ subject.should_not be_new_record
+ end
+ end
+
describe "#find" do
it "should fetch tasks" do

0 comments on commit fb6c9e5

Please sign in to comment.