Commit ef938b66 authored by dgt's avatar dgt

Merge branch '34-missing-template-pages-posts-index-html' into 'master'

Resolve "Missing Template pages/posts/index.html"

Closes #34

See merge request !257
parents 5dd83db8 e8492e70
......@@ -11,13 +11,6 @@ class Page::PostsController < ApplicationController
track_actions :create, :update, :destroy
# js action to rerender the posts
def index
authorize @page, :show?
@posts = @page.posts(pagination_params)
@post = Post.new
end
def show
authorize @page
respond_to do |format|
......@@ -30,7 +23,7 @@ class Page::PostsController < ApplicationController
authorize @page, :show?
if @post = @page.add_post(current_user, post_params)
respond_to do |format|
format.js { redirect_to action: :index }
format.js { @posts = @page.posts(pagination_params) }
format.html { redirect_to page_url(@page) + "#post-#{@post.id}" }
end
authorize @post
......
......@@ -186,7 +186,7 @@ Crabgrass::Application.routes.draw do
# resources :changes
resources :assets, only: %i[index update create]
resources :tags, only: %i[index create destroy show], :constraints => { :id => /.*/ }
resources :posts, except: [:new]
resources :posts, except: [:index, :new]
# page sidebar/popup controllers:
resource :sidebar, only: [:show]
......
......@@ -42,7 +42,7 @@ class Page::PostsControllerTest < ActionController::TestCase
end
def assert_successfully_posted_to(page)
assert_response :redirect
assert_response :success
assert_equal 1, page.reload.posts.count
assert_equal body, page.posts.first.body
assert_equal users(:blue), page.updated_by
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment