Add a LecturesController#index action
This commit is contained in:
parent
663cd6bcde
commit
d43a9bc941
|
@ -2,6 +2,10 @@ class LecturesController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
before_action :assign_lecture, only: [:show, :edit, :update]
|
before_action :assign_lecture, only: [:show, :edit, :update]
|
||||||
|
|
||||||
|
def index
|
||||||
|
@lectures = Lecture.where user: current_user
|
||||||
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@lecture = Lecture.new
|
@lecture = Lecture.new
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
<%= content_tag :li, class: [('current_page_item' if controller_name == 'sessions')] do %>
|
<%= content_tag :li, class: [('current_page_item' if controller_name == 'sessions')] do %>
|
||||||
<%= link_to "Вход", new_user_session_path %>
|
<%= link_to "Вход", new_user_session_path %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= content_tag :li, class: [('current_page_item' if controller_name == 'registrations')] do %>
|
|
||||||
<%= link_to "Регистрация", new_user_registration_path %>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
<% 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 %>
|
<%= content_tag :li, class: [('current_page_item' if controller_name == 'registrations')] do %>
|
||||||
<%= link_to "Редакция на профил", edit_user_registration_path %>
|
<%= link_to "Редакция на профил", edit_user_registration_path %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
h1.entry-title Моите предложения за лекции
|
||||||
|
|
||||||
|
ul
|
||||||
|
- for lecture in @lectures
|
||||||
|
li = link_to lecture.title, lecture
|
||||||
|
|
||||||
|
= link_to 'Предложи лекция', new_lecture_path
|
|
@ -1,5 +1,5 @@
|
||||||
Rails.application.routes.draw do
|
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
|
devise_for :users
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,13 @@ RSpec.describe LecturesController, type: :controller do
|
||||||
sign_in user
|
sign_in user
|
||||||
end
|
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
|
describe 'GET new' do
|
||||||
it 'returns http success' do
|
it 'returns HTTP Success status code' do
|
||||||
get :new
|
get :new
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue