Skip to content

Instantly share code, notes, and snippets.

@seeflanigan
Created October 5, 2010 20:38
Show Gist options
  • Save seeflanigan/612286 to your computer and use it in GitHub Desktop.
Save seeflanigan/612286 to your computer and use it in GitHub Desktop.
def [your_conventional_method_name_here]
@foo ||= Factory(:foo)
@foo.authorize!
end
@ryanbriones
Copy link

if you are using rspec you could use a shared behavior so that you have:

it_should_behave_like "an action that requires an authorized foo"

if not, maybe that gives you some more ideas to choose from :)

@seeflanigan
Copy link
Author

Shoulda, and Matchy. FactoryGirl has callbacks that seem to fit the use case, @mbleigh suggested trying that approach. Another suggestion was to make the factory return an authorized or confirmed user. Seems to me like taking that happy path approach, and creating a factory for unconfirmed/unauthorized users to test those cases (they are fewer in number) is a reasonable proposition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment