[#4180] Block total from getting set on HourlyDeliverables.
This commit is contained in:
@@ -7,7 +7,23 @@ class HourlyDeliverable < Deliverable
|
||||
|
||||
# Accessors
|
||||
|
||||
# Callbacks
|
||||
before_save :clear_total
|
||||
|
||||
def short_type
|
||||
'H'
|
||||
end
|
||||
|
||||
# Block getting and setting the total on HourlyDeliverables
|
||||
def total
|
||||
nil
|
||||
end
|
||||
|
||||
def total=(v)
|
||||
nil
|
||||
end
|
||||
|
||||
def clear_total
|
||||
write_attribute(:total, nil)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -90,6 +90,7 @@ class DeliverablesNewTest < ActionController::IntegrationTest
|
||||
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'
|
||||
|
||||
# Hide and clear the total
|
||||
assert js("jQuery('#deliverable_total_input').is(':hidden')"),
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class HourlyDeliverableTest < ActiveSupport::TestCase
|
||||
context "#total=" do
|
||||
should "not write any attributes" do
|
||||
d = HourlyDeliverable.new
|
||||
d.total = '$100.00'
|
||||
|
||||
assert_equal nil, d.total
|
||||
end
|
||||
end
|
||||
|
||||
context "clear_total" do
|
||||
should "clear any total attributes" do
|
||||
d = HourlyDeliverable.new
|
||||
d.write_attribute(:total, 100.00)
|
||||
d.clear_total
|
||||
|
||||
assert_equal nil, d.total
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user