##// END OF EJS Templates
Fixed MissingFeatureException: let user choose to copy attachments or not when bulk copying issues....
Jean-Philippe Lang -
r9271:231282ddcb73
parent child
Show More
@@ -235,6 +235,9 class IssuesController < ApplicationController
235 235 @trackers = target_projects.map(&:trackers).reduce(:&)
236 236 @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
237 237 @categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
238 if @copy
239 @attachments_present = @issues.detect {|i| i.attachments.any?}.present?
240 end
238 241
239 242 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
240 243 render :layout => false if request.xhr?
@@ -250,7 +253,7 class IssuesController < ApplicationController
250 253 @issues.each do |issue|
251 254 issue.reload
252 255 if @copy
253 issue = issue.copy
256 issue = issue.copy({}, :attachments => params[:copy_attachments].present?)
254 257 end
255 258 journal = issue.init_journal(User.current, params[:notes])
256 259 issue.safe_attributes = attributes
@@ -145,8 +145,8 class Issue < ActiveRecord::Base
145 145 end
146 146
147 147 # Returns an unsaved copy of the issue
148 def copy(attributes=nil)
149 copy = self.class.new.copy_from(self)
148 def copy(attributes=nil, copy_options={})
149 copy = self.class.new.copy_from(self, copy_options)
150 150 copy.attributes = attributes if attributes
151 151 copy
152 152 end
@@ -60,6 +60,13
60 60 <p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('issue', custom_field, @projects) %></p>
61 61 <% end %>
62 62
63 <% if @copy && @attachments_present %>
64 <p>
65 <label for='copy_attachments'><%= l(:label_copy_attachments) %></label>
66 <%= check_box_tag 'copy_attachments', '1', true %>
67 </p>
68 <% end %>
69
63 70 <%= call_hook(:view_issues_bulk_edit_details_bottom, { :issues => @issues }) %>
64 71 </div>
65 72
@@ -3057,6 +3057,19 class IssuesControllerTest < ActionController::TestCase
3057 3057 assert_equal 'Failed to save 1 issue(s) on 2 selected: #2.', flash[:error]
3058 3058 end
3059 3059
3060 def test_get_bulk_copy
3061 @request.session[:user_id] = 2
3062 get :bulk_edit, :ids => [1, 2, 3], :copy => '1'
3063 assert_response :success
3064 assert_template 'bulk_edit'
3065
3066 issues = assigns(:issues)
3067 assert_not_nil issues
3068 assert_equal [1, 2, 3], issues.map(&:id).sort
3069
3070 assert_select 'input[name=copy_attachments]'
3071 end
3072
3060 3073 def test_bulk_copy_to_another_project
3061 3074 @request.session[:user_id] = 2
3062 3075 assert_difference 'Issue.count', 2 do
@@ -3099,7 +3112,7 class IssuesControllerTest < ActionController::TestCase
3099 3112 end
3100 3113 end
3101 3114
3102 def test_bulk_copy_should_allow_changing_the_issue_attributes
3115 def test_bulk_copy_should_allow_changing_the_issue_attributes
3103 3116 # Fixes random test failure with Mysql
3104 3117 # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
3105 3118 # doesn't return the expected results
@@ -3145,6 +3158,36 class IssuesControllerTest < ActionController::TestCase
3145 3158 assert_equal 'Copying one issue', journal.notes
3146 3159 end
3147 3160
3161 def test_bulk_copy_should_allow_not_copying_the_attachments
3162 attachment_count = Issue.find(3).attachments.size
3163 assert attachment_count > 0
3164 @request.session[:user_id] = 2
3165
3166 assert_difference 'Issue.count', 1 do
3167 assert_no_difference 'Attachment.count' do
3168 post :bulk_update, :ids => [3], :copy => '1',
3169 :issue => {
3170 :project_id => ''
3171 }
3172 end
3173 end
3174 end
3175
3176 def test_bulk_copy_should_allow_copying_the_attachments
3177 attachment_count = Issue.find(3).attachments.size
3178 assert attachment_count > 0
3179 @request.session[:user_id] = 2
3180
3181 assert_difference 'Issue.count', 1 do
3182 assert_difference 'Attachment.count', attachment_count do
3183 post :bulk_update, :ids => [3], :copy => '1', :copy_attachments => '1',
3184 :issue => {
3185 :project_id => ''
3186 }
3187 end
3188 end
3189 end
3190
3148 3191 def test_bulk_copy_to_another_project_should_follow_when_needed
3149 3192 @request.session[:user_id] = 2
3150 3193 post :bulk_update, :ids => [1], :copy => '1', :issue => {:project_id => 2}, :follow => '1'
General Comments 0
You need to be logged in to leave comments. Login now