Add a LecturesController#index action

This commit is contained in:
Petko Bordjukov 2014-08-30 19:45:25 +03:00
parent 663cd6bcde
commit d43a9bc941
5 changed files with 21 additions and 5 deletions

View File

@ -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

View File

@ -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 %>

View File

@ -0,0 +1,7 @@
h1.entry-title Моите предложения за лекции
ul
- for lecture in @lectures
li = link_to lecture.title, lecture
= link_to 'Предложи лекция', new_lecture_path

View File

@ -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

View File

@ -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