Login as users defined in your FactoryGirl factories.
Preview email while logged in as users defined in your FactoryGirl factories.
To test with your desired version of rails, do this:
RAILS_VERSION=3.1.4 bundel exec rake test
FactoryScenarios is a mountable engine. Add a line like this to your routes.rb file:
if Rails.env.to_s != 'production'
mount FactoryScenarios::Engine, :at => '/factory_scenarios'
end
The current configuration options are as follows
Important Note
Create an initializer file called app/config/initializers/factory_scenarios.rb, add the following:
if Rails.env.to_s != 'production'
FactoryScenarios.config.user_class = 'Spree::User'
FactoryScenarios.config.iframe_width = '1400px'
end
To redirect to a specific location in your application after logging in as a scenario define handle_factory_scenario in your ApplicationController.
# Be sure to use main_app for url_generation as this method will be called
# from inside the engine controllers
def handle_factory_scenario
redirect_to main_app.root_url(subdomain: current_user.subdomain)
end
Specify your mail previews in a file "config/mail_preview.rb"
FactoryScenarios::Mail.registrations do
register "Org Membership Invitation (no login)" do
mailer MembershipMailer
message :approval_message
message_args { Factory.create(:membership) }
end
register "Org Membership Invitation (correct login)" do
mailer MembershipMailer
message :approval_message
message_args { Factory.create(:membership) }
# Arguments to login_as block are the return value of the message_args block.
login_as { |membership| membership.user }
end
register "Org Membership Invitation (wrong login)" do
mailer MembershipMailer
message :approval_message
message_args { Factory.create(:membership) }
login_as { Factory.create :user }
end
register "User registration" do
mailer Devise::Mailer
message :confirmation_instructions
message_args { Factory.create(:unconfirmed_user) }
end
register "Reset password instructions" do
mailer Devise::Mailer
message :reset_password_instructions
message_args { Factory.create(:recoverable_user) }
end
end
Original gem written by Collin Miller. Updated for Rails 3.1 by David Guthu.
Copyright (c) 2011 Collin Miller. See LICENSE.txt for further details.