[#887] afficher la liste des dossiers à l'utilisateur

This commit is contained in:
Tanguy PATTE 2015-09-23 12:04:57 +02:00
parent ca363ca095
commit 8c549bf27b
10 changed files with 69 additions and 12 deletions

View file

@ -0,0 +1,6 @@
class Users::DossiersController < ApplicationController
before_action :authenticate_user!
def index
@dossiers = Dossier.all.decorate
end
end

View file

@ -1,6 +0,0 @@
class WelcomeController < ApplicationController
before_action :authenticate_user!
def index
end
end

View file

@ -0,0 +1,10 @@
%h1 Vos dossiers :
%table.table
%thead
%th Nom du Projet
%th Mise à jour
- @dossiers.each do |dossier|
%tr
%td= dossier.nom_projet
%td= dossier.last_update

View file

@ -1,2 +0,0 @@
%h1 coucou

View file

@ -9,7 +9,8 @@ Rails.application.routes.draw do
}, skip: [:password, :registrations]
root 'welcome#index'
# root 'welcome#index'
root 'users/dossiers#index'
get 'start' => 'start#index'
get 'start/index'

View file

@ -11,7 +11,6 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150922141232) do
# These are extensions that must be enabled in order to support this database
@ -47,7 +46,7 @@ ActiveRecord::Schema.define(version: 20150922141232) do
t.date "date_previsionnelle"
t.datetime "created_at"
t.datetime "updated_at"
t.string "state"
t.string "state"
end
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree

View file

@ -1,6 +1,6 @@
require 'spec_helper'
RSpec.describe DossiersController, type: :controller do
describe DossiersController, type: :controller do
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
let(:dossier_id) { dossier.id }
let(:siret_not_found) { 999_999_999_999 }

View file

@ -0,0 +1,17 @@
require 'spec_helper'
describe Users::DossiersController, type: :controller do
describe '.index' do
subject { get :index }
context 'when user is not logged in' do
it { is_expected.to redirect_to('/users/sign_in') }
end
context 'when user is logged in' do
before do
sign_in create(:user)
end
it { is_expected.to render_template('users/dossiers/index') }
it { is_expected.to have_http_status(:success) }
end
end
end

View file

@ -0,0 +1,16 @@
require 'spec_helper'
feature 'user access to the list of his dossier' do
let(:user) { create(:user) }
let!(:dossier1) { create(:dossier) }
before do
visit root_path
page.find_by_id('user_email').set user.email
page.find_by_id('user_password').set user.password
page.click_on 'Se connecter'
end
scenario 'the list of dossier is displayed' do
expect(page).to have_content(dossier1.nom_projet)
end
end

View file

@ -0,0 +1,16 @@
require 'spec_helper'
describe 'users/dossiers/index.html.haml', type: :view do
describe 'list dossiers' do
let(:dossier1) { create(:dossier).decorate }
let(:dossier2) { create(:dossier).decorate }
before do
assign(:dossiers, [dossier1, dossier2])
render
end
subject { rendered }
it { expect(subject).to have_content(dossier1.nom_projet) }
end
end