mirror of
https://github.com/zhigang1992/tsemple.git
synced 2026-04-29 13:15:25 +08:00
29 lines
715 B
Ruby
29 lines
715 B
Ruby
require 'test_helper'
|
|
|
|
class TopicsControllerTest < ActionController::TestCase
|
|
test "should get index page" do
|
|
3.times { create(:topic) }
|
|
get :index
|
|
assert_response :success, @response.body
|
|
end
|
|
|
|
test "should get new page" do
|
|
assert_require_logined do
|
|
get :new
|
|
end
|
|
assert_response :success, @response.body
|
|
end
|
|
|
|
test "should create topic" do
|
|
assert_difference "Topic.count" do
|
|
assert_require_logined do
|
|
post :create, topic: { title: 'Title', posts_attributes: [ content: 'Content' ] }
|
|
end
|
|
end
|
|
topic = Topic.last
|
|
assert_equal 'Title', topic.title
|
|
assert_equal 'Content', topic.posts.first.content
|
|
assert_redirected_to topic
|
|
end
|
|
end
|