2015-12-14 17:27:14 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'Administrator connection' do
|
2018-10-03 11:11:02 +02:00
|
|
|
include ActiveJob::TestHelper
|
|
|
|
|
2018-10-30 15:31:13 +01:00
|
|
|
let(:email) { 'admin1@admin.com' }
|
|
|
|
let(:password) { 'mon chien aime les bananes' }
|
|
|
|
let!(:admin) { create(:administrateur, email: email, password: password) }
|
|
|
|
let!(:gestionnaire) { create(:gestionnaire, email: email, password: password) }
|
2018-10-03 11:11:02 +02:00
|
|
|
|
2015-12-14 17:27:14 +01:00
|
|
|
before do
|
|
|
|
visit new_administrateur_session_path
|
|
|
|
end
|
2018-10-03 11:11:02 +02:00
|
|
|
|
2017-06-13 17:46:08 +02:00
|
|
|
scenario 'administrator is on sign in page' do
|
|
|
|
expect(page).to have_css('#new_user')
|
2015-12-14 17:27:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context "admin fills form and log in" do
|
|
|
|
before do
|
2018-10-03 11:11:02 +02:00
|
|
|
sign_in_with(email, password, true)
|
2015-12-14 17:27:14 +01:00
|
|
|
end
|
2018-10-03 11:11:02 +02:00
|
|
|
|
2015-12-14 17:27:14 +01:00
|
|
|
scenario 'a menu button is available' do
|
|
|
|
expect(page).to have_css('#admin_menu')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when he click on the menu' do
|
|
|
|
before do
|
|
|
|
page.find_by_id('admin_menu').click
|
|
|
|
end
|
|
|
|
scenario 'it displays the menu' do
|
|
|
|
expect(page).to have_css('a#profile')
|
2017-04-12 11:12:05 +02:00
|
|
|
expect(page).to have_css('#sign-out')
|
2015-12-14 17:27:14 +01:00
|
|
|
end
|
2017-04-12 11:12:05 +02:00
|
|
|
context 'when clicking on sign-out' do
|
2015-12-14 17:27:14 +01:00
|
|
|
before do
|
2018-01-10 17:26:12 +01:00
|
|
|
stub_request(:get, "https://api.github.com/repos/betagouv/tps/releases/latest")
|
2018-01-15 19:34:08 +01:00
|
|
|
.to_return(:status => 200, :body => '{"tag_name": "plip", "body": "blabla", "published_at": "2016-02-09T16:46:47Z"}', :headers => {})
|
2016-02-16 12:01:39 +01:00
|
|
|
|
2017-12-11 11:51:18 +01:00
|
|
|
page.find_by_id('sign-out').find('a').click
|
2015-12-14 17:27:14 +01:00
|
|
|
end
|
|
|
|
scenario 'admin is redireted to home page' do
|
2017-04-17 15:03:23 +02:00
|
|
|
expect(page).to have_css('.landing')
|
2015-12-14 17:27:14 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
context 'when clicking on profile' do
|
|
|
|
before do
|
|
|
|
page.find_by_id('profile').click
|
|
|
|
end
|
|
|
|
scenario 'it redirects to profile page' do
|
2018-08-23 18:53:35 +02:00
|
|
|
expect(page).to have_css('#profil-page')
|
2015-12-14 17:27:14 +01:00
|
|
|
end
|
|
|
|
context 'when clicking on procedure' do
|
|
|
|
before do
|
2018-08-24 17:55:35 +02:00
|
|
|
page.click_on('Tableau de bord').click
|
2015-12-14 17:27:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'it redirects to procedure page' do
|
2018-09-05 14:48:42 +02:00
|
|
|
expect(page).to have_content('Démarches')
|
2015-12-14 17:27:14 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|