From 86ab596a87ac77ddb550a414f5ac620f2ab4073c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Apr 2017 16:58:00 +0200 Subject: [PATCH] Change test structure --- .../drawing_a_zone_with_freedraw_spec.rb | 23 ++++++++++++++----- spec/features/users/list_dossiers_spec.rb | 1 - 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/spec/features/users/drawing_a_zone_with_freedraw_spec.rb b/spec/features/users/drawing_a_zone_with_freedraw_spec.rb index b7a4f8495..3cbd1c26e 100644 --- a/spec/features/users/drawing_a_zone_with_freedraw_spec.rb +++ b/spec/features/users/drawing_a_zone_with_freedraw_spec.rb @@ -15,13 +15,24 @@ feature 'drawing a zone with freedraw' do expect(page).to have_css('#login_user') end - context 'when he enter login information' do + scenario 'he logs in and he is redirected to carte page', vcr: { cassette_name: 'drawing_a_zone_with_freedraw_redirected_to_carte_page' } do + within('#new_user') do + page.find_by_id('user_email').set user.email + page.find_by_id('user_password').set user.password + page.click_on 'Se connecter' + end + expect(page).to have_css('.content #map') + end + end + + context 'when user is logged in' do + before do + login_as user, scope: :user + end + + context 'when he is visiting the map page' do before do - within('#new_user') do - page.find_by_id('user_email').set user.email - page.find_by_id('user_password').set user.password - page.click_on 'Se connecter' - end + visit users_dossier_carte_path dossier_id: dossier.id end context 'when procedure have api carto activated' do diff --git a/spec/features/users/list_dossiers_spec.rb b/spec/features/users/list_dossiers_spec.rb index d970de7b4..1ae783994 100644 --- a/spec/features/users/list_dossiers_spec.rb +++ b/spec/features/users/list_dossiers_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' feature 'user access to the list of his dossier' do - let(:user) { create(:user) } let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'replied')} let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'replied') }