Merge pull request #543 from opf/fix/remove_pe_status_enumeration

pull/459/head
Hagen Schink 11 years ago
commit 35846a1b26
  1. 57
      app/controllers/api/v2/planning_element_statuses_controller.rb
  2. 50
      app/controllers/planning_element_statuses_controller.rb
  3. 2
      app/models/enumeration.rb
  4. 48
      app/models/planning_element_status.rb
  5. 1
      config/locales/de.yml
  6. 1
      config/locales/en.yml
  7. 2
      config/routes.rb
  8. 3
      doc/CHANGELOG.md
  9. 29
      features/step_definitions/planning_element_status_steps.rb
  10. 8
      features/step_definitions/timelines_given_steps.rb
  11. 3
      features/timelines/timeline_wiki_macro.feature
  12. 122
      spec/controllers/api/v2/planning_element_statuses_controller_spec.rb
  13. 35
      spec/factories/planning_element_status_factory.rb
  14. 70
      spec/views/api/v2/planning_element_statuses/_planning_element_status_api_rsb_spec.rb
  15. 104
      spec/views/api/v2/planning_element_statuses/index_api_rsb_spec.rb
  16. 74
      spec/views/api/v2/planning_element_statuses/show_api_rsb_spec.rb

@ -1,57 +0,0 @@
#-- 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.
#++
module Api
module V2
class PlanningElementStatusesController < PlanningElementStatusesController
unloadable
helper :timelines
include ::Api::V2::ApiController
accept_key_auth :index, :show
def index
@planning_element_statuses = PlanningElementStatus.active
respond_to do |format|
format.api
end
end
def show
@planning_element_status = PlanningElementStatus.active.find(params[:id])
respond_to do |format|
format.api
end
end
end
end
end

@ -1,50 +0,0 @@
#-- 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.
#++
class PlanningElementStatusesController < ApplicationController
unloadable
helper :timelines
before_filter :disable_api
accept_key_auth :index, :show
def index
@planning_element_statuses = PlanningElementStatus.active
respond_to do |format|
format.html { render_404 }
end
end
def show
@planning_element_status = PlanningElementStatus.active.find(params[:id])
respond_to do |format|
format.html { render_404 }
end
end
end

@ -177,7 +177,7 @@ end
# Force load the subclasses in development mode
['time_entry_activity', 'issue_priority',
'reported_project_status', 'planning_element_status'].each do |enum_subclass|
'reported_project_status'].each do |enum_subclass|
require_dependency enum_subclass
end

@ -1,48 +0,0 @@
#-- 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.
#++
class PlanningElementStatus < Enumeration
unloadable
has_many :planning_elements, :class_name => "PlanningElement",
:foreign_key => 'planning_element_status_id'
OptionName = :enumeration_planning_element_statuses
def option_name
OptionName
end
def objects_count
planning_elements.count
end
def transfer_relations(to)
planning_elements.update_all(:planning_element_status_id => to.id)
end
end

@ -481,7 +481,6 @@ de:
enumeration_activities: "Aktivitäten (Zeiterfassung)"
enumeration_work_package_priorities: "Arbeitspaket-Prioritäten"
enumeration_planning_element_statuses: "Planungselement-Status"
enumeration_reported_project_statuses: "Gemeldeter Projekt-Status"
enumeration_system_activity: "System-Aktivität"

@ -478,7 +478,6 @@ en:
enumeration_activities: "Activities (time tracking)"
enumeration_work_package_priorities: "Work package priorities"
enumeration_system_activity: "System Activity"
enumeration_planning_element_statuses: "Planning element status"
enumeration_reported_project_statuses: "Reported project status"
error_can_not_archive_project: "This project cannot be archived"

@ -422,8 +422,6 @@ OpenProject::Application.routes.draw do
end
end
resources :planning_element_statuses, :controller => 'planning_element_statuses'
resources :project_types, :controller => 'project_types' do
member do
get :confirm_destroy

@ -38,7 +38,8 @@ See doc/COPYRIGHT.rdoc for more details.
* `#2026` 404 error when letters are entered in category Work Package
* `#2371` Add support for IE10 to Timelines
* `#2423` [Issue Tracker] Several Internal Errors when there is no default work package status
* `#2427` [Issue Tracker] Cannot delete work package priority
* `#2426` [Core] Enumerations for planning elements
* `#2427` [Issue Tracker] Cannot delete work package priority
* `#2433` [Timelines] Empty timeline report not displayed initially
* `#2448` Accelerate work package updates
* `#2464` No initial attachment journal for messages

@ -1,29 +0,0 @@
#-- 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.
#++
InstanceFinder.register(PlanningElementStatus, Proc.new { |name| PlanningElementStatus.find_by_name(name) })

@ -47,14 +47,6 @@ Given /^I am working in the [tT]imeline "([^"]*)" of the project called "([^"]*)
@timeline_name = timeline_name
end
Given /^there are the following planning element statuses:$/ do |table|
table.map_headers! { |header| header.underscore.gsub(' ', '_') }
table.hashes.each do |type_attributes|
FactoryGirl.create(:planning_element_status, type_attributes)
end
end
Given /^there are the following reported project statuses:$/ do |table|
table.map_headers! { |header| header.underscore.gsub(' ', '_') }

@ -82,9 +82,6 @@ Feature: Timeline Wiki Macro
And the user "manager" is a "loser"
And the user "mrtimeline" is a "god"
And there are the following planning element statuses:
| Name |
| closed |
And there are the following work packages:
| Subject | Start date | Due date | description | status | responsible |
| January | 2012-01-01 | 2012-01-31 | Avocado Grande | closed | manager |

@ -1,122 +0,0 @@
#-- 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 File.expand_path('../../../../spec_helper', __FILE__)
describe Api::V2::PlanningElementStatusesController do
let(:current_user) { FactoryGirl.create(:admin) }
before do
User.stub(:current).and_return current_user
end
describe 'index.xml' do
def fetch
get 'index', :format => 'xml'
end
it_should_behave_like "a controller action with unrestricted access"
describe 'with no planning element statuses available' do
it 'assigns an empty planning_element_statuses array' do
get 'index', :format => 'xml'
assigns(:planning_element_statuses).should == []
end
it 'renders the index builder template' do
get 'index', :format => 'xml'
response.should render_template('planning_element_statuses/index', :formats => ["api"])
end
end
describe 'with 3 planning element statuses available' do
before do
@created_planning_element_statuses = [
FactoryGirl.create(:planning_element_status),
FactoryGirl.create(:planning_element_status),
FactoryGirl.create(:planning_element_status)
]
end
it 'assigns an array with all planning element statuses' do
get 'index', :format => 'xml'
assigns(:planning_element_statuses).should == @created_planning_element_statuses
end
it 'renders the index template' do
get 'index', :format => 'xml'
response.should render_template('planning_element_statuses/index', :formats => ["api"])
end
end
end
describe 'show.xml' do
describe 'with unknown planning element status' do
if false # would like to write it this way
it 'returns status code 404' do
get 'show', :id => '1337', :format => 'xml'
response.status.should == '404 Not Found'
end
it 'returns an empty body' do
get 'show', :id => '1337', :format => 'xml'
response.body.should be_empty
end
else # but have to write it that way
it 'raises ActiveRecord::RecordNotFound errors' do
lambda do
get 'show', :id => '1337', :format => 'xml'
end.should raise_error(ActiveRecord::RecordNotFound)
end
end
end
describe 'with an available planning element status' do
before do
@available_planning_element_status = FactoryGirl.create(:planning_element_status, :id => '1337')
end
def fetch
get 'show', :id => '1337', :format => 'xml'
end
it_should_behave_like "a controller action with unrestricted access"
it 'assigns the available planning element status' do
get 'show', :id => '1337', :format => 'xml'
assigns(:planning_element_status).should == @available_planning_element_status
end
it 'renders the show template' do
get 'show', :id => '1337', :format => 'xml'
response.should render_template('planning_element_statuses/show', :formats => ["api"])
end
end
end
end

@ -1,35 +0,0 @@
#-- 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.
#++
FactoryGirl.define do
factory(:planning_element_status, :class => PlanningElementStatus) do
sequence(:name) { |n| "Planning Element Status No. #{n}" }
sequence(:position) { |n| n }
end
end

@ -1,70 +0,0 @@
#-- 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 File.expand_path('../../../../../spec_helper', __FILE__)
describe 'api/v2/planning_element_statuses/_planning_element_status.api' do
before do
view.extend TimelinesHelper
end
# added to pass in locals
def render
params[:format] = 'xml'
super(:partial => 'api/v2/planning_element_statuses/planning_element_status.api', :object => planning_element_status)
end
describe 'with an assigned planning_element_status' do
let(:planning_element_status) { FactoryGirl.build(:planning_element_status,
:id => 1,
:name => 'Awesometastic Planning Element Status',
:position => 100) }
it 'renders a planning_element_status node' do
render
response.should have_selector('planning_element_status', :count => 1)
end
describe 'planning_element_status node' do
it 'contains an id element containing the planning element status id' do
render
response.should have_selector('planning_element_status id', :text => '1')
end
it 'contains a name element containing the planning element status name' do
render
response.should have_selector('planning_element_status name', :text => 'Awesometastic Planning Element Status')
end
it 'contains an position element containing the planning element status position' do
render
response.should have_selector('planning_element_status position', :text => '100')
end
end
end
end

@ -1,104 +0,0 @@
#-- 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 File.expand_path('../../../../../spec_helper', __FILE__)
describe 'api/v2/planning_element_statuses/index.api.rsb' do
before do
view.extend TimelinesHelper
end
before do
params[:format] = 'xml'
end
describe 'with no planning element statuses available' do
it 'renders an empty planning_element_statuses document' do
assign(:planning_element_statuses, [])
render
response.should have_selector('planning_element_statuses', :count => 1)
response.should have_selector('planning_element_statuses[type=array][size="0"]') do
without_tag 'planning_element_status'
end
end
end
describe 'with 3 planning element statuses available' do
let(:planning_element_statuses) do
[
FactoryGirl.build(:planning_element_status),
FactoryGirl.build(:planning_element_status),
FactoryGirl.build(:planning_element_status)
]
end
it 'renders a planning_element_statuses document with the size 3 of type array' do
assign(:planning_element_statuses, planning_element_statuses)
render
response.should have_selector('planning_element_statuses', :count => 1)
response.should have_selector('planning_element_statuses[type=array][size="3"]')
end
it 'renders a planning_element_status for each assigned planning element' do
assign(:planning_element_statuses, planning_element_statuses)
render
response.should have_selector('planning_element_statuses planning_element_status', :count => 3)
end
it 'renders the _planning_element_status template for each assigned planning element status' do
assign(:planning_element_statuses, planning_element_statuses)
view.should_receive(:render).exactly(3).times.with(hash_including(:partial => '/api/v2/planning_element_statuses/planning_element_status.api')).and_return('')
# just to be able to call render despite the should_receive expectations above
view.should_receive(:render).once.with({:template=>"api/v2/planning_element_statuses/index", :handlers=>["rsb"], :formats=>["api"]}, {}).and_call_original
render
end
it 'passes the planning element statuses as local var to the partial' do
assign(:planning_element_statuses, planning_element_statuses)
view.should_receive(:render).once.with(hash_including(:object => planning_element_statuses.first)).and_return('')
view.should_receive(:render).once.with(hash_including(:object => planning_element_statuses.second)).and_return('')
view.should_receive(:render).once.with(hash_including(:object => planning_element_statuses.third)).and_return('')
# just to be able to call render despite the should_receive expectations above
view.should_receive(:render).once.with({:template=>"api/v2/planning_element_statuses/index", :handlers=>["rsb"], :formats=>["api"]}, {}).and_call_original
render
end
end
end

@ -1,74 +0,0 @@
#-- 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 File.expand_path('../../../../../spec_helper', __FILE__)
describe 'api/v2/planning_element_statuses/show.api.rsb' do
before do
view.extend TimelinesHelper
end
before do
params[:format] = 'xml'
end
describe 'with an assigned planning element status' do
let(:planning_element_status) { FactoryGirl.build(:planning_element_status) }
before do
assign(:planning_element_status, planning_element_status)
end
it 'renders a planning_element_status document' do
render
response.should have_selector('planning_element_status', :count => 1)
end
it 'renders the _planning_element_status template once' do
view.should_receive(:render).once.with(hash_including(:partial => '/api/v2/planning_element_statuses/planning_element_status.api')).and_return('')
# just to render the speced template despite the should receive expectations above
view.should_receive(:render).once.with({:template=>"api/v2/planning_element_statuses/show", :handlers=>["rsb"], :formats=>["api"]}, {}).and_call_original
render
end
it 'passes the planning element status as local var to the partial' do
view.should_receive(:render).once.with(hash_including(:object => planning_element_status)).and_return('')
# just to render the speced template despite the should receive expectations above
view.should_receive(:render).once.with({:template=>"api/v2/planning_element_statuses/show", :handlers=>["rsb"], :formats=>["api"]}, {}).and_call_original
render
end
end
end
Loading…
Cancel
Save