diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb new file mode 100644 index 000000000..eaf68cfc4 --- /dev/null +++ b/app/controllers/users/dossiers_controller.rb @@ -0,0 +1,6 @@ +class Users::DossiersController < ApplicationController + before_action :authenticate_user! + def index + @dossiers = Dossier.all.decorate + end +end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb deleted file mode 100644 index 0a135b18b..000000000 --- a/app/controllers/welcome_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class WelcomeController < ApplicationController - before_action :authenticate_user! - def index - - end -end \ No newline at end of file diff --git a/app/views/users/dossiers/index.html.haml b/app/views/users/dossiers/index.html.haml new file mode 100644 index 000000000..30f4a7fb4 --- /dev/null +++ b/app/views/users/dossiers/index.html.haml @@ -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 \ No newline at end of file diff --git a/app/views/welcome/index.html.haml b/app/views/welcome/index.html.haml deleted file mode 100644 index 0956bc2a7..000000000 --- a/app/views/welcome/index.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -%h1 coucou - diff --git a/config/routes.rb b/config/routes.rb index df5c8f0a3..a192e08dd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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' diff --git a/db/schema.rb b/db/schema.rb index ee8bf168b..2603b24dd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 diff --git a/spec/controllers/dossiers_controller_spec.rb b/spec/controllers/dossiers_controller_spec.rb index 65136dbbd..9a235e65f 100644 --- a/spec/controllers/dossiers_controller_spec.rb +++ b/spec/controllers/dossiers_controller_spec.rb @@ -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 } diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb new file mode 100644 index 000000000..6a136ab38 --- /dev/null +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/users/list_dossiers_spec.rb b/spec/features/users/list_dossiers_spec.rb new file mode 100644 index 000000000..2d1db6656 --- /dev/null +++ b/spec/features/users/list_dossiers_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/views/users/dossiers/index.html.haml_spec.rb b/spec/views/users/dossiers/index.html.haml_spec.rb new file mode 100644 index 000000000..bd88b8ddc --- /dev/null +++ b/spec/views/users/dossiers/index.html.haml_spec.rb @@ -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 \ No newline at end of file