persisted? should be false after a document has been destroyed.
See https://github.com/rails/rails/blob/master/activemodel/CHANGELOG#L72
This commit is contained in:
parent
98772ae98a
commit
b3a005b86d
|
@ -82,7 +82,7 @@ module CouchRest
|
||||||
end
|
end
|
||||||
|
|
||||||
def persisted?
|
def persisted?
|
||||||
!new?
|
!new? && !destroyed?
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_key
|
def to_key
|
||||||
|
|
|
@ -44,7 +44,7 @@ module CouchRest::Model
|
||||||
alias :new_record? :new?
|
alias :new_record? :new?
|
||||||
|
|
||||||
def persisted?
|
def persisted?
|
||||||
!new?
|
!new? && !destroyed?
|
||||||
end
|
end
|
||||||
|
|
||||||
# The to_param method is needed for rails to generate resourceful routes.
|
# The to_param method is needed for rails to generate resourceful routes.
|
||||||
|
|
|
@ -110,14 +110,22 @@ describe "Model Base" do
|
||||||
describe "#persisted?" do
|
describe "#persisted?" do
|
||||||
context "when the document is new" do
|
context "when the document is new" do
|
||||||
it "returns false" do
|
it "returns false" do
|
||||||
@obj.persisted?.should == false
|
@obj.persisted?.should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the document is not new" do
|
context "when the document is not new" do
|
||||||
it "returns id" do
|
it "returns id" do
|
||||||
@obj.save
|
@obj.save
|
||||||
@obj.persisted?.should == true
|
@obj.persisted?.should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when the document is destroyed" do
|
||||||
|
it "returns false" do
|
||||||
|
@obj.save
|
||||||
|
@obj.destroy
|
||||||
|
@obj.persisted?.should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue