Show More
Commit Description:
add announcement controller test
Commit Description:
add announcement controller test
References:
File last commit:
Show/Diff file:
Action:
test/controllers/announcements_controller_test.rb
| 50 lines
| 1.3 KiB
| text/x-ruby
| RubyLexer
|
r638 | require 'test_helper' | |||
class AnnouncementsControllerTest < ActionController::TestCase | ||||
setup do | ||||
@announcement = announcements(:one) | ||||
r642 | @request.session[:user_id] = users(:admin).id | |||
r638 | end | |||
test "should get index" do | ||||
get :index | ||||
assert_response :success | ||||
assert_not_nil assigns(:announcements) | ||||
end | ||||
test "should get new" do | ||||
get :new | ||||
assert_response :success | ||||
end | ||||
test "should create announcement" do | ||||
assert_difference('Announcement.count') do | ||||
r642 | post :create, announcement: { author: 'aa',body: 'bb', published: true, frontpage: true, title: 'test'} | |||
r638 | end | |||
assert_redirected_to announcement_path(assigns(:announcement)) | ||||
end | ||||
test "should show announcement" do | ||||
get :show, id: @announcement | ||||
assert_response :success | ||||
end | ||||
test "should get edit" do | ||||
get :edit, id: @announcement | ||||
assert_response :success | ||||
end | ||||
test "should update announcement" do | ||||
r642 | patch :update, id: @announcement, announcement: { author: 'aa',body: 'bb', published: true, frontpage: true, title: 'test'} | |||
r638 | assert_redirected_to announcement_path(assigns(:announcement)) | |||
end | ||||
test "should destroy announcement" do | ||||
assert_difference('Announcement.count', -1) do | ||||
delete :destroy, id: @announcement | ||||
end | ||||
assert_redirected_to announcements_path | ||||
end | ||||
end | ||||