diff --git a/app/assets/javascripts/components/common/date_picker.jsx b/app/assets/javascripts/components/common/date_picker.jsx index af5d162576..31946cbe37 100644 --- a/app/assets/javascripts/components/common/date_picker.jsx +++ b/app/assets/javascripts/components/common/date_picker.jsx @@ -148,12 +148,18 @@ const DatePicker = createReactClass({ }, handleHourFieldChange(e) { + if (this.state.value === '') { + this.handleDatePickerChange(new Date()); + } this.setState({ hour: e.target.value }, this.onChangeHandler); }, handleMinuteFieldChange(e) { + if (this.state.value === '') { + this.handleDatePickerChange(new Date()); + } this.setState({ minute: e.target.value }, this.onChangeHandler); diff --git a/spec/features/campaign_overview_spec.rb b/spec/features/campaign_overview_spec.rb index 8d69c92932..1dabb6e959 100644 --- a/spec/features/campaign_overview_spec.rb +++ b/spec/features/campaign_overview_spec.rb @@ -215,7 +215,7 @@ module ResetLocale fill_in('campaign_end', with: '2016-02-10'.to_date) find('.campaign-details .rails_editable-save').click expect(campaign.reload.start).to eq(Time.zone.parse('2016-01-10 00:00:00')) - expect(campaign.end).to eq(Time.zone.parse('2016-02-10 23:59:59')) + expect(campaign.end).to be_within(1.second).of(Time.zone.parse('2016-02-10 23:59:59')) click_button 'Edit' find('.campaign-details .rails_editable-edit').click find('#use_dates').click # uncheck diff --git a/spec/features/campaigns_spec.rb b/spec/features/campaigns_spec.rb index a31d9d6997..4d8d1c3834 100644 --- a/spec/features/campaigns_spec.rb +++ b/spec/features/campaigns_spec.rb @@ -97,7 +97,7 @@ expect(Campaign.last.title).to eq(title) expect(Campaign.last.description).to eq(description) expect(Campaign.last.start).to eq(Time.zone.parse('2016-1-10 00:00:00')) - expect(Campaign.last.end).to eq(Time.zone.parse('2016-02-10 23:59:59')) + expect(Campaign.last.end).to be_within(1.second).of(Time.zone.parse('2016-02-10 23:59:59')) end it 'can be reached from the explore page' do diff --git a/spec/models/campaign_spec.rb b/spec/models/campaign_spec.rb index 6a707864b7..d0bfeb05d6 100644 --- a/spec/models/campaign_spec.rb +++ b/spec/models/campaign_spec.rb @@ -137,7 +137,7 @@ campaign.end = '2016-02-10' campaign.save expect(campaign.start).to eq(Time.new(2016, 1, 10, 0, 0, 0, '+00:00')) - expect(campaign.end).to eq(Time.new(2016, 2, 10, 23, 59, 59, '+00:00')) + expect(campaign.end).to be_within(1.second).of(Time.new(2016, 2, 10, 23, 59, 59, '+00:00')) end end