Make sure to perform authorization when switching districts. Make sure to use apparition for system specs

pull/1/head
rebuilt 3 years ago
parent d48a4efda2
commit 09be5f1fc8

@ -1,18 +1,18 @@
require 'simplecov' require "simplecov"
SimpleCov.start do SimpleCov.start do
add_filter '/app/models/legacy' add_filter "/app/models/legacy"
add_filter '/app/views/legacy' add_filter "/app/views/legacy"
add_filter '/app/controllers/legacy' add_filter "/app/controllers/legacy"
add_filter '/spec/models/legacy' add_filter "/spec/models/legacy"
add_filter '/spec/views/legacy' add_filter "/spec/views/legacy"
add_filter '/spec/controllers/legacy' add_filter "/spec/controllers/legacy"
add_filter '/app/helpers/schedules_helper.rb' add_filter "/app/helpers/schedules_helper.rb"
add_filter '/lib/tasks/survey.rake' add_filter "/lib/tasks/survey.rake"
add_filter '/spec/lib/tasks/survey_rake_spec.rb' add_filter "/spec/lib/tasks/survey_rake_spec.rb"
end end
require 'capybara/rspec' require "capybara/rspec"
require 'capybara/apparition' require "capybara/apparition"
# This file was generated by the `rails generate rspec:install` command. Conventionally, all # This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause # The generated `.rspec` file contains `--require spec_helper` which will cause
@ -68,7 +68,7 @@ RSpec.configure do |config|
config.include Capybara::DSL config.include Capybara::DSL
config.before(:each, type: :system) do config.before(:each, type: :system) do
driven_by :rack_test driven_by :apparition
end end
config.before(:each, js: true) do config.before(:each, js: true) do
@ -89,7 +89,7 @@ RSpec.configure do |config|
# # Allows RSpec to persist some state between runs in order to support # # Allows RSpec to persist some state between runs in order to support
# # the `--only-failures` and `--next-failure` CLI options. We recommend # # the `--only-failures` and `--next-failure` CLI options. We recommend
# # you configure your source control system to ignore this file. # # you configure your source control system to ignore this file.
config.example_status_persistence_file_path = 'spec/examples.txt' config.example_status_persistence_file_path = "spec/examples.txt"
# #
# # Limits the available syntax to the non-monkey patched syntax that is # # Limits the available syntax to the non-monkey patched syntax that is
# # recommended. For more details, see: # # recommended. For more details, see:
@ -126,7 +126,7 @@ RSpec.configure do |config|
# Kernel.srand config.seed # Kernel.srand config.seed
config.before(:each) do config.before(:each) do
stub_const('Twilio::REST::Client', FakeSMS) stub_const("Twilio::REST::Client", FakeSMS)
end end
config.after(:each) do config.after(:each) do
@ -134,14 +134,15 @@ RSpec.configure do |config|
end end
end end
require 'active_support/all' require "active_support/all"
class FakeSMS class FakeSMS
Message = Struct.new(:from, :to, :body) Message = Struct.new(:from, :to, :body)
cattr_accessor :messages cattr_accessor :messages
self.messages = [] self.messages = []
def initialize(_account_sid, _auth_token); end def initialize(_account_sid, _auth_token)
end
def self.reset def self.reset
self.messages = [] self.messages = []
@ -158,7 +159,7 @@ class FakeSMS
def get(sid) def get(sid)
phone = self.class.messages[sid].to phone = self.class.messages[sid].to
phone = "+1#{phone}" unless phone.starts_with?('+1') phone = "+1#{phone}" unless phone.starts_with?("+1")
Struct.new(:to).new(phone) Struct.new(:to).new(phone)
end end
end end
@ -168,7 +169,7 @@ def create_recipients(school, count)
count.times do |i| count.times do |i|
recipients << school.recipients.create( recipients << school.recipients.create(
name: "Person#{i}", name: "Person#{i}",
phone: '+' + (i.to_s * 10) phone: "+" + (i.to_s * 10)
) )
end end
recipients recipients

@ -1,7 +1,7 @@
require 'rails_helper' require 'rails_helper'
include AnalyzeHelper include AnalyzeHelper
xdescribe 'District Admin', js: true do describe 'District Admin', js: true do
let(:district) { District.find_by_slug 'lee-public-schools' } let(:district) { District.find_by_slug 'lee-public-schools' }
let(:different_district) { District.find_by_slug 'maynard-public-schools' } let(:different_district) { District.find_by_slug 'maynard-public-schools' }
let(:school) { School.find_by_slug 'lee-elementary-school' } let(:school) { School.find_by_slug 'lee-elementary-school' }
@ -40,7 +40,7 @@ xdescribe 'District Admin', js: true do
end end
end end
let(:username) { district.short_name} let(:username) { district.short_name }
let(:password) { "#{district.short_name}!" } let(:password) { "#{district.short_name}!" }
let(:respondents) do let(:respondents) do
@ -140,6 +140,7 @@ xdescribe 'District Admin', js: true do
district_admin_sees_schools_change district_admin_sees_schools_change
go_to_different_district(different_district) go_to_different_district(different_district)
page.driver.basic_authorize(different_district.short_name, "#{different_district.short_name}!")
district_admin_sees_district_change district_admin_sees_district_change
go_to_different_year(ay_2019_20) go_to_different_year(ay_2019_20)

Loading…
Cancel
Save