Commit b267a7e3 authored by dgt's avatar dgt

Merge branch '289-fix-500-when-deleting-direct-message' into 'master'

fix redirect after deleting post without js

Closes #289

See merge request !267
parents d27fda55 89f92296
......@@ -30,7 +30,17 @@ module Common::Posts
@post.destroy
respond_to do |format|
format.js { render template: 'common/posts/destroy' }
format.html { redirect_to page_url(@page) }
format.html { redirect_to parent_redirect }
end
end
protected
def parent_redirect
if @page.present?
page_url(@page)
else
{action: :index}
end
end
......
......@@ -32,4 +32,15 @@ class Me::PostsControllerTest < ActionController::TestCase
assert_response :success
end
end
def test_delete_post_without_js
me = users(:blue)
you = users(:red)
post = Message.send from: me, to: you, body: 'test message'
login_as me
assert_difference 'Post.count', -1 do
delete :destroy, discussion_id: you.login, id: post
assert_response :redirect
end
end
end
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