add database cleaner

add factory girl
fix tests
rename dossier_pdf into piece_jointe
rename ref_piece_jointe into content
This commit is contained in:
Tanguy PATTE 2015-08-13 15:55:19 +02:00
parent c16d7a12f2
commit 3c57643f76
48 changed files with 338 additions and 174 deletions

View file

@ -5,7 +5,7 @@ module ControllerHelpers
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({:email => 'test@localhost.com'})
allow(controller).to receive(:current_user).and_return(create(:user))
end
end
end

View file

@ -0,0 +1,21 @@
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation, {:except => %w[evenement_vies ref_formulaires ref_pieces_jointes]})
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
# config.before(:each, :js => true) do
# DatabaseCleaner.strategy = :truncation, {:except => %w[evenement_vies ref_formulaires ref_pieces_jointes]}
# end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end

View file

@ -1,6 +1,6 @@
module FeatureHelpers
def login_admin
user = User.first
user = create :user
login_as user, scope: :user
user
end