enables status for issues

pull/243/head
Jens Ulferts 11 years ago
parent 57604d70dd
commit 3c909e6d65
  1. 9
      app/controllers/work_packages_controller.rb
  2. 16
      app/helpers/work_packages_helper.rb
  3. 1
      app/views/work_packages/_attributes.html.erb
  4. 2
      app/views/work_packages/_form.html.erb
  5. 1
      app/views/work_packages/new.html.erb
  6. 41
      spec/controllers/work_packages_controller_spec.rb

@ -61,7 +61,11 @@ class WorkPackagesController < ApplicationController
when PlanningElement.to_s
PlanningElement.new :project => project
when Issue.to_s
Issue.new :project => project
#TODO: generating a new work_package should probably be moved inside work_package
tracker = project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
Issue.new :project => project,
:tracker => tracker
else
raise ArgumentError, "type #{params[:type]} is not supported"
end
@ -128,8 +132,7 @@ class WorkPackagesController < ApplicationController
end
[:changesets, :relations, :allowed_statuses, :priorities].each do |method|
[:changesets, :relations, :priorities].each do |method|
define_method method do
[]
end

@ -141,13 +141,17 @@ module WorkPackagesHelper
end
def work_package_form_status_attribute(form, work_package, locals = {})
field = if locals[:allowed_statuses].any?
form.select(:status_id, (locals[:allowed_statuses].map {|p| [p.name, p.id]}), :required => true)
else
form.label(:status) + work_package.status.name
end
if work_package.is_a?(Issue)
allowed = work_package.new_statuses_allowed_to(User.current, true)
WorkPackageAttribute.new(:status, field)
field = if allowed.any?
form.select(:status_id, (allowed.map {|p| [p.name, p.id]}), :required => true)
else
form.label(:status) + work_package.status.name
end
WorkPackageAttribute.new(:status, field)
end
end
def work_package_form_priority_attribute(form, work_package, locals = {})

@ -12,7 +12,6 @@ See doc/COPYRIGHT.rdoc for more details.
<%= fields_for :work_package, work_package, :builder => TabularFormBuilder do |f| %>
<% attributes = work_package_form_two_column_attributes(f, work_package,
:allowed_statuses => allowed_statuses,
:priorities => priorities,
:project => project) %>

@ -15,7 +15,6 @@ See doc/COPYRIGHT.rdoc for more details.
<div id="issue_descr_fields"<% unless work_package.new_record? || work_package.errors.any? %> style="display:none;"<% end %>>
<% work_package_form_top_attributes(f, work_package,
:allowed_statuses => allowed_statuses,
:priorities => priorities,
:project => project).each do |attribute| %>
<p>
@ -29,7 +28,6 @@ See doc/COPYRIGHT.rdoc for more details.
<div id="attributes" class="attributes">
<%= render :partial => 'attributes', :locals => { :work_package => work_package,
:project => project,
:allowed_statuses => allowed_statuses,
:priorities => priorities
} %>
</div>

@ -25,7 +25,6 @@ See doc/COPYRIGHT.rdoc for more details.
<%= render :partial => 'form', :locals => { :f => f,
:work_package => controller.new_work_package,
:project => controller.project,
:allowed_statuses => controller.allowed_statuses,
:priorities => controller.priorities } %>
<%= send_notification_option %>
</div>

@ -54,6 +54,10 @@ describe WorkPackagesController do
let(:planning_element) { FactoryGirl.create(:planning_element, :project_id => project.id) }
let(:project) { FactoryGirl.create(:project, :identifier => 'test_project', :is_public => false) }
let(:stub_planning_element) { FactoryGirl.build_stubbed(:planning_element, :project_id => stub_project.id) }
let(:stub_project) { FactoryGirl.build_stubbed(:project, :identifier => 'test_project', :is_public => false) }
let(:stub_issue) { FactoryGirl.build_stubbed(:issue, :project_id => stub_project.id) }
let(:current_user) { FactoryGirl.create(:user) }
describe 'show.html' do
@ -223,6 +227,43 @@ describe WorkPackagesController do
it 'should have the project associated' do
controller.new_work_package.project.should == project
end
it "should have the project's first tracker assigned tracker is not specified" do
expected_tracker = FactoryGirl.build_stubbed(:tracker)
trackers = double('trackers')
project.stub!(:trackers).and_return(trackers)
trackers.stub!(:find).with(:first).and_return(expected_tracker)
controller.stub!(:project).and_return(project)
controller.new_work_package.tracker.should == expected_tracker
end
it "should have the project's tracker identified by tracker_id param if provided" do
expected_tracker = FactoryGirl.build_stubbed(:tracker)
trackers = double('trackers')
project.stub!(:trackers).and_return(trackers)
trackers.stub!(:find).with('2').and_return(expected_tracker)
controller.params.merge!({ :tracker_id => '2' })
controller.stub!(:project).and_return(project)
controller.new_work_package.tracker.should == expected_tracker
end
it "should have the project's tracker identified by tracker_id param inside issue param if provided" do
expected_tracker = FactoryGirl.build_stubbed(:tracker)
trackers = double('trackers')
project.stub!(:trackers).and_return(trackers)
trackers.stub!(:find).with('2').and_return(expected_tracker)
controller.params.merge!({ :issue => { :tracker_id => '2' } })
controller.stub!(:project).and_return(project)
controller.new_work_package.tracker.should == expected_tracker
end
end
describe 'when the type is "Project"' do

Loading…
Cancel
Save