Mercurial > hg > soundsoftware-site
comparison test/functional/.svn/text-base/issues_controller_test.rb.svn-base @ 507:0c939c159af4 redmine-1.2
Update to Redmine 1.2.1 on 1.2-stable branch (Redmine SVN rev 6270)
author | Chris Cannam |
---|---|
date | Thu, 14 Jul 2011 10:32:19 +0100 |
parents | cbce1fd3b1b7 |
children |
comparison
equal
deleted
inserted
replaced
441:cbce1fd3b1b7 | 507:0c939c159af4 |
---|---|
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require File.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
19 require 'issues_controller' | 19 require 'issues_controller' |
20 | |
21 # Re-raise errors caught by the controller. | |
22 class IssuesController; def rescue_action(e) raise e end; end | |
23 | 20 |
24 class IssuesControllerTest < ActionController::TestCase | 21 class IssuesControllerTest < ActionController::TestCase |
25 fixtures :projects, | 22 fixtures :projects, |
26 :users, | 23 :users, |
27 :roles, | 24 :roles, |
191 assert_response :success | 188 assert_response :success |
192 assert_template 'index.rhtml' | 189 assert_template 'index.rhtml' |
193 assert_not_nil assigns(:issues) | 190 assert_not_nil assigns(:issues) |
194 assert_not_nil assigns(:issue_count_by_group) | 191 assert_not_nil assigns(:issue_count_by_group) |
195 end | 192 end |
193 | |
194 def test_private_query_should_not_be_available_to_other_users | |
195 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil) | |
196 @request.session[:user_id] = 3 | |
197 | |
198 get :index, :query_id => q.id | |
199 assert_response 403 | |
200 end | |
201 | |
202 def test_private_query_should_be_available_to_its_user | |
203 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil) | |
204 @request.session[:user_id] = 2 | |
205 | |
206 get :index, :query_id => q.id | |
207 assert_response :success | |
208 end | |
209 | |
210 def test_public_query_should_be_available_to_other_users | |
211 q = Query.create!(:name => "private", :user => User.find(2), :is_public => true, :project => nil) | |
212 @request.session[:user_id] = 3 | |
213 | |
214 get :index, :query_id => q.id | |
215 assert_response :success | |
216 end | |
196 | 217 |
197 def test_index_sort_by_field_not_included_in_columns | 218 def test_index_sort_by_field_not_included_in_columns |
198 Setting.issue_list_default_columns = %w(subject author) | 219 Setting.issue_list_default_columns = %w(subject author) |
199 get :index, :sort => 'tracker' | 220 get :index, :sort => 'tracker' |
200 end | 221 end |
265 | 286 |
266 # columns should be stored in session | 287 # columns should be stored in session |
267 assert_kind_of Hash, session[:query] | 288 assert_kind_of Hash, session[:query] |
268 assert_kind_of Array, session[:query][:column_names] | 289 assert_kind_of Array, session[:query][:column_names] |
269 assert_equal columns, session[:query][:column_names].map(&:to_s) | 290 assert_equal columns, session[:query][:column_names].map(&:to_s) |
291 | |
292 # ensure only these columns are kept in the selected columns list | |
293 assert_tag :tag => 'select', :attributes => { :id => 'selected_columns' }, | |
294 :children => { :count => 3 } | |
295 assert_no_tag :tag => 'option', :attributes => { :value => 'project' }, | |
296 :parent => { :tag => 'select', :attributes => { :id => "selected_columns" } } | |
270 end | 297 end |
271 | 298 |
272 def test_index_with_custom_field_column | 299 def test_index_with_custom_field_column |
273 columns = %w(tracker subject cf_2) | 300 columns = %w(tracker subject cf_2) |
274 get :index, :set_filter => 1, :c => columns | 301 get :index, :set_filter => 1, :c => columns |
603 :parent_issue_id => 'ABC'} | 630 :parent_issue_id => 'ABC'} |
604 end | 631 end |
605 issue = Issue.find_by_subject('This is a child issue') | 632 issue = Issue.find_by_subject('This is a child issue') |
606 assert_not_nil issue | 633 assert_not_nil issue |
607 assert_nil issue.parent | 634 assert_nil issue.parent |
635 end | |
636 | |
637 def test_post_create_private | |
638 @request.session[:user_id] = 2 | |
639 | |
640 assert_difference 'Issue.count' do | |
641 post :create, :project_id => 1, | |
642 :issue => {:tracker_id => 1, | |
643 :subject => 'This is a private issue', | |
644 :is_private => '1'} | |
645 end | |
646 issue = Issue.first(:order => 'id DESC') | |
647 assert issue.is_private? | |
648 end | |
649 | |
650 def test_post_create_private_with_set_own_issues_private_permission | |
651 role = Role.find(1) | |
652 role.remove_permission! :set_issues_private | |
653 role.add_permission! :set_own_issues_private | |
654 | |
655 @request.session[:user_id] = 2 | |
656 | |
657 assert_difference 'Issue.count' do | |
658 post :create, :project_id => 1, | |
659 :issue => {:tracker_id => 1, | |
660 :subject => 'This is a private issue', | |
661 :is_private => '1'} | |
662 end | |
663 issue = Issue.first(:order => 'id DESC') | |
664 assert issue.is_private? | |
608 end | 665 end |
609 | 666 |
610 def test_post_create_should_send_a_notification | 667 def test_post_create_should_send_a_notification |
611 ActionMailer::Base.deliveries.clear | 668 ActionMailer::Base.deliveries.clear |
612 @request.session[:user_id] = 2 | 669 @request.session[:user_id] = 2 |