Skip to content

Instantly share code, notes, and snippets.

@squarelover
Created July 30, 2010 17:29
Show Gist options
  • Save squarelover/500947 to your computer and use it in GitHub Desktop.
Save squarelover/500947 to your computer and use it in GitHub Desktop.
def reset_attribute!(name)
value = attribute_was(name)
@attributes[name] = value
modifications.delete(name)
end
# ...
# this is line 396
context "change previously unset attribute" do
before do
@person.ssn = "111-22-3456"
end
it "resets the value to unset" do
@person.reset_attribute!("ssn")
@person.ssn.should be_nil
end
it "removes the field from the changes" do
@person.reset_attribute!("ssn")
@person.changed.should == []
end
end
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment