@ -1,4 +1,4 @@
require 'rails_helper'
require " rails_helper "
describe VarianceChartRowPresenter do
describe VarianceChartRowPresenter do
let ( :watch_low_benchmark ) { 2 . 9 }
let ( :watch_low_benchmark ) { 2 . 9 }
@ -9,15 +9,15 @@ describe VarianceChartRowPresenter do
let ( :measure ) do
let ( :measure ) do
measure = create (
measure = create (
:measure ,
:measure ,
name : 'Some Title'
name : " Some Title "
)
)
scale = create ( :scale , measure : )
scale = create ( :scale , measure : )
create ( :student_survey_item , scale : ,
create ( :student_survey_item , scale : ,
watch_low_benchmark : ,
watch_low_benchmark : ,
growth_low_benchmark : ,
growth_low_benchmark : ,
approval_low_benchmark : ,
approval_low_benchmark : ,
ideal_low_benchmark : )
ideal_low_benchmark : )
measure
measure
end
end
@ -25,7 +25,7 @@ describe VarianceChartRowPresenter do
let ( :measure_without_admin_data_items ) do
let ( :measure_without_admin_data_items ) do
create (
create (
:measure ,
:measure ,
name : 'Some Title'
name : " Some Title "
)
)
end
end
@ -33,216 +33,216 @@ describe VarianceChartRowPresenter do
VarianceChartRowPresenter . new measure : , score :
VarianceChartRowPresenter . new measure : , score :
end
end
shared_examples_for 'measure_name' do
shared_examples_for " measure_name " do
it 'returns the measure name' do
it " returns the measure name " do
expect ( presenter . measure_name ) . to eq 'Some Title'
expect ( presenter . measure_name ) . to eq " Some Title "
end
end
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 ) }
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
it " returns the correct color " do
expect ( presenter . bar_color ) . to eq 'fill-ideal'
expect ( presenter . bar_color ) . to eq " fill-ideal "
end
end
it 'returns a bar width equal to the approval zone width plus the proportionate ideal zone width' do
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%'
expect ( presenter . bar_width ) . to eq " 30.0% "
end
end
it 'returns an x-offset of 60%' do
it " returns an x-offset of 60% " do
expect ( presenter . x_offset ) . to eq '60%'
expect ( presenter . x_offset ) . to eq " 60% "
end
end
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 ) }
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
it " returns the correct color " do
expect ( presenter . bar_color ) . to eq 'fill-approval'
expect ( presenter . bar_color ) . to eq " fill-approval "
end
end
it 'returns a bar width equal to the proportionate approval zone width' do
it " returns a bar width equal to the proportionate approval zone width " do
expect ( presenter . bar_width ) . to eq '10.0%'
expect ( presenter . bar_width ) . to eq " 10.0% "
end
end
it 'returns an x-offset of 60%' do
it " returns an x-offset of 60% " do
expect ( presenter . x_offset ) . to eq '60%'
expect ( presenter . x_offset ) . to eq " 60% "
end
end
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 ) }
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
it " returns the correct color " do
expect ( presenter . bar_color ) . to eq 'fill-growth'
expect ( presenter . bar_color ) . to eq " fill-growth "
end
end
it 'returns a bar width equal to the proportionate growth zone width' do
it " returns a bar width equal to the proportionate growth zone width " do
expect ( presenter . bar_width ) . to eq '16.0%'
expect ( presenter . bar_width ) . to eq " 16.0% "
end
end
context 'in order to achieve the visual effect' do
context " in order to achieve the visual effect " do
it 'returns an x-offset equal to 60% minus the bar width' do
it " returns an x-offset equal to 60% minus the bar width " do
expect ( presenter . x_offset ) . to eq '44.0%'
expect ( presenter . x_offset ) . to eq " 44.0% "
end
end
end
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 ) }
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
it " returns the correct color " do
expect ( presenter . bar_color ) . to eq 'fill-watch'
expect ( presenter . bar_color ) . to eq " fill-watch "
end
end
it 'returns a bar width equal to the proportionate watch zone width plus the growth zone width' do
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%'
expect ( presenter . bar_width ) . to eq " 40.0% "
end
end
context 'in order to achieve the visual effect' do
context " in order to achieve the visual effect " do
it 'returns an x-offset equal to 60% minus the bar width' do
it " returns an x-offset equal to 60% minus the bar width " do
expect ( presenter . x_offset ) . to eq '20.0%'
expect ( presenter . x_offset ) . to eq " 20.0% "
end
end
end
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 ) }
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
it " returns the correct color " do
expect ( presenter . bar_color ) . to eq 'fill-warning'
expect ( presenter . bar_color ) . to eq " fill-warning "
end
end
it ' returns a bar width equal to the proportionate warning zone width plus the watch & growth zone widths' do
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%'
expect ( presenter . bar_width ) . to eq " 60.0% "
end
end
context 'in order to achieve the visual effect' do
context " in order to achieve the visual effect " do
it 'returns an x-offset equal to 60% minus the bar width' do
it " returns an x-offset equal to 60% minus the bar width " do
expect ( presenter . x_offset ) . to eq '0.0%'
expect ( presenter . x_offset ) . to eq " 0.0% "
end
end
end
end
end
end
context 'when a measure does not contain admin data items' do
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 ) }
let ( :score ) { Score . new ( average : nil , meets_teacher_threshold : false , meets_student_threshold : false ) }
it 'it does not show a partial data indicator' do
it " it does not show a partial data indicator " do
presenter_without_admin_data = VarianceChartRowPresenter . new measure : measure_without_admin_data_items ,
presenter_without_admin_data = VarianceChartRowPresenter . new measure : measure_without_admin_data_items ,
score : score
score : score
expect ( presenter_without_admin_data . show_partial_data_indicator? ) . to be false
expect ( presenter_without_admin_data . show_partial_data_indicator? ) . to be false
end
end
end
end
context 'when a measure contains admin data items' do
context " when a measure contains admin data items " do
before :each do
before :each do
end
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_with_admin_data = create (
:measure ,
:measure ,
name : 'Some Title'
name : " Some Title "
)
)
scale_with_admin_data = create ( :scale , measure : measure_with_admin_data )
scale_with_admin_data = create ( :scale , measure : measure_with_admin_data )
create :admin_data_item ,
create :admin_data_item ,
scale : scale_with_admin_data ,
scale : scale_with_admin_data ,
watch_low_benchmark : watch_low_benchmark ,
watch_low_benchmark : watch_low_benchmark ,
growth_low_benchmark : growth_low_benchmark ,
growth_low_benchmark : growth_low_benchmark ,
approval_low_benchmark : approval_low_benchmark ,
approval_low_benchmark : approval_low_benchmark ,
ideal_low_benchmark : ideal_low_benchmark
ideal_low_benchmark : ideal_low_benchmark
admin_data_presenter = VarianceChartRowPresenter . new measure : measure_with_admin_data ,
admin_data_presenter = VarianceChartRowPresenter . new measure : measure_with_admin_data ,
score : Score . new (
score : Score . new (
average : 3 . 7 , meets_teacher_threshold : true , meets_student_threshold : true
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 . 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 [ " school data " ]
end
end
end
end
context 'when a measure contains teacher survey items' do
context " when a measure contains teacher survey items " do
before :each do
before :each do
scale = create ( :scale , measure : )
scale = create ( :scale , measure : )
create :teacher_survey_item , scale :
create :teacher_survey_item , scale :
end
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 ) }
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 . 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
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 ) }
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
expect ( presenter . show_partial_data_indicator? ) . to be false
end
end
end
end
end
end
context 'when a measure contains student survey items' do
context " when a measure contains student survey items " do
before :each do
before :each do
scale = create ( :scale , measure : )
scale = create ( :scale , measure : )
create :student_survey_item , scale :
create :student_survey_item , scale :
end
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 ) }
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 . 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
end
context 'where there are also admin data items' do
context " where there are also admin data items " do
before :each do
before :each do
scale = create ( :scale , measure : )
scale = create ( :scale , measure : )
create :admin_data_item , scale :
create :admin_data_item , scale :
end
end
it 'returns the sources for partial results of administrative data and student survey results' do
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' ]
expect ( presenter . partial_data_sources ) . to eq [ " student survey results " , " school data " ]
end
end
end
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 ) }
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
expect ( presenter . show_partial_data_indicator? ) . to be false
end
end
end
end
end
end
context 'sorting scores' do
context " sorting scores " do
it 'selects a longer bar before a shorter bar for measures in the approval/ideal zones' 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 : )
scale_with_student_survey_items = create ( :scale , measure : )
create ( :student_survey_item ,
create ( :student_survey_item ,
scale : scale_with_student_survey_items ,
scale : scale_with_student_survey_items ,
watch_low_benchmark : ,
watch_low_benchmark : ,
growth_low_benchmark : ,
growth_low_benchmark : ,
approval_low_benchmark : ,
approval_low_benchmark : ,
ideal_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 )
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 )
ideal_presenter = VarianceChartRowPresenter . new measure : measure , score : Score . new ( average : 4 . 4 , meets_teacher_threshold : true , meets_student_threshold : true )
expect ( ideal_presenter < = > approval_presenter ) . to be < 0
expect ( ideal_presenter < = > approval_presenter ) . to be < 0
expect ( [ approval_presenter , ideal_presenter ] . sort ) . to eq [ ideal_presenter , approval_presenter ]
expect ( [ approval_presenter , ideal_presenter ] . sort ) . to eq [ ideal_presenter , approval_presenter ]
end
end
it 'selects a warning bar below a ideal bar' do
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 )
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 )
ideal_presenter = VarianceChartRowPresenter . new measure : 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 ) . to be > 0