Planting feature specs passing

This commit is contained in:
Brenda Wallace
2017-10-29 21:39:47 +13:00
parent 54b204c636
commit adf07ce5ef
5 changed files with 14 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
module PlantingsHelper
def display_finished(planting)
if !planting.finished_at.nil?
if planting.finished_at.present?
planting.finished_at
elsif planting.finished
"Yes (no date specified)"

View File

@@ -4,7 +4,6 @@
= render "plantings/progress_bar", status: "not planted", progress: 0
- elsif planting.finished?
= render "plantings/progress_bar", status: 'finished', progress: 100
- elsif planting.finish_predicted_at.nil?
- if show_explanation == true
Progress: Not enough data

View File

@@ -5,7 +5,7 @@
-# haml-lint:disable InlineStyles
%div{ class: "progress-bar progress-bar-#{status}", role: "progressbar", style: "width: #{progress}%" }
- if progress >= 30
#{sprintf '%.2f', progress}%
#{sprintf '%.0f', progress}%
- if progress < 30
#{sprintf '%.2f', progress}%
#{sprintf '%.0f', progress}%
-# haml-lint:enable InlineStyles

View File

@@ -41,16 +41,14 @@
= sunniness
- unless @planting.crop.perennial
- if @planting.finished_at.present?
%dt Finished:
%dd= display_finished(@planting)
-else
%dt Predicted finish:
%dd
- if @planting.planted_at.present?
=@planting.finish_predicted_at
- else
Set planted date to get predictions
%dt Finished:
%dd= display_finished(@planting)
%dt Predicted finish:
%dd
- if @planting.finish_predicted_at.present?
=@planting.finish_predicted_at
- else
Set planted date to get predictions
- if @planting.lifespan.present?
%dt Lifespan:

View File

@@ -92,7 +92,6 @@ feature "Planting a crop", :js, :elasticsearch do
expect(page).to have_content "planting was successfully created"
expect(page).to have_content "Progress: Not enough data"
expect(page).to have_content "Days until maturity: unknown"
end
it "should show that planting is in progress" do
@@ -127,9 +126,8 @@ feature "Planting a crop", :js, :elasticsearch do
end
expect(page).to have_content "planting was successfully created"
expect(page).to have_content "Progress: 100%"
expect(page).to have_content "100%"
expect(page).to have_content "Yes (no date specified)"
expect(page).to have_content "Days until maturity: 0"
end
it "should show that planting is 100% complete (date specified)" do
@@ -146,8 +144,7 @@ feature "Planting a crop", :js, :elasticsearch do
end
expect(page).to have_content "planting was successfully created"
expect(page).to have_content "Progress: 100%"
expect(page).to have_content "Days until maturity: 0"
expect(page).to have_content "100%"
end
end
@@ -232,7 +229,7 @@ feature "Planting a crop", :js, :elasticsearch do
end
expect(page).to have_content "planting was successfully created"
expect(page).to have_content "Finished: Yes (no date specified)"
expect(page).to have_content "Progress: 100%"
expect(page).to have_content "100%"
end
describe "Planting sunniness" do