Moves ProjectsController#add_version to VersionsController#new.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3548 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
2af97616f7
commit
729bea1cf3
|
@ -266,39 +266,6 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new version to @project
|
|
||||||
def add_version
|
|
||||||
@version = @project.versions.build
|
|
||||||
if params[:version]
|
|
||||||
attributes = params[:version].dup
|
|
||||||
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
|
|
||||||
@version.attributes = attributes
|
|
||||||
end
|
|
||||||
if request.post?
|
|
||||||
if @version.save
|
|
||||||
respond_to do |format|
|
|
||||||
format.html do
|
|
||||||
flash[:notice] = l(:notice_successful_create)
|
|
||||||
redirect_to :action => 'settings', :tab => 'versions', :id => @project
|
|
||||||
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
|
|
||||||
|
|
||||||
def add_file
|
def add_file
|
||||||
if request.post?
|
if request.post?
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
class VersionsController < ApplicationController
|
class VersionsController < ApplicationController
|
||||||
menu_item :roadmap
|
menu_item :roadmap
|
||||||
before_filter :find_version, :except => :close_completed
|
before_filter :find_version, :except => [:new, :close_completed]
|
||||||
before_filter :find_project, :only => :close_completed
|
before_filter :find_project, :only => [:new, :close_completed]
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
|
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
|
@ -27,6 +27,38 @@ class VersionsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@version = @project.versions.build
|
||||||
|
if params[:version]
|
||||||
|
attributes = params[:version].dup
|
||||||
|
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
|
||||||
|
@version.attributes = attributes
|
||||||
|
end
|
||||||
|
if request.post?
|
||||||
|
if @version.save
|
||||||
|
respond_to do |format|
|
||||||
|
format.html do
|
||||||
|
flash[:notice] = l(:notice_successful_create)
|
||||||
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||||
|
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
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
if request.post? && params[:version]
|
if request.post? && params[:version]
|
||||||
attributes = params[:version].dup
|
attributes = params[:version].dup
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
<%= prompt_to_remote(image_tag('add.png', :style => 'vertical-align: middle;'),
|
<%= prompt_to_remote(image_tag('add.png', :style => 'vertical-align: middle;'),
|
||||||
l(:label_version_new),
|
l(:label_version_new),
|
||||||
'version[name]',
|
'version[name]',
|
||||||
{:controller => 'projects', :action => 'add_version', :id => @project},
|
{:controller => 'versions', :action => 'new', :project_id => @project},
|
||||||
:title => l(:label_version_new),
|
:title => l(:label_version_new),
|
||||||
:tabindex => 200) if authorize_for('projects', 'add_version') %>
|
:tabindex => 200) if authorize_for('versions', 'new') %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -38,4 +38,4 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p><%= link_to_if_authorized l(:label_version_new), :controller => 'projects', :action => 'add_version', :id => @project %></p>
|
<p><%= link_to_if_authorized l(:label_version_new), :controller => 'versions', :action => 'new', :project_id => @project %></p>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<h2><%=l(:label_version_new)%></h2>
|
<h2><%=l(:label_version_new)%></h2>
|
||||||
|
|
||||||
<% labelled_tabular_form_for :version, @version, :url => { :action => 'add_version' } do |f| %>
|
<% labelled_tabular_form_for :version, @version, :url => { :action => 'new' } do |f| %>
|
||||||
<%= render :partial => 'versions/form', :locals => { :f => f } %>
|
<%= render :partial => 'versions/form', :locals => { :f => f } %>
|
||||||
<%= submit_tag l(:button_create) %>
|
<%= submit_tag l(:button_create) %>
|
||||||
<% end %>
|
<% end %>
|
|
@ -191,7 +191,6 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
project_views.connect 'projects/:id/:action', :action => /roadmap|destroy|settings/
|
project_views.connect 'projects/:id/:action', :action => /roadmap|destroy|settings/
|
||||||
project_views.connect 'projects/:id/files', :action => 'list_files'
|
project_views.connect 'projects/:id/files', :action => 'list_files'
|
||||||
project_views.connect 'projects/:id/files/new', :action => 'add_file'
|
project_views.connect 'projects/:id/files/new', :action => 'add_file'
|
||||||
project_views.connect 'projects/:id/versions/new', :action => 'add_version'
|
|
||||||
project_views.connect 'projects/:id/categories/new', :action => 'add_issue_category'
|
project_views.connect 'projects/:id/categories/new', :action => 'add_issue_category'
|
||||||
project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
|
project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
|
||||||
end
|
end
|
||||||
|
@ -209,7 +208,6 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
project_actions.connect 'projects.:format', :action => 'add', :format => /xml/
|
project_actions.connect 'projects.:format', :action => 'add', :format => /xml/
|
||||||
project_actions.connect 'projects/:id/:action', :action => /edit|destroy|archive|unarchive/
|
project_actions.connect 'projects/:id/:action', :action => /edit|destroy|archive|unarchive/
|
||||||
project_actions.connect 'projects/:id/files/new', :action => 'add_file'
|
project_actions.connect 'projects/:id/files/new', :action => 'add_file'
|
||||||
project_actions.connect 'projects/:id/versions/new', :action => 'add_version'
|
|
||||||
project_actions.connect 'projects/:id/categories/new', :action => 'add_issue_category'
|
project_actions.connect 'projects/:id/categories/new', :action => 'add_issue_category'
|
||||||
project_actions.connect 'projects/:id/activities/save', :action => 'save_activities'
|
project_actions.connect 'projects/:id/activities/save', :action => 'save_activities'
|
||||||
end
|
end
|
||||||
|
@ -225,6 +223,7 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
end
|
end
|
||||||
|
|
||||||
map.with_options :controller => 'versions' do |versions|
|
map.with_options :controller => 'versions' do |versions|
|
||||||
|
versions.connect 'projects/:project_id/versions/new', :action => 'new'
|
||||||
versions.with_options :conditions => {:method => :post} do |version_actions|
|
versions.with_options :conditions => {:method => :post} do |version_actions|
|
||||||
version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed'
|
version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed'
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,7 +39,7 @@ Redmine::AccessControl.map do |map|
|
||||||
map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member
|
map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member
|
||||||
map.permission :select_project_modules, {:projects => :modules}, :require => :member
|
map.permission :select_project_modules, {:projects => :modules}, :require => :member
|
||||||
map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member
|
map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member
|
||||||
map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :close_completed, :destroy]}, :require => :member
|
map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :close_completed, :destroy]}, :require => :member
|
||||||
map.permission :add_subprojects, {:projects => :add}, :require => :member
|
map.permission :add_subprojects, {:projects => :add}, :require => :member
|
||||||
|
|
||||||
map.project_module :issue_tracking do |map|
|
map.project_module :issue_tracking do |map|
|
||||||
|
|
|
@ -329,41 +329,6 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
assert_equal 'Test changed name', project.name
|
assert_equal 'Test changed name', project.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_version_routing
|
|
||||||
assert_routing(
|
|
||||||
{:method => :get, :path => 'projects/64/versions/new'},
|
|
||||||
:controller => 'projects', :action => 'add_version', :id => '64'
|
|
||||||
)
|
|
||||||
assert_routing(
|
|
||||||
#TODO: use PUT
|
|
||||||
{:method => :post, :path => 'projects/64/versions/new'},
|
|
||||||
:controller => 'projects', :action => 'add_version', :id => '64'
|
|
||||||
)
|
|
||||||
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'},
|
||||||
|
|
|
@ -40,6 +40,40 @@ class VersionsControllerTest < ActionController::TestCase
|
||||||
assert_tag :tag => 'h2', :content => /1.0/
|
assert_tag :tag => 'h2', :content => /1.0/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_new_routing
|
||||||
|
assert_routing(
|
||||||
|
{:method => :get, :path => 'projects/foo/versions/new'},
|
||||||
|
:controller => 'versions', :action => 'new', :project_id => 'foo'
|
||||||
|
)
|
||||||
|
assert_routing(
|
||||||
|
{:method => :post, :path => 'projects/foo/versions/new'},
|
||||||
|
:controller => 'versions', :action => 'new', :project_id => 'foo'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_new
|
||||||
|
@request.session[:user_id] = 2 # manager
|
||||||
|
assert_difference 'Version.count' do
|
||||||
|
post :new, :project_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_new_from_issue_form
|
||||||
|
@request.session[:user_id] = 2 # manager
|
||||||
|
assert_difference 'Version.count' do
|
||||||
|
xhr :post, :new, :project_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_get_edit
|
def test_get_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :edit, :id => 2
|
get :edit, :id => 2
|
||||||
|
|
Loading…
Reference in New Issue