Fix some tests

This commit is contained in:
Xavier J 2017-01-03 11:32:21 +01:00
parent 02d7dfb1dc
commit 2750319f77
10 changed files with 34 additions and 79 deletions

View file

@ -22,4 +22,22 @@ class ApplicationController < ActionController::Base
@left_pannel_url = service.left_panel
@facade_data_view = nil
end
protected
def authenticate_gestionnaire!
if gestionnaire_signed_in?
super
else
redirect_to new_user_session_path
end
end
def authenticate_administrateur!
if administrateur_signed_in?
super
else
redirect_to new_user_session_path
end
end
end

View file

@ -1,4 +1,4 @@
#form_login
#form_login.user_connexion_page
%br
= render partial: 'users/sessions/resume_procedure'

View file

@ -11,8 +11,8 @@ feature 'Administrator connection' do
context "admin fills form and log in" do
before do
page.find_by_id('administrateur_email').set admin.email
page.find_by_id('administrateur_password').set admin.password
page.find_by_id('user_email').set admin.email
page.find_by_id('user_password').set admin.password
page.click_on 'Se connecter'
end
scenario 'a menu button is available' do

View file

@ -85,7 +85,7 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
page.find_by_id('onglet-accompagnateurs').click
expect(page).to have_current_path(admin_procedure_accompagnateurs_path(Procedure.first.id.to_s))
page.find_by_id('gestionnaire_email').set 'gestionnaire@apientreprise.fr'
page.find_by_id('user_email').set 'gestionnaire@apientreprise.fr'
page.find_by_id('add-gestionnaire-email').click
page.first('.gestionnaire-affectation').click

View file

@ -11,8 +11,8 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do
end
context 'when user enter bad credentials' do
before do
page.find_by_id(:gestionnaire_email).set 'unknown@plop.com'
page.find_by_id(:gestionnaire_password).set 'password'
page.find_by_id(:user_email).set 'unknown@plop.com'
page.find_by_id(:user_password).set 'password'
page.click_on 'Se connecter'
end
scenario 'he stay on the same page with an error' do
@ -25,8 +25,8 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do
before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
page.find_by_id(:gestionnaire_email).set gestionnaire.email
page.find_by_id(:gestionnaire_password).set gestionnaire.password
page.find_by_id(:user_email).set gestionnaire.email
page.find_by_id(:user_password).set gestionnaire.password
page.click_on 'Se connecter'
end
scenario 'he is redirected to /backoffice' do

View file

@ -9,20 +9,13 @@ feature 'usage of pref list dossier lateral panel', js: true do
before do
create(:dossier, :with_entreprise, procedure: procedure, state: 'updated')
create :assign_to, procedure: procedure, gestionnaire: gestionnaire
login_as gestionnaire, scope: :gestionnaire
visit backoffice_path
end
scenario 'he is redirected to /gestionnaires/sign_id' do
expect(page).to have_css('#gestionnaire_login')
end
context 'when user enter good credentials' do
before do
page.find_by_id(:gestionnaire_email).set gestionnaire.email
page.find_by_id(:gestionnaire_password).set gestionnaire.password
page.click_on 'Se connecter'
end
scenario 'he is redirected to /backoffice' do
expect(page).to have_css('#backoffice_index')
end

View file

@ -9,20 +9,13 @@ feature 'usage of pref list dossier lateral panel by procedure', js: true do
before do
create(:dossier, :with_entreprise, procedure: procedure, state: 'updated')
create :assign_to, procedure: procedure, gestionnaire: gestionnaire
login_as gestionnaire, scope: :gestionnaire
visit backoffice_path
end
scenario 'he is redirected to /gestionnaires/sign_id' do
expect(page).to have_css('#gestionnaire_login')
end
context 'when user enter good credentials' do
before do
page.find_by_id(:gestionnaire_email).set gestionnaire.email
page.find_by_id(:gestionnaire_password).set gestionnaire.password
page.click_on 'Se connecter'
end
scenario 'he is redirected to /backoffice/dossiers/' do
expect(page).to have_css('#backoffice_index')
end

View file

@ -16,8 +16,8 @@ feature 'on backoffice page' do
context 'when gestionnaire is logged in' do
before do
page.find_by_id(:gestionnaire_email).set gestionnaire.email
page.find_by_id(:gestionnaire_password).set gestionnaire.password
page.find_by_id(:user_email).set gestionnaire.email
page.find_by_id(:user_password).set gestionnaire.password
page.click_on 'Se connecter'
end

View file

@ -1,26 +0,0 @@
require 'spec_helper'
describe Github::API do
describe '.base_uri' do
it { expect(described_class.base_uri).to eq 'https://api.github.com' }
end
describe '.latest_release' do
subject { described_class.latest_release }
context 'when github is up', vcr: {cassette_name: 'github_lastrelease'} do
it { expect(subject).to be_a RestClient::Response }
it { expect(subject.code).to eq 200 }
end
context 'when github is down' do
before do
allow_any_instance_of(RestClient::Resource).to receive(:get).and_raise(RestClient::Forbidden)
end
it { is_expected.to be_nil }
end
end
end

View file

@ -1,23 +0,0 @@
require 'spec_helper'
describe Github::Releases do
describe '.latest' do
subject { described_class.latest }
context 'when github is up', vcr: {cassette_name: 'github_lastrelease'} do
it { expect(subject.url).to eq 'https://api.github.com/repos/sgmap/tps/releases/4685573' }
it { expect(subject.body).to match /.*[Nouveautés].*/ }
it { expect(subject.published_at).to match /[0-9][0-9][\/][0-9][0-9][\/][0-9][0-9][0-9][0-9]/ }
end
context 'when github is down' do
before do
allow_any_instance_of(RestClient::Resource).to receive(:get).and_raise(RestClient::Forbidden)
end
it { is_expected.to be_nil }
end
end
end