Mercurial > hg > soundsoftware-site
comparison test/functional/news_controller_test.rb @ 38:33d69fee1d99 cannam
* Merge SVN update from default branch
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 19 Nov 2010 13:41:40 +0000 |
parents | 94944d00e43c |
children | af80e5618e9b |
comparison
equal
deleted
inserted
replaced
29:192d132064a5 | 38:33d69fee1d99 |
---|---|
71 | 71 |
72 @request.session[:user_id] = 2 | 72 @request.session[:user_id] = 2 |
73 post :create, :project_id => 1, :news => { :title => 'NewsControllerTest', | 73 post :create, :project_id => 1, :news => { :title => 'NewsControllerTest', |
74 :description => 'This is the description', | 74 :description => 'This is the description', |
75 :summary => '' } | 75 :summary => '' } |
76 assert_redirected_to 'projects/ecookbook/news' | 76 assert_redirected_to '/projects/ecookbook/news' |
77 | 77 |
78 news = News.find_by_title('NewsControllerTest') | 78 news = News.find_by_title('NewsControllerTest') |
79 assert_not_nil news | 79 assert_not_nil news |
80 assert_equal 'This is the description', news.description | 80 assert_equal 'This is the description', news.description |
81 assert_equal User.find(2), news.author | 81 assert_equal User.find(2), news.author |
91 end | 91 end |
92 | 92 |
93 def test_put_update | 93 def test_put_update |
94 @request.session[:user_id] = 2 | 94 @request.session[:user_id] = 2 |
95 put :update, :id => 1, :news => { :description => 'Description changed by test_post_edit' } | 95 put :update, :id => 1, :news => { :description => 'Description changed by test_post_edit' } |
96 assert_redirected_to 'news/1' | 96 assert_redirected_to '/news/1' |
97 news = News.find(1) | 97 news = News.find(1) |
98 assert_equal 'Description changed by test_post_edit', news.description | 98 assert_equal 'Description changed by test_post_edit', news.description |
99 end | 99 end |
100 | 100 |
101 def test_post_create_with_validation_failure | 101 def test_post_create_with_validation_failure |
111 :content => /1 error/ | 111 :content => /1 error/ |
112 end | 112 end |
113 | 113 |
114 def test_destroy | 114 def test_destroy |
115 @request.session[:user_id] = 2 | 115 @request.session[:user_id] = 2 |
116 post :destroy, :id => 1 | 116 delete :destroy, :id => 1 |
117 assert_redirected_to 'projects/ecookbook/news' | 117 assert_redirected_to '/projects/ecookbook/news' |
118 assert_nil News.find_by_id(1) | 118 assert_nil News.find_by_id(1) |
119 end | 119 end |
120 | |
121 def test_preview | |
122 get :preview, :project_id => 1, | |
123 :news => {:title => '', | |
124 :description => 'News description', | |
125 :summary => ''} | |
126 assert_response :success | |
127 assert_template 'common/_preview' | |
128 assert_tag :tag => 'fieldset', :attributes => { :class => 'preview' }, | |
129 :content => /News description/ | |
130 end | |
131 end | 120 end |