Ability to add a new version from the issue form (#4315).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3126 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
8f33c6589d
commit
a2b4bb0dfb
@ -234,10 +234,29 @@ class ProjectsController < ApplicationController
|
|||||||
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
|
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
|
||||||
@version.attributes = attributes
|
@version.attributes = attributes
|
||||||
end
|
end
|
||||||
if request.post? and @version.save
|
if request.post?
|
||||||
|
if @version.save
|
||||||
|
respond_to do |format|
|
||||||
|
format.html do
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'settings', :tab => 'versions', :id => @project
|
redirect_to :action => 'settings', :tab => 'versions', :id => @project
|
||||||
end
|
end
|
||||||
|
format.js do
|
||||||
|
# IE doesn't support the replace_html rjs method for select box options
|
||||||
|
render(:update) {|page| page.replace "issue_fixed_version_id",
|
||||||
|
content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]')
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.js do
|
||||||
|
render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_file
|
def add_file
|
||||||
|
@ -19,7 +19,14 @@
|
|||||||
:tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p>
|
:tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% unless @issue.assignable_versions.empty? %>
|
<% unless @issue.assignable_versions.empty? %>
|
||||||
<p><%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version), :include_blank => true %></p>
|
<p><%= 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') %>
|
||||||
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -242,6 +242,29 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||||||
)
|
)
|
||||||
end
|
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
|
def test_add_issue_category_routing
|
||||||
assert_routing(
|
assert_routing(
|
||||||
{:method => :get, :path => 'projects/test/categories/new'},
|
{:method => :get, :path => 'projects/test/categories/new'},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user