Merge branch 'france_connect' of ssh://37.187.249.111:2200/opt/git/tps into france_connect

Conflicts:
	spec/controllers/france_connect_controller_spec.rb
This commit is contained in:
Tanguy PATTE 2015-10-07 12:03:14 +02:00
commit 76e3b60f71
6 changed files with 56 additions and 37 deletions

View file

@ -1,5 +1,4 @@
#form_login{
text-align:center;
h4{
margin-top:11px;
}

View file

@ -23,6 +23,11 @@ class FranceConnectController < ApplicationController
sign_in @user
if current_user == @user
@user.login_with_france_connect = true
@user.save
end
redirect_to(controller: 'users/dossiers', action: :index)
end
rescue Rack::OAuth2::Client::Error => e

View file

@ -1,7 +1,7 @@
#div{style:'text-align:center'}
%div{style:'text-align:center'}
%h2#login_user Connexion
%br
%div#form_login.row
%br
%div#form_login.row
%div.col-md-6.col-lg-6
= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
%h4
@ -26,5 +26,5 @@
%img#logo_fc{src: '/assets/logo_FC_03.png', style:'max-height:180px'}
%br
%button.btn.btn-info.btn-lg
= link_to "Se connecter", '/france_connect', id: 'france_connect', style:'color:white; text-decoration: none'
= link_to "Connexion", '/france_connect', id: 'france_connect', style:'color:white; text-decoration: none'

View file

@ -0,0 +1,5 @@
class AddLoginWithFranceConnectToUser < ActiveRecord::Migration
def change
add_column :users, :login_with_france_connect, :boolean, :default => false
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151006155256) do
ActiveRecord::Schema.define(version: 20151007085022) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -44,8 +44,8 @@ ActiveRecord::Schema.define(version: 20151006155256) do
t.string "montant_aide_demande"
t.integer "procedure_id"
t.date "date_previsionnelle"
t.datetime "created_at", default: '2015-09-22 09:25:29'
t.datetime "updated_at", default: '2015-09-22 09:25:29'
t.datetime "created_at"
t.datetime "updated_at"
t.string "state"
t.integer "user_id"
end
@ -110,7 +110,7 @@ ActiveRecord::Schema.define(version: 20151006155256) do
t.integer "type_de_piece_justificative_id"
end
add_index "pieces_justificatives", ["type_de_piece_justificative_id"], name: "index_pieces_justificatives_on_type_de_piece_justificative_id", using: :btree
add_index "pieces_justificatives", ["type_de_piece_justificative_id"], name: "index_pieces_justificatives_on_type_piece_jointe_id", using: :btree
create_table "procedures", force: :cascade do |t|
t.string "libelle"
@ -121,6 +121,7 @@ ActiveRecord::Schema.define(version: 20151006155256) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "test"
t.boolean "use_api_carto", default: false
end
create_table "types_de_piece_justificative", force: :cascade do |t|
@ -145,6 +146,7 @@ ActiveRecord::Schema.define(version: 20151006155256) do
t.inet "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "login_with_france_connect", default: false
t.string "siret"
end

View file

@ -22,10 +22,18 @@ describe FranceConnectController, type: :controller do
let(:siret) { '41123069100049' }
let(:user_info) { Hashie::Mash.new(email: email, siret: siret) }
context 'when code is correct' do
before do
let(:email) { 'patator@cake.com' }
let(:current_user) { User.find_by_email(email) }
before do
allow(FranceConnectService).to receive(:retrieve_user_informations).and_return(user_info)
get :callback, code: code
end
it 'login_with_france_connect user attribut is true' do
expect(current_user.login_with_france_connect).to be_truthy
end
it 'redirect to dossiers list' do
get :callback, code: code
expect(response).to redirect_to(controller: 'users/dossiers', action: :index)