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
if request.post?
class VersionsController < ApplicationController
menu_item :roadmap
- before_filter :find_version, :except => :close_completed
- before_filter :find_project, :only => :close_completed
+ before_filter :find_version, :except => [:new, :close_completed]
+ before_filter :find_project, :only => [:new, :close_completed]
before_filter :authorize
helper :custom_fields
def show
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
if request.post? && params[:version]
attributes = params[:version].dup
<%= prompt_to_remote(image_tag('add.png', :style => 'vertical-align: middle;'),
l(:label_version_new),
'version[name]',
- {:controller => 'projects', :action => 'add_version', :id => @project},
+ {:controller => 'versions', :action => 'new', :project_id => @project},
:title => l(:label_version_new),
- :tabindex => 200) if authorize_for('projects', 'add_version') %>
+ :tabindex => 200) if authorize_for('versions', 'new') %>
</p>
<% end %>
</div>
+++ /dev/null
-<h2><%=l(:label_version_new)%></h2>
-
-<% labelled_tabular_form_for :version, @version, :url => { :action => 'add_version' } do |f| %>
-<%= render :partial => 'versions/form', :locals => { :f => f } %>
-<%= submit_tag l(:button_create) %>
-<% end %>
\ No newline at end of file
<% end %>
</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>
--- /dev/null
+<h2><%=l(:label_version_new)%></h2>
+
+<% labelled_tabular_form_for :version, @version, :url => { :action => 'new' } do |f| %>
+<%= render :partial => 'versions/form', :locals => { :f => f } %>
+<%= submit_tag l(:button_create) %>
+<% end %>
\ No newline at end of file
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/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/settings/:tab', :action => 'settings'
end
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/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/activities/save', :action => 'save_activities'
end
end
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|
version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed'
end
map.permission :edit_project, {:projects => [:settings, :edit]}, :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_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.project_module :issue_tracking do |map|
assert_equal 'Test changed name', project.name
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
assert_routing(
{:method => :get, :path => 'projects/test/categories/new'},
assert_tag :tag => 'h2', :content => /1.0/
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
@request.session[:user_id] = 2
get :edit, :id => 2