comparison test/functional/custom_fields_controller_test.rb @ 524:1248a47e81b3 feature_36

Merge from branch "luisf"
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Mon, 25 Jul 2011 14:39:38 +0100
parents cbce1fd3b1b7
children cbb26bc654de
comparison
equal deleted inserted replaced
519:3be6bc3c2a17 524:1248a47e81b3
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.
13 # 13 #
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
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.dirname(__FILE__) + '/../test_helper' 18 require File.expand_path('../../test_helper', __FILE__)
19 require 'custom_fields_controller' 19 require 'custom_fields_controller'
20 20
21 # Re-raise errors caught by the controller. 21 # Re-raise errors caught by the controller.
22 class CustomFieldsController; def rescue_action(e) raise e end; end 22 class CustomFieldsController; def rescue_action(e) raise e end; end
23 23
27 def setup 27 def setup
28 @controller = CustomFieldsController.new 28 @controller = CustomFieldsController.new
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
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'
32 end 57 end
33 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",
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