diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index ad2bada..353f213 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -16,7 +16,7 @@ class TasksController < MyProfileController decision = params[:decision] if request.post? && VALID_DECISIONS.include?(decision) && params[:id] task = profile.find_in_all_tasks(params[:id]) - task.update_attributes!(params[:task]) + task.update_attributes(params[:task]) begin task.send(decision) rescue Exception => ex diff --git a/app/models/create_enterprise.rb b/app/models/create_enterprise.rb index aef1dba..63d0b54 100644 --- a/app/models/create_enterprise.rb +++ b/app/models/create_enterprise.rb @@ -59,7 +59,7 @@ class CreateEnterprise < Task end end - if self.identifier && Profile.exists?(:identifier => self.identifier) + if self.status != Task::Status::CANCELLED && self.identifier && Profile.exists?(:identifier => self.identifier) self.errors.add(:identifier, '%{fn} is already being as identifier by another enterprise, organization or person.') end end diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index b25cba0..763c2ee 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -223,4 +223,18 @@ class TasksControllerTest < Test::Unit::TestCase assert_includes c_blog2.children(true), p_article end + should 'cancel an enterprise registration task even if there is an enterprise with the same identifier' do + e = Environment.default + e.add_admin(profile) + task = CreateEnterprise.create!(:name => "My Enterprise", :identifier => "my-enterprise", :requestor => profile, :target => e) + enterprise = fast_create(Enterprise, :name => "My Enterprise", :identifier => "my-enterprise") + + assert_nothing_raised do + post :close, {:profile => profile.identifier, :id => task.id, :task => {:reject_explanation => "Bla bla"}, :decision => "cancel"} + end + + task.reload + assert_equal Task::Status::CANCELLED, task.status + end + end -- libgit2 0.21.2