diff --git a/app/controllers/lectures_controller.rb b/app/controllers/lectures_controller.rb index 1397267..c18612b 100644 --- a/app/controllers/lectures_controller.rb +++ b/app/controllers/lectures_controller.rb @@ -2,6 +2,10 @@ class LecturesController < ApplicationController before_filter :authenticate_user! before_action :assign_lecture, only: [:show, :edit, :update] + def index + @lectures = Lecture.where user: current_user + end + def new @lecture = Lecture.new end diff --git a/app/views/layouts/_nav.html.erb b/app/views/layouts/_nav.html.erb index 2a04c27..bc5ecf2 100644 --- a/app/views/layouts/_nav.html.erb +++ b/app/views/layouts/_nav.html.erb @@ -8,10 +8,10 @@ <%= content_tag :li, class: [('current_page_item' if controller_name == 'sessions')] do %> <%= link_to "Вход", new_user_session_path %> <% end %> - <%= content_tag :li, class: [('current_page_item' if controller_name == 'registrations')] do %> - <%= link_to "Регистрация", new_user_registration_path %> - <% end %> <% else %> + <%= content_tag :li, class: [('current_page_item' if controller_name == 'lectures')] do %> + <%= link_to "Лекции", lectures_path %> + <% end %> <%= content_tag :li, class: [('current_page_item' if controller_name == 'registrations')] do %> <%= link_to "Редакция на профил", edit_user_registration_path %> <% end %> diff --git a/app/views/lectures/index.html.slim b/app/views/lectures/index.html.slim new file mode 100644 index 0000000..3324930 --- /dev/null +++ b/app/views/lectures/index.html.slim @@ -0,0 +1,7 @@ +h1.entry-title Моите предложения за лекции + +ul + - for lecture in @lectures + li = link_to lecture.title, lecture + += link_to 'Предложи лекция', new_lecture_path diff --git a/config/routes.rb b/config/routes.rb index a08d41f..6b707c3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Rails.application.routes.draw do - resources :lectures, only: [:new, :create, :edit, :update, :show] + resources :lectures, only: [:index, :new, :create, :edit, :update, :show] devise_for :users diff --git a/spec/controllers/lectures_controller_spec.rb b/spec/controllers/lectures_controller_spec.rb index 637c2c6..b4095a2 100644 --- a/spec/controllers/lectures_controller_spec.rb +++ b/spec/controllers/lectures_controller_spec.rb @@ -7,8 +7,13 @@ RSpec.describe LecturesController, type: :controller do sign_in user end + describe 'GET index' do + it 'returns HTTP Success status code' + it 'assigns the lectures of the current user to @lectures' + end + describe 'GET new' do - it 'returns http success' do + it 'returns HTTP Success status code' do get :new expect(response).to be_success end