Skip to content

Commit

Permalink
Add comments to mark_as_persisted! method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
sdjmchattie committed Nov 7, 2024
1 parent 92241e8 commit 13a5eab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion spec/factories/submission_factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
state { 'ready' }
created_at { Time.current.to_s }
updated_at { Time.current.to_s }
to_create { |instance, _evaluator| instance.mark_as_persisted! }

to_create do |instance, _evaluator|
# JSON API client resources are not persisted in the database, but we need Limber to treat them as if they are.
# This ensures the `url_for` method will use their UUIDs in URLs via the `to_param` method on the resource.
# Otherwise it just redirects to the root URL for the resource type.
instance.mark_as_persisted!
end
end
end
7 changes: 6 additions & 1 deletion spec/factories/tube_factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@
custom_metadatum_collection { nil }
end

to_create { |instance, _evaluator| instance.mark_as_persisted! }
to_create do |instance, _evaluator|
# JSON API client resources are not persisted in the database, but we need Limber to treat them as if they are.
# This ensures the `url_for` method will use their UUIDs in URLs via the `to_param` method on the resource.
# Otherwise it just redirects to the root URL for the resource type.
instance.mark_as_persisted!
end

# See the README.md for an explanation under "FactoryBot is not mocking my related resources correctly"
after(:build) do |asset, evaluator|
Expand Down

0 comments on commit 13a5eab

Please sign in to comment.