# HG changeset patch # User Nattee Niparnan # Date 2017-02-28 08:12:43 # Node ID a8976e9a07cd633eb57f24364d69f24547dbd5eb # Parent 2a2038aee8bdff8b46023423bf1cb2a84f7b5a21 add announcement controller test diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -111,6 +111,6 @@ private def announcement_params - params.require(:announcement).permit(:author, :body, :published, :frontpage, :contest_only,:title, :note) + params.require(:announcement).permit(:author, :body, :published, :frontpage, :contest_only, :title) end end diff --git a/test/controllers/announcements_controller_test.rb b/test/controllers/announcements_controller_test.rb --- a/test/controllers/announcements_controller_test.rb +++ b/test/controllers/announcements_controller_test.rb @@ -3,7 +3,7 @@ class AnnouncementsControllerTest < ActionController::TestCase setup do @announcement = announcements(:one) - @request.session[:user_id] = user(:admin).id + @request.session[:user_id] = users(:admin).id end test "should get index" do @@ -19,7 +19,7 @@ test "should create announcement" do assert_difference('Announcement.count') do - post :create, announcement: { } + post :create, announcement: { author: 'aa',body: 'bb', published: true, frontpage: true, title: 'test'} end assert_redirected_to announcement_path(assigns(:announcement)) @@ -36,7 +36,7 @@ end test "should update announcement" do - patch :update, id: @announcement, announcement: { } + patch :update, id: @announcement, announcement: { author: 'aa',body: 'bb', published: true, frontpage: true, title: 'test'} assert_redirected_to announcement_path(assigns(:announcement)) end