diff --git a/app/helpers/header_helper.rb b/app/helpers/header_helper.rb index 6b21f48b..602de338 100644 --- a/app/helpers/header_helper.rb +++ b/app/helpers/header_helper.rb @@ -1,7 +1,7 @@ module HeaderHelper def link_to_dashboard(district:, school:, academic_year:) - dashboard_link(district_slug: district.slug, school_slug: school.slug, academic_year_range: academic_year.range) + "/districts/#{district.slug}/schools/#{school.slug}/dashboard?year=#{academic_year.range}" end def link_to_browse(district:, school:, academic_year:) @@ -9,17 +9,20 @@ module HeaderHelper end def district_url_for(district:, academic_year:) - dashboard_link(district_slug: district.slug, school_slug: district.schools.alphabetic.first.slug, academic_year_range: academic_year.range) + dashboard_link(district_slug: district.slug, school_slug: district.schools.alphabetic.first.slug, academic_year_range: academic_year.range, uri_path: request.fullpath) end def school_url_for(school:, academic_year:) - dashboard_link(district_slug: school.district.slug, school_slug: school.slug, academic_year_range: academic_year.range) + dashboard_link(district_slug: school.district.slug, school_slug: school.slug, academic_year_range: academic_year.range, uri_path: request.fullpath) end private - def dashboard_link(district_slug:, school_slug:, academic_year_range:) - "/districts/#{district_slug}/schools/#{school_slug}/dashboard?year=#{academic_year_range}" + def dashboard_link(district_slug:, school_slug:, academic_year_range:, uri_path:) + if uri_path.include?("dashboard") + return "/districts/#{district_slug}/schools/#{school_slug}/dashboard?year=#{academic_year_range}" + end + "/districts/#{district_slug}/schools/#{school_slug}/browse/teachers-and-leadership?year=#{academic_year_range}" end end diff --git a/spec/features/school_dashboard_feature_spec.rb b/spec/features/school_dashboard_feature_spec.rb index 1257fc46..c0cd8f21 100644 --- a/spec/features/school_dashboard_feature_spec.rb +++ b/spec/features/school_dashboard_feature_spec.rb @@ -121,6 +121,20 @@ feature 'School dashboard', type: feature do break if index == school_options.length-1 expect(school.text).to be < school_options[index+1].text end + + visit "/districts/#{district.slug}/schools/#{school.slug}/browse/teachers-and-leadership?year=#{ay_2020_21.range}" + + expected_num_of_schools = district.schools.count + expect(page.all('.school-options').count).to eq expected_num_of_schools + expect(page.all('.school-options[selected]').count).to eq 1 + expect(page.all('.school-options[selected]')[0].text).to eq 'Winchester High School' + expect(page.all('.school-options[selected]')[0].value).to eq "/districts/#{district.slug}/schools/#{school.slug}/browse/teachers-and-leadership?year=#{ay_2020_21.range}" + + school_options = page.all('.school-options') + school_options.each_with_index do |school , index| + break if index == school_options.length-1 + expect(school.text).to be < school_options[index+1].text + end end scenario 'user sees all districts in dropdown menu' do @@ -138,6 +152,20 @@ feature 'School dashboard', type: feature do break if index == district_options.length-1 expect(district.text).to be < district_options[index+1].text end + + visit "/districts/#{district.slug}/schools/#{school.slug}/browse/teachers-and-leadership?year=#{ay_2020_21.range}" + + expected_num_of_districts = District.count + expect(page.all('.district-options').count).to eq expected_num_of_districts + expect(page.all('.district-options[selected]').count).to eq 1 + expect(page.all('.district-options[selected]')[0].text).to eq 'Winchester' + expect(page.all('.district-options[selected]')[0].value).to eq "/districts/#{district.slug}/schools/#{district.schools.alphabetic.first.slug}/browse/teachers-and-leadership?year=#{ay_2020_21.range}" + + district_options = page.all('.district-options') + district_options.each_with_index do |district , index| + break if index == district_options.length-1 + expect(district.text).to be < district_options[index+1].text + end end end