Compare commits

...

17 Commits

Author SHA1 Message Date
Daniel O'Connor
44e2149fe1 Merge branch 'dev' into planted_at 2025-03-29 14:24:06 +10:30
Daniel O'Connor
4f548a8f8e Update planting_a_crop_spec.rb 2024-10-14 09:09:40 +10:30
Daniel O'Connor
6c1f1a8542 Update planting_a_crop_spec.rb 2024-10-14 09:05:54 +10:30
Daniel O'Connor
37441120c2 Update planting_a_crop_spec.rb 2024-10-14 09:04:57 +10:30
Daniel O'Connor
6ec5226f0b Update planting.rb 2024-10-14 08:43:45 +10:30
Daniel O'Connor
6ecac1526d Merge branch 'dev' into planted_at 2024-10-14 07:01:20 +10:30
Daniel O'Connor
d5ad194ded Update spec/features/plantings/planting_a_crop_spec.rb 2024-10-14 00:36:32 +10:30
Daniel O'Connor
30ac140eb7 Apply suggestions from code review 2024-10-14 00:36:07 +10:30
Daniel O'Connor
d1e6ce6c42 Update spec/features/plantings/planting_a_crop_spec.rb 2024-10-14 00:35:16 +10:30
Daniel O'Connor
0eacdf8fb8 Apply suggestions from code review 2024-10-14 00:35:08 +10:30
Daniel O'Connor
724d55147b Update spec/features/plantings/planting_a_crop_spec.rb 2024-10-14 00:33:58 +10:30
Daniel O'Connor
e4efa0bfab Update spec/features/plantings/planting_a_crop_spec.rb 2024-10-14 00:28:04 +10:30
Daniel O'Connor
64d51ec4bd Update spec/features/plantings/planting_a_crop_spec.rb 2024-10-14 00:27:50 +10:30
Daniel O'Connor
a689b04bfc Update spec/features/plantings/planting_a_crop_spec.rb 2024-10-14 00:27:34 +10:30
Daniel O'Connor
bce1407859 Update spec/features/plantings/planting_a_crop_spec.rb 2024-10-14 00:23:34 +10:30
Daniel O'Connor
a04cbf3b2a Update spec/features/plantings/planting_a_crop_spec.rb 2024-10-14 00:23:13 +10:30
Daniel O'Connor
5cf14ad536 Refactor planted at 2024-10-13 13:36:15 +00:00
4 changed files with 11 additions and 13 deletions

View File

@@ -124,7 +124,7 @@ class Planting < ApplicationRecord
def finished_must_be_after_planted
return unless planted_at && finished_at # only check if we have both
errors.add(:finished_at, "must be after the planting date") unless planted_at < finished_at
errors.add(:finished_at, "must be after the planting date (#{finished_at}) < #{planted_at}") unless planted_at < finished_at
end
def owner_must_match_garden_owner

View File

@@ -32,9 +32,9 @@
label: 'Where did you plant it?')
= link_to "Add a garden.", new_garden_path
.col-md-4
= f.text_field :planted_at,
= f.date_field :planted_at,
value: @planting.planted_at ? @planting.planted_at.to_fs(:ymd) : '',
class: 'add-datepicker', label: 'When?'
label: 'When?'
%span.help-inline
Tip: Plan our your future plantings by forward dating, and subscribe to your iCalendar feed for reminders to plant
@@ -52,11 +52,9 @@
= f.check_box :finished, label: 'Mark as finished'
%span.help-block= t('.finish_helper')
.col-md-6
= f.text_field :finished_at,
= f.date_field :finished_at,
value: @planting.finished_at ? @planting.finished_at.to_fs(:ymd) : '',
class: 'add-datepicker',
label: 'Finished date',
placeholder: 'optional'
label: 'Finished date'
.card-footer
.text-right= f.submit 'Save'

View File

@@ -39,7 +39,7 @@ describe "Planting a crop", :js, :search do
select "semi-shade", from: "Sun or shade?"
fill_in "Tell us more about it", with: "It's rad."
choose 'Garden'
fill_in "When", with: "2014-06-15"
fill_in "When", with: Date.parse("2014-06-15")
click_button "Save"
end
end
@@ -185,7 +185,7 @@ describe "Planting a crop", :js, :search do
click_link 'Actions'
click_link "Edit"
check "finished"
fill_in "Finished date", with: "2015-06-25"
fill_in "Finished date", with: Date.parse("2015-06-25")
click_button "Save"
expect(page).to have_content "planting was successfully updated"
expect(page).to have_content "Finished"
@@ -196,9 +196,9 @@ describe "Planting a crop", :js, :search do
select_from_autocomplete "maize"
choose(member.gardens.first.name)
within "form#new_planting" do
fill_in "When?", with: "2014-07-01"
fill_in "When?", with: Date.parse("2014-07-01")
check "Mark as finished"
fill_in "Finished date", with: "2014-08-30"
fill_in "Finished date", with: Date.parse("2014-08-30")
uncheck 'Mark as finished'
end
@@ -253,7 +253,7 @@ describe "Planting a crop", :js, :search do
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When", with: "2015-10-15"
fill_in "When", with: Date.parse("2015-10-15")
fill_in "How many?", with: 42
select "cutting", from: "Planted from"
select "sun", from: "Sun or shade?"

View File

@@ -22,6 +22,6 @@ describe "plantings/_form" do
end
it "has a free-form text field containing the planting date in ISO format" do
assert_select "input#planting_planted_at[type='text'][value='2013-03-01']"
assert_select "input#planting_planted_at[type='date'][value='2013-03-01']"
end
end