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

Define test factory classes using stringified class names #1176

Merged
merged 1 commit into from
Jan 4, 2019

Conversation

sman591
Copy link
Contributor

@sman591 sman591 commented Jan 2, 2019

As described in #1043, factories defined by doorkeeper are unable to be loaded by host apps using the factory_bot_rails gem (receiving errors such as uninitialized constant Doorkeeper::AccessGrant)

Documentation for factory_bot was later added to explain an easy fix for this: instead of defining the factory's class: with a named constant, wrap the constant in a string. By doing so, the constant isn't evaluated until the factory actually runs, at which point the Doorkeeper:: models have all been loaded.

Fixes thoughtbot/factory_bot#1188

@doorkeeper-bot
Copy link

1 Message
📖 We really appreciate pull requests that demonstrate issues, even without a fix. That said, the next step is to try and fix the failing tests!

Generated by 🚫 Danger

@nbulaj
Copy link
Member

nbulaj commented Jan 4, 2019

Hi @sman591 . Thanks for your work! Could you please add an entry to changelog (NEWS.md) and squash all the commits to a single one?

@nbulaj nbulaj self-assigned this Jan 4, 2019
@nbulaj nbulaj added this to the 5.1 milestone Jan 4, 2019
As described in doorkeeper-gem#1043,
factories defined by doorkeeper are unable to be loaded by host apps
using the `factory_bot_rails` gem (receiving errors such as
`uninitialized constant Doorkeeper::AccessGrant`)

Documentation for factory_bot was later added to explain an easy fix for
this: instead of defining the factory's `class: ` with a named constant,
wrap the constant in a string. By doing so, the constant isn't evaluated
until the factory actually runs, at which point the `Doorkeeper::` models
have all been loaded.

Fixes thoughtbot/factory_bot#1188
@sman591
Copy link
Contributor Author

sman591 commented Jan 4, 2019

@nbulaj Added & squashed! Happy to reword news entry if needed.

@nbulaj nbulaj merged commit 89d217a into doorkeeper-gem:master Jan 4, 2019
@sman591 sman591 deleted the string-factories branch January 4, 2019 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document using string for class when defining a factory
3 participants