-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add #reload method to Granite::Querying Co-authored-by: jphaward <[email protected]> * Add documentation for #reload Co-authored-by: jphaward <[email protected]> * Only define #reload when `Spec` module is defined * Move macro condition inside #reload Co-authored-by: Seth T. <[email protected]> --------- Co-authored-by: jphaward <[email protected]> Co-authored-by: Seth T. <[email protected]>
- Loading branch information
1 parent
a996473
commit faa7ea2
Showing
4 changed files
with
174 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require "../../spec_helper" | ||
|
||
describe "#reload" do | ||
before_each do | ||
Parent.clear | ||
end | ||
|
||
it "reloads the record from the database" do | ||
parent = Parent.create(name: "Parent") | ||
|
||
Parent.find!(parent.id).update(name: "Other") | ||
|
||
parent.reload.name.should eq "Other" | ||
end | ||
|
||
it "raises an error if the record no longer exists" do | ||
parent = Parent.create(name: "Parent") | ||
parent.destroy | ||
|
||
expect_raises(Granite::Querying::NotFound) do | ||
parent.reload | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters