Merge pull request #616 from opf/fix/work_package_priority_deletion

[FIX] Work package priority deletion
pull/624/head
cratz 11 years ago
commit b2c0496b32
  1. 3
      app/controllers/enumerations_controller.rb
  2. 4
      app/views/enumerations/destroy.html.erb
  3. 1
      doc/CHANGELOG.md
  4. 76
      spec/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

@ -29,11 +29,11 @@ See doc/COPYRIGHT.rdoc for more details.
<h2><%= l(@enumeration.option_name) %>: <%=h @enumeration %></h2>
<%= form_tag({}) do %>
<%= form_tag({}, :method => :delete) do %>
<div class="box">
<p><strong><%= l(:text_enumeration_destroy_question, @enumeration.objects_count) %></strong></p>
<p><label for='reassign_to_id'><%= l(:text_enumeration_category_reassign_to) %></label>
<%= select_tag 'reassign_to_id', ("<option>--- #{l(:actionview_instancetag_blank_option)} ---</option>" + options_from_collection_for_select(@enumerations, 'id', 'name')) %></p>
<%= select_tag 'reassign_to_id', options_from_collection_for_select(@enumerations, 'id', 'name') %></p>
</div>
<%= submit_tag l(:button_apply) %>

@ -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

@ -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
Loading…
Cancel
Save