[#4420] Add the frequency field for Retainers to the Model and View.
This commit is contained in:
@@ -5,4 +5,21 @@
|
||||
class RetainerDeliverable < HourlyDeliverable
|
||||
unloadable
|
||||
|
||||
# Associations
|
||||
|
||||
# Validations
|
||||
ValidFrequencies = ["monthly", "quarterly"]
|
||||
validates_inclusion_of :frequency, :in => ValidFrequencies, :allow_nil => true, :allow_blank => true
|
||||
|
||||
# Accessors
|
||||
|
||||
# Callbacks
|
||||
|
||||
def short_type
|
||||
'R'
|
||||
end
|
||||
|
||||
def self.frequencies_to_select
|
||||
ValidFrequencies.collect {|f| [l("text_#{f}"), f]}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
<% form.inputs :name => l(:text_deliverable_details_legend) do %>
|
||||
<%= form.input :title, :required => true %>
|
||||
<% if resource.new_record? %>
|
||||
<%= form.input(:type, :required => true, :as => :select, :collection => [["Fixed", "FixedDeliverable"],["Hourly", "HourlyDeliverable"]], :include_blank => false, :input_html => {:class => 'type'}) %>
|
||||
<li class="select required" id="deliverable_type_input">
|
||||
<%= form.label(:type, l(:field_type)) %>
|
||||
<%= form.select(:type, [["Fixed", "FixedDeliverable"], ["Hourly", "HourlyDeliverable"], ["Retainer", "RetainerDeliverable"]], {:include_blank => false}, {:class => 'type'}) %>
|
||||
|
||||
<%= form.select(:frequency, RetainerDeliverable.frequencies_to_select, :include_blank => false) %>
|
||||
</li>
|
||||
<% else %>
|
||||
<%= form.input :type, :as => :hidden, :class => 'type' %>
|
||||
<% end %>
|
||||
|
||||
@@ -60,3 +60,6 @@ en:
|
||||
field_deliverable_title: "Deliverable"
|
||||
field_contract_name: "Contract"
|
||||
field_contract: "Contract"
|
||||
field_frequency: "Frequency"
|
||||
text_monthly: "Monthly"
|
||||
text_quarterly: "Quarterly"
|
||||
|
||||
@@ -4,4 +4,9 @@ class RetainerDeliverableTest < ActiveSupport::TestCase
|
||||
should "be a subclass of HourlyDeliverable" do
|
||||
assert_equal HourlyDeliverable, RetainerDeliverable.superclass
|
||||
end
|
||||
|
||||
context "#frequency" do
|
||||
should_allow_values_for(:frequency, nil, '', 'monthly', 'quarterly')
|
||||
should_not_allow_values_for(:frequency, 'anything', 'else', 'weekly')
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user