demarches-normaliennes/spec/support/controller_helpers.rb
Tanguy PATTE 3c57643f76 add database cleaner
add factory girl
fix tests
rename dossier_pdf into piece_jointe
rename ref_piece_jointe into content
2015-08-13 15:56:58 +02:00

16 lines
No EOL
589 B
Ruby

module ControllerHelpers
def sign_in(user = double('test@localhost.com'))
if user.nil?
allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => :user})
allow(controller).to receive(:current_user).and_return(nil)
else
allow(request.env['warden']).to receive(:authenticate!).and_return(user)
allow(controller).to receive(:current_user).and_return(create(:user))
end
end
end
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
config.include ControllerHelpers, :type => :controller
end