diff --git a/app/presenters/gauge_presenter.rb b/app/presenters/gauge_presenter.rb
index 955271f8..d6fa7eaa 100644
--- a/app/presenters/gauge_presenter.rb
+++ b/app/presenters/gauge_presenter.rb
@@ -27,7 +27,7 @@ class GaugePresenter
end
def percentage_for(number)
- return 0 if number.nil?
+ return nil if number.nil?
scale_minimum = @scale.warning_zone.low_benchmark
scale_maximum = @scale.ideal_zone.high_benchmark
diff --git a/app/presenters/scale.rb b/app/presenters/scale.rb
index 5f4d189a..760c4488 100644
--- a/app/presenters/scale.rb
+++ b/app/presenters/scale.rb
@@ -35,6 +35,8 @@ class Scale
def zone_for_score(score)
case score
+ when nil
+ insufficient_data
when ideal_zone.low_benchmark..ideal_zone.high_benchmark
ideal_zone
when approval_zone.low_benchmark..approval_zone.high_benchmark
diff --git a/app/views/categories/_gauge_graph.html.erb b/app/views/categories/_gauge_graph.html.erb
index 26d9ca69..e1b7f7b1 100644
--- a/app/views/categories/_gauge_graph.html.erb
+++ b/app/views/categories/_gauge_graph.html.erb
@@ -3,16 +3,18 @@
viewBox="<%= viewbox.x %> <%= viewbox.y %> <%= viewbox.width %> <%= viewbox.height %>"
class="<%= gauge_class %>"
>
-
+ <% if gauge.score_percentage.present? %>
+
+ <% end %>
-
+ <% if gauge.key_benchmark_percentage.present? %>
+
-
+
+ <% end %>
<%= gauge.title %>
diff --git a/spec/presenters/gauge_presenter_spec.rb b/spec/presenters/gauge_presenter_spec.rb
index 6ebc230e..3d6db5ba 100644
--- a/spec/presenters/gauge_presenter_spec.rb
+++ b/spec/presenters/gauge_presenter_spec.rb
@@ -1,25 +1,6 @@
require 'rails_helper'
describe GaugePresenter do
- # let(:academic_year) { create(:academic_year, range: '1989-90') }
- # let(:school) { create(:school, name: 'Best School') }
- # let(:subcategory_presenter) do
- # subcategory = create(:subcategory, name: 'A great subcategory')
-
- # measure1 = create(:measure, watch_low_benchmark: 4, growth_low_benchmark: 4.25, approval_low_benchmark: 4.5, ideal_low_benchmark: 4.75, subcategory: subcategory)
- # survey_item1 = create(:survey_item, measure: measure1)
- # create(:survey_item_response, survey_item: survey_item1, academic_year: academic_year, school: school, likert_score: 1)
- # create(:survey_item_response, survey_item: survey_item1, academic_year: academic_year, school: school, likert_score: 5)
-
- # measure2 = create(:measure, watch_low_benchmark: 1.25, growth_low_benchmark: 1.5, approval_low_benchmark: 1.75, ideal_low_benchmark: 2.0, subcategory: subcategory)
- # survey_item2 = create(:survey_item, measure: measure2)
- # create(:survey_item_response, survey_item: survey_item2, academic_year: academic_year, school: school, likert_score: 1)
- # create(:survey_item_response, survey_item: survey_item2, academic_year: academic_year, school: school, likert_score: 5)
-
- # create_survey_item_responses_for_different_years_and_schools(survey_item1)
-
- # return SubcategoryPresenter.new(subcategory: subcategory, academic_year: academic_year, school: school)
- # end
let(:scale) do
Scale.new(
watch_low_benchmark: 1.5,
@@ -30,7 +11,6 @@ describe GaugePresenter do
end
let(:score) { 3 }
-
let(:gauge_presenter) { GaugePresenter.new(scale: scale, score: score) }
it 'returns the key benchmark percentage for the gauge' do
@@ -117,4 +97,28 @@ describe GaugePresenter do
end
end
+ context 'when there are no benchmarks or score for the gauge' do
+ let(:scale) do
+ Scale.new(
+ watch_low_benchmark: nil,
+ growth_low_benchmark: nil,
+ approval_low_benchmark: nil,
+ ideal_low_benchmark: nil,
+ )
+ end
+ let(:score) { nil }
+
+ it 'returns the title of the zone' do
+ expect(gauge_presenter.title).to eq 'Insufficient Data'
+ end
+
+ it 'returns the color class for the gauge' do
+ expect(gauge_presenter.color_class).to eq 'fill-insufficient_data'
+ end
+
+ it 'returns the score percentage for the gauge' do
+ expect(gauge_presenter.score_percentage).to be_nil
+ end
+ end
+
end