diff --git a/spec/presenters/analyze/presenter_spec.rb b/spec/presenters/analyze/presenter_spec.rb index 2c8d6984..bba430b3 100644 --- a/spec/presenters/analyze/presenter_spec.rb +++ b/spec/presenters/analyze/presenter_spec.rb @@ -177,7 +177,7 @@ describe Analyze::Presenter do context "when multiple academic years are provided in the params hash" do it "returns the academic year with the given ids" do - params = { academic_years: "2021-22,2022-23" } + params = { academic_year1: "2021-22", academic_year2: "2022-23" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.selected_academic_years).to eq [AcademicYear.find_by_range("2021-22"), AcademicYear.find_by_range("2022-23")] @@ -215,11 +215,11 @@ describe Analyze::Presenter do context "when one race is provided in the params hash" do it "returns a single race with the given slug" do - params = { races: "white" } + params = { "race1-checkbox" => "white" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.selected_races).to eq [Race.find_by_slug("white")] - params = { races: "black" } + params = { "race1-checkbox" => "black" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.selected_races).to eq [Race.find_by_slug("black")] end @@ -227,7 +227,8 @@ describe Analyze::Presenter do context "when multiple races are provided in the params hash" do it "returns multiple races with the given slugs" do - params = { races: "white,black" } + params = { "race1-checkbox" => "white", + "race2-checkbox" => "black" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.selected_races).to eq [Race.find_by_slug("white"), Race.find_by_slug("black")] end @@ -307,7 +308,7 @@ describe Analyze::Presenter do context "when no grades are provided in the params hash" do it "returns only the set of grades selected even if other grades have sufficient responses" do - params = { grades: "1,2,3" } + params = { "grade1-checkbox" => "1", "grade2-checkbox" => "2", "grade3-checkbox" => "3" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.selected_grades).to eq [1, 2, 3] end @@ -330,11 +331,11 @@ describe Analyze::Presenter do context "when a single gender is provided in the params hash" do it "returns the gender with the given designation" do - params = { genders: "female" } + params = { "gender1-checkbox" => "female" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.selected_genders).to eq [Gender.find_by_designation("female")] - params = { genders: "male" } + params = { "gender1-checkbox" => "male" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.selected_genders).to eq [Gender.find_by_designation("male")] end @@ -342,7 +343,7 @@ describe Analyze::Presenter do context "when multiple genders are provided in the params hash" do it "returns multilple genders with the given designations" do - params = { genders: "female,male" } + params = { "gender1-checkbox" => "female", "gender2-checkbox" => "male" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.selected_genders).to eq [Gender.find_by_designation("female"), Gender.find_by_designation("male")] @@ -386,10 +387,9 @@ describe Analyze::Presenter do presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.group.slug).to eq "race" - # Not yet implemented - # params = { group: 'income' } - # presenter = Analyze::Presenter.new(params:, school:, academic_year:) - # expect(presenter.group.slug).to eq 'income' + params = { group: "income" } + presenter = Analyze::Presenter.new(params:, school:, academic_year:) + expect(presenter.group.slug).to eq "income" end end @@ -411,27 +411,47 @@ describe Analyze::Presenter do end end - context "when a slice is provided in the params hash" do + context "when the graph is all-data" do it "returns the slice with the given slug" do - params = { source: "survey-data-only", slice: "students-and-teachers" } + params = { graph: "all-data" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) - expect(presenter.slice.slug).to eq "students-and-teachers" + expect(presenter.slice.slug).to eq "all-data" end end - context "when a slice is provided but the source is left blank " do - it "returns the slice from the default source (all-data)" do - params = { slice: "students-and-teachers" } + context "when the graph is 'students-and-teachers'" do + it "returns the slice with the given slug" do + params = { graph: "students-and-teachers" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) - expect(presenter.slice.slug).to eq "all-data" + expect(presenter.slice.slug).to eq "students-and-teachers" end end - context "when a parameter that does not match a slice is provided" do - it "it returns the first slice from the chosen source" do - params = { source: "survey-data-only", slice: "invalid-slice" } + context "when the graph is of a disaggregation group" do + it "returns the slice with the given slug" do + params = { graph: "students-by-ell" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) - expect(presenter.slice.slug).to eq "students-and-teachers" + expect(presenter.slice.slug).to eq "students-by-group" + + params = { graph: "students-by-gender" } + presenter = Analyze::Presenter.new(params:, school:, academic_year:) + expect(presenter.slice.slug).to eq "students-by-group" + + params = { graph: "students-by-grade" } + presenter = Analyze::Presenter.new(params:, school:, academic_year:) + expect(presenter.slice.slug).to eq "students-by-group" + + params = { graph: "students-by-income" } + presenter = Analyze::Presenter.new(params:, school:, academic_year:) + expect(presenter.slice.slug).to eq "students-by-group" + + params = { graph: "students-by-race" } + presenter = Analyze::Presenter.new(params:, school:, academic_year:) + expect(presenter.slice.slug).to eq "students-by-group" + + params = { graph: "students-by-sped" } + presenter = Analyze::Presenter.new(params:, school:, academic_year:) + expect(presenter.slice.slug).to eq "students-by-group" end end end @@ -445,21 +465,21 @@ describe Analyze::Presenter do end end - context "when a source is provided in the params hash" do + context "when a graph is provided in the params hash" do it "returns the source with the given slug" do - params = { source: "all-data" } + params = { graph: "all-data" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.source.slug).to eq "all-data" - params = { source: "survey-data-only" } + params = { graph: "students-and-teachers" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.source.slug).to eq "survey-data-only" end end - context "when a parameter that does not match a source is provided" do + context "when a parameter that does not match a graph is provided" do it "returns the first item in the list of sources" do - params = { source: "invalid-source" } + params = { graph: "invalid-source" } presenter = Analyze::Presenter.new(params:, school:, academic_year:) expect(presenter.slice.slug).to eq "all-data" end diff --git a/spec/presenters/category_presenter_spec.rb b/spec/presenters/category_presenter_spec.rb index 6b7ffcc2..365fb2dc 100644 --- a/spec/presenters/category_presenter_spec.rb +++ b/spec/presenters/category_presenter_spec.rb @@ -1,37 +1,37 @@ -require 'rails_helper' +require "rails_helper" describe CategoryPresenter do let(:category_presenter) do - subcategory1 = Subcategory.create(name: 'A subcategory', subcategory_id: '1') - subcategory2 = Subcategory.create(name: 'Another subcategory', subcategory_id: '2') + subcategory1 = Subcategory.create(name: "A subcategory", subcategory_id: "1") + subcategory2 = Subcategory.create(name: "Another subcategory", subcategory_id: "2") - category = Category.create(name: 'Some Category', subcategories: [subcategory1, subcategory2], - description: 'A description for some Category', short_description: 'A short description for some Category', category_id: '1') + category = Category.create(name: "Some Category", subcategories: [subcategory1, subcategory2], + description: "A description for some Category", short_description: "A short description for some Category", category_id: "1") return CategoryPresenter.new(category:) end let(:teachers_and_leadership_presenter) do - category = create(:category, name: 'Teachers & Leadership') + category = create(:category, name: "Teachers & Leadership") return CategoryPresenter.new(category:) end let(:school_culture_presenter) do - category = create(:category, name: 'School Culture') + category = create(:category, name: "School Culture") return CategoryPresenter.new(category:) end let(:resources_presenter) do - category = create(:category, name: 'Resources') + category = create(:category, name: "Resources") return CategoryPresenter.new(category:) end let(:academic_learning_presenter) do - category = create(:category, name: 'Academic Learning') + category = create(:category, name: "Academic Learning") return CategoryPresenter.new(category:) end let(:community_and_wellbeing_presenter) do - category = create(:category, name: 'Community & Wellbeing') + category = create(:category, name: "Community & Wellbeing") return CategoryPresenter.new(category:) end @@ -39,33 +39,33 @@ describe CategoryPresenter do DatabaseCleaner.clean end - it 'returns the name, id and description of the category' do - expect(category_presenter.name).to eq 'Some Category' - expect(category_presenter.description).to eq 'A description for some Category' - expect(category_presenter.short_description).to eq 'A short description for some Category' - expect(category_presenter.id).to eq '1' + it "returns the name, id and description of the category" do + expect(category_presenter.name).to eq "Some Category" + expect(category_presenter.description).to eq "A description for some Category" + expect(category_presenter.short_description).to eq "A short description for some Category" + expect(category_presenter.id).to eq "1" end - it 'maps subcategories to subcategory presenters' do + it "maps subcategories to subcategory presenters" do expect(category_presenter.subcategories(academic_year: AcademicYear.new, school: School.new).map(&:name)).to eq [ - 'A subcategory', 'Another subcategory' + "A subcategory", "Another subcategory" ] end - it 'returns the correct icon for the given category' do - expect(teachers_and_leadership_presenter.icon_class).to eq 'fas fa-apple-alt' - expect(school_culture_presenter.icon_class).to eq 'fas fa-school' - expect(resources_presenter.icon_class).to eq 'fas fa-users-cog' - expect(academic_learning_presenter.icon_class).to eq 'fas fa-graduation-cap' - expect(community_and_wellbeing_presenter.icon_class).to eq 'fas fa-heart' + it "returns the correct icon for the given category" do + expect(teachers_and_leadership_presenter.icon_class).to eq "fas fa-apple-alt" + expect(school_culture_presenter.icon_class).to eq "fas fa-school" + expect(resources_presenter.icon_class).to eq "fas fa-users-cog" + expect(academic_learning_presenter.icon_class).to eq "fas fa-graduation-cap" + expect(community_and_wellbeing_presenter.icon_class).to eq "fas fa-heart" end - it 'returns the correct color for the given category' do - expect(teachers_and_leadership_presenter.icon_color_class).to eq 'color-blue' - expect(school_culture_presenter.icon_color_class).to eq 'color-red' - expect(resources_presenter.icon_color_class).to eq 'color-black' - expect(academic_learning_presenter.icon_color_class).to eq 'color-lime' - expect(community_and_wellbeing_presenter.icon_color_class).to eq 'color-teal' + it "returns the correct color for the given category" do + expect(teachers_and_leadership_presenter.icon_color_class).to eq "color-blue" + expect(school_culture_presenter.icon_color_class).to eq "color-red" + expect(resources_presenter.icon_color_class).to eq "color-black" + expect(academic_learning_presenter.icon_color_class).to eq "color-lime" + expect(community_and_wellbeing_presenter.icon_color_class).to eq "color-teal" end end diff --git a/spec/presenters/data_item_presenters/admin_data_presenter_spec.rb b/spec/presenters/data_item_presenters/admin_data_presenter_spec.rb index 4e4040b3..0bb922fc 100644 --- a/spec/presenters/data_item_presenters/admin_data_presenter_spec.rb +++ b/spec/presenters/data_item_presenters/admin_data_presenter_spec.rb @@ -40,39 +40,6 @@ describe AdminDataPresenter do admin_data_item_5 end - describe '#item_description' do - context 'When the presenter is based on measure 1A-1' 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, - has_sufficient_data: true, school:, academic_year:).item_descriptions).to eq [ - 'Percentage teachers with 5+ years of experience', 'Percentage teachers National Board certified', 'Percentage teachers teaching in area of licensure' - ] - end - context 'When the measure is missing all admin data values' do - it 'if it lacks sufficient data, it shows a warning ' do - expect(AdminDataPresenter.new(measure_id: measure_1A_i.measure_id, admin_data_items: measure_1A_i.admin_data_items, - has_sufficient_data: false, school:, academic_year:).sufficient_data?).to eq false - end - end - - context 'When the measure has at least one admin data value' do - it 'if it lacks sufficient data, it doesnt show a warning ' 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:).sufficient_data?).to eq true - end - end - end - - context 'When the presenter is based on measure 1A-iii' 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(AdminDataPresenter.new(measure_id: measure_1A_iii.measure_id, admin_data_items: measure_1A_iii.admin_data_items, - has_sufficient_data: true, school:, academic_year:).item_descriptions).to eq [ - 'Percent teacher returning (excluding retirement)', 'Percent teachers with 10+ days absent' - ] - end - end - end - describe '#descriptions_and_availibility' do context 'when there are any matching values for admin data items' do before do diff --git a/spec/presenters/data_item_presenters/teacher_survey_presenter_spec.rb b/spec/presenters/data_item_presenters/teacher_survey_presenter_spec.rb index 533ebf6b..07157946 100644 --- a/spec/presenters/data_item_presenters/teacher_survey_presenter_spec.rb +++ b/spec/presenters/data_item_presenters/teacher_survey_presenter_spec.rb @@ -1,27 +1,27 @@ -require 'rails_helper' +require "rails_helper" describe TeacherSurveyPresenter do let(:school) { nil } let(:academic_year) { nil } - let(:measure_1A_i) { create(:measure, measure_id: '1A-i') } + let(:measure_1A_i) { create(:measure, measure_id: "1A-i") } let(:scale_1) { create(:teacher_scale, measure: measure_1A_i) } let(:survey_item_1) do - create(:teacher_survey_item, survey_item_id: 't-1', scale: scale_1, - prompt: 'Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?') + create(:teacher_survey_item, survey_item_id: "t-1", scale: scale_1, + prompt: "Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?") end let(:survey_item_2) do - create(:teacher_survey_item, survey_item_id: 't-2', scale: scale_1, - prompt: 'How prepared are you for teaching the topics that you are expected to teach in your assignment?') + create(:teacher_survey_item, survey_item_id: "t-2", scale: scale_1, + 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?') + 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(: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') + 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 @@ -32,31 +32,31 @@ describe TeacherSurveyPresenter do survey_item_4 end - describe '#item_description' do - context 'When the presenter is based on measure 1A-1' do - it 'returns a list of survey prompts for teacher survey items' do + describe "#item_description" do + context "When the presenter is based on measure 1A-1" 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, has_sufficient_data: true, school:, academic_year:).item_descriptions).to eq [ - 'Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?', - 'How prepared are you for teaching the topics that you are expected to teach in your assignment?', - 'How confident are you in working with the student body at your school?' + "Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?", + "How prepared are you for teaching the topics that you are expected to teach in your assignment?", + "How confident are you in working with the student body at your school?" ] 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 + 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:).item_descriptions).to eq [ - 'Items available upon request to MCIEA.' + "Items available upon request to MCIEA." ] 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 + 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, @@ -66,17 +66,17 @@ describe TeacherSurveyPresenter do academic_year: ).descriptions_and_availability ).to eq [ - Summary.new('t-1', - 'Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?', true), - Summary.new('t-2', - 'How prepared are you for teaching the topics that you are expected to teach in your assignment?', true), - Summary.new('t-3', - 'How confident are you in working with the student body at your school?', true) + Summary.new("t-1", + "Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?", true), + Summary.new("t-2", + "How prepared are you for teaching the topics that you are expected to teach in your assignment?", true), + Summary.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 + 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, @@ -86,7 +86,7 @@ describe TeacherSurveyPresenter do academic_year: ).descriptions_and_availability ).to eq [ - Summary.new('1B-i', 'Items available upon request to MCIEA', true) + Summary.new("1B-i", "Items available upon request to MCIEA", true) ] end end