Mercurial > hg > soundsoftware-site
diff test/functional/custom_fields_controller_test.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | cbce1fd3b1b7 |
children | 433d4f72a19b |
line wrap: on
line diff
--- a/test/functional/custom_fields_controller_test.rb Fri Feb 24 18:36:29 2012 +0000 +++ b/test/functional/custom_fields_controller_test.rb Fri Feb 24 19:09:32 2012 +0000 @@ -5,12 +5,12 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -22,15 +22,21 @@ class CustomFieldsController; def rescue_action(e) raise e end; end class CustomFieldsControllerTest < ActionController::TestCase - fixtures :custom_fields, :trackers, :users - + fixtures :custom_fields, :custom_values, :trackers, :users + def setup @controller = CustomFieldsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @request.session[:user_id] = 1 end - + + def test_index + get :index + assert_response :success + assert_template 'index' + end + def test_get_new_issue_custom_field get :new, :type => 'IssueCustomField' assert_response :success @@ -50,12 +56,12 @@ :content => 'Version' } end - + def test_get_new_with_invalid_custom_field_class_should_redirect_to_list get :new, :type => 'UnknownCustomField' assert_redirected_to '/custom_fields' end - + def test_post_new_list_custom_field assert_difference 'CustomField.count' do post :new, :type => "IssueCustomField", @@ -71,11 +77,41 @@ :is_required =>"0", :field_format => "list", :tracker_ids => ["1", ""]} - end + end assert_redirected_to '/custom_fields?tab=IssueCustomField' field = IssueCustomField.find_by_name('test_post_new_list') assert_not_nil field assert_equal ["0.1", "0.2"], field.possible_values assert_equal 1, field.trackers.size end + + def test_get_edit + get :edit, :id => 1 + assert_response :success + assert_template 'edit' + assert_tag 'input', :attributes => {:name => 'custom_field[name]', :value => 'Database'} + end + + def test_post_edit + post :edit, :id => 1, :custom_field => {:name => 'New name'} + assert_redirected_to '/custom_fields?tab=IssueCustomField' + + field = CustomField.find(1) + assert_equal 'New name', field.name + end + + def test_destroy + custom_values_count = CustomValue.count(:conditions => {:custom_field_id => 1}) + assert custom_values_count > 0 + + assert_difference 'CustomField.count', -1 do + assert_difference 'CustomValue.count', - custom_values_count do + post :destroy, :id => 1 + end + end + + assert_redirected_to '/custom_fields?tab=IssueCustomField' + assert_nil CustomField.find_by_id(1) + assert_nil CustomValue.find_by_custom_field_id(1) + end end