diff --git a/spec/presenters/scorecard_presenter_spec.rb b/spec/presenters/scorecard_presenter_spec.rb
new file mode 100644
index 00000000..3ce76dff
--- /dev/null
+++ b/spec/presenters/scorecard_presenter_spec.rb
@@ -0,0 +1,89 @@
+require "rails_helper"
+
+describe Overview::ScorecardPresenter do
+ let(:zones) do
+ Zones.new(
+ watch_low_benchmark: 1.5,
+ growth_low_benchmark: 2.5,
+ approval_low_benchmark: 3.5,
+ ideal_low_benchmark: 4.5
+ )
+ end
+
+ let(:subcategory_card_presenter) do
+ subcategory = Subcategory.new(name: "A subcategory")
+ Overview::ScorecardPresenter.new(construct: subcategory, zones:, score:, id: subcategory.subcategory_id)
+ end
+
+ context "when the given score is in the Warning zone for the given scale" do
+ let(:score) { 1 }
+
+ it "returns the icon that represents the zone" do
+ expect(subcategory_card_presenter.harvey_ball_icon).to eq "warning-harvey-ball"
+ end
+
+ it "returns the color class of the zone" do
+ expect(subcategory_card_presenter.color).to eq "warning"
+ end
+ end
+
+ context "when the given score is in the Watch zone for the given scale" do
+ let(:score) { 2 }
+
+ it "returns the icon that represents the zone" do
+ expect(subcategory_card_presenter.harvey_ball_icon).to eq "watch-harvey-ball"
+ end
+
+ it "returns the color class of the zone" do
+ expect(subcategory_card_presenter.color).to eq "watch"
+ end
+ end
+
+ context "when the given score is in the Growth zone for the given scale" do
+ let(:score) { 3 }
+
+ it "returns the icon that represents the zone" do
+ expect(subcategory_card_presenter.harvey_ball_icon).to eq "growth-harvey-ball"
+ end
+
+ it "returns the color class of the zone" do
+ expect(subcategory_card_presenter.color).to eq "growth"
+ end
+ end
+
+ context "when the given score is in the Approval zone for the given scale" do
+ let(:score) { 4 }
+
+ it "returns the icon that represents the zone" do
+ expect(subcategory_card_presenter.harvey_ball_icon).to eq "approval-harvey-ball"
+ end
+
+ it "returns the color class of the zone" do
+ expect(subcategory_card_presenter.color).to eq "approval"
+ end
+ end
+
+ context "when the given score is in the Ideal zone for the given scale" do
+ let(:score) { 5 }
+
+ it "returns the icon that represents the zone" do
+ expect(subcategory_card_presenter.harvey_ball_icon).to eq "ideal-harvey-ball"
+ end
+
+ it "returns the color class of the zone" do
+ expect(subcategory_card_presenter.color).to eq "ideal"
+ end
+ end
+
+ context "when the given score is invalid for the given scale" do
+ let(:score) { 0 }
+
+ it "returns the icon that represents the zone" do
+ expect(subcategory_card_presenter.harvey_ball_icon).to eq "insufficient_data-harvey-ball"
+ end
+
+ it "reports that there is insufficient data" do
+ expect(subcategory_card_presenter.insufficient_data?).to be true
+ end
+ end
+end
diff --git a/spec/presenters/subcategory_card_presenter_spec.rb b/spec/presenters/subcategory_card_presenter_spec.rb
deleted file mode 100644
index 627f7934..00000000
--- a/spec/presenters/subcategory_card_presenter_spec.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-require 'rails_helper'
-
-describe SubcategoryCardPresenter do
- let(:zones) do
- Zones.new(
- watch_low_benchmark: 1.5,
- growth_low_benchmark: 2.5,
- approval_low_benchmark: 3.5,
- ideal_low_benchmark: 4.5
- )
- end
-
- let(:subcategory_card_presenter) { SubcategoryCardPresenter.new(subcategory: Subcategory.new(name: 'A subcategory'), zones:, score:) }
-
- context 'when the given score is in the Warning zone for the given scale' do
- let(:score) { 1 }
-
- it 'returns the icon that represents the zone' do
- expect(subcategory_card_presenter.harvey_ball_icon).to eq 'warning-harvey-ball'
- end
-
- it 'returns the color class of the zone' do
- expect(subcategory_card_presenter.color).to eq 'warning'
- end
- end
-
- context 'when the given score is in the Watch zone for the given scale' do
- let(:score) { 2 }
-
- it 'returns the icon that represents the zone' do
- expect(subcategory_card_presenter.harvey_ball_icon).to eq 'watch-harvey-ball'
- end
-
- it 'returns the color class of the zone' do
- expect(subcategory_card_presenter.color).to eq 'watch'
- end
- end
-
- context 'when the given score is in the Growth zone for the given scale' do
- let(:score) { 3 }
-
- it 'returns the icon that represents the zone' do
- expect(subcategory_card_presenter.harvey_ball_icon).to eq 'growth-harvey-ball'
- end
-
- it 'returns the color class of the zone' do
- expect(subcategory_card_presenter.color).to eq 'growth'
- end
- end
-
- context 'when the given score is in the Approval zone for the given scale' do
- let(:score) { 4 }
-
- it 'returns the icon that represents the zone' do
- expect(subcategory_card_presenter.harvey_ball_icon).to eq 'approval-harvey-ball'
- end
-
- it 'returns the color class of the zone' do
- expect(subcategory_card_presenter.color).to eq 'approval'
- end
- end
-
- context 'when the given score is in the Ideal zone for the given scale' do
- let(:score) { 5 }
-
- it 'returns the icon that represents the zone' do
- expect(subcategory_card_presenter.harvey_ball_icon).to eq 'ideal-harvey-ball'
- end
-
- it 'returns the color class of the zone' do
- expect(subcategory_card_presenter.color).to eq 'ideal'
- end
- end
-
- context 'when the given score is invalid for the given scale' do
- let(:score) { 0 }
-
- it 'returns the icon that represents the zone' do
- expect(subcategory_card_presenter.harvey_ball_icon).to eq 'insufficient_data-harvey-ball'
- end
-
- it 'reports that there is insufficient data' do
- expect(subcategory_card_presenter.insufficient_data?).to be true
- end
- end
-end
diff --git a/spec/presenters/subcategory_presenter_spec.rb b/spec/presenters/subcategory_presenter_spec.rb
index dfd0c22d..a225fdeb 100644
--- a/spec/presenters/subcategory_presenter_spec.rb
+++ b/spec/presenters/subcategory_presenter_spec.rb
@@ -85,16 +85,6 @@ describe SubcategoryPresenter do
expect(subcategory_presenter.measure_presenters.count).to eq subcategory.measures.count
end
- context "When there are no measures populated with student or teacher surveys" do
- let(:empty_subcategory) { create :subcategory }
- let(:empty_subcategory_presenter) do
- SubcategoryPresenter.new(subcategory: empty_subcategory, academic_year:, school:)
- end
- it "should make a subcategory presenter return insufficient data" do
- expect(empty_subcategory_presenter.subcategory_card_presenter.insufficient_data?).to eq true
- end
- end
-
def create_survey_item_responses_for_different_years_and_schools(survey_item)
create_list(:survey_item_response, SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD, survey_item:,
school: worst_school, likert_score: 1)
diff --git a/spec/presenters/variance_chart_row_presenter_spec.rb b/spec/presenters/variance_chart_row_presenter_spec.rb
index 579dee33..7e937783 100644
--- a/spec/presenters/variance_chart_row_presenter_spec.rb
+++ b/spec/presenters/variance_chart_row_presenter_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe VarianceChartRowPresenter do
+describe Overview::VarianceChartRowPresenter do
let(:watch_low_benchmark) { 2.9 }
let(:growth_low_benchmark) { 3.1 }
let(:approval_low_benchmark) { 3.6 }
@@ -9,7 +9,7 @@ describe VarianceChartRowPresenter do
let(:measure) do
measure = create(
:measure,
- name: 'Some Title'
+ name: "Some Title"
)
scale = create(:scale, measure:)
@@ -25,210 +25,210 @@ describe VarianceChartRowPresenter do
let(:measure_without_admin_data_items) do
create(
:measure,
- name: 'Some Title'
+ name: "Some Title"
)
end
let(:presenter) do
- VarianceChartRowPresenter.new measure:, score:
+ Overview::VarianceChartRowPresenter.new measure:, score:
end
- shared_examples_for 'measure_name' do
- it 'returns the measure name' do
- expect(presenter.measure_name).to eq 'Some Title'
+ shared_examples_for "measure_name" do
+ it "returns the measure name" do
+ expect(presenter.measure_name).to eq "Some Title"
end
end
- context 'when the score is in the Ideal zone' do
+ context "when the score is in the Ideal zone" do
let(:score) { Score.new(average: 4.4, meets_teacher_threshold: true, meets_student_threshold: true) }
- it_behaves_like 'measure_name'
+ it_behaves_like "measure_name"
- it 'returns the correct color' do
- expect(presenter.bar_color).to eq 'fill-ideal'
+ it "returns the correct color" do
+ expect(presenter.bar_color).to eq "fill-ideal"
end
- it 'returns a bar width equal to the approval zone width plus the proportionate ideal zone width' do
- expect(presenter.bar_width).to eq '30.0%'
+ it "returns a bar width equal to the approval zone width plus the proportionate ideal zone width" do
+ expect(presenter.bar_width).to eq "30.0%"
end
- it 'returns an x-offset of 60%' do
- expect(presenter.x_offset).to eq '60%'
+ it "returns an x-offset of 60%" do
+ expect(presenter.x_offset).to eq "60%"
end
end
- context 'when the score is in the Approval zone' do
+ context "when the score is in the Approval zone" do
let(:score) { Score.new(average: 3.7, meets_teacher_threshold: true, meets_student_threshold: true) }
- it_behaves_like 'measure_name'
+ it_behaves_like "measure_name"
- it 'returns the correct color' do
- expect(presenter.bar_color).to eq 'fill-approval'
+ it "returns the correct color" do
+ expect(presenter.bar_color).to eq "fill-approval"
end
- it 'returns a bar width equal to the proportionate approval zone width' do
- expect(presenter.bar_width).to eq '10.0%'
+ it "returns a bar width equal to the proportionate approval zone width" do
+ expect(presenter.bar_width).to eq "10.0%"
end
- it 'returns an x-offset of 60%' do
- expect(presenter.x_offset).to eq '60%'
+ it "returns an x-offset of 60%" do
+ expect(presenter.x_offset).to eq "60%"
end
end
- context 'when the score is in the Growth zone' do
+ context "when the score is in the Growth zone" do
let(:score) { Score.new(average: 3.2, meets_teacher_threshold: true, meets_student_threshold: true) }
- it_behaves_like 'measure_name'
+ it_behaves_like "measure_name"
- it 'returns the correct color' do
- expect(presenter.bar_color).to eq 'fill-growth'
+ it "returns the correct color" do
+ expect(presenter.bar_color).to eq "fill-growth"
end
- it 'returns a bar width equal to the proportionate growth zone width' do
- expect(presenter.bar_width).to eq '16.0%'
+ it "returns a bar width equal to the proportionate growth zone width" do
+ expect(presenter.bar_width).to eq "16.0%"
end
- context 'in order to achieve the visual effect' do
- it 'returns an x-offset equal to 60% minus the bar width' do
- expect(presenter.x_offset).to eq '44.0%'
+ context "in order to achieve the visual effect" do
+ it "returns an x-offset equal to 60% minus the bar width" do
+ expect(presenter.x_offset).to eq "44.0%"
end
end
end
- context 'when the score is in the Watch zone' do
+ context "when the score is in the Watch zone" do
let(:score) { Score.new(average: 2.9, meets_teacher_threshold: true, meets_student_threshold: true) }
- it_behaves_like 'measure_name'
+ it_behaves_like "measure_name"
- it 'returns the correct color' do
- expect(presenter.bar_color).to eq 'fill-watch'
+ it "returns the correct color" do
+ expect(presenter.bar_color).to eq "fill-watch"
end
- it 'returns a bar width equal to the proportionate watch zone width plus the growth zone width' do
- expect(presenter.bar_width).to eq '40.0%'
+ it "returns a bar width equal to the proportionate watch zone width plus the growth zone width" do
+ expect(presenter.bar_width).to eq "40.0%"
end
- context 'in order to achieve the visual effect' do
- it 'returns an x-offset equal to 60% minus the bar width' do
- expect(presenter.x_offset).to eq '20.0%'
+ context "in order to achieve the visual effect" do
+ it "returns an x-offset equal to 60% minus the bar width" do
+ expect(presenter.x_offset).to eq "20.0%"
end
end
end
- context 'when the score is in the Warning zone' do
+ context "when the score is in the Warning zone" do
let(:score) { Score.new(average: 1.0, meets_teacher_threshold: true, meets_student_threshold: true) }
- it_behaves_like 'measure_name'
+ it_behaves_like "measure_name"
- it 'returns the correct color' do
- expect(presenter.bar_color).to eq 'fill-warning'
+ it "returns the correct color" do
+ expect(presenter.bar_color).to eq "fill-warning"
end
- it 'returns a bar width equal to the proportionate warning zone width plus the watch & growth zone widths' do
- expect(presenter.bar_width).to eq '60.0%'
+ it "returns a bar width equal to the proportionate warning zone width plus the watch & growth zone widths" do
+ expect(presenter.bar_width).to eq "60.0%"
end
- context 'in order to achieve the visual effect' do
- it 'returns an x-offset equal to 60% minus the bar width' do
- expect(presenter.x_offset).to eq '0.0%'
+ context "in order to achieve the visual effect" do
+ it "returns an x-offset equal to 60% minus the bar width" do
+ expect(presenter.x_offset).to eq "0.0%"
end
end
end
- context 'when a measure does not contain admin data items' do
- let(:score) { Score.new(average: nil, meets_teacher_threshold: false, meets_student_threshold: false) }
+ context "when a measure does not contain admin data items" do
+ let(:score) { Score.new(average: nil, meets_teacher_threshold: false, meets_student_threshold: false) }
- it 'it does not show a partial data indicator' do
- presenter_without_admin_data = VarianceChartRowPresenter.new measure: measure_without_admin_data_items,
- score: score
+ it "it does not show a partial data indicator" do
+ presenter_without_admin_data = Overview::VarianceChartRowPresenter.new(measure: measure_without_admin_data_items,
+ score:)
expect(presenter_without_admin_data.show_partial_data_indicator?).to be false
end
end
- context 'when a measure contains admin data items' do
+ context "when a measure contains admin data items" do
before :each do
end
- let(:score) { Score.new(average: nil, meets_teacher_threshold: false, meets_student_threshold: false) }
+ let(:score) { Score.new(average: nil, meets_teacher_threshold: false, meets_student_threshold: false) }
- it 'shows a partial data indicator' do
+ it "shows a partial data indicator" do
measure_with_admin_data = create(
:measure,
- name: 'Some Title'
+ name: "Some Title"
)
scale_with_admin_data = create(:scale, measure: measure_with_admin_data)
- create :admin_data_item,
+ create(:admin_data_item,
scale: scale_with_admin_data,
- watch_low_benchmark: watch_low_benchmark,
- growth_low_benchmark: growth_low_benchmark,
- approval_low_benchmark: approval_low_benchmark,
- ideal_low_benchmark: ideal_low_benchmark
- admin_data_presenter = VarianceChartRowPresenter.new measure: measure_with_admin_data,
- score: Score.new(
- average: 3.7, meets_teacher_threshold: true, meets_student_threshold: true
- )
+ watch_low_benchmark:,
+ growth_low_benchmark:,
+ approval_low_benchmark:,
+ ideal_low_benchmark:)
+ admin_data_presenter = Overview::VarianceChartRowPresenter.new measure: measure_with_admin_data,
+ score: Score.new(
+ average: 3.7, meets_teacher_threshold: true, meets_student_threshold: true
+ )
expect(admin_data_presenter.show_partial_data_indicator?).to be true
- expect(admin_data_presenter.partial_data_sources).to eq ['administrative data']
+ expect(admin_data_presenter.partial_data_sources).to eq ["administrative data"]
end
end
- context 'when a measure contains teacher survey items' do
+ context "when a measure contains teacher survey items" do
before :each do
scale = create(:scale, measure:)
create :teacher_survey_item, scale:
end
- context 'when there are insufficient teacher survey item responses' do
+ context "when there are insufficient teacher survey item responses" do
let(:score) { Score.new(average: nil, meets_teacher_threshold: false, meets_student_threshold: true) }
- it 'shows a partial data indicator' do
+ it "shows a partial data indicator" do
expect(presenter.show_partial_data_indicator?).to be true
- expect(presenter.partial_data_sources).to eq ['teacher survey results']
+ expect(presenter.partial_data_sources).to eq ["teacher survey results"]
end
end
- context 'when there are sufficient teacher survey item responses' do
+ context "when there are sufficient teacher survey item responses" do
let(:score) { Score.new(average: nil, meets_teacher_threshold: true, meets_student_threshold: true) }
- it 'does not show a partial data indicator' do
+ it "does not show a partial data indicator" do
expect(presenter.show_partial_data_indicator?).to be false
end
end
end
- context 'when a measure contains student survey items' do
+ context "when a measure contains student survey items" do
before :each do
scale = create(:scale, measure:)
create :student_survey_item, scale:
end
- context 'when there are insufficient student survey item responses' do
+ context "when there are insufficient student survey item responses" do
let(:score) { Score.new(average: nil, meets_teacher_threshold: true, meets_student_threshold: false) }
- it 'shows a partial data indicator' do
+ it "shows a partial data indicator" do
expect(presenter.show_partial_data_indicator?).to be true
- expect(presenter.partial_data_sources).to eq ['student survey results']
+ expect(presenter.partial_data_sources).to eq ["student survey results"]
end
- context 'where there are also admin data items' do
+ context "where there are also admin data items" do
before :each do
scale = create(:scale, measure:)
create :admin_data_item, scale:
end
- it 'returns the sources for partial results of administrative data and student survey results' do
- expect(presenter.partial_data_sources).to eq ['student survey results', 'administrative data']
+ it "returns the sources for partial results of administrative data and student survey results" do
+ expect(presenter.partial_data_sources).to eq ["student survey results", "administrative data"]
end
end
end
- context 'When there are sufficient student survey item responses' do
+ context "When there are sufficient student survey item responses" do
let(:score) { Score.new(average: nil, meets_teacher_threshold: true, meets_student_threshold: true) }
- it 'does not show a partial data indicator' do
+ it "does not show a partial data indicator" do
expect(presenter.show_partial_data_indicator?).to be false
end
end
end
- context 'sorting scores' do
- it 'selects a longer bar before a shorter bar for measures in the approval/ideal zones' do
+ context "sorting scores" do
+ it "selects a longer bar before a shorter bar for measures in the approval/ideal zones" do
scale_with_student_survey_items = create(:scale, measure:)
create(:student_survey_item,
scale: scale_with_student_survey_items,
@@ -236,15 +236,27 @@ describe VarianceChartRowPresenter do
growth_low_benchmark:,
approval_low_benchmark:,
ideal_low_benchmark:)
- approval_presenter = VarianceChartRowPresenter.new measure: measure, score: Score.new(average: 3.7, meets_teacher_threshold: true,meets_student_threshold: true)
- ideal_presenter = VarianceChartRowPresenter.new measure: measure, score: Score.new(average: 4.4, meets_teacher_threshold: true, meets_student_threshold: true)
+ approval_presenter = Overview::VarianceChartRowPresenter.new measure:,
+ score: Score.new(
+ average: 3.7, meets_teacher_threshold: true, meets_student_threshold: true
+ )
+ ideal_presenter = Overview::VarianceChartRowPresenter.new measure:,
+ score: Score.new(
+ average: 4.4, meets_teacher_threshold: true, meets_student_threshold: true
+ )
expect(ideal_presenter <=> approval_presenter).to be < 0
expect([approval_presenter, ideal_presenter].sort).to eq [ideal_presenter, approval_presenter]
end
- it 'selects a warning bar below a ideal bar' do
- warning_presenter = VarianceChartRowPresenter.new measure: measure, score: Score.new(average: 1.0, meets_teacher_threshold: true, meets_student_threshold: true)
- ideal_presenter = VarianceChartRowPresenter.new measure: measure, score: Score.new(average: 5.0, meets_teacher_threshold: true, meets_student_threshold: true)
+ it "selects a warning bar below a ideal bar" do
+ warning_presenter = Overview::VarianceChartRowPresenter.new measure:,
+ score: Score.new(
+ average: 1.0, meets_teacher_threshold: true, meets_student_threshold: true
+ )
+ ideal_presenter = Overview::VarianceChartRowPresenter.new measure:,
+ score: Score.new(
+ average: 5.0, meets_teacher_threshold: true, meets_student_threshold: true
+ )
expect(warning_presenter <=> ideal_presenter).to be > 0
expect([warning_presenter, ideal_presenter].sort).to eq [ideal_presenter, warning_presenter]
end
diff --git a/spec/views/overview/index.html.erb_spec.rb b/spec/views/overview/index.html.erb_spec.rb
index 375744d3..a74ba6cd 100644
--- a/spec/views/overview/index.html.erb_spec.rb
+++ b/spec/views/overview/index.html.erb_spec.rb
@@ -40,31 +40,33 @@ describe "overview/index" do
measure
end
- before :each do
- assign :category_presenters, []
- assign :variance_chart_row_presenters, variance_chart_row_presenters
- @academic_year = create(:academic_year)
- assign :academic_years, [@academic_year]
- @district = create(:district)
- @school = create(:school)
- @student_response_rate_presenter = ResponseRatePresenter.new(focus: :student, school: @school,
- academic_year: @academic_year)
- @teacher_response_rate_presenter = ResponseRatePresenter.new(focus: :teacher, school: @school,
- academic_year: @academic_year)
-
- Respondent.create!(school: @school, academic_year: @academic_year, total_students: 40, total_teachers: 40)
- ResponseRate.create!(subcategory: Subcategory.first, school: @school, academic_year: @academic_year,
- student_response_rate: 100, teacher_response_rate: 100, meets_student_threshold: true, meets_teacher_threshold: true)
-
- render
- end
-
context "when some presenters have a nil score" do
+ before :each do
+ assign :category_presenters, []
+ assign :variance_chart_row_presenters, variance_chart_row_presenters
+ @academic_year = create(:academic_year)
+ assign :academic_years, [@academic_year]
+ @district = create(:district)
+ @school = create(:school)
+ assign :page,
+ Overview::OverviewPresenter.new(params: { view: "student" }, school: @school,
+ academic_year: @academic_year)
+ @student_response_rate_presenter = ResponseRatePresenter.new(focus: :student, school: @school,
+ academic_year: @academic_year)
+ @teacher_response_rate_presenter = ResponseRatePresenter.new(focus: :teacher, school: @school,
+ academic_year: @academic_year)
+
+ Respondent.create!(school: @school, academic_year: @academic_year, total_students: 40, total_teachers: 40)
+ ResponseRate.create!(subcategory: Subcategory.first, school: @school, academic_year: @academic_year,
+ student_response_rate: 100, teacher_response_rate: 100, meets_student_threshold: true, meets_teacher_threshold: true)
+
+ render
+ end
let(:variance_chart_row_presenters) do
[
- VarianceChartRowPresenter.new(measure: support_for_teaching, score: Score.new),
- VarianceChartRowPresenter.new(measure: effective_leadership, score: Score.new(average: rand)),
- VarianceChartRowPresenter.new(measure: professional_qualifications, score: Score.new)
+ Overview::VarianceChartRowPresenter.new(measure: support_for_teaching, score: Score.new),
+ Overview::VarianceChartRowPresenter.new(measure: effective_leadership, score: Score.new(average: rand)),
+ Overview::VarianceChartRowPresenter.new(measure: professional_qualifications, score: Score.new)
]
end
@@ -84,6 +86,27 @@ describe "overview/index" do
end
context "when all the presenters have a non-nil score" do
+ before :each do
+ assign :category_presenters, []
+ assign :variance_chart_row_presenters, variance_chart_row_presenters
+ @academic_year = create(:academic_year)
+ assign :academic_years, [@academic_year]
+ @district = create(:district)
+ @school = create(:school)
+ assign :page,
+ Overview::OverviewPresenter.new(params: { view: "student" }, school: @school,
+ academic_year: @academic_year)
+ @student_response_rate_presenter = ResponseRatePresenter.new(focus: :student, school: @school,
+ academic_year: @academic_year)
+ @teacher_response_rate_presenter = ResponseRatePresenter.new(focus: :teacher, school: @school,
+ academic_year: @academic_year)
+
+ Respondent.create!(school: @school, academic_year: @academic_year, total_students: 40, total_teachers: 40)
+ ResponseRate.create!(subcategory: Subcategory.first, school: @school, academic_year: @academic_year,
+ student_response_rate: 100, teacher_response_rate: 100, meets_student_threshold: true, meets_teacher_threshold: true)
+
+ render
+ end
let(:variance_chart_row_presenters) do
measure = create(:measure, name: "Display Me", measure_id: "display-me")
scale = create(:scale, measure:)
@@ -94,8 +117,8 @@ describe "overview/index" do
approval_low_benchmark: 3.5,
ideal_low_benchmark: 4.5)
[
- VarianceChartRowPresenter.new(measure:,
- score: Score.new(average: rand))
+ Overview::VarianceChartRowPresenter.new(measure:,
+ score: Score.new(average: rand))
]
end
@@ -113,4 +136,88 @@ describe "overview/index" do
expect(displayed_variance_labels.first.inner_text).to include "Display Me"
end
end
+
+ context "when the default view is shown" do
+ let(:variance_chart_row_presenters) do
+ measure = create(:measure, name: "Display Me", measure_id: "display-me")
+ scale = create(:scale, measure:)
+ create(:student_survey_item,
+ scale:,
+ watch_low_benchmark: 1.5,
+ growth_low_benchmark: 2.5,
+ approval_low_benchmark: 3.5,
+ ideal_low_benchmark: 4.5)
+ [
+ Overview::VarianceChartRowPresenter.new(measure:,
+ score: Score.new(average: rand))
+ ]
+ end
+
+ before :each do
+ assign :category_presenters, []
+ assign :variance_chart_row_presenters, variance_chart_row_presenters
+ @academic_year = create(:academic_year)
+ assign :academic_years, [@academic_year]
+ @district = create(:district)
+ @school = create(:school)
+ assign :page,
+ Overview::OverviewPresenter.new(params: { view: "student" }, school: @school,
+ academic_year: @academic_year)
+ @student_response_rate_presenter = ResponseRatePresenter.new(focus: :student, school: @school,
+ academic_year: @academic_year)
+ @teacher_response_rate_presenter = ResponseRatePresenter.new(focus: :teacher, school: @school,
+ academic_year: @academic_year)
+
+ Respondent.create!(school: @school, academic_year: @academic_year, total_students: 40, total_teachers: 40)
+ ResponseRate.create!(subcategory: Subcategory.first, school: @school, academic_year: @academic_year,
+ student_response_rate: 100, teacher_response_rate: 100, meets_student_threshold: true, meets_teacher_threshold: true)
+
+ render
+ end
+ it "shows the view with the students & teachers button active" do
+ expect(subject.css("input[id='student_and_teacher_btn'][checked='checked']").count).to eq 1
+ end
+ end
+
+ context "when the parent view is shown" do
+ let(:variance_chart_row_presenters) do
+ measure = create(:measure, name: "Display Me", measure_id: "display-me")
+ scale = create(:scale, measure:)
+ create(:student_survey_item,
+ scale:,
+ watch_low_benchmark: 1.5,
+ growth_low_benchmark: 2.5,
+ approval_low_benchmark: 3.5,
+ ideal_low_benchmark: 4.5)
+ [
+ Overview::VarianceChartRowPresenter.new(measure:,
+ score: Score.new(average: rand))
+ ]
+ end
+
+ before :each do
+ assign :category_presenters, []
+ assign :variance_chart_row_presenters, variance_chart_row_presenters
+ @academic_year = create(:academic_year)
+ assign :academic_years, [@academic_year]
+ @district = create(:district)
+ @school = create(:school)
+ assign :page,
+ Overview::OverviewPresenter.new(params: { view: "parent" }, school: @school,
+ academic_year: @academic_year)
+ @student_response_rate_presenter = ResponseRatePresenter.new(focus: :student, school: @school,
+ academic_year: @academic_year)
+ @teacher_response_rate_presenter = ResponseRatePresenter.new(focus: :teacher, school: @school,
+ academic_year: @academic_year)
+
+ Respondent.create!(school: @school, academic_year: @academic_year, total_students: 40, total_teachers: 40)
+ ResponseRate.create!(subcategory: Subcategory.first, school: @school, academic_year: @academic_year,
+ student_response_rate: 100, teacher_response_rate: 100, meets_student_threshold: true, meets_teacher_threshold: true)
+
+ render
+ end
+ it "shows the view with the students & teachers button active" do
+ expect(subject.css("input[id='parent_btn'][checked='checked']").count).to eq 1
+ end
+ end
end
diff --git a/spec/views/overview/variance_chart.html.erb_spec.rb b/spec/views/overview/variance_chart.html.erb_spec.rb
index 81c86b72..a1547fa6 100644
--- a/spec/views/overview/variance_chart.html.erb_spec.rb
+++ b/spec/views/overview/variance_chart.html.erb_spec.rb
@@ -27,8 +27,8 @@ describe "overview/_variance_chart.html.erb" do
before :each do
presenters = [
- VarianceChartRowPresenter.new(measure: lower_scoring_measure, score: Score.new(average: 1)),
- VarianceChartRowPresenter.new(measure: higher_scoring_measure, score: Score.new(average: 5))
+ Overview::VarianceChartRowPresenter.new(measure: lower_scoring_measure, score: Score.new(average: 1)),
+ Overview::VarianceChartRowPresenter.new(measure: higher_scoring_measure, score: Score.new(average: 5))
]
render partial: "variance_chart", locals: { presenters: }
@@ -53,8 +53,8 @@ describe "overview/_variance_chart.html.erb" do
measure_lacking_score = create(:measure)
another_measure_lacking_score = create(:measure)
presenters = [
- VarianceChartRowPresenter.new(measure: measure_lacking_score, score: Score.new(average: nil)),
- VarianceChartRowPresenter.new(measure: another_measure_lacking_score, score: Score.new(average: nil))
+ Overview::VarianceChartRowPresenter.new(measure: measure_lacking_score, score: Score.new(average: nil)),
+ Overview::VarianceChartRowPresenter.new(measure: another_measure_lacking_score, score: Score.new(average: nil))
]
render partial: "variance_chart", locals: { presenters: }