forked from bofh/fetsite
AutoCommit Mon Aug 3 08:03:01 CEST 2015
This commit is contained in:
@@ -3,10 +3,15 @@ class CommentsController < ApplicationController
|
|||||||
before_filter :decode_commentable_type
|
before_filter :decode_commentable_type
|
||||||
def index
|
def index
|
||||||
@commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
|
@commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
|
||||||
|
if @commentable.nil?
|
||||||
|
render status: 404
|
||||||
|
else
|
||||||
@comments=@commentable.comments.order(:created_at).roots.accessible_by(current_ability, :show).page(params[:page]).per(Comment::NUM[params[:commentable_type]]).reverse_order
|
@comments=@commentable.comments.order(:created_at).roots.accessible_by(current_ability, :show).page(params[:page]).per(Comment::NUM[params[:commentable_type]]).reverse_order
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def hide
|
def hide
|
||||||
@commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
|
@commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :choices
|
resources :choices
|
||||||
resources :answers
|
|
||||||
end
|
end
|
||||||
|
|
||||||
themes_for_rails
|
themes_for_rails
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
class AddTemplateToSurveyQuestion < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -32,9 +32,13 @@ describe CommentsController do
|
|||||||
|
|
||||||
describe "GET index" do
|
describe "GET index" do
|
||||||
it "assigns all comments as @comments" do
|
it "assigns all comments as @comments" do
|
||||||
comment = Comment.create! valid_attributes
|
comment = Comment.create! valid_attributes # add items to database
|
||||||
get :index, {}, valid_session
|
get :index, {}, valid_session
|
||||||
assigns(:comments).should eq([comment])
|
assigns(:comments).should eq([comment]) # check if all items are returned
|
||||||
|
end
|
||||||
|
it "has a 200 status code" do
|
||||||
|
get :index
|
||||||
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user