Skip to content

Instantly share code, notes, and snippets.

@Lackoftactics
Created February 26, 2018 12:03
Show Gist options
  • Select an option

  • Save Lackoftactics/0e24918b2758c0b71bd84cfd4b77fd2f to your computer and use it in GitHub Desktop.

Select an option

Save Lackoftactics/0e24918b2758c0b71bd84cfd4b77fd2f to your computer and use it in GitHub Desktop.
Smarter tests without workaround
factory :registration_active_registrant, class: Registration::Registrant do
before(:create) do |registrant|
registrant.class.skip_callback(:create, :before, :init)
create(:active_registration_registrant_status) unless Registration::RegistrantStatus.exists?(name: 'Active')
end
completed_at Date.current
activated_at Date.current
status_id { Registration::RegistrantStatus::ACTIVE_ID }
after(:create) do |registrant|
registrant.class.set_callback(:create, :before, :init)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment