diff --git a/spec/teachers_signup_test.rb b/spec/teachers_signup_test.rb new file mode 100644 index 00000000..56ef2824 --- /dev/null +++ b/spec/teachers_signup_test.rb @@ -0,0 +1,51 @@ +require 'rails_helper' + +RSpec.describe TeachersController, type: :controller do + fixtures :all + it "rejects invalid signup information" do + previous_count = Teacher.count + post :create, { + params: { + school: { + name: "invalid", + city: "Berkeley", + state: "CA", + website: "invalid.com" + }, + teacher: { + first_name: "", + last_name: "invalid", + email: "invalid@invalid.edu", + status: "invalid", + snap: "invalid" + } + } + } + expect(Teacher.count).to eq(previous_count) + assert_match(/First name can't be blank/, flash[:alert]) + end + + + it "accepts valid signup information" do + previous_count = Teacher.count + post :create, { + params: { + school: { + name: "valid_example", + city: "Berkeley", + state: "CA", + website: "valid_example.com" + }, + teacher: { + first_name: "valid_example", + last_name: "valid_example", + email: "valid_example@valid_example.edu", + status: 0, + snap: "valid_example" + } + } + } + expect(Teacher.count).to eq(previous_count + 1) + assert_match(/Thanks for signing up for BJC/, flash[:success]) + end +end diff --git a/test/fixtures/schools.yml b/test/fixtures/schools.yml deleted file mode 100644 index 69ef903b..00000000 --- a/test/fixtures/schools.yml +++ /dev/null @@ -1,33 +0,0 @@ -# == Schema Information -# -# Table name: schools -# -# id :bigint not null, primary key -# city :string -# lat :float -# lng :float -# name :string -# num_denied_teachers :integer default(0) -# num_validated_teachers :integer default(0) -# state :string -# teachers_count :integer default(0) -# website :string -# created_at :datetime -# updated_at :datetime -# -# Indexes -# -# index_schools_on_name_city_and_website (name,city,website) -# - -berkeley: - name: UC Berkeley - city: Berkeley - state: CA - website: 'https://berkeley.edu' - -stanfurd: - name: $tanfurd - city: Palo Alto - state: CA - website: 'https://stanford.edu' diff --git a/test/fixtures/teachers.yml b/test/fixtures/teachers.yml deleted file mode 100644 index 74520093..00000000 --- a/test/fixtures/teachers.yml +++ /dev/null @@ -1,51 +0,0 @@ -# == Schema Information -# -# Table name: teachers -# -# id :bigint not null, primary key -# admin :boolean default(FALSE) -# application_status :string default("pending") -# education_level :integer default(NULL) -# email :string -# encrypted_google_refresh_token :string -# encrypted_google_refresh_token_iv :string -# encrypted_google_token :string -# encrypted_google_token_iv :string -# first_name :string -# last_name :string -# more_info :string -# personal_website :string -# snap :string -# status :integer -# created_at :datetime -# updated_at :datetime -# school_id :integer -# -# Indexes -# -# index_teachers_on_email (email) UNIQUE -# index_teachers_on_email_and_first_name (email,first_name) -# index_teachers_on_school_id (school_id) -# index_teachers_on_status (status) -# - -ye: - first_name: Ye - last_name: Wang - status: 4 - more_info: A CS169 Student - email: 'ye@berkeley.edu' - snap: ye - application_status: Validated - school_id: 1 - education_level: 1 - -bob_teacher: - first_name: Bob - last_name: Johnson - snap: BobJohnson - email: 'bob@gmail.com' - status: 1 - more_info: '' - application_status: Denied - school_id: 1 diff --git a/test/integration/teachers_signup_test.rb b/test/integration/teachers_signup_test.rb deleted file mode 100644 index c7de0e70..00000000 --- a/test/integration/teachers_signup_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'test_helper' - -class TeachersSignupTest < ActionDispatch::IntegrationTest - - test "invalid signup information" do - get root_path - assert_no_difference 'Teacher.count' do - post teachers_path, { - params: { school: { - name: "invalid", - city: "Berkeley", - state: "CA", - website: "invalid.com" - }, - teacher: { - first_name: "", - last_name: "invalid", - email: "invalid@invalid.edu", - status: "invalid", - snap: "invalid" - } - } - } - end - assert_match(/First name can't be blank/, flash[:alert]) - end - - - test "valid signup information" do - get root_path - assert_difference 'Teacher.count', 1 do - post teachers_path, params: { school: {name: "valid_example", - city: "Berkeley", - state: "CA", - website: "valid_example.com" - }, teacher: { - first_name: "valid_example", - last_name: "valid_example", - email: "valid_example@valid_example.edu", - status: 0, - snap: "valid_example" - } - } - end - assert_match(/Thanks for signing up for BJC/, flash[:success]) - end -end diff --git a/test/mailers/previews/teacher_mailer_preview.rb b/test/mailers/previews/teacher_mailer_preview.rb deleted file mode 100644 index 961e6393..00000000 --- a/test/mailers/previews/teacher_mailer_preview.rb +++ /dev/null @@ -1,4 +0,0 @@ -# Preview all emails at http://localhost:3000/rails/mailers/teacher_mailer -class TeacherMailerPreview < ActionMailer::Preview - -end diff --git a/test/mailers/teacher_mailer_test.rb b/test/mailers/teacher_mailer_test.rb deleted file mode 100644 index a395c4ac..00000000 --- a/test/mailers/teacher_mailer_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class TeacherMailerTest < ActionMailer::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index ec62da5e..00000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'simplecov' -SimpleCov.start 'rails' -SimpleCov.command_name -ENV['RAILS_ENV'] ||= 'test' - -require File.expand_path('../../config/environment', __FILE__) -require 'rails/test_help' - -class ActiveSupport::TestCase - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - fixtures :all - - # Add more helper methods to be used by all tests here... -end