From 327412fba3f46dd1c4798ebb2328905ef3436787 Mon Sep 17 00:00:00 2001 From: Tanguy PATTE Date: Mon, 24 Aug 2015 11:42:06 +0200 Subject: [PATCH] fix datepicker and test it --- config/environments/development.rb | 2 +- spec/features/datepicker_spec.rb | 19 +++++++++++++++++++ spec/rails_helper.rb | 2 +- spec/spec_helper.rb | 2 ++ spec/support/database_cleaner.rb | 10 +++++++++- 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 spec/features/datepicker_spec.rb diff --git a/config/environments/development.rb b/config/environments/development.rb index d803d0a2d..5fafdd184 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -25,7 +25,7 @@ Rails.application.configure do # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. - config.assets.debug = false + config.assets.debug = true # Asset digests allow you to set far-future HTTP expiration dates on all assets, # yet still be able to expire them through the digest params. diff --git a/spec/features/datepicker_spec.rb b/spec/features/datepicker_spec.rb new file mode 100644 index 000000000..baae9612b --- /dev/null +++ b/spec/features/datepicker_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +feature 'On the description page' do + let!(:dossier) { create(:dossier, :with_entreprise, :with_pieces_jointes) } + before do + visit dossier_description_path dossier + end + scenario 'date_previsionnelle field is present' do + expect(page).to have_css('#date_previsionnelle') + end + context 'when user clic on date_previsionnelle field', js: true do + before do + find_by_id('date_previsionnelle').click + end + scenario 'the datepicker popup is displayed' do + expect(page).to have_css('.datepicker-days') + end + end +end \ No newline at end of file diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index c278035b8..244c97e4d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -31,7 +31,7 @@ RSpec.configure do |config| # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. - config.use_transactional_fixtures = true + config.use_transactional_fixtures = false # RSpec Rails can automatically mix in different behaviours to your tests # based on their file location, for example enabling you to call `get` and diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 918a21a1c..57953a907 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -51,6 +51,8 @@ SIADETOKEN = :valid_token unless defined? SIADETOKEN include Warden::Test::Helpers +WebMock.disable_net_connect!(allow_localhost: true) + RSpec.configure do |config| config.filter_run_excluding disable: true config.color = true diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index e2a8b7b56..305f2fbee 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -1,12 +1,20 @@ RSpec.configure do |config| + + expect_list = %w(evenement_vies formulaires types_piece_jointe) + config.before(:suite) do - DatabaseCleaner.clean_with(:truncation, except: %w(evenement_vies formulaires types_piece_jointe)) + DatabaseCleaner.clean_with(:truncation, except: expect_list) end config.before(:each) do DatabaseCleaner.strategy = :transaction end + config.before(:each, js: true) do + DatabaseCleaner.strategy = :truncation, { except: expect_list } + end + + config.before(:each) do DatabaseCleaner.start end