From e69f850cc5683a44a3c2b21123eae4741593af40 Mon Sep 17 00:00:00 2001 From: rebuilt Date: Tue, 1 Feb 2022 19:33:24 +0100 Subject: [PATCH] Add missing tests. Remove unused code. Filter out legacy specs from code coverage report --- app/helpers/gauge_helper.rb | 18 ------------------ app/models/measure.rb | 4 +--- spec/models/measure_spec.rb | 29 +++++++++++++++++++++++++++++ spec/spec_helper.rb | 2 ++ spec/system/journey_spec.rb | 10 ---------- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/app/helpers/gauge_helper.rb b/app/helpers/gauge_helper.rb index afcdd4cb..bfd03b7e 100644 --- a/app/helpers/gauge_helper.rb +++ b/app/helpers/gauge_helper.rb @@ -30,20 +30,6 @@ module GaugeHelper Point.new(0, 0) end - def indicator_tip - Point.new(arc_center.x, arc_center.y - outer_radius - 2) - end - - def indicator_right_corner - Point.new(key_benchmark_indicator_gutter / Math.sqrt(3), - arc_center.y - outer_radius - key_benchmark_indicator_gutter) - end - - def indicator_left_corner - Point.new(-key_benchmark_indicator_gutter / Math.sqrt(3), - arc_center.y - outer_radius - key_benchmark_indicator_gutter) - end - def arc_radius(radius) "#{radius} #{radius}" end @@ -90,10 +76,6 @@ module GaugeHelper Point.new(x, y) end - def rotation_angle_for(percentage:) - 180.0 * percentage - 90 - end - def coordinates_for(point) "#{point.x} #{point.y}" end diff --git a/app/models/measure.rb b/app/models/measure.rb index a2b62d4c..36e54703 100644 --- a/app/models/measure.rb +++ b/app/models/measure.rb @@ -40,9 +40,7 @@ class Measure < ActiveRecord::Base end def warning_low_benchmark - return @warning_low_benchmark unless @warning_low_benchmark.nil? - - @warning_low_benchmark = benchmark(:warning_low_benchmark) + 1 end def watch_low_benchmark diff --git a/spec/models/measure_spec.rb b/spec/models/measure_spec.rb index 25c9da43..2eba286c 100644 --- a/spec/models/measure_spec.rb +++ b/spec/models/measure_spec.rb @@ -28,6 +28,10 @@ RSpec.describe Measure, type: :model do it 'returns a watch low benchmark equal to the admin data item watch low benchmark' do expect(measure.watch_low_benchmark).to be 2.0 end + + it 'returns the source as an admin_data_item' do + expect(measure.sources).to eq [:admin_data] + end end context 'when a measure includes only student survey items' do @@ -41,6 +45,12 @@ RSpec.describe Measure, type: :model do it 'returns a watch low benchmark equal to the student survey item watch low benchmark ' do expect(measure.watch_low_benchmark).to be 1.5 end + it 'returns a warning low benchmark equal to the student survey item warning low benchmark ' do + expect(measure.warning_low_benchmark).to eq 1 + end + it 'returns the source as student_surveys' do + expect(measure.sources).to eq [:student_surveys] + end end context 'when a measure includes only teacher survey items' do @@ -54,6 +64,12 @@ RSpec.describe Measure, type: :model do it 'returns a watch low benchmark equal to the teacher survey item watch low benchmark ' do expect(measure.watch_low_benchmark).to be 1.2 end + it 'returns a warning low benchmark equal to the teacher survey item warning low benchmark ' do + expect(measure.warning_low_benchmark).to eq 1 + end + it 'returns the source as teacher_surveys' do + expect(measure.sources).to eq [:teacher_surveys] + end end context 'when a measure includes admin data and student survey items' do @@ -75,6 +91,9 @@ RSpec.describe Measure, type: :model do # (2*3 + 1.5)/4 expect(measure.watch_low_benchmark).to be 1.875 end + it 'returns the source as admin and student survey items' do + expect(measure.sources).to eq [:admin_data, :student_surveys] + end end context 'when a measure includes admin data and teacher survey items' do @@ -96,6 +115,9 @@ RSpec.describe Measure, type: :model do # (2*3 + 1.2)/4 expect(measure.watch_low_benchmark).to be 1.8 end + it 'returns the source as admin and teacher survey items' do + expect(measure.sources).to eq [:admin_data, :teacher_surveys] + end end context 'when a measure includes student and teacher survey items' do @@ -117,6 +139,9 @@ RSpec.describe Measure, type: :model do # (1.2+ 1.5)/2 expect(measure.watch_low_benchmark).to be 1.35 end + it 'returns the source as student and teacher survey items' do + expect(measure.sources).to eq [:student_surveys, :teacher_surveys] + end end context 'when a measure includes admin data and student and teacher survey items' do @@ -149,5 +174,9 @@ RSpec.describe Measure, type: :model do # (5 * 3 + 4.2 + 4.5)/ 5 expect(measure.ideal_low_benchmark).to be_within(0.001).of 4.74 end + + it 'returns the source as admin student and teacher survey items' do + expect(measure.sources).to eq [:admin_data, :student_surveys, :teacher_surveys] + end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 79d8c42f..5f2ee6b0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,6 +6,8 @@ SimpleCov.start do add_filter "/spec/models/legacy" add_filter "/spec/views/legacy" add_filter "/spec/controllers/legacy" + add_filter "/app/helpers/schedules_helper.rb" + add_filter "/lib/tasks/survey.rake" end require 'capybara/rspec' diff --git a/spec/system/journey_spec.rb b/spec/system/journey_spec.rb index 6971c8c3..9a8f4aa3 100644 --- a/spec/system/journey_spec.rb +++ b/spec/system/journey_spec.rb @@ -124,16 +124,6 @@ def go_to_different_district(district) select district.name, from: 'select-district' end -def go_to_browse_page_for_school_without_data(school) - click_on 'Browse' - select school.name, from: 'select-school' -end - -def go_to_overview_page_for_school_without_data(school) - click_on 'Overview' - select school.name, from: 'select-school' -end - def district_admin_sees_schools_change expected_path = "/districts/#{school_in_same_district.district.slug}/schools/#{school_in_same_district.slug}/browse/teachers-and-leadership?year=2020-21" expect(page).to have_current_path(expected_path)