mirror of
https://github.com/zhigang1992/tsemple.git
synced 2026-04-29 05:05:25 +08:00
Fixed post missing user error when create topic
This commit is contained in:
@@ -16,6 +16,7 @@ class TopicsController < ApplicationController
|
||||
|
||||
def create
|
||||
@topic = Topic.new topic_params.merge(user: current_user)
|
||||
@topic.posts.first.user = current_user
|
||||
if @topic.save
|
||||
redirect_to @topic
|
||||
else
|
||||
|
||||
@@ -28,6 +28,8 @@ class TopicsControllerTest < ActionController::TestCase
|
||||
topic = Topic.last
|
||||
assert_equal 'Title', topic.title
|
||||
assert_equal 'Content', topic.posts.first.content
|
||||
assert_not_nil topic.user
|
||||
assert_equal topic.user, topic.posts.first.user
|
||||
assert_redirected_to topic
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user