[#4420] Hook up Retainers so they can be saved.
This commit is contained in:
@@ -14,7 +14,7 @@ class DeliverablesController < InheritedResources::Base
|
||||
|
||||
def create
|
||||
@deliverable = begin_of_association_chain.deliverables.build(params[:deliverable])
|
||||
if params[:deliverable] && params[:deliverable][:type] && ['FixedDeliverable','HourlyDeliverable'].include?(params[:deliverable][:type])
|
||||
if params[:deliverable] && params[:deliverable][:type] && ['FixedDeliverable','HourlyDeliverable','RetainerDeliverable'].include?(params[:deliverable][:type])
|
||||
@deliverable.type = params[:deliverable][:type]
|
||||
end
|
||||
create! { contract_url(@project, @contract) }
|
||||
|
||||
@@ -68,6 +68,10 @@ class Deliverable < ActiveRecord::Base
|
||||
end_date
|
||||
end
|
||||
|
||||
def retainer?
|
||||
type == "RetainerDeliverable"
|
||||
end
|
||||
|
||||
if Rails.env.test?
|
||||
generator_for :title, :method => :next_title
|
||||
|
||||
|
||||
@@ -119,7 +119,18 @@
|
||||
|
||||
<%= textilizable(deliverable, :notes) %>
|
||||
|
||||
<% if deliverable.retainer? %>
|
||||
<form action="">
|
||||
<fieldset>
|
||||
<select name="m">
|
||||
<option value="1">TODO: Release 2</option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</form>
|
||||
<% end %>
|
||||
|
||||
<table>
|
||||
<%= show_field(deliverable, :frequency, :html_options => {:class => 'deliverable-frequency'}) if deliverable.retainer? %>
|
||||
<%= show_field(deliverable, :start_date, :format => :format_date, :html_options => {:class => 'deliverable-start-date'}) %>
|
||||
<%= show_field(deliverable, :end_date, :format => :format_date, :html_options => {:class => 'deliverable-end-date'}) %>
|
||||
</table>
|
||||
|
||||
@@ -111,6 +111,39 @@ class DeliverablesNewTest < ActionController::IntegrationTest
|
||||
|
||||
end
|
||||
|
||||
should "create a new Retainer deliverable" do
|
||||
@manager = User.generate!
|
||||
@role = Role.generate!
|
||||
User.add_to_project(@manager, @project, @role)
|
||||
|
||||
visit_contract_page(@contract)
|
||||
click_link 'Add New'
|
||||
assert_response :success
|
||||
|
||||
fill_in "Title", :with => 'A New Deliverable'
|
||||
select "Retainer", :from => "Type"
|
||||
select "Monthly", :from => 'deliverable_frequency'
|
||||
select @manager.name, :from => "Manager"
|
||||
fill_in "Start", :with => '2010-01-01'
|
||||
fill_in "End Date", :with => '2010-12-31'
|
||||
fill_in "Notes", :with => 'Some notes on the deliverable'
|
||||
fill_in "Total", :with => '1,000.00'
|
||||
|
||||
click_button "Save"
|
||||
|
||||
assert_response :success
|
||||
assert_template 'contracts/show'
|
||||
|
||||
@deliverable = Deliverable.last
|
||||
assert_equal "A New Deliverable", @deliverable.title
|
||||
assert_equal @contract, @deliverable.contract
|
||||
assert_equal "RetainerDeliverable", @deliverable.type
|
||||
assert_equal '2010-01-01', @deliverable.start_date.to_s
|
||||
assert_equal '2010-12-31', @deliverable.end_date.to_s
|
||||
assert_equal @manager, @deliverable.manager
|
||||
assert_equal "monthly", @deliverable.frequency
|
||||
end
|
||||
|
||||
should "create new budget items for the deliverables" do
|
||||
@manager = User.generate!
|
||||
@role = Role.generate!
|
||||
|
||||
Reference in New Issue
Block a user