[#887] afficher la liste des dossiers à l'utilisateur
This commit is contained in:
parent
ca363ca095
commit
8c549bf27b
10 changed files with 69 additions and 12 deletions
6
app/controllers/users/dossiers_controller.rb
Normal file
6
app/controllers/users/dossiers_controller.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class Users::DossiersController < ApplicationController
|
||||||
|
before_action :authenticate_user!
|
||||||
|
def index
|
||||||
|
@dossiers = Dossier.all.decorate
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +0,0 @@
|
||||||
class WelcomeController < ApplicationController
|
|
||||||
before_action :authenticate_user!
|
|
||||||
def index
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
10
app/views/users/dossiers/index.html.haml
Normal file
10
app/views/users/dossiers/index.html.haml
Normal 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
|
|
@ -1,2 +0,0 @@
|
||||||
%h1 coucou
|
|
||||||
|
|
|
@ -9,7 +9,8 @@ Rails.application.routes.draw do
|
||||||
}, skip: [:password, :registrations]
|
}, skip: [:password, :registrations]
|
||||||
|
|
||||||
|
|
||||||
root 'welcome#index'
|
# root 'welcome#index'
|
||||||
|
root 'users/dossiers#index'
|
||||||
|
|
||||||
get 'start' => 'start#index'
|
get 'start' => 'start#index'
|
||||||
get 'start/index'
|
get 'start/index'
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150922141232) do
|
ActiveRecord::Schema.define(version: 20150922141232) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# 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.date "date_previsionnelle"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "state"
|
t.string "state"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
|
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
RSpec.describe DossiersController, type: :controller do
|
describe DossiersController, type: :controller do
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:siret_not_found) { 999_999_999_999 }
|
let(:siret_not_found) { 999_999_999_999 }
|
||||||
|
|
17
spec/controllers/users/dossiers_controller_spec.rb
Normal file
17
spec/controllers/users/dossiers_controller_spec.rb
Normal 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
|
16
spec/features/users/list_dossiers_spec.rb
Normal file
16
spec/features/users/list_dossiers_spec.rb
Normal 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
|
16
spec/views/users/dossiers/index.html.haml_spec.rb
Normal file
16
spec/views/users/dossiers/index.html.haml_spec.rb
Normal 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
|
Loading…
Reference in a new issue