From a2b4bb0dfb932b4e93efe4c85ac7f65033b87f7a 2009-12-06 11:09:12
From: Jean-Philippe Lang
<%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version), :include_blank => true %>
+<%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version), :include_blank => true %> +<%= prompt_to_remote(image_tag('add.png', :style => 'vertical-align: middle;'), + l(:label_version_new), + 'version[name]', + {:controller => 'projects', :action => 'add_version', :id => @project}, + :title => l(:label_version_new), + :tabindex => 200) if authorize_for('projects', 'add_version') %> +
<% end %> diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 21223fc..81c3d8b 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -242,6 +242,29 @@ class ProjectsControllerTest < ActionController::TestCase ) end + def test_add_version + @request.session[:user_id] = 2 # manager + assert_difference 'Version.count' do + post :add_version, :id => '1', :version => {:name => 'test_add_version'} + end + assert_redirected_to '/projects/ecookbook/settings/versions' + version = Version.find_by_name('test_add_version') + assert_not_nil version + assert_equal 1, version.project_id + end + + def test_add_version_from_issue_form + @request.session[:user_id] = 2 # manager + assert_difference 'Version.count' do + xhr :post, :add_version, :id => '1', :version => {:name => 'test_add_version_from_issue_form'} + end + assert_response :success + assert_select_rjs :replace, 'issue_fixed_version_id' + version = Version.find_by_name('test_add_version_from_issue_form') + assert_not_nil version + assert_equal 1, version.project_id + end + def test_add_issue_category_routing assert_routing( {:method => :get, :path => 'projects/test/categories/new'},