##// END OF EJS Templates
Modules selection lost on project form after validation failure (#8012)....
Jean-Philippe Lang -
r5145:8b39f62a4ce7
parent child
Show More
@@ -517,10 +517,7 class Project < ActiveRecord::Base
517 517 def enabled_module_names=(module_names)
518 518 if module_names && module_names.is_a?(Array)
519 519 module_names = module_names.collect(&:to_s).reject(&:blank?)
520 # remove disabled modules
521 enabled_modules.each {|mod| mod.destroy unless module_names.include?(mod.name)}
522 # add new modules
523 module_names.reject {|name| module_enabled?(name)}.each {|name| enabled_modules << EnabledModule.new(:name => name)}
520 self.enabled_modules = module_names.collect {|name| enabled_modules.detect {|mod| mod.name == name} || EnabledModule.new(:name => name)}
524 521 else
525 522 enabled_modules.clear
526 523 end
@@ -288,6 +288,22 class ProjectsControllerTest < ActionController::TestCase
288 288 end
289 289 end
290 290
291 def test_create_should_preserve_modules_on_validation_failure
292 with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
293 @request.session[:user_id] = 1
294 assert_no_difference 'Project.count' do
295 post :create, :project => {
296 :name => "blog",
297 :identifier => "",
298 :enabled_module_names => %w(issue_tracking news)
299 }
300 end
301 assert_response :success
302 project = assigns(:project)
303 assert_equal %w(issue_tracking news), project.enabled_module_names.sort
304 end
305 end
306
291 307 def test_create_should_not_accept_get
292 308 @request.session[:user_id] = 1
293 309 get :create
@@ -588,6 +588,14 class ProjectTest < ActiveSupport::TestCase
588 588 assert_nil Project.next_identifier
589 589 end
590 590
591 def test_enabled_module_names
592 with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
593 project = Project.new
594
595 project.enabled_module_names = %w(issue_tracking news)
596 assert_equal %w(issue_tracking news), project.enabled_module_names.sort
597 end
598 end
591 599
592 600 def test_enabled_module_names_should_not_recreate_enabled_modules
593 601 project = Project.find(1)
General Comments 0
You need to be logged in to leave comments. Login now