Avoid time travel in favour of calculating a number of past/future dates

This commit is contained in:
Daniel O'Connor committed 2016-04-11 09:29:06 +09:30
1 parent 3644a8124f
commit 82553d6e0a
1 file changed
+11 -8
@@ -53,16 +53,19 @@ feature "Planting a crop", :js do
describe "Progress bar status on planting creation" do
before do
DateTime.stub(:now) { DateTime.new(2015, 10, 20, 10, 34) }
login_as member
visit new_planting_path
@a_past_date = 15.days.ago.strftime("%Y-%m-%d")
@right_now = Date.today.strftime("%Y-%m-%d")
@a_future_date = 1.years.from_now.strftime("%Y-%m-%d")
end
it "should show that it is not planted yet" do
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When", with: "2015-12-15"
fill_in "When", with: @a_future_date
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "semi-shade", from: "Sun or shade?"
@@ -78,7 +81,7 @@ feature "Planting a crop", :js do
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When", with: "2015-9-15"
fill_in "When", with: @a_past_date
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "semi-shade", from: "Sun or shade?"
@@ -95,12 +98,12 @@ feature "Planting a crop", :js 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: @right_now
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "semi-shade", from: "Sun or shade?"
fill_in "Tell us more about it", with: "It's rad."
fill_in "Finished date", with: "2015-10-30"
fill_in "Finished date", with: @a_future_date
click_button "Save"
end
@@ -113,7 +116,7 @@ feature "Planting a crop", :js 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: @right_now
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "semi-shade", from: "Sun or shade?"
@@ -132,12 +135,12 @@ feature "Planting a crop", :js 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: @a_past_date
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "semi-shade", from: "Sun or shade?"
fill_in "Tell us more about it", with: "It's rad."
fill_in "Finished date", with: "2015-10-19"
fill_in "Finished date", with: @right_now
click_button "Save"
end