mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Fix failing tests
This commit is contained in:
parent
658995c427
commit
dcade06ce2
5 changed files with 26 additions and 6 deletions
|
|
@ -18,4 +18,8 @@ class District < ApplicationRecord
|
||||||
def self.boston
|
def self.boston
|
||||||
District.find_by_name('Boston')
|
District.find_by_name('Boston')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def short_name
|
||||||
|
name.split(" ").first.downcase
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
15
spec/models/district_spec.rb
Normal file
15
spec/models/district_spec.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe District, type: :model do
|
||||||
|
let(:lowell) { create(:district, name: "Lowell public schools") }
|
||||||
|
let(:lee) { create(:district, name: "Lee public schools") }
|
||||||
|
let(:maynard) { create(:district, name: "Maynard public schools") }
|
||||||
|
|
||||||
|
context '.short_name' do
|
||||||
|
it "returns the first word in lowercase of a district's name" do
|
||||||
|
expect(lowell.short_name).to eq "lowell"
|
||||||
|
expect(lee.short_name).to eq "lee"
|
||||||
|
expect(maynard.short_name).to eq "maynard"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module BasicAuthHelper
|
module BasicAuthHelper
|
||||||
def login_as(district)
|
def login_as(district)
|
||||||
user = district.name.downcase
|
user = district.short_name
|
||||||
pw = "#{district.name.downcase}!"
|
pw = "#{user}!"
|
||||||
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user, pw)
|
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user, pw)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,9 @@ xdescribe 'District Admin', js: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# let(:username) { 'winchester' }
|
let(:username) { district.short_name}
|
||||||
# let(:password) { 'winchester!' }
|
let(:password) { "#{district.short_name}!" }
|
||||||
|
|
||||||
let(:respondents) do
|
let(:respondents) do
|
||||||
respondent = Respondent.find_or_initialize_by(school:, academic_year: ay_2021_22)
|
respondent = Respondent.find_or_initialize_by(school:, academic_year: ay_2021_22)
|
||||||
respondent.total_students = 8
|
respondent.total_students = 8
|
||||||
|
|
@ -104,7 +105,7 @@ xdescribe 'District Admin', js: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'navigates through the site' do
|
it 'navigates through the site' do
|
||||||
# page.driver.basic_authorize(username, password)
|
page.driver.basic_authorize(username, password)
|
||||||
|
|
||||||
visit '/welcome'
|
visit '/welcome'
|
||||||
expect(page).to have_text('Teachers & Leadership')
|
expect(page).to have_text('Teachers & Leadership')
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ describe 'SQM Application' do
|
||||||
private
|
private
|
||||||
|
|
||||||
def username
|
def username
|
||||||
district.name.downcase
|
district.short_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def password
|
def password
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue