From adf07ce5efd69ceb2f5cd0c54def56682b012d95 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 29 Oct 2017 21:39:47 +1300 Subject: [PATCH] Planting feature specs passing --- app/helpers/plantings_helper.rb | 2 +- app/views/plantings/_progress.html.haml | 1 - app/views/plantings/_progress_bar.html.haml | 4 ++-- app/views/plantings/show.html.haml | 18 ++++++++---------- .../features/plantings/planting_a_crop_spec.rb | 9 +++------ 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/app/helpers/plantings_helper.rb b/app/helpers/plantings_helper.rb index 823167773..b8e2b257c 100644 --- a/app/helpers/plantings_helper.rb +++ b/app/helpers/plantings_helper.rb @@ -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)" diff --git a/app/views/plantings/_progress.html.haml b/app/views/plantings/_progress.html.haml index 260082736..36a3ab4d4 100644 --- a/app/views/plantings/_progress.html.haml +++ b/app/views/plantings/_progress.html.haml @@ -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 diff --git a/app/views/plantings/_progress_bar.html.haml b/app/views/plantings/_progress_bar.html.haml index 59d4f2f37..e8544fc65 100644 --- a/app/views/plantings/_progress_bar.html.haml +++ b/app/views/plantings/_progress_bar.html.haml @@ -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 diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index 4f8fbfe35..6f5284cd3 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -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: diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index d78ec107e..432672874 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -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