Commit 82978b68ac9cc5fafb6f833dedef73943e1b3110

Authored by Victor Costa
1 parent 1e34e5c2

Set default dates for a step at community track

plugins/community_track/lib/community_track_plugin/step.rb
... ... @@ -25,6 +25,12 @@ class CommunityTrackPlugin::Step < Folder
25 25 before_create :set_hidden_position
26 26 before_save :set_hidden_position
27 27  
  28 + def initialize(*args)
  29 + super(*args)
  30 + self.start_date ||= Date.today
  31 + self.end_date ||= Date.today + 1.day
  32 + end
  33 +
28 34 def set_hidden_position
29 35 if hidden
30 36 decrement_positions_on_lower_items
... ...
plugins/community_track/test/unit/community_track_plugin/step_test.rb
... ... @@ -282,4 +282,10 @@ class StepTest < ActiveSupport::TestCase
282 282 assert_not_equal article, @step.tool
283 283 end
284 284  
  285 + should 'initialize start date and end date with default values' do
  286 + step = CommunityTrackPlugin::Step.new
  287 + assert step.start_date
  288 + assert step.end_date
  289 + end
  290 +
285 291 end
... ...