Fix regression where we accidentally list the questions for measure 1B-i

pull/1/head
rebuilt 3 years ago
parent ea09fa06b7
commit fc853c4fbc

@ -25,6 +25,8 @@ class TeacherSurveyPresenter < DataItemPresenter
end end
def descriptions_and_availability def descriptions_and_availability
return [DataAvailability.new('1B-i', 'Items available upon request to MCIEA.', true)] if @measure_id == '1B-i'
survey_items.map do |survey_item| survey_items.map do |survey_item|
DataAvailability.new(survey_item.survey_item_id, survey_item.prompt, true) DataAvailability.new(survey_item.survey_item_id, survey_item.prompt, true)
end end

@ -88,7 +88,7 @@ FactoryBot.define do
scale_id { "s-#{rand}" } scale_id { "s-#{rand}" }
end end
factory :admin_scale do factory :admin_scale do
scale_id { 'a-{rand' } scale_id { "a-#{rand}" }
end end
end end

@ -1,19 +1,46 @@
require 'rails_helper' require 'rails_helper'
describe AdminDataPresenter do describe AdminDataPresenter do
let(:school) { School.find_by_slug 'milford-high-school' } let(:school) { create(:school) }
let(:academic_year) { AcademicYear.find_by_range '2021-22' } let(:academic_year) { create(:academic_year) }
let(:measure_1A_i) { Measure.find_by_measure_id '1A-i' }
let(:measure_1A_iii) { Measure.find_by_measure_id '1A-iii' } let(:measure_1A_i) { create(:measure, measure_id: '1A-i') }
describe '#item_description' do let(:scale_1) { create(:admin_scale, measure: measure_1A_i) }
before :each do let(:admin_data_item_1) do
Rails.application.load_seed create(:admin_data_item, admin_data_item_id: 'a-exp-i1', scale: scale_1,
description: 'Percentage teachers with 5+ years of experience')
end
let(:admin_data_item_2) do
create(:admin_data_item, admin_data_item_id: 'a-exp-i2', scale: scale_1,
description: 'Percentage teachers National Board certified')
end
let(:admin_data_item_3) do
create(:admin_data_item, admin_data_item_id: 'a-exp-i3', scale: scale_1,
description: 'Percentage teachers teaching in area of licensure')
end
let(:measure_1A_iii) { create(:measure, measure_id: '1B-i') }
let(:scale_2) { create(:admin_scale, measure: measure_1A_iii) }
let(:admin_data_item_4) do
create(:admin_data_item, admin_data_item_id: 'a-pcom-i1', scale: scale_2,
description: 'Percent teacher returning (excluding retirement)')
end
let(:admin_data_item_5) do
create(:admin_data_item, admin_data_item_id: 'a-pcom-i2', scale: scale_2,
description: 'Percent teachers with 10+ days absent')
end end
after :each do before :each do
DatabaseCleaner.clean scale_1
scale_2
admin_data_item_1
admin_data_item_2
admin_data_item_3
admin_data_item_4
admin_data_item_5
end end
describe '#item_description' do
context 'When the presenter is based on measure 1A-1' do context 'When the presenter is based on measure 1A-1' do
it 'returns a list of survey prompts for teacher survey items' do it 'returns a list of survey prompts for teacher survey items' do
expect(AdminDataPresenter.new(measure_id: measure_1A_i.measure_id, admin_data_items: measure_1A_i.admin_data_items, expect(AdminDataPresenter.new(measure_id: measure_1A_i.measure_id, admin_data_items: measure_1A_i.admin_data_items,
@ -47,13 +74,6 @@ describe AdminDataPresenter do
end end
describe '#descriptions_and_availibility' do describe '#descriptions_and_availibility' do
before :each do
Rails.application.load_seed
end
after :each do
DatabaseCleaner.clean
end
context 'when there are any matching values for admin data items' do context 'when there are any matching values for admin data items' do
before do before do
admin_data_item = measure_1A_i.admin_data_items.first admin_data_item = measure_1A_i.admin_data_items.first
@ -72,6 +92,17 @@ describe AdminDataPresenter do
end end
end end
context 'when there are NO matching values for admin data items' do context 'when there are NO matching values for admin data items' do
it 'returns a list of admin data items and whether there is a matching value' do
expect(
AdminDataPresenter.new(
measure_id: measure_1A_i.measure_id, admin_data_items: measure_1A_i.admin_data_items, has_sufficient_data: true, school:, academic_year:
).descriptions_and_availability
).to eq [
DataAvailability.new('a-exp-i1', 'Percentage teachers with 5+ years of experience', false),
DataAvailability.new('a-exp-i2', 'Percentage teachers National Board certified', false),
DataAvailability.new('a-exp-i3', 'Percentage teachers teaching in area of licensure', false)
]
end
end end
end end
end end

@ -1,20 +1,38 @@
require 'rails_helper' require 'rails_helper'
describe TeacherSurveyPresenter do describe TeacherSurveyPresenter do
let(:school) { School.first } let(:school) { nil }
let(:academic_year) { AcademicYear.first } let(:academic_year) { nil }
let(:measure_1A_i) { Measure.find_by_measure_id '1A-i' } let(:measure_1A_i) { create(:measure, measure_id: '1A-i') }
let(:measure_1B_i) { Measure.find_by_measure_id '1B-i' } let(:scale_1) { create(:teacher_scale, measure: measure_1A_i) }
let(:survey_item_1) do
describe '#item_description' do create(:teacher_survey_item, survey_item_id: 't-1', scale: scale_1,
before :each do prompt: 'Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?')
Rails.application.load_seed
end end
let(:survey_item_2) do
after :each do create(:teacher_survey_item, survey_item_id: 't-2', scale: scale_1,
DatabaseCleaner.clean prompt: 'How prepared are you for teaching the topics that you are expected to teach in your assignment?')
end
let(:survey_item_3) do
create(:teacher_survey_item, survey_item_id: 't-3', scale: scale_1,
prompt: 'How confident are you in working with the student body at your school?')
end
let(:measure_1B_i) { create(:measure, measure_id: '1B-i') }
let(:scale_2) { create(:teacher_scale, measure: measure_1B_i) }
let(:survey_item_4) do
create(:teacher_survey_item, scale: scale_2,
prompt: 'Some prompt that will not be shown. Instead it will say items will be available upon request to MCIEA')
end
before do
scale_1
scale_2
survey_item_1
survey_item_2
survey_item_3
survey_item_4
end end
describe '#item_description' do
context 'When the presenter is based on measure 1A-1' do context 'When the presenter is based on measure 1A-1' do
it 'returns a list of survey prompts for teacher survey items' do it 'returns a list of survey prompts for teacher survey items' do
expect(TeacherSurveyPresenter.new(measure_id: measure_1A_i.measure_id, survey_items: measure_1A_i.teacher_survey_items, expect(TeacherSurveyPresenter.new(measure_id: measure_1A_i.measure_id, survey_items: measure_1A_i.teacher_survey_items,
@ -35,4 +53,42 @@ describe TeacherSurveyPresenter do
end end
end end
end end
describe '#descriptions_and_availability' do
context 'When the presenter is NOT based on measure 1B-i' do
it 'returns a list containing the survey item properties' do
expect(
TeacherSurveyPresenter.new(
measure_id: measure_1A_i.measure_id,
survey_items: measure_1A_i.teacher_survey_items,
has_sufficient_data: true,
school:,
academic_year:
).descriptions_and_availability
).to eq [
DataAvailability.new('t-1',
'Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?', true),
DataAvailability.new('t-2',
'How prepared are you for teaching the topics that you are expected to teach in your assignment?', true),
DataAvailability.new('t-3',
'How confident are you in working with the student body at your school?', true)
]
end
end
context 'When the presenter is based on measure 1B-i' do
it 'returns a message hiding the actual prompts. Instead it presents a message telling the user they can ask for more information' do
expect(
TeacherSurveyPresenter.new(
measure_id: measure_1B_i.measure_id,
survey_items: measure_1B_i.teacher_survey_items,
has_sufficient_data: true,
school:,
academic_year:
).descriptions_and_availability
).to eq [
DataAvailability.new('1B-i', 'Items available upon request to MCIEA.', true)
]
end
end
end
end end

Loading…
Cancel
Save