diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rb index e03bbf0413..8b620e4a93 100644 --- a/app/controllers/enumerations_controller.rb +++ b/app/controllers/enumerations_controller.rb @@ -91,9 +91,6 @@ class EnumerationsController < ApplicationController end end @enumerations = @enumeration.class.find(:all) - [@enumeration] - #rescue - # flash[:error] = 'Unable to delete enumeration' - # redirect_to :action => 'index' end def default_breadcrumb diff --git a/app/views/enumerations/destroy.html.erb b/app/views/enumerations/destroy.html.erb index 8313dcef7f..25af4f3acd 100644 --- a/app/views/enumerations/destroy.html.erb +++ b/app/views/enumerations/destroy.html.erb @@ -29,11 +29,11 @@ See doc/COPYRIGHT.rdoc for more details.

<%= l(@enumeration.option_name) %>: <%=h @enumeration %>

-<%= form_tag({}) do %> +<%= form_tag({}, :method => :delete) do %>

<%= l(:text_enumeration_destroy_question, @enumeration.objects_count) %>

-<%= select_tag 'reassign_to_id', ("" + options_from_collection_for_select(@enumerations, 'id', 'name')) %>

+<%= select_tag 'reassign_to_id', options_from_collection_for_select(@enumerations, 'id', 'name') %>

<%= submit_tag l(:button_apply) %> diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 7327422c15..ce1720f2d1 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -32,6 +32,7 @@ See doc/COPYRIGHT.rdoc for more details. * `#2363` When all wiki pages have been deleted new wiki pages cannot be created (respecification) * `#2566` Fix: [Timelines] Searching when selecting columns for a timeline configuration does not work * `#2631` Fix: [Timelines] Work package cannot be created out of timeline. +* `#2685` [Work package tracking] 404 when deleting work package priority which is assigned to work package * `#2686` Fix: [Work package tracking] Work package summary not displayed correctly * `#2687` Fix: [Work Package Tracking] No error for parallel editing * `#2708` Fix: API key auth does not work for custom_field actions diff --git a/spec/controllers/enumerations_controller.rb b/spec/controllers/enumerations_controller.rb new file mode 100644 index 0000000000..d22e7364df --- /dev/null +++ b/spec/controllers/enumerations_controller.rb @@ -0,0 +1,76 @@ +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2013 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See doc/COPYRIGHT.rdoc for more details. +#++ + +require 'spec_helper' + +describe EnumerationsController do + before { controller.stub(:require_admin).and_return(true) } + + describe :destroy do + describe :priority do + let(:enum_to_delete) { FactoryGirl.create(:priority_normal) } + + shared_examples_for "successful delete" do + it { expect(Enumeration.find_by_id(enum_to_delete.id)).to be_nil } + + it { expect(response).to redirect_to(enumerations_path) } + end + + describe "not in use" do + before { post :destroy, id: enum_to_delete.id } + + it_behaves_like "successful delete" + end + + describe "in use" do + let!(:enum_to_reassign) { FactoryGirl.create(:priority_high) } + let!(:work_package) { FactoryGirl.create(:work_package, + priority: enum_to_delete) } + + describe "no reassign" do + before { post :destroy, id: enum_to_delete.id } + + it { expect(assigns(:enumerations)).to include(enum_to_reassign) } + + it { expect(Enumeration.find_by_id(enum_to_delete.id)).not_to be_nil } + + it { expect(response).to render_template("enumerations/destroy")} + end + + describe "reassign" do + before do + post :destroy, id: enum_to_delete.id, + reassign_to_id: enum_to_reassign.id + end + + it_behaves_like "successful delete" + end + end + end + end +end