comparison test/functional/news_controller_test.rb @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents e248c7af89ec
children
comparison
equal deleted inserted replaced
1516:b450a9d58aed 1517:dffacf8a6908
100 post :create, :project_id => 1, 100 post :create, :project_id => 1,
101 :news => { :title => 'Test', :description => 'This is the description' }, 101 :news => { :title => 'Test', :description => 'This is the description' },
102 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} 102 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
103 end 103 end
104 end 104 end
105 attachment = Attachment.first(:order => 'id DESC') 105 attachment = Attachment.order('id DESC').first
106 news = News.first(:order => 'id DESC') 106 news = News.order('id DESC').first
107 assert_equal news, attachment.container 107 assert_equal news, attachment.container
108 end 108 end
109 109
110 def test_post_create_with_validation_failure 110 def test_post_create_with_validation_failure
111 @request.session[:user_id] = 2 111 @request.session[:user_id] = 2
114 :summary => '' } 114 :summary => '' }
115 assert_response :success 115 assert_response :success
116 assert_template 'new' 116 assert_template 'new'
117 assert_not_nil assigns(:news) 117 assert_not_nil assigns(:news)
118 assert assigns(:news).new_record? 118 assert assigns(:news).new_record?
119 assert_error_tag :content => /title can't be blank/i 119 assert_error_tag :content => /title #{ESCAPED_CANT} be blank/i
120 end 120 end
121 121
122 def test_get_edit 122 def test_get_edit
123 @request.session[:user_id] = 2 123 @request.session[:user_id] = 2
124 get :edit, :id => 1 124 get :edit, :id => 1
142 put :update, :id => 1, 142 put :update, :id => 1,
143 :news => { :description => 'This is the description' }, 143 :news => { :description => 'This is the description' },
144 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} 144 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
145 end 145 end
146 end 146 end
147 attachment = Attachment.first(:order => 'id DESC') 147 attachment = Attachment.order('id DESC').first
148 assert_equal News.find(1), attachment.container 148 assert_equal News.find(1), attachment.container
149 end 149 end
150 150
151 def test_update_with_failure 151 def test_update_with_failure
152 @request.session[:user_id] = 2 152 @request.session[:user_id] = 2
153 put :update, :id => 1, :news => { :description => '' } 153 put :update, :id => 1, :news => { :description => '' }
154 assert_response :success 154 assert_response :success
155 assert_template 'edit' 155 assert_template 'edit'
156 assert_error_tag :content => /description can't be blank/i 156 assert_error_tag :content => /description #{ESCAPED_CANT} be blank/i
157 end 157 end
158 158
159 def test_destroy 159 def test_destroy
160 @request.session[:user_id] = 2 160 @request.session[:user_id] = 2
161 delete :destroy, :id => 1 161 delete :destroy, :id => 1