[#4181] Hooked up the Edit and Update actions for FixedDeliverables.

This commit is contained in:
Eric Davis
2010-06-23 17:05:28 -07:00
parent 32f91e8da2
commit 2ce9c55239
5 changed files with 53 additions and 3 deletions
@@ -16,6 +16,12 @@ class DeliverablesController < InheritedResources::Base
create! { contract_url(@project, @contract) }
end
def update
@deliverable = begin_of_association_chain.deliverables.find_by_id(params[:id])
@deliverable.attributes = params[:fixed_deliverable] # TODO: hardcoded
update! { contract_url(@project, @contract) }
end
def show
redirect_to contract_url(@project, @contract)
end
+2 -2
View File
@@ -31,7 +31,7 @@
<th><%= l(:field_labor) %></th>
<th><%= l(:field_overhead) %></th>
<th><%= l(:field_fixed) %></th>
<th>&nbsp;</th>
<th><%= l(:button_edit) %></th>
<th><%= l(:button_delete) %></th>
</thead>
<tbody>
@@ -46,7 +46,7 @@
<td class="labor">---</td>
<td class="overhead">---</td>
<td class="fixed">---</td>
<td>&nbsp;</td>
<td><%= link_to(l(:button_edit), edit_contract_deliverable_path(@project, resource, deliverable), :class => 'icon icon-edit') %></td>
<td><%= link_to(l(:button_delete), contract_deliverable_path(@project, resource, deliverable), :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %></td>
<% end %>
+9
View File
@@ -0,0 +1,9 @@
<%= content_tag(:h2, h(resource.title)) %>
<% semantic_form_for [@project, @contract, resource], :url => contract_deliverable_path(@project, @contract, resource), :html => {:class => 'tabular'} do |form| %>
<%= render :partial => 'form', :object => form, :locals => {:cancel_path => contract_path(@project, resource)} %>
<% end %>
<% content_for(:header_tags) do %>
<%= stylesheet_link_tag "redmine_contracts", :plugin => "redmine_contracts", :media => "screen" %>
<% end %>
+1 -1
View File
@@ -16,7 +16,7 @@ Redmine::Plugin.register :redmine_contracts do
project_module :contracts do
permission(:manage_budget, {
:contracts => [:index, :new, :create, :show, :edit, :update, :destroy],
:deliverables => [:index, :new, :create, :show, :destroy]
:deliverables => [:index, :new, :create, :show, :edit, :update, :destroy]
}, :public => true)
end
@@ -0,0 +1,35 @@
require 'test_helper'
class DeliverablesEditTest < ActionController::IntegrationTest
include Redmine::I18n
def setup
@project = Project.generate!(:identifier => 'main')
@contract = Contract.generate!(:project => @project, :name => 'A Contract', :payment_terms => 'net_15')
@manager = User.generate!
@deliverable = FixedDeliverable.generate!(:contract => @contract, :manager => @manager, :title => 'The Title')
end
should "allow any user to edit the deliverable" do
visit_contract_page(@contract)
click_link_within "#fixed_deliverable_#{@deliverable.id}", 'Edit'
assert_response :success
assert_template 'deliverables/edit'
assert_select "form#edit_fixed_deliverable_#{@deliverable.id}" do
assert_select "input#fixed_deliverable_title[value=?]", /#{@deliverable.title}/
assert_select "select#fixed_deliverable_type" do
assert_select "option[selected=selected][value=FixedDeliverable]"
end
end
fill_in "Title", :with => 'An updated title'
click_button "Save"
assert_response :success
assert_template 'contracts/show'
assert_equal "An updated title", @deliverable.reload.title
end
end