Description:
add announcement controller test
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r642:a8976e9a07cd - - 2 files changed: 4 inserted, 4 deleted

@@ -108,9 +108,9
108 end
108 end
109 end
109 end
110
110
111 private
111 private
112
112
113 def announcement_params
113 def announcement_params
114 - params.require(:announcement).permit(:author, :body, :published, :frontpage, :contest_only,:title, :note)
114 + params.require(:announcement).permit(:author, :body, :published, :frontpage, :contest_only, :title)
115 end
115 end
116 end
116 end
@@ -1,12 +1,12
1 require 'test_helper'
1 require 'test_helper'
2
2
3 class AnnouncementsControllerTest < ActionController::TestCase
3 class AnnouncementsControllerTest < ActionController::TestCase
4 setup do
4 setup do
5 @announcement = announcements(:one)
5 @announcement = announcements(:one)
6 - @request.session[:user_id] = user(:admin).id
6 + @request.session[:user_id] = users(:admin).id
7 end
7 end
8
8
9 test "should get index" do
9 test "should get index" do
10 get :index
10 get :index
11 assert_response :success
11 assert_response :success
12 assert_not_nil assigns(:announcements)
12 assert_not_nil assigns(:announcements)
@@ -16,13 +16,13
16 get :new
16 get :new
17 assert_response :success
17 assert_response :success
18 end
18 end
19
19
20 test "should create announcement" do
20 test "should create announcement" do
21 assert_difference('Announcement.count') do
21 assert_difference('Announcement.count') do
22 - post :create, announcement: { }
22 + post :create, announcement: { author: 'aa',body: 'bb', published: true, frontpage: true, title: 'test'}
23 end
23 end
24
24
25 assert_redirected_to announcement_path(assigns(:announcement))
25 assert_redirected_to announcement_path(assigns(:announcement))
26 end
26 end
27
27
28 test "should show announcement" do
28 test "should show announcement" do
@@ -33,13 +33,13
33 test "should get edit" do
33 test "should get edit" do
34 get :edit, id: @announcement
34 get :edit, id: @announcement
35 assert_response :success
35 assert_response :success
36 end
36 end
37
37
38 test "should update announcement" do
38 test "should update announcement" do
39 - patch :update, id: @announcement, announcement: { }
39 + patch :update, id: @announcement, announcement: { author: 'aa',body: 'bb', published: true, frontpage: true, title: 'test'}
40 assert_redirected_to announcement_path(assigns(:announcement))
40 assert_redirected_to announcement_path(assigns(:announcement))
41 end
41 end
42
42
43 test "should destroy announcement" do
43 test "should destroy announcement" do
44 assert_difference('Announcement.count', -1) do
44 assert_difference('Announcement.count', -1) do
45 delete :destroy, id: @announcement
45 delete :destroy, id: @announcement
You need to be logged in to leave comments. Login now