Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Stub): align #destroyed with #new_record/#persisted #1576

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# News

## Unreleased

* Changed: Explicitly define `#destroyed?` within the `Stub` strategy to return `false` to be consistent
with `#new_record?` and `#persisted?`.

## 6.2.1 (March 8, 2022)
* Added: CI testing against truffleruby
* Changed: Documentation improvements for sequences and traits
Expand Down
2 changes: 1 addition & 1 deletion docs/src/ref/build-strategies.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ data as appropriate:
- all [ActiveModel::Dirty] change tracking is cleared
- `persisted?` is true
- `new_record?` is false
- `destroyed?` is nil
- `destroyed?` is false
- persistence methods raise a `RuntimeError` (`#connection`, `#delete`, `#save`, `#update`, etc.)

[ActiveModel::Dirty]: https://api.rubyonrails.org/classes/ActiveModel/Dirty.html
Expand Down
2 changes: 1 addition & 1 deletion lib/factory_bot/strategy/stub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def new_record?
end

def destroyed?
nil
false
end

DISABLED_PERSISTENCE_METHODS.each do |write_method|
Expand Down