comparison test/functional/custom_fields_controller_test.rb @ 442:753f1380d6bc cannam

Merge from branch "redmine-1.2"
author Chris Cannam
date Mon, 06 Jun 2011 14:41:04 +0100
parents cbce1fd3b1b7
children cbb26bc654de
comparison
equal deleted inserted replaced
252:adc8466df404 442:753f1380d6bc
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2009 Jean-Philippe Lang 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
29 @request = ActionController::TestRequest.new 29 @request = ActionController::TestRequest.new
30 @response = ActionController::TestResponse.new 30 @response = ActionController::TestResponse.new
31 @request.session[:user_id] = 1 31 @request.session[:user_id] = 1
32 end 32 end
33 33
34 def test_get_new_issue_custom_field
35 get :new, :type => 'IssueCustomField'
36 assert_response :success
37 assert_template 'new'
38 assert_tag :select,
39 :attributes => {:name => 'custom_field[field_format]'},
40 :child => {
41 :tag => 'option',
42 :attributes => {:value => 'user'},
43 :content => 'User'
44 }
45 assert_tag :select,
46 :attributes => {:name => 'custom_field[field_format]'},
47 :child => {
48 :tag => 'option',
49 :attributes => {:value => 'version'},
50 :content => 'Version'
51 }
52 end
53
54 def test_get_new_with_invalid_custom_field_class_should_redirect_to_list
55 get :new, :type => 'UnknownCustomField'
56 assert_redirected_to '/custom_fields'
57 end
58
34 def test_post_new_list_custom_field 59 def test_post_new_list_custom_field
35 assert_difference 'CustomField.count' do 60 assert_difference 'CustomField.count' do
36 post :new, :type => "IssueCustomField", 61 post :new, :type => "IssueCustomField",
37 :custom_field => {:name => "test_post_new_list", 62 :custom_field => {:name => "test_post_new_list",
38 :default_value => "", 63 :default_value => "",
51 field = IssueCustomField.find_by_name('test_post_new_list') 76 field = IssueCustomField.find_by_name('test_post_new_list')
52 assert_not_nil field 77 assert_not_nil field
53 assert_equal ["0.1", "0.2"], field.possible_values 78 assert_equal ["0.1", "0.2"], field.possible_values
54 assert_equal 1, field.trackers.size 79 assert_equal 1, field.trackers.size
55 end 80 end
56
57 def test_invalid_custom_field_class_should_redirect_to_list
58 get :new, :type => 'UnknownCustomField'
59 assert_redirected_to '/custom_fields'
60 end
61 end 81 end