@@ -234,9 +234,28 class ProjectsController < ApplicationController | |||
|
234 | 234 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
|
235 | 235 | @version.attributes = attributes |
|
236 | 236 | end |
|
237 |
if request.post? |
|
|
238 | flash[:notice] = l(:notice_successful_create) | |
|
239 | redirect_to :action => 'settings', :tab => 'versions', :id => @project | |
|
237 | if request.post? | |
|
238 | if @version.save | |
|
239 | respond_to do |format| | |
|
240 | format.html do | |
|
241 | flash[:notice] = l(:notice_successful_create) | |
|
242 | redirect_to :action => 'settings', :tab => 'versions', :id => @project | |
|
243 | end | |
|
244 | format.js do | |
|
245 | # IE doesn't support the replace_html rjs method for select box options | |
|
246 | render(:update) {|page| page.replace "issue_fixed_version_id", | |
|
247 | content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') | |
|
248 | } | |
|
249 | end | |
|
250 | end | |
|
251 | else | |
|
252 | respond_to do |format| | |
|
253 | format.html | |
|
254 | format.js do | |
|
255 | render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) } | |
|
256 | end | |
|
257 | end | |
|
258 | end | |
|
240 | 259 | end |
|
241 | 260 | end |
|
242 | 261 |
@@ -19,7 +19,14 | |||
|
19 | 19 | :tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p> |
|
20 | 20 | <% end %> |
|
21 | 21 | <% unless @issue.assignable_versions.empty? %> |
|
22 |
<p><%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version), :include_blank => true %> |
|
|
22 | <p><%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version), :include_blank => true %> | |
|
23 | <%= prompt_to_remote(image_tag('add.png', :style => 'vertical-align: middle;'), | |
|
24 | l(:label_version_new), | |
|
25 | 'version[name]', | |
|
26 | {:controller => 'projects', :action => 'add_version', :id => @project}, | |
|
27 | :title => l(:label_version_new), | |
|
28 | :tabindex => 200) if authorize_for('projects', 'add_version') %> | |
|
29 | </p> | |
|
23 | 30 | <% end %> |
|
24 | 31 | </div> |
|
25 | 32 |
@@ -242,6 +242,29 class ProjectsControllerTest < ActionController::TestCase | |||
|
242 | 242 | ) |
|
243 | 243 | end |
|
244 | 244 | |
|
245 | def test_add_version | |
|
246 | @request.session[:user_id] = 2 # manager | |
|
247 | assert_difference 'Version.count' do | |
|
248 | post :add_version, :id => '1', :version => {:name => 'test_add_version'} | |
|
249 | end | |
|
250 | assert_redirected_to '/projects/ecookbook/settings/versions' | |
|
251 | version = Version.find_by_name('test_add_version') | |
|
252 | assert_not_nil version | |
|
253 | assert_equal 1, version.project_id | |
|
254 | end | |
|
255 | ||
|
256 | def test_add_version_from_issue_form | |
|
257 | @request.session[:user_id] = 2 # manager | |
|
258 | assert_difference 'Version.count' do | |
|
259 | xhr :post, :add_version, :id => '1', :version => {:name => 'test_add_version_from_issue_form'} | |
|
260 | end | |
|
261 | assert_response :success | |
|
262 | assert_select_rjs :replace, 'issue_fixed_version_id' | |
|
263 | version = Version.find_by_name('test_add_version_from_issue_form') | |
|
264 | assert_not_nil version | |
|
265 | assert_equal 1, version.project_id | |
|
266 | end | |
|
267 | ||
|
245 | 268 | def test_add_issue_category_routing |
|
246 | 269 | assert_routing( |
|
247 | 270 | {:method => :get, :path => 'projects/test/categories/new'}, |
General Comments 0
You need to be logged in to leave comments.
Login now