From f2ee4d2b966a9a1907eb402b76b15bff90776f9f Mon Sep 17 00:00:00 2001 From: razztech Date: Thu, 7 Mar 2024 19:41:38 -0800 Subject: [PATCH 01/60] Added frontend + db logic for country field in international schools --- Gemfile | 3 +++ Gemfile.lock | 6 +++++ app/controllers/schools_controller.rb | 6 ++--- app/controllers/teachers_controller.rb | 4 +-- app/models/school.rb | 8 +++--- app/views/schools/_form.html.erb | 27 ++++++++++++++++++- .../20240307225738_add_country_to_schools.rb | 5 ++++ db/schema.rb | 3 ++- spec/fixtures/schools.yml | 1 + 9 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20240307225738_add_country_to_schools.rb diff --git a/Gemfile b/Gemfile index 4e87cca0..0b73d21e 100644 --- a/Gemfile +++ b/Gemfile @@ -49,6 +49,9 @@ gem "activerecord-import", require: false gem "httparty", "~> 0.21.0" + +gem "country_select", "~> 8.0" + group :development do gem "annotate" diff --git a/Gemfile.lock b/Gemfile.lock index 47f889a5..24ef2246 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,6 +140,10 @@ GEM coercible (1.0.0) descendants_tracker (~> 0.0.1) concurrent-ruby (1.2.3) + countries (5.7.2) + unaccent (~> 0.3) + country_select (8.0.3) + countries (~> 5.0) crass (1.0.6) cucumber (7.1.0) builder (~> 3.2, >= 3.2.4) @@ -528,6 +532,7 @@ GEM concurrent-ruby (~> 1.0) tzinfo-data (1.2021.5) tzinfo (>= 1.0.0) + unaccent (0.4.0) unicode-display_width (2.4.2) version_gem (1.1.3) virtus (2.0.0) @@ -563,6 +568,7 @@ DEPENDENCIES axe-core-cucumber axe-core-rspec bootsnap (>= 1.4.4) + country_select (~> 8.0) cucumber-rails database_cleaner debug diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index 001e9606..0ea311f1 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -12,11 +12,11 @@ def show end def search - School.all.collect { |school| ["#{school.name}, #{school.city}, #{school.state}", school.name] } + School.all.collect { |school| ["#{school.name}, #{school.country}, #{school.city}, #{school.state}", school.name] } end def create - @school = School.find_by(name: school_params[:name], city: school_params[:city], state: school_params[:state]) + @school = School.find_by(name: school_params[:name], country: school_params[:country], city: school_params[:city], state: school_params[:state]) if @school @school.assign_attributes(school_params) else @@ -64,7 +64,7 @@ def destroy private def school_params - params.require(:school).permit(:name, :city, :state, :website, :grade_level, :school_type, { tags: [] }, :nces_id) + params.require(:school).permit(:name, :country, :city, :state, :website, :grade_level, :school_type, :country, { tags: [] }, :nces_id) end def load_ordered_schools diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb index d6f0a5a1..e96597f5 100644 --- a/app/controllers/teachers_controller.rb +++ b/app/controllers/teachers_controller.rb @@ -189,7 +189,7 @@ def load_school if teacher_params[:school_id].present? @school ||= School.find(teacher_params[:school_id]) end - @school ||= School.find_or_create_by(name: school_params[:name], city: school_params[:city], state: school_params[:state]) + @school ||= School.find_or_create_by(name: school_params[:name], city: school_params[:city], country: school_params[:country], state: school_params[:state]) end def teacher_params @@ -203,7 +203,7 @@ def teacher_params def school_params return unless params[:school] - params.require(:school).permit(:name, :city, :state, :website, :grade_level, :school_type) + params.require(:school).permit(:name, :country, :city, :state, :website, :grade_level, :school_type) end def omniauth_data diff --git a/app/models/school.rb b/app/models/school.rb index 82eaf4ff..8c109351 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -6,6 +6,7 @@ # # id :integer not null, primary key # city :string +# country :string # grade_level :integer # lat :float # lng :float @@ -25,10 +26,11 @@ # class School < ApplicationRecord - VALID_STATES = [ "AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY", "International"].freeze + VALID_STATES = [ "AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"].freeze - validates :state, inclusion: { in: VALID_STATES } - validates :name, :city, :state, :website, presence: true + validates :name, :city, :website, :country, presence: true + validates :state, inclusion: { in: VALID_STATES }, if: -> { country == "United States" } + validates :state, presence: true, if: -> { country == "United States" } validates_format_of :website, with: /.+\..+/, on: :create before_save :update_gps_data, if: -> { lat.nil? || lng.nil? } diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb index 8b46ae1c..489e9218 100644 --- a/app/views/schools/_form.html.erb +++ b/app/views/schools/_form.html.erb @@ -5,6 +5,16 @@ <%= f.text_field :name, placeholder: 'UC Berkeley', class: 'form-control', required: false, id: 'school_name' %> + +
+
+ <%= f.label :country, "Country", class: "label-required", for: "school_country" %> + <%= f.country_select( + :country, + { priority_countries: ['United States'], include_blank: "Select an option" }, + { class: 'form-control', required: true, id: 'school_country', format: :with_full_country_name} + ) %> +
<%= f.label :city, class: "label-required", for: "school_city" %> @@ -12,7 +22,7 @@ required: false, id: 'school_city' %>
-
+
<%= f.label :state, class: "label-required", for: "school_state" %> <%= f.select( :state, @@ -88,3 +98,18 @@ class: "form-control", title: "Please enter a valid NCES ID.", id: "school_nces_id" %>
<%- end %> + + diff --git a/db/migrate/20240307225738_add_country_to_schools.rb b/db/migrate/20240307225738_add_country_to_schools.rb new file mode 100644 index 00000000..ee25792d --- /dev/null +++ b/db/migrate/20240307225738_add_country_to_schools.rb @@ -0,0 +1,5 @@ +class AddCountryToSchools < ActiveRecord::Migration[6.1] + def change + add_column :schools, :country, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index acd0374a..a9927666 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2024_02_20_192015) do +ActiveRecord::Schema.define(version: 2024_03_07_225738) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -96,6 +96,7 @@ t.integer "school_type" t.text "tags", default: [], array: true t.string "nces_id" + t.string "country" t.index ["name", "city", "website"], name: "index_schools_on_name_city_and_website" end diff --git a/spec/fixtures/schools.yml b/spec/fixtures/schools.yml index 1f4816ce..e33bb16f 100644 --- a/spec/fixtures/schools.yml +++ b/spec/fixtures/schools.yml @@ -4,6 +4,7 @@ # # id :integer not null, primary key # city :string +# country :string # grade_level :integer # lat :float # lng :float From 100025064f5b5283ec6826a162cc4e0994f15508 Mon Sep 17 00:00:00 2001 From: razztech Date: Fri, 8 Mar 2024 11:46:19 -0800 Subject: [PATCH 02/60] Added some new frontend logic --- app/models/school.rb | 2 +- app/views/schools/_form.html.erb | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/models/school.rb b/app/models/school.rb index 8c109351..c9709cc8 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -29,7 +29,7 @@ class School < ApplicationRecord VALID_STATES = [ "AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"].freeze validates :name, :city, :website, :country, presence: true - validates :state, inclusion: { in: VALID_STATES }, if: -> { country == "United States" } + validates :state, inclusion: { in: VALID_STATES }, if: -> { country == "United States" } validates :state, presence: true, if: -> { country == "United States" } validates_format_of :website, with: /.+\..+/, on: :create diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb index 489e9218..00288a19 100644 --- a/app/views/schools/_form.html.erb +++ b/app/views/schools/_form.html.erb @@ -22,7 +22,7 @@ required: false, id: 'school_city' %>
-
+
<%= f.label :state, class: "label-required", for: "school_state" %> <%= f.select( :state, @@ -31,6 +31,13 @@ { class: 'form-control', required: false, id: 'school_state'} ) %>
+
+ <%= f.label :state, for: "school_state" %> + <%= f.text_field( + :state, placeholder: "State", + class: 'form-control' + ) %> +
@@ -102,14 +109,16 @@ From 277e4dea37f8bbff6dbfd6294a1610fbc0aaaaff Mon Sep 17 00:00:00 2001 From: razztech Date: Sun, 10 Mar 2024 20:50:33 -0700 Subject: [PATCH 03/60] Made changes to UI logic and updated tests --- app/models/school.rb | 4 +- app/views/schools/_form.html.erb | 45 ++++++++------ features/admin.feature | 40 ++++++------ features/school_form_submission.feature | 6 +- features/teacher.feature | 67 +++++++++++---------- spec/controllers/schools_controller_spec.rb | 10 +++ spec/controllers/teachers_signup_spec.rb | 1 + 7 files changed, 97 insertions(+), 76 deletions(-) diff --git a/app/models/school.rb b/app/models/school.rb index c9709cc8..b9599163 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -29,8 +29,8 @@ class School < ApplicationRecord VALID_STATES = [ "AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"].freeze validates :name, :city, :website, :country, presence: true - validates :state, inclusion: { in: VALID_STATES }, if: -> { country == "United States" } - validates :state, presence: true, if: -> { country == "United States" } + validates :state, inclusion: { in: VALID_STATES }, if: -> { country == "US" } + validates :state, presence: true, if: -> { country == "US" } validates_format_of :website, with: /.+\..+/, on: :create before_save :update_gps_data, if: -> { lat.nil? || lng.nil? } diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb index 00288a19..b44d09be 100644 --- a/app/views/schools/_form.html.erb +++ b/app/views/schools/_form.html.erb @@ -22,21 +22,14 @@ required: false, id: 'school_city' %>
-
+
<%= f.label :state, class: "label-required", for: "school_state" %> - <%= f.select( - :state, - School::VALID_STATES, - { include_blank: "State" }, - { class: 'form-control', required: false, id: 'school_state'} - ) %> + <%= f.select :state, School::VALID_STATES, { include_blank: "State" }, { id: "state_select", class: 'form-control' } %>
+
<%= f.label :state, for: "school_state" %> - <%= f.text_field( - :state, placeholder: "State", - class: 'form-control' - ) %> + <%= f.text_field :state, placeholder: "State", class: 'form-control', id: "state_textfield" %>
@@ -108,17 +101,33 @@ diff --git a/features/admin.feature b/features/admin.feature index 3c066a9f..77bf135a 100644 --- a/features/admin.feature +++ b/features/admin.feature @@ -76,8 +76,8 @@ Feature: basic admin functionality Scenario: Edit teacher info as an admin Given the following schools exist: - | name | city | state | website | grade_level | school_type | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public | + | name | country | city | state | website | grade_level | school_type | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | Given the following teachers exist: | first_name | last_name | admin | email | school | snap | | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | alonzo | @@ -96,8 +96,8 @@ Feature: basic admin functionality Scenario: Deny teacher as an admin Given the following schools exist: - | name | city | state | website | grade_level | school_type | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public | + | name | country | city | state | website | grade_level | school_type | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | Given the following teachers exist: | first_name | last_name | admin | email | school | | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | @@ -118,8 +118,8 @@ Feature: basic admin functionality Scenario: Not logged in should not have access to edit Given the following schools exist: - | name | city | state | website | grade_level | school_type | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public | + | name | country | city | state | website | grade_level | school_type | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | Given the following teachers exist: | first_name | last_name | admin | email | school | | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | @@ -128,8 +128,8 @@ Feature: basic admin functionality Scenario: Filter all teacher info as an admin Given the following schools exist: - | name | city | state | website | grade_level | school_type | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public | + | name | country | city | state | website | grade_level | school_type | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | Given the following teachers exist: | first_name | last_name | admin | email | school | application_status | | Victor | Validateme | false | testteacher1@berkeley.edu | UC Berkeley | Validated | @@ -152,8 +152,8 @@ Feature: basic admin functionality Scenario: View teacher info as an admin Given the following schools exist: - | name | city | state | website | grade_level | school_type | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public | + | name | country | city | state | website | grade_level | school_type | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | Given the following teachers exist: | first_name | last_name | admin | email | school | snap | | Joseph | Test | false | testteacher@berkeley.edu | UC Berkeley | alonzo | @@ -173,8 +173,8 @@ Feature: basic admin functionality Scenario: Edit teacher info as an admin navigating from view only page to edit page Given the following schools exist: - | name | city | state | website | grade_level | school_type | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public | + | name | country | city | state | website | grade_level | school_type | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | Given the following teachers exist: | first_name | last_name | admin | email | school | snap | | Joseph | Mamoa New | false | testteacher@berkeley.edu | UC Berkeley | alonzo | @@ -197,8 +197,8 @@ Feature: basic admin functionality Scenario: Should be able to resend welcome email Given the following schools exist: - | name | city | state | website | grade_level | school_type | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public | + | name | country | city | state | website | grade_level | school_type | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | Given the following teachers exist: | first_name | last_name | admin | email | school | snap | application_status | | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | alonzo | validated | @@ -234,8 +234,8 @@ Feature: basic admin functionality Scenario: Request information from a teacher as an admin Given the following schools exist: - | name | city | state | website | grade_level | school_type | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | university | public | + | name | country | city | state | website | grade_level | school_type | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | And the following teachers exist: | first_name | last_name | admin | email | school | | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | @@ -257,8 +257,8 @@ Feature: basic admin functionality # Scenario: Admin can import csv file. The loader should filter invalid record and create associate school. # Given the following schools exist: -# | name | city | state | website | -# | UC Berkeley | Berkeley | CA | https://bjc.berkeley.edu | +# | name | country | city | state | website | +# | UC Berkeley | US | Berkeley | CA | https://bjc.berkeley.edu | # Given I am on the BJC home page # Given I have an admin email # And I follow "Log In" @@ -287,8 +287,8 @@ Feature: basic admin functionality # Scenario: Importing with new schools model fields works # Given the following schools exist: -# | name | city | state | website | -# | UC Berkeley | Berkeley | CA | https://bjc.berkeley.edu | +# | name | country | city | state | website | +# | UC Berkeley | US | Berkeley | CA | https://bjc.berkeley.edu | # Given I am on the BJC home page # Given I have an admin email # And I follow "Log In" diff --git a/features/school_form_submission.feature b/features/school_form_submission.feature index 11371a11..72f25db6 100644 --- a/features/school_form_submission.feature +++ b/features/school_form_submission.feature @@ -5,9 +5,9 @@ Feature: view schools Scenario: Viewing the schools page should show the all current schools Given the following schools exist: - | name | city | state | website | - | UC Irvine | Irvine | CA | https://www.uci.edu | - | UC Scam Diego | La Jolla | CA | https://www.ucsd.edu | + | name | country | city | state | website | + | UC Irvine | US | Irvine | CA | https://www.uci.edu | + | UC Scam Diego | US | La Jolla | CA | https://www.ucsd.edu | And the following teachers exist: | first_name | last_name | admin | email | school | | Admin | User | true | testadminuser@berkeley.edu | UC Berkeley | diff --git a/features/teacher.feature b/features/teacher.feature index 2e89c0ee..d4ef8a64 100644 --- a/features/teacher.feature +++ b/features/teacher.feature @@ -23,9 +23,9 @@ Scenario: Logging in as a teacher Scenario: Logging in as a teacher with Google account should be able to edit their info Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | - | Cupertino High School | Cupertino | CA | https://chs.fuhsd.org | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | + | Cupertino High School | US | Cupertino | CA | https://chs.fuhsd.org | Given the following teachers exist: | first_name | last_name | admin | email | school | | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | @@ -48,8 +48,8 @@ Scenario: Logging in as a teacher with Google account should be able to edit the Scenario: Logging in as a teacher with Microsoft account should be able to edit their info Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | school | | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | @@ -62,8 +62,8 @@ Scenario: Logging in as a teacher with Microsoft account should be able to edit Scenario: Logging in as a teacher with Snap account should be able to edit their info Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | school | | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | @@ -76,8 +76,8 @@ Scenario: Logging in as a teacher with Snap account should be able to edit their Scenario: Logging in as a teacher with Clever account should be able to edit their info Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | school | | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | @@ -90,8 +90,8 @@ Scenario: Logging in as a teacher with Snap account should be able to edit their Scenario: Logged in teacher with Not_Reviewed application status can update their info Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | school | snap | | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | alonzo | @@ -106,6 +106,7 @@ Scenario: Logged in teacher with Not_Reviewed application status can update thei And I set my education level target as "High School" And I fill in the school name selectize box with "Cupertino High School" and choose to add a new school And I fill in the following: + | Country | US | | City | Cupertino | | State | CA | | School Website | https://chs.fuhsd.org | @@ -118,8 +119,8 @@ Scenario: Logged in teacher with Not_Reviewed application status can update thei # TODO: Should this test updating to a new school? Scenario: Logged in teacher with not_reviewed status cannot change Snap from new form path Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | school | snap | | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | alonzo | @@ -143,8 +144,8 @@ Scenario: Logged in teacher with Not_Reviewed application status can update thei Scenario: Logged in teacher can only edit their own information Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | | Joseph | Mamoa | false | testteacher@berkeley.edu | @@ -158,8 +159,8 @@ Scenario: Logged in teacher can only edit their own information Scenario: Logging in as a teacher with not_reviewed status should see "Update" instead of "Submit" when editing info Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | | Joseph | Mamoa | false | testteacher@berkeley.edu | @@ -172,8 +173,8 @@ Scenario: Logging in as a teacher with not_reviewed status should see "Update" i Scenario: Frontend should not allow Teacher to edit their email Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | snap | | Jane | Austin | false | testteacher@berkeley.edu | Jane | @@ -190,8 +191,8 @@ Scenario: Frontend should not allow Teacher to edit their email Scenario: Validated teacher should see resend button Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | snap | application_status | | Jane | Austin | false | testteacher@berkeley.edu | Jane | validated | @@ -204,8 +205,8 @@ Scenario: Validated teacher should see resend button Scenario: teacher with not_reviewed status should not see resend button Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | snap | application_status | | Jane | Austin | false | testteacher@berkeley.edu | Jane | Not Reviewed | @@ -218,8 +219,8 @@ Scenario: teacher with not_reviewed status should not see resend button Scenario: Denied teacher should not see resend button Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | snap | application_status | | Jane | Austin | false | testteacher@berkeley.edu | Jane | denied | @@ -232,8 +233,8 @@ Scenario: Denied teacher should not see resend button Scenario: Denied teacher cannot edit their information Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | snap | application_status | more_info | | Jane | Austin | false | testteacher@berkeley.edu | Jane | denied | Original Information | @@ -248,8 +249,8 @@ Scenario: Denied teacher cannot edit their information Scenario: Validated teacher should not see Tags or NCES ID Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | snap | application_status | | Jane | Austin | false | testteacher@berkeley.edu | Jane | validated | @@ -263,8 +264,8 @@ Scenario: Validated teacher should not see Tags or NCES ID Scenario: Teacher with not_reviewed status should not see Tags or NCES ID Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | snap | application_status | | Jane | Austin | false | testteacher@berkeley.edu | Jane | Not Reviewed | @@ -278,8 +279,8 @@ Scenario: Teacher with not_reviewed status should not see Tags or NCES ID Scenario: Denied teacher should not see Tags or NCES ID Given the following schools exist: - | name | city | state | website | - | UC Berkeley | Berkeley | CA | https://www.berkeley.edu | + | name | country | city | state | website | + | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | Given the following teachers exist: | first_name | last_name | admin | email | snap | application_status | | Jane | Austin | false | testteacher@berkeley.edu | Jane | denied | diff --git a/spec/controllers/schools_controller_spec.rb b/spec/controllers/schools_controller_spec.rb index dd051c56..ee826722 100644 --- a/spec/controllers/schools_controller_spec.rb +++ b/spec/controllers/schools_controller_spec.rb @@ -43,6 +43,7 @@ school: { name: @create_school_name, city: "Berkeley", + country: "US", state: "CA", website: "www.berkeley.edu", school_type: "public", @@ -61,6 +62,7 @@ school: { name: @create_school_name, # missing city + country: "US", state: "CA", website: "www.berkeley.edu", school_type: "public", @@ -75,6 +77,7 @@ post schools_path, params: { school: { name: @create_school_name, + country: "US", city: "Berkeley", state: "CA", # missing website @@ -90,6 +93,7 @@ post schools_path, params: { school: { # missing name + country: "US", city: "Berkeley", state: "CA", website: "www.berkeley.edu", @@ -109,6 +113,7 @@ post schools_path, params: { school: { name: @create_school_name, + country: "US", city: "Berkeley", state: "DISTRESS", website: "www.berkeley.edu", @@ -124,6 +129,7 @@ post schools_path, params: { school: { name: @create_school_name, + country: "US", city: "Berkeley", state: "CA", website: "wwwberkeleyedu", @@ -140,6 +146,7 @@ expect { post schools_path, params: { school: { name: @create_school_name, + country: "US", city: "Berkeley", state: "CA", website: "www.berkeley.edu", @@ -157,6 +164,7 @@ params: { school: { name: @create_school_name, + country: "US", city: "Berkeley", state: "CA", website: "www.berkeley.edu", @@ -177,6 +185,7 @@ post schools_path, params: { school: { name: @create_school_name, + country: "US", city: "Berkeley", state: "CA", website: "www.berkeley.edu", @@ -189,6 +198,7 @@ post schools_path, params: { school: { name: @create_school_name, + country: "US", city: "Berkeley", state: "CA", website: "www.berkeley.edu", diff --git a/spec/controllers/teachers_signup_spec.rb b/spec/controllers/teachers_signup_spec.rb index 3385bc29..b3f6ca1b 100644 --- a/spec/controllers/teachers_signup_spec.rb +++ b/spec/controllers/teachers_signup_spec.rb @@ -50,6 +50,7 @@ post :create, params: { school: { name: "valid_example", + country: "US", city: "Berkeley", state: "CA", website: "valid_example.com", From 43b0a3dadd597a8901cbd4d14bb699effefabf4f Mon Sep 17 00:00:00 2001 From: razztech Date: Sun, 10 Mar 2024 22:07:03 -0700 Subject: [PATCH 04/60] Update tests to use country dropdown --- features/form_submission.feature | 30 ++++++++++++++++--------- features/school_form_submission.feature | 3 ++- features/step_definitions/web_steps.rb | 16 +++++++++++-- features/teacher.feature | 19 ++++++++-------- spec/factories/factories.rb | 1 + 5 files changed, 47 insertions(+), 22 deletions(-) diff --git a/features/form_submission.feature b/features/form_submission.feature index 639b8ea5..b9b8bb9e 100644 --- a/features/form_submission.feature +++ b/features/form_submission.feature @@ -19,8 +19,9 @@ Scenario: Correctly filling out and successful form submission And I fill in "More Information" with "I am after school volunteer" And I enter my "Personal or Course Website" as "https://chs.fuhsd.org" And I fill in the school name selectize box with "Cupertino High School" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Cupertino" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "https://chs.fuhsd.org" And I select "University" from "Grade Level" And I select "Public" from "School Type" @@ -33,8 +34,9 @@ Scenario: Not Correctly filling out and unsuccessful form submission And I enter my "Last Name" as "Zhu" And I set my status as "I am teaching BJC as an AP CS Principles course." And I fill in the school name selectize box with "Cupertino High School" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Cupertino" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "chs.fuhsd.org" And I select "University" from "Grade Level" And I select "Public" from "School Type" @@ -53,8 +55,9 @@ Scenario: Missing the compulsory more info field And I set my education level target as "High School" And I enter my "Personal or Course Website" as "https://chs.fuhsd.org" And I fill in the school name selectize box with "Cupertino High School" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Cupertino" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "https://chs.fuhsd.org" And I select "University" from "Grade Level" And I select "Public" from "School Type" @@ -72,8 +75,9 @@ Scenario: Websites validation - two invalid websites And I set my education level target as "High School" And I fill in "More Information" with "I am teaching BJC" And I fill in the school name selectize box with "Stafford High School" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Palo Alto" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "stafford" And I select "University" from "Grade Level" And I select "Public" from "School Type" @@ -90,8 +94,9 @@ Scenario: Websites validation - one invalid website And I set my education level target as "High School" And I fill in "More Information" with "I am teaching BJC" And I fill in the school name selectize box with "Stafford High School" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Palo Alto" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "stafford" And I select "University" from "Grade Level" And I select "Public" from "School Type" @@ -108,8 +113,9 @@ Scenario: Websites validation - one valid website And I set my education level target as "High School" And I fill in "More Information" with "I am teaching BJC" And I fill in the school name selectize box with "Stafford High School" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Palo Alto" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "https://stafford.edu" And I select "University" from "Grade Level" And I select "Public" from "School Type" @@ -128,8 +134,9 @@ Scenario: Filling out new form with existing email should not update information And I set my education level target as "High School" And I fill in "More Information" with "I am teaching BJC" And I fill in the school name selectize box with "Cupertino High School" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Cupertino" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "https://chs.fuhsd.org" And I select "University" from "Grade Level" And I select "Public" from "School Type" @@ -151,8 +158,9 @@ Scenario: Filling out new form with existing Snap should not create new teacher And I fill in "More Information" with "I am teaching BJC" And I set my education level target as "High School" And I fill in the school name selectize box with "Cupertino High School" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Cupertino" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "https://chs.fuhsd.org" And I select "University" from "Grade Level" And I select "Public" from "School Type" @@ -172,8 +180,9 @@ Scenario: Filling out form should have the correct information in a Teacher And I fill in "More Information" with "I am a TEALS program employee!" And I set my education level target as "High School" And I fill in the school name selectize box with "Castro Valley High School" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Castro Valley" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "https://cvhs.cv.k12.ca.us" And I select "University" from "Grade Level" And I select "Public" from "School Type" @@ -200,8 +209,9 @@ Scenario: Filling out form should have the correct information in a Teacher And I fill in "More Information" with "Rebecca" And I set my education level target as "High School" And I fill in the school name selectize box with "Castro Valley High School" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Castro Valley" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "https://cvhs.cv.k12.ca.us" And I select "University" from "Grade Level" And I select "Public" from "School Type" diff --git a/features/school_form_submission.feature b/features/school_form_submission.feature index 72f25db6..bbe4249c 100644 --- a/features/school_form_submission.feature +++ b/features/school_form_submission.feature @@ -47,8 +47,9 @@ Scenario: Admins can create new schools Then I can log in with Google When I go to the new schools page And I fill in the school name selectize box with "New UC Berkeley" and choose to add a new school + And I select "United States" from "Country" And I fill in "City" with "Berkeley" - And I select "CA" from "State" + And I select "CA" from "state_select" And I fill in "School Website" with "https://www.berkeley.edu/" And I select "University" from "Grade Level" And I select "Public" from "School Type" diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index 6f216b75..8056eaaa 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -98,7 +98,19 @@ def with_scope(locator, &block) end When(/^(?:|I )select "([^"]*)" from "([^"]*)"$/) do |value, field| - select(value, from: field) + # Find the select element + select_box = find_field(field) + + # Find all options with the specified value + options = select_box.all('option', text: value) + + if options.length > 1 + # If there are multiple options with the same value, choose the first one + options.first.select_option + else + # If there's only one option or no option, use the default select method + select(value, from: field) + end end When(/^(?:|I )check "([^"]*)"$/) do |field| @@ -256,4 +268,4 @@ def with_scope(locator, &block) with_scope(selector) do field_labeled(field).find(:xpath, ".//option[@selected = 'selected'][text() = '#{value}']").should be_present end -end +end \ No newline at end of file diff --git a/features/teacher.feature b/features/teacher.feature index d4ef8a64..c9c1ee2d 100644 --- a/features/teacher.feature +++ b/features/teacher.feature @@ -39,8 +39,9 @@ Scenario: Logging in as a teacher with Google account should be able to edit the And I set my status as "I am a TEALS volunteer, and am teaching the BJC curriculum." And I set my education level target as "College" And I fill in the school name selectize box with "Cupertino High School, Cupertino, CA" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Cupertino" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "https://chs.fuhsd.org" And I press "Update" Then I see a confirmation "Successfully updated your information" @@ -105,13 +106,12 @@ Scenario: Logged in teacher with Not_Reviewed application status can update thei And I set my status as "I am teaching BJC as an AP CS Principles course." And I set my education level target as "High School" And I fill in the school name selectize box with "Cupertino High School" and choose to add a new school - And I fill in the following: - | Country | US | - | City | Cupertino | - | State | CA | - | School Website | https://chs.fuhsd.org | - | Grade Level | High School | - | School Type | Public | + And I select "United States" from "Country" + And I enter my "City" as "Cupertino" + And I select "CA" from "state_select" + And I enter my "School Website" as "https://chs.fuhsd.org" + And I select "High School" from "Grade Level" + And I select "Public" from "School Type" And I press "Update" Then I see a confirmation "Successfully updated your information" And I am on the edit page for Joe Mamoa @@ -135,8 +135,9 @@ Scenario: Logged in teacher with Not_Reviewed application status can update thei And I set my status as "I am teaching BJC as an AP CS Principles course." And I set my education level target as "High School" And I fill in the school name selectize box with "Cupertino High School" and choose to add a new school + And I select "United States" from "Country" And I enter my "City" as "Cupertino" - And I select "CA" from "State" + And I select "CA" from "state_select" And I enter my "School Website" as "https://chs.fuhsd.org" And I press "Update" And I should see "Edit Joe Mamoa" diff --git a/spec/factories/factories.rb b/spec/factories/factories.rb index 9be9fd1b..a0aa40b2 100644 --- a/spec/factories/factories.rb +++ b/spec/factories/factories.rb @@ -4,6 +4,7 @@ FactoryBot.define do factory :school do name { "Basic School" } + country { "US" } city { "Berkeley" } state { "CA" } grade_level { 4 } From f3cd0cd2c02513b4c771f5171075d49aa56bc580 Mon Sep 17 00:00:00 2001 From: razztech Date: Mon, 11 Mar 2024 15:54:21 -0700 Subject: [PATCH 05/60] All tests are passing --- app/views/schools/_form.html.erb | 5 +---- app/views/schools/index.html.erb | 1 + app/views/schools/show.html.erb | 14 ++++++++++---- app/views/teachers/_table_headers.erb | 1 + app/views/teachers/_teacher.erb | 3 +++ app/views/teachers/_teacher_info.html.erb | 6 ++++++ app/views/teachers/index.html.erb | 1 + features/form_submission.feature | 20 ++++++++++---------- features/school_form_submission.feature | 2 +- features/step_definitions/web_steps.rb | 18 +++++++++++++----- features/teacher.feature | 6 +++--- 11 files changed, 50 insertions(+), 27 deletions(-) diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb index b44d09be..c15b959d 100644 --- a/app/views/schools/_form.html.erb +++ b/app/views/schools/_form.html.erb @@ -12,7 +12,7 @@ <%= f.country_select( :country, { priority_countries: ['United States'], include_blank: "Select an option" }, - { class: 'form-control', required: true, id: 'school_country', format: :with_full_country_name} + { class: 'form-control', required: false, id: 'school_country', format: :with_full_country_name} ) %>
@@ -102,10 +102,8 @@ From 772f2df7c142ceccbff554d886d61dec22ba2e6d Mon Sep 17 00:00:00 2001 From: Jingchao Zhong <92573736+perryzjc@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:26:46 -0700 Subject: [PATCH 19/60] Add cucumber test for unexpected user behavior --- features/school_form_submission.feature | 19 ++++++++++++++++++- features/step_definitions/form_steps.rb | 6 ++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/features/school_form_submission.feature b/features/school_form_submission.feature index 053c7074..618aae17 100644 --- a/features/school_form_submission.feature +++ b/features/school_form_submission.feature @@ -96,4 +96,21 @@ Scenario: Admin can see international schools in the submission And I select "Public" from "School Type" And I press "Submit" And I see a confirmation "Thanks for signing up for BJC" - Then I should find a teacher with email "razztech@berkeley.edu" and school country "RO" in the database + Then I should find a teacher with email "razztech@berkeley.edu" and school country "RO" in the database + +Scenario: Attempt to create an international school with missing mandatory fields + Given "razztech@berkeley.edu" is not in the database + And I am on the BJC home page + And I enter my "First Name" as "Perry" + And I enter my "Last Name" as "Zhong" + And I enter my "School Email" as "jzhong12@berkeley.edu" + And I set my status as "I am teaching BJC as an AP CS Principles course." + And I set my education level target as "High School" + And I fill in "More Information" with "I am after school volunteer" + And I enter my "Personal or Course Website" as "https://chs.fuhsd.org" + And I fill in the school name selectize box with "Bucharest International School" and choose to add a new school + # Leaving out mandatory fields "Country", "City", and "School Website" to simulate user error + And I select "University" from "Grade Level" + And I select "Public" from "School Type" + And I press "Submit" + Then the new teacher form should not be submitted diff --git a/features/step_definitions/form_steps.rb b/features/step_definitions/form_steps.rb index 8f38bf61..567706c6 100644 --- a/features/step_definitions/form_steps.rb +++ b/features/step_definitions/form_steps.rb @@ -88,3 +88,9 @@ Then(/^"([^"]*)" click and fill option for "([^"]*)"(?: within "([^"]*)")?$/) do |value| find("#school_selectize").click.set(value) end + +Then(/^the new teacher form should not be submitted$/) do + expect(current_path).to eq(new_teacher_path) + expect(page).to have_content("Your Information") + expect(page).to have_content("Create a new School") +end From 05d989eb686f2cb323bc99e812dac78c895289ba Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati Date: Wed, 13 Mar 2024 20:20:05 -0700 Subject: [PATCH 20/60] fix glitch --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index a9927666..52b296b9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2024_03_07_225738) do +ActiveRecord::Schema.define(version: 2024_02_18_225738) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From a2ea667c7d1bffa3792626a0e99190d5dd8f461d Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati Date: Wed, 13 Mar 2024 20:20:37 -0700 Subject: [PATCH 21/60] resolve merge conflict --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 52b296b9..a9927666 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2024_02_18_225738) do +ActiveRecord::Schema.define(version: 2024_03_07_225738) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From fa1155b28740c27b7bd7d2830b5f02bd9d41ca3d Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:31:06 -0700 Subject: [PATCH 22/60] ok actually fixed merge conflict now --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index a9927666..0bab93fc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2024_03_07_225738) do +ActiveRecord::Schema.define(version: 2024_02_18_005604) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From a155d65f7fc264ba712a202f13d669417c1d021d Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:40:42 -0700 Subject: [PATCH 23/60] no choice, have to resolve conflict manually --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 0bab93fc..a9927666 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2024_02_18_005604) do +ActiveRecord::Schema.define(version: 2024_03_07_225738) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From 3f190c37483a82a97b496e2e09318d13c449507d Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Mon, 18 Mar 2024 13:58:22 -0700 Subject: [PATCH 24/60] admin update teacher now redirect to show teacher page --- app/controllers/teachers_controller.rb | 2 +- features/admin.feature | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb index 4b2954ed..8a78ca41 100644 --- a/app/controllers/teachers_controller.rb +++ b/app/controllers/teachers_controller.rb @@ -122,7 +122,7 @@ def update TeacherMailer.teacher_form_submission(@teacher).deliver_now end if is_admin? - redirect_to teachers_path, notice: "Saved #{@teacher.full_name}" + redirect_to edit_teacher_path(current_user.id), notice: "Saved #{@teacher.full_name}" return else @teacher.try_append_ip(request.remote_ip) diff --git a/features/admin.feature b/features/admin.feature index 23882731..5b5486be 100644 --- a/features/admin.feature +++ b/features/admin.feature @@ -163,7 +163,8 @@ Feature: basic admin functionality And I set my application status as "Validated" And I press "Update" Then I see a confirmation "Saved" - When I check "Validated" + When I go to the teachers page + And I check "Validated" Then I should see "Bobby John" Scenario: Deny teacher as an admin From 58abf8de7866db5f8c0954d150f256e6f0282e8d Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:18:48 -0700 Subject: [PATCH 25/60] fix javascript to make state select required --- app/views/schools/_form.html.erb | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb index 07ebc9bd..ce338301 100644 --- a/app/views/schools/_form.html.erb +++ b/app/views/schools/_form.html.erb @@ -2,33 +2,33 @@
<%= f.label :name, "School Name", class: "label-required" %> - <%= f.text_field :name, placeholder: 'UC Berkeley', class: 'form-control', + <%= f.text_field :name, placeholder: 'Name of School', class: 'form-control', required: false, id: 'school_name' %>
<%= f.label :city, class: "label-required", for: "school_city" %> - <%= f.text_field :city, placeholder: 'Berkeley', class: 'form-control', - required: false, id: 'school_city' %> + <%= f.text_field :city, placeholder: 'Name of City', class: 'form-control', + required: true, id: 'school_city' %>
<%= f.label :state, class: "label-required", for: "school_state" %> - <%= f.select :state, School::VALID_STATES, { include_blank: "State" }, { id: "state_select", class: 'form-control' } %> + <%= f.select :state, School::VALID_STATES, { include_blank: "Select a state" }, { id: "state_select", class: 'form-control' } %>
<%= f.label :state, for: "school_state" %> - <%= f.text_field :state, placeholder: "State", class: 'form-control', id: "state_textfield" %> + <%= f.text_field :state, placeholder: "Name of State", class: 'form-control', id: "state_textfield" %>
<%= f.label :country, "Country", class: "label-required", for: "school_country" %> <%= f.country_select( :country, - { priority_countries: ['United States'] }, - { class: 'form-control', required: false, id: 'school_country', format: :with_full_country_name, selected: 'United States'} + { priority_countries: ['United States'], include_blank: "Select a country" }, + { class: 'form-control', required: true, id: 'school_country', format: :with_full_country_name, selected: 'United States'} ) %>
@@ -110,14 +110,21 @@ function handleCountryChange() { if (countrySelected.val() === 'US') { - stateSelectContainer.show().attr('required', true); + stateSelectContainer.show(); + stateSelect.attr('required', '') //make state select required stateTextfieldContainer.hide(); stateTextfield.removeAttr('name'); stateSelect.attr('name', 'school[state]'); + // Delay the call to reportValidity + setTimeout(function() { + stateSelectContainer.get(0).reportValidity(); + }, 100); // Adjust the delay time as needed } else { - stateTextfieldContainer.show().attr('required', false); + stateTextfieldContainer.show(); + stateSelect.removeAttr('required') stateSelectContainer.hide(); + stateSelect.removeAttr('name'); stateTextfield.attr('name', 'school[state]'); From 7dd74526ecaf28c7fe4aee7ae7d34caff6fa82f7 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:59:54 -0700 Subject: [PATCH 26/60] standardize all form submission backend validation to have format 'An error occured: [error messages]' --- app/controllers/email_templates_controller.rb | 4 ++-- app/controllers/pages_controller.rb | 4 ++-- app/controllers/schools_controller.rb | 6 ++++-- app/controllers/teachers_controller.rb | 11 +++++++---- app/models/email_template.rb | 4 ++-- app/views/schools/_form.html.erb | 4 ++-- features/email_template.feature | 6 +++--- 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/controllers/email_templates_controller.rb b/app/controllers/email_templates_controller.rb index 0ee2bcc1..8e9a3a1f 100644 --- a/app/controllers/email_templates_controller.rb +++ b/app/controllers/email_templates_controller.rb @@ -18,7 +18,7 @@ def update flash[:success] = "Updated #{@email_template.title} template successfully." redirect_to email_templates_path else - flash.now[:alert] = "Failed to save #{@email_template.title} template: #{@email_template.errors.full_messages.join(", ")}" + flash.now[:alert] = "An error occured: #{@email_template.errors.full_messages.join(', ')}" render "edit" end end @@ -36,7 +36,7 @@ def create flash[:success] = "Created #{@email_template.title} successfully." redirect_to email_templates_path else - flash.now[:alert] = "Failed to submit information: #{@email_template.errors.full_messages.join(", ")}" + flash[:alert] = "An error occurred: #{@school.errors.full_messages.join(', ')}" render "new" end end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 0a913198..e82d6109 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -25,7 +25,7 @@ def create flash[:success] = "Created #{@page.title} page successfully." redirect_to action: "show", url_slug: @page.url_slug else - flash.now[:alert] = "An error occurred! #{@page.errors.full_messages}" + flash.now[:alert] = "An error occurred: #{@page.errors.full_messages.join(", ")}" render "edit" end end @@ -58,7 +58,7 @@ def update flash[:success] = "Updated #{@page.title} page successfully." redirect_to pages_path else - flash.now[:alert] = "An error occurred! #{@page.errors.full_messages.to_sentence}" + flash.now[:alert] = "An error occurred: #{@page.errors.full_messages.join(', ')}" render "edit" end end diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index 0ea311f1..9a20546b 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -44,11 +44,13 @@ def edit def update @school = School.find(params[:id]) @school.assign_attributes(school_params) + debugger if @school.save - flash[:success] = "Update #{@school.name} successfully." + flash[:success] = "Updated #{@school.name} successfully." redirect_to school_path(@school) else - render "edit", alert: "Failed to submit information :(" + flash[:alert] = "An error occurred: #{@school.errors.full_messages.join(', ')}" + render "edit" end end diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb index 8a78ca41..b82f0c3c 100644 --- a/app/controllers/teachers_controller.rb +++ b/app/controllers/teachers_controller.rb @@ -65,7 +65,7 @@ def create if @school.new_record? @school = School.new(school_params) unless @school.save - flash[:alert] = "An error occurred! #{@school.errors.full_messages}" + flash[:alert] = "An error occurred! #{@school.errors.full_messages.join(', ')}" render "new" && return end end @@ -81,7 +81,7 @@ def create TeacherMailer.teacher_form_submission(@teacher).deliver_now redirect_to root_path else - redirect_to new_teacher_path, alert: "An error occurred while trying to save. #{@teacher.errors.full_messages}" + redirect_to new_teacher_path, alert: "An error occurred: #{@teacher.errors.full_messages.join(', ')}" end end @@ -100,7 +100,10 @@ def update @teacher.school = @school else @school.update(school_params) if school_params - @school.save! + unless @school.save + flash[:alert] = "An error occurred: #{@school.errors.full_messages.join(', ')}" + render "new" && return + end @teacher.school = @school end send_email_if_application_status_changed_and_email_resend_enabled @@ -114,7 +117,7 @@ def update end if !@teacher.save redirect_to edit_teacher_path(current_user.id), - alert: "Failed to update data. #{@teacher.errors.full_messages.to_sentence}" + alert: "An error occured: #{@teacher.errors.full_messages.join(', ')}" return end if !@teacher.validated? && !current_user.admin? diff --git a/app/models/email_template.rb b/app/models/email_template.rb index f8d516c2..a3fb339e 100644 --- a/app/models/email_template.rb +++ b/app/models/email_template.rb @@ -22,8 +22,8 @@ class EmailTemplate < ApplicationRecord validates :title, inclusion: TeacherMailer.instance_methods(false).map { |method| method.to_s.titlecase }, if: -> { self.required? } - validates :body, presence: { message: "cannot be blank" } - validates :to, presence: { message: "cannot be blank" } + validates :body, presence: true + validates :to, presence: true before_destroy :prevent_deleting_required_emails diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb index ce338301..b05e9bad 100644 --- a/app/views/schools/_form.html.erb +++ b/app/views/schools/_form.html.erb @@ -10,7 +10,7 @@
<%= f.label :city, class: "label-required", for: "school_city" %> <%= f.text_field :city, placeholder: 'Name of City', class: 'form-control', - required: true, id: 'school_city' %> + required: false, id: 'school_city' %>
@@ -28,7 +28,7 @@ <%= f.country_select( :country, { priority_countries: ['United States'], include_blank: "Select a country" }, - { class: 'form-control', required: true, id: 'school_country', format: :with_full_country_name, selected: 'United States'} + { class: 'form-control', required: false, id: 'school_country', format: :with_full_country_name, selected: 'United States'} ) %>
diff --git a/features/email_template.feature b/features/email_template.feature index 36e96d97..f192c57c 100644 --- a/features/email_template.feature +++ b/features/email_template.feature @@ -38,7 +38,7 @@ Scenario: Creating new email template with blank fields displays flash error Given I am on the email templates index And I press "New Email Templates" When I press "Submit" - Then I should see "Failed to submit information: Body cannot be blank, To cannot be blank" + Then I should see "An error occured: Body can't be blank, To can't be blank" Scenario: Creating and deleting new email template with valid fields succeeds Given I am on the email templates index @@ -59,7 +59,7 @@ Scenario: Editing email template to have blank body or to field displays flash e And I follow "Welcome Email" And I fill in "email_template_to" with "" And I press "Submit" - Then I should see "Failed to save Welcome Email template: To cannot be blank" + Then I should see "An error occured: To can't be blank" When I fill in TinyMCE email form with "" And I press "Submit" - Then I should see "Failed to save Welcome Email template: Body cannot be blank" + Then I should see "An error occured: Body can't be blank" From 824423251d6ace9c9b5052608784ff14403b6d70 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Wed, 20 Mar 2024 17:01:05 -0700 Subject: [PATCH 27/60] missed one --- app/controllers/schools_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index 9a20546b..127fb8ca 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -27,7 +27,7 @@ def create flash[:success] = "Created #{@school.name} successfully." redirect_to schools_path else - flash[:alert] = "Failed to submit information :(" + flash[:alert] = "An error occurred: #{@school.errors.full_messages.join(', ')}" render "new" end end From 63b3a91ec9b8fa2a7cdbda90ab39384b772c75a1 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Wed, 20 Mar 2024 17:56:59 -0700 Subject: [PATCH 28/60] changed tests to reflect more informative error messages --- app/models/school.rb | 2 +- spec/controllers/schools_controller_spec.rb | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/models/school.rb b/app/models/school.rb index 8bb950c2..f33f4c8b 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -29,7 +29,7 @@ class School < ApplicationRecord VALID_STATES = [ "AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"].freeze validates :name, :city, :website, :country, presence: true - validates :country, inclusion: { in: ISO3166::Country.all.map(&:alpha2), message: "%{value} is not a valid country" }, presence: true + validates :country, inclusion: { in: ISO3166::Country.all.map(&:alpha2), message: "%{value} is not a valid country" } validates :state, presence: true, if: -> { country == "US" } validates :state, inclusion: { in: VALID_STATES }, if: -> { country == "US" } validates_format_of :website, with: /.+\..+/, on: :create diff --git a/spec/controllers/schools_controller_spec.rb b/spec/controllers/schools_controller_spec.rb index ee826722..8de95c78 100644 --- a/spec/controllers/schools_controller_spec.rb +++ b/spec/controllers/schools_controller_spec.rb @@ -9,7 +9,7 @@ before(:all) do @create_school_name = "University of California, Berkeley" - @fail_flash_alert = /Failed to submit information :\(/ + @fail_flash_error_text = "An error occurred: " @success_flash_alert = Regexp.new("Created #{@create_school_name} successfully.") end @@ -72,7 +72,8 @@ } } expect(School.find_by(name: @create_school_name)).to be_nil - expect(flash[:alert]).to match @fail_flash_alert + error = @fail_flash_error_text + "City can't be blank" + expect(flash[:alert]).to match error post schools_path, params: { school: { @@ -88,7 +89,8 @@ } } expect(School.find_by(name: @create_school_name)).to be_nil - expect(flash[:alert]).to match @fail_flash_alert + error = @fail_flash_error_text + "Website can't be blank, Website is invalid" + expect(flash[:alert]).to match error post schools_path, params: { school: { @@ -104,7 +106,8 @@ } } expect(School.find_by(name: @create_school_name)).to be_nil - expect(@fail_flash_alert).to match flash[:alert] + error = @fail_flash_error_text + "Name can't be blank" + expect(flash[:alert]).to match error end it "requires proper inputs for fields" do @@ -124,7 +127,8 @@ } } expect(School.find_by(name: @create_school_name)).to be_nil - expect(@fail_flash_alert).to match flash[:alert] + error = @fail_flash_error_text + "State is not included in the list" + expect(flash[:alert]).to match error post schools_path, params: { school: { @@ -140,7 +144,8 @@ } } expect(School.find_by(name: @create_school_name)).to be_nil - expect(@fail_flash_alert).to match flash[:alert] + error = @fail_flash_error_text + "Website is invalid" + expect(flash[:alert]).to match error # Incorrect school type expect { post schools_path, params: { From 1bab7b51e81c751ebf824850011333ac75190266 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Wed, 20 Mar 2024 18:05:03 -0700 Subject: [PATCH 29/60] added two more tests --- spec/controllers/schools_controller_spec.rb | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/spec/controllers/schools_controller_spec.rb b/spec/controllers/schools_controller_spec.rb index 8de95c78..ed3f0f33 100644 --- a/spec/controllers/schools_controller_spec.rb +++ b/spec/controllers/schools_controller_spec.rb @@ -184,6 +184,44 @@ expect(School.find_by(name: @create_school_name)).to be_nil end + it "does not allow invalid country" do + post schools_path, params: { + school: { + name: @create_school_name, + city: "Test City", + country: "XX", #invalid country + state: "CA", + website: "www.berkeley.edu", + school_type: "public", + grade_level: "university", + tags: [], + nces_id: 123456789000 + } + } + expect(School.find_by(name: @create_school_name)).to be_nil + error = @fail_flash_error_text + "Country XX is not a valid country" + expect(flash[:alert]).to match error + + end + + it "allows any state when country is not US" do + post schools_path, params: { + school: { + name: @create_school_name, + city: "Ottawa", + country: "CA", #Canada + state: "Ontario", + website: "www.berkeley.edu", + school_type: "public", + grade_level: "university", + tags: [], + nces_id: 123456789000 + } + } + expect(School.find_by(name: @create_school_name)).not_to be_nil + expect(@success_flash_alert).to match flash[:success] + end + it "does not create duplicate schools in the same city" do expect(School.where(name: @create_school_name).count).to eq 0 From 4f4d828b640ee2a83956efebbb67d0efe05ac2dd Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Wed, 20 Mar 2024 18:08:44 -0700 Subject: [PATCH 30/60] rubocop fix --- spec/controllers/schools_controller_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/controllers/schools_controller_spec.rb b/spec/controllers/schools_controller_spec.rb index ed3f0f33..791c5331 100644 --- a/spec/controllers/schools_controller_spec.rb +++ b/spec/controllers/schools_controller_spec.rb @@ -189,7 +189,7 @@ school: { name: @create_school_name, city: "Test City", - country: "XX", #invalid country + country: "XX", # invalid country state: "CA", website: "www.berkeley.edu", school_type: "public", @@ -201,7 +201,6 @@ expect(School.find_by(name: @create_school_name)).to be_nil error = @fail_flash_error_text + "Country XX is not a valid country" expect(flash[:alert]).to match error - end it "allows any state when country is not US" do @@ -209,7 +208,7 @@ school: { name: @create_school_name, city: "Ottawa", - country: "CA", #Canada + country: "CA", # Canada state: "Ontario", website: "www.berkeley.edu", school_type: "public", From f97820498840e2fe43d974b7f625003fe78f20c3 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Thu, 21 Mar 2024 10:44:13 -0700 Subject: [PATCH 31/60] fixed cucumber test bugs --- app/controllers/email_templates_controller.rb | 4 ++-- app/controllers/teachers_controller.rb | 2 +- app/views/schools/_form.html.erb | 5 +---- features/email_template.feature | 6 +++--- features/school_form_submission.feature | 4 ++-- features/step_definitions/form_steps.rb | 4 ++++ 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/controllers/email_templates_controller.rb b/app/controllers/email_templates_controller.rb index 8e9a3a1f..8fb28361 100644 --- a/app/controllers/email_templates_controller.rb +++ b/app/controllers/email_templates_controller.rb @@ -18,7 +18,7 @@ def update flash[:success] = "Updated #{@email_template.title} template successfully." redirect_to email_templates_path else - flash.now[:alert] = "An error occured: #{@email_template.errors.full_messages.join(', ')}" + flash.now[:alert] = "An error occurred: #{@email_template.errors.full_messages.join(', ')}" render "edit" end end @@ -36,7 +36,7 @@ def create flash[:success] = "Created #{@email_template.title} successfully." redirect_to email_templates_path else - flash[:alert] = "An error occurred: #{@school.errors.full_messages.join(', ')}" + flash[:alert] = "An error occurred: #{@email_template.errors.full_messages.join(', ')}" render "new" end end diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb index b82f0c3c..fd167eab 100644 --- a/app/controllers/teachers_controller.rb +++ b/app/controllers/teachers_controller.rb @@ -117,7 +117,7 @@ def update end if !@teacher.save redirect_to edit_teacher_path(current_user.id), - alert: "An error occured: #{@teacher.errors.full_messages.join(', ')}" + alert: "An error occurred: #{@teacher.errors.full_messages.join(', ')}" return end if !@teacher.validated? && !current_user.admin? diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb index b05e9bad..b0b3a37e 100644 --- a/app/views/schools/_form.html.erb +++ b/app/views/schools/_form.html.erb @@ -116,10 +116,7 @@ stateTextfield.removeAttr('name'); stateSelect.attr('name', 'school[state]'); - // Delay the call to reportValidity - setTimeout(function() { - stateSelectContainer.get(0).reportValidity(); - }, 100); // Adjust the delay time as needed + } else { stateTextfieldContainer.show(); stateSelect.removeAttr('required') diff --git a/features/email_template.feature b/features/email_template.feature index f192c57c..e527204c 100644 --- a/features/email_template.feature +++ b/features/email_template.feature @@ -38,7 +38,7 @@ Scenario: Creating new email template with blank fields displays flash error Given I am on the email templates index And I press "New Email Templates" When I press "Submit" - Then I should see "An error occured: Body can't be blank, To can't be blank" + Then I should see "An error occurred: Body can't be blank, To can't be blank" Scenario: Creating and deleting new email template with valid fields succeeds Given I am on the email templates index @@ -59,7 +59,7 @@ Scenario: Editing email template to have blank body or to field displays flash e And I follow "Welcome Email" And I fill in "email_template_to" with "" And I press "Submit" - Then I should see "An error occured: To can't be blank" + Then I should see "An error occurred: To can't be blank" When I fill in TinyMCE email form with "" And I press "Submit" - Then I should see "An error occured: Body can't be blank" + Then I should see "An error occurred: Body can't be blank" diff --git a/features/school_form_submission.feature b/features/school_form_submission.feature index 618aae17..0710f69a 100644 --- a/features/school_form_submission.feature +++ b/features/school_form_submission.feature @@ -70,7 +70,7 @@ Scenario: User can create an international school And I fill in the school name selectize box with "Bucharest International School" and choose to add a new school And I select "Romania" from "Country" And I enter my "City" as "Bucharest" - And I enter my "State" as "Bucharest, Sector 1" + And I fill in state with "Bucharest, Sector 1" And I enter my "School Website" as "https://chs.fuhsd.org" And I select "University" from "Grade Level" And I select "Public" from "School Type" @@ -90,7 +90,7 @@ Scenario: Admin can see international schools in the submission And I fill in the school name selectize box with "Bucharest International School" and choose to add a new school And I select "Romania" from "Country" And I enter my "City" as "Bucharest" - And I enter my "State" as "Bucharest, Sector 1" + And I fill in state with "Bucharest, Sector 1" And I enter my "School Website" as "https://chs.fuhsd.org" And I select "University" from "Grade Level" And I select "Public" from "School Type" diff --git a/features/step_definitions/form_steps.rb b/features/step_definitions/form_steps.rb index 567706c6..ec901e82 100644 --- a/features/step_definitions/form_steps.rb +++ b/features/step_definitions/form_steps.rb @@ -89,6 +89,10 @@ find("#school_selectize").click.set(value) end +When(/^(?:|I )fill in state with "([^"]*)"$/) do |text| + fill_in("state_textfield", with: text) +end + Then(/^the new teacher form should not be submitted$/) do expect(current_path).to eq(new_teacher_path) expect(page).to have_content("Your Information") From ef2d3c4c019d3cb51b3fd94d8dc9dd8bd3d4d7e1 Mon Sep 17 00:00:00 2001 From: razztech <41014369+razztech@users.noreply.github.com> Date: Mon, 8 Apr 2024 11:53:58 -0700 Subject: [PATCH 32/60] Removed empty lines --- app/views/teachers/_form.html.erb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/views/teachers/_form.html.erb b/app/views/teachers/_form.html.erb index 8f16299c..5397d0ee 100644 --- a/app/views/teachers/_form.html.erb +++ b/app/views/teachers/_form.html.erb @@ -186,7 +186,4 @@ status ONLY IF the person viewing this page is an admin. %> } } - - - From ff543d6be3c86d62becbdf5b79e5fcc879b6be55 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:30:39 -0700 Subject: [PATCH 33/60] Update email_template.feature Fix cucumber test -- note that error messages have been standardized in the application to have the common format "An error occured: ..." --- features/email_template.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/email_template.feature b/features/email_template.feature index d0d8e008..28a3c89a 100644 --- a/features/email_template.feature +++ b/features/email_template.feature @@ -62,7 +62,7 @@ Scenario: Editing email template to have blank body or to field displays flash e Then I should see "An error occurred: To can't be blank" When I fill in TinyMCE email form with "" And I press "Submit" - Then I should see "Failed to save Welcome Email template: Body cannot be blank" + Then I should see "An error occured: Body can't be blank" Scenario: Updating email template with valid parameters succeeds Given I am on the email templates index From 2e1c1d15fa64d488253d548b89cbe5224ea20551 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:45:05 -0700 Subject: [PATCH 34/60] Update schools_controller.rb remove debugger --- app/controllers/schools_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index 127fb8ca..500f6ca0 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -44,7 +44,6 @@ def edit def update @school = School.find(params[:id]) @school.assign_attributes(school_params) - debugger if @school.save flash[:success] = "Updated #{@school.name} successfully." redirect_to school_path(@school) From d58eda9cea0429e02df5b595fbfb2078b201bc00 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:45:42 -0700 Subject: [PATCH 35/60] fix cucumber tests --- app/controllers/email_templates_controller.rb | 2 +- app/controllers/teachers_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/email_templates_controller.rb b/app/controllers/email_templates_controller.rb index 0ee2bcc1..85c02069 100644 --- a/app/controllers/email_templates_controller.rb +++ b/app/controllers/email_templates_controller.rb @@ -36,7 +36,7 @@ def create flash[:success] = "Created #{@email_template.title} successfully." redirect_to email_templates_path else - flash.now[:alert] = "Failed to submit information: #{@email_template.errors.full_messages.join(", ")}" + flash.now[:alert] = "An error occurred: #{@email_template.errors.full_messages.join(", ")}" render "new" end end diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb index fd167eab..9c923f17 100644 --- a/app/controllers/teachers_controller.rb +++ b/app/controllers/teachers_controller.rb @@ -65,7 +65,7 @@ def create if @school.new_record? @school = School.new(school_params) unless @school.save - flash[:alert] = "An error occurred! #{@school.errors.full_messages.join(', ')}" + flash[:alert] = "An error occurred: #{@school.errors.full_messages.join(', ')}" render "new" && return end end From 838c4c02f1d096c099af3b02c84a5ebf214283f8 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:47:07 -0700 Subject: [PATCH 36/60] change new --> edit redirect for update school failure --- app/controllers/teachers_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb index 9c923f17..886ccc89 100644 --- a/app/controllers/teachers_controller.rb +++ b/app/controllers/teachers_controller.rb @@ -102,7 +102,7 @@ def update @school.update(school_params) if school_params unless @school.save flash[:alert] = "An error occurred: #{@school.errors.full_messages.join(', ')}" - render "new" && return + render "edit" && return end @teacher.school = @school end From b1fe2d5e9317e0c839496fb6d754e20be83bd893 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:49:44 -0700 Subject: [PATCH 37/60] actually fixed it now --- app/controllers/email_templates_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/email_templates_controller.rb b/app/controllers/email_templates_controller.rb index 85c02069..45f63b99 100644 --- a/app/controllers/email_templates_controller.rb +++ b/app/controllers/email_templates_controller.rb @@ -18,7 +18,7 @@ def update flash[:success] = "Updated #{@email_template.title} template successfully." redirect_to email_templates_path else - flash.now[:alert] = "Failed to save #{@email_template.title} template: #{@email_template.errors.full_messages.join(", ")}" + flash.now[:alert] = "An error occured: #{@email_template.errors.full_messages.join(", ")}" render "edit" end end From 66eb04c604dd74620e796ef580de1af4fa8d53ab Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:51:01 -0700 Subject: [PATCH 38/60] it turns out I don't know how to spell the word 'occured' --- features/email_template.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/email_template.feature b/features/email_template.feature index 28a3c89a..3da35895 100644 --- a/features/email_template.feature +++ b/features/email_template.feature @@ -62,7 +62,7 @@ Scenario: Editing email template to have blank body or to field displays flash e Then I should see "An error occurred: To can't be blank" When I fill in TinyMCE email form with "" And I press "Submit" - Then I should see "An error occured: Body can't be blank" + Then I should see "An error occurred: Body can't be blank" Scenario: Updating email template with valid parameters succeeds Given I am on the email templates index From 6e46e5cd0159cf66ef4b1cb05b415952bec0a8f2 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:12:12 -0700 Subject: [PATCH 39/60] fixed another myterious cucumber test bug --- app/controllers/email_templates_controller.rb | 2 +- features/teacher_info_request.feature | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/email_templates_controller.rb b/app/controllers/email_templates_controller.rb index 45f63b99..76a78b65 100644 --- a/app/controllers/email_templates_controller.rb +++ b/app/controllers/email_templates_controller.rb @@ -18,7 +18,7 @@ def update flash[:success] = "Updated #{@email_template.title} template successfully." redirect_to email_templates_path else - flash.now[:alert] = "An error occured: #{@email_template.errors.full_messages.join(", ")}" + flash.now[:alert] = "An error occurred: #{@email_template.errors.full_messages.join(", ")}" render "edit" end end diff --git a/features/teacher_info_request.feature b/features/teacher_info_request.feature index 367d60a4..ca698981 100644 --- a/features/teacher_info_request.feature +++ b/features/teacher_info_request.feature @@ -25,7 +25,7 @@ Feature: Request additional information for teacher application And I should see "Request Info from Joseph Mamoa" And I fill in "request_reason" with "Please provide more details on your teaching experience" And I press "Submit" - Then I can send a request info email + Then I send a request info email And I follow "Logout" Given I am on the BJC home page From f9388fc79b881b1614f65656e4c141c9645d486a Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:17:23 -0700 Subject: [PATCH 40/60] remove country from teachers table --- app/views/schools/index.html.erb | 1 - app/views/teachers/_table_headers.erb | 1 - app/views/teachers/_teacher.erb | 3 --- 3 files changed, 5 deletions(-) diff --git a/app/views/schools/index.html.erb b/app/views/schools/index.html.erb index 103478dc..ae0d33fa 100644 --- a/app/views/schools/index.html.erb +++ b/app/views/schools/index.html.erb @@ -6,7 +6,6 @@ Name Location - Country URL Teachers Grade Level diff --git a/app/views/teachers/_table_headers.erb b/app/views/teachers/_table_headers.erb index f519ec1e..8c070619 100644 --- a/app/views/teachers/_table_headers.erb +++ b/app/views/teachers/_table_headers.erb @@ -4,6 +4,5 @@ Status Snap! School -Country Approved? Created diff --git a/app/views/teachers/_teacher.erb b/app/views/teachers/_teacher.erb index beed2b95..7523cca7 100644 --- a/app/views/teachers/_teacher.erb +++ b/app/views/teachers/_teacher.erb @@ -27,9 +27,6 @@ <%= link_to(teacher.school.name, school_path(teacher.school)) %> <%= teacher.school.location %> - - <%= teacher.school.country %> - <%= teacher.short_application_status %> From 8ca38723be52e72970f4d5783b59fc95a7bcde0a Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:18:50 -0700 Subject: [PATCH 41/60] removed one unnecessary deletion --- app/views/schools/index.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/schools/index.html.erb b/app/views/schools/index.html.erb index ae0d33fa..103478dc 100644 --- a/app/views/schools/index.html.erb +++ b/app/views/schools/index.html.erb @@ -6,6 +6,7 @@ Name Location + Country URL Teachers Grade Level From 05df57cbc122e105c7c238b449ce53376a4dde88 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:21:52 -0700 Subject: [PATCH 42/60] update location method to display country --- app/models/school.rb | 2 +- app/views/teachers/_teacher_info.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/school.rb b/app/models/school.rb index f33f4c8b..b07a7047 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -61,7 +61,7 @@ def website end def location - "#{city}, #{state}" + "#{city}, #{state}, #{country}" end # TODO: Consider renaming this. diff --git a/app/views/teachers/_teacher_info.html.erb b/app/views/teachers/_teacher_info.html.erb index 38622fc5..6a08e630 100644 --- a/app/views/teachers/_teacher_info.html.erb +++ b/app/views/teachers/_teacher_info.html.erb @@ -74,7 +74,7 @@
School Location:
- <%= "#{teacher.school.location}, #{teacher.school.country}" %> + <%= "#{teacher.school.location}" %>
From 38b2ce1871a35c318bef7bf890a6ce9c76ac7486 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:25:58 -0700 Subject: [PATCH 43/60] update selectize options --- app/models/school.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/school.rb b/app/models/school.rb index b07a7047..6a15ad62 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -78,11 +78,11 @@ def display_grade_level end def selectize_options - [name_location, to_json(only: [:id, :name, :city, :state, :website]) ] + [name_location, to_json(only: [:id, :name, :city, :state, :country, :website]) ] end def name_location - "#{name} (#{city}, #{state})" + "#{name} (#{city}, #{state}, #{country})" end def update_gps_data From 8f831eb05a3a0ae60a676505006e82ad42ae4a90 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:28:46 -0700 Subject: [PATCH 44/60] revert placeholder --- app/views/schools/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb index b0b3a37e..1d911cee 100644 --- a/app/views/schools/_form.html.erb +++ b/app/views/schools/_form.html.erb @@ -2,7 +2,7 @@
<%= f.label :name, "School Name", class: "label-required" %> - <%= f.text_field :name, placeholder: 'Name of School', class: 'form-control', + <%= f.text_field :name, placeholder: 'UC Berkeley', class: 'form-control', required: false, id: 'school_name' %>
From fb9e87742532dc68fed65583c1b966e3a86057e7 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:21:52 -0700 Subject: [PATCH 45/60] update location method to display country --- app/models/school.rb | 2 +- app/views/teachers/_teacher_info.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/school.rb b/app/models/school.rb index f33f4c8b..b07a7047 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -61,7 +61,7 @@ def website end def location - "#{city}, #{state}" + "#{city}, #{state}, #{country}" end # TODO: Consider renaming this. diff --git a/app/views/teachers/_teacher_info.html.erb b/app/views/teachers/_teacher_info.html.erb index 38622fc5..6a08e630 100644 --- a/app/views/teachers/_teacher_info.html.erb +++ b/app/views/teachers/_teacher_info.html.erb @@ -74,7 +74,7 @@
School Location:
- <%= "#{teacher.school.location}, #{teacher.school.country}" %> + <%= "#{teacher.school.location}" %>
From 4cf6fbc746a93731082c4b49146de84ed854d70a Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:25:58 -0700 Subject: [PATCH 46/60] update selectize options --- app/models/school.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/school.rb b/app/models/school.rb index b07a7047..6a15ad62 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -78,11 +78,11 @@ def display_grade_level end def selectize_options - [name_location, to_json(only: [:id, :name, :city, :state, :website]) ] + [name_location, to_json(only: [:id, :name, :city, :state, :country, :website]) ] end def name_location - "#{name} (#{city}, #{state})" + "#{name} (#{city}, #{state}, #{country})" end def update_gps_data From eeea4caa2dcca937fe2d5074a94d89c8c072a51a Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:53:15 -0700 Subject: [PATCH 47/60] add back teachers to table to prevent cucumber bugs --- app/views/teachers/_table_headers.erb | 1 + app/views/teachers/_teacher.erb | 3 +++ 2 files changed, 4 insertions(+) diff --git a/app/views/teachers/_table_headers.erb b/app/views/teachers/_table_headers.erb index 8c070619..f519ec1e 100644 --- a/app/views/teachers/_table_headers.erb +++ b/app/views/teachers/_table_headers.erb @@ -4,5 +4,6 @@ Status Snap! School +Country Approved? Created diff --git a/app/views/teachers/_teacher.erb b/app/views/teachers/_teacher.erb index 7523cca7..beed2b95 100644 --- a/app/views/teachers/_teacher.erb +++ b/app/views/teachers/_teacher.erb @@ -27,6 +27,9 @@ <%= link_to(teacher.school.name, school_path(teacher.school)) %> <%= teacher.school.location %> + + <%= teacher.school.country %> + <%= teacher.short_application_status %> From fa97d32051cefd796433c41f61d61d2709dd5301 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:30:11 -0700 Subject: [PATCH 48/60] make search_list change --- app/controllers/schools_controller.rb | 2 +- app/models/school.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index 500f6ca0..191191f5 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -12,7 +12,7 @@ def show end def search - School.all.collect { |school| ["#{school.name}, #{school.country}, #{school.city}, #{school.state}", school.name] } + School.search_list end def create diff --git a/app/models/school.rb b/app/models/school.rb index 6a15ad62..2d12c61e 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -101,6 +101,18 @@ def maps_marker_data } end + def format_school(data) + name, city, state, country = data + country_str = country == "US" ? "" : ", #{country}" + "#{name} (#{city}, #{state}#{country_str})" + end + + def self.search_list + School.pluck(:name, :city, :state, :country).map do |data| + format_school(data) + end + end + def self.grade_level_options School.grade_levels.map { |key, _val| [key.to_s.titlecase, key] } end From c027698129c2f92211f7bdb0535808ff9704c800 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:58:18 -0700 Subject: [PATCH 49/60] added unique school params and DRY out code --- app/controllers/concerns/school_params.rb | 17 +++++++++++++++++ app/controllers/schools_controller.rb | 7 ++----- app/controllers/teachers_controller.rb | 9 +++------ 3 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 app/controllers/concerns/school_params.rb diff --git a/app/controllers/concerns/school_params.rb b/app/controllers/concerns/school_params.rb new file mode 100644 index 00000000..5bb01362 --- /dev/null +++ b/app/controllers/concerns/school_params.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module SchoolParams + private + def unique_school_params + { + name: school_params[:name], + country: school_params[:country], + city: school_params[:city], + state: school_params[:state] + } + end + + def school_params + params.require(:school).permit(:name, :country, :city, :state, :website, :grade_level, :school_type, :country, { tags: [] }, :nces_id) + end +end diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index 191191f5..ecdbfc37 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class SchoolsController < ApplicationController + include SchoolParams before_action :require_admin def index @@ -16,7 +17,7 @@ def search end def create - @school = School.find_by(name: school_params[:name], country: school_params[:country], city: school_params[:city], state: school_params[:state]) + @school = School.find_by(**unique_school_params) if @school @school.assign_attributes(school_params) else @@ -64,10 +65,6 @@ def destroy end private - def school_params - params.require(:school).permit(:name, :country, :city, :state, :website, :grade_level, :school_type, :country, { tags: [] }, :nces_id) - end - def load_ordered_schools @ordered_schools ||= School.all.order(:name) end diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb index 886ccc89..ec6cd27e 100644 --- a/app/controllers/teachers_controller.rb +++ b/app/controllers/teachers_controller.rb @@ -6,6 +6,7 @@ require "activerecord-import" class TeachersController < ApplicationController + include SchoolParams include CsvProcess before_action :load_pages, only: [:new, :create, :edit, :update] @@ -63,6 +64,7 @@ def create load_school if @school.new_record? + return unless params[:school] @school = School.new(school_params) unless @school.save flash[:alert] = "An error occurred: #{@school.errors.full_messages.join(', ')}" @@ -205,7 +207,7 @@ def load_school if teacher_params[:school_id].present? @school ||= School.find(teacher_params[:school_id]) end - @school ||= School.find_or_create_by(name: school_params[:name], city: school_params[:city], country: school_params[:country], state: school_params[:state]) + @school ||= School.find_or_create_by(**unique_school_params) end def teacher_params @@ -218,11 +220,6 @@ def teacher_params params.require(:teacher).permit(*teacher_attributes) end - def school_params - return unless params[:school] - params.require(:school).permit(:name, :country, :city, :state, :website, :grade_level, :school_type) - end - def omniauth_data @omniauth_data ||= session[:auth_data]&.slice("first_name", "last_name", "email") end From f41d0b94367877c204c3a4840e646fce02251e9c Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 18:01:30 -0700 Subject: [PATCH 50/60] converted valid states list using country gem --- app/models/school.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/school.rb b/app/models/school.rb index 2d12c61e..040ddbd9 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -26,8 +26,7 @@ # class School < ApplicationRecord - VALID_STATES = [ "AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"].freeze - + VALID_STATES = ISO3166::Country['US'].subdivisions.keys.freeze validates :name, :city, :website, :country, presence: true validates :country, inclusion: { in: ISO3166::Country.all.map(&:alpha2), message: "%{value} is not a valid country" } validates :state, presence: true, if: -> { country == "US" } From 1f682da9753058c0d8b1353344f74896334ab45c Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati <65872167+ArushC@users.noreply.github.com> Date: Fri, 12 Apr 2024 18:02:34 -0700 Subject: [PATCH 51/60] fixed rubocop --- app/models/school.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/school.rb b/app/models/school.rb index 040ddbd9..b51b546c 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -26,7 +26,7 @@ # class School < ApplicationRecord - VALID_STATES = ISO3166::Country['US'].subdivisions.keys.freeze + VALID_STATES = ISO3166::Country["US"].subdivisions.keys.freeze validates :name, :city, :website, :country, presence: true validates :country, inclusion: { in: ISO3166::Country.all.map(&:alpha2), message: "%{value} is not a valid country" } validates :state, presence: true, if: -> { country == "US" } From 22df60190abcefaa5466c73f4f76694f22923607 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 22 Apr 2024 17:04:32 -0700 Subject: [PATCH 52/60] Update app/models/school.rb --- app/models/school.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/school.rb b/app/models/school.rb index b51b546c..ac1ae256 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -60,7 +60,8 @@ def website end def location - "#{city}, #{state}, #{country}" + country_text = country == "US" ? '' : ", #{country}" + "#{city}, #{state}#{country_text}" end # TODO: Consider renaming this. From a2bf6e1230eb051591e356999e591c0c14b07cd8 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 22 Apr 2024 17:04:52 -0700 Subject: [PATCH 53/60] Update app/views/schools/_form.html.erb --- app/views/schools/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb index 1d911cee..4f23165d 100644 --- a/app/views/schools/_form.html.erb +++ b/app/views/schools/_form.html.erb @@ -9,7 +9,7 @@
<%= f.label :city, class: "label-required", for: "school_city" %> - <%= f.text_field :city, placeholder: 'Name of City', class: 'form-control', + <%= f.text_field :city, placeholder: 'Berkeley', class: 'form-control', required: false, id: 'school_city' %>
From 875b65b49a93d7cdbbd552ac7f331844eb38cbcb Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 22 Apr 2024 17:05:30 -0700 Subject: [PATCH 54/60] Update app/views/schools/show.html.erb --- app/views/schools/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/schools/show.html.erb b/app/views/schools/show.html.erb index 5a579716..4a179b3a 100644 --- a/app/views/schools/show.html.erb +++ b/app/views/schools/show.html.erb @@ -18,7 +18,7 @@
Location
- <%= "#{@school.location}, #{@school.country}" %> + <%= @school.location %>
From 53fcb0b4074fed403788d6fb3759608ae0599990 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 22 Apr 2024 17:05:43 -0700 Subject: [PATCH 55/60] Update app/views/teachers/_table_headers.erb --- app/views/teachers/_table_headers.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/teachers/_table_headers.erb b/app/views/teachers/_table_headers.erb index f519ec1e..8c070619 100644 --- a/app/views/teachers/_table_headers.erb +++ b/app/views/teachers/_table_headers.erb @@ -4,6 +4,5 @@ Status Snap! School -Country Approved? Created From eb884a92be51f422d613ea3b136a6817f19c367a Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 22 Apr 2024 17:05:58 -0700 Subject: [PATCH 56/60] Update app/views/teachers/_teacher.erb --- app/views/teachers/_teacher.erb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/views/teachers/_teacher.erb b/app/views/teachers/_teacher.erb index beed2b95..7523cca7 100644 --- a/app/views/teachers/_teacher.erb +++ b/app/views/teachers/_teacher.erb @@ -27,9 +27,6 @@ <%= link_to(teacher.school.name, school_path(teacher.school)) %> <%= teacher.school.location %> - - <%= teacher.school.country %> - <%= teacher.short_application_status %> From 9207b11c6f9fb391c4832d51fe664294032a74a6 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 22 Apr 2024 17:06:30 -0700 Subject: [PATCH 57/60] Update app/views/teachers/_teacher_info.html.erb --- app/views/teachers/_teacher_info.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/teachers/_teacher_info.html.erb b/app/views/teachers/_teacher_info.html.erb index 6a08e630..74c707f7 100644 --- a/app/views/teachers/_teacher_info.html.erb +++ b/app/views/teachers/_teacher_info.html.erb @@ -74,7 +74,6 @@
School Location:
- <%= "#{teacher.school.location}" %>
From 57dd25a0c549fa24bc772f95e2ad81cbfe9fc362 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Tue, 23 Apr 2024 10:19:46 -0700 Subject: [PATCH 58/60] delint... --- app/models/school.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/school.rb b/app/models/school.rb index ac1ae256..2bde54f9 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -60,7 +60,7 @@ def website end def location - country_text = country == "US" ? '' : ", #{country}" + country_text = country == "US" ? "" : ", #{country}" "#{city}, #{state}#{country_text}" end From c4ad7f5c5fabeb4dd14aad5295af13af3104f5e4 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Fri, 10 May 2024 10:33:17 +0200 Subject: [PATCH 59/60] Apply suggestions from code review --- app/models/school.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/school.rb b/app/models/school.rb index 2bde54f9..29966ddc 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -108,9 +108,7 @@ def format_school(data) end def self.search_list - School.pluck(:name, :city, :state, :country).map do |data| - format_school(data) - end + School.pluck(:name, :city, :state, :country).map(&:format_school) end def self.grade_level_options From 163e2a9901a5ae13e09f3d4be2fdc73cfcb8dfa0 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Fri, 10 May 2024 10:55:03 +0200 Subject: [PATCH 60/60] move datatables stuff to new file --- .github/workflows/specs.yml | 2 +- features/admin.feature | 44 ----------------------------- features/data_tables.feature | 54 ++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 45 deletions(-) create mode 100644 features/data_tables.feature diff --git a/.github/workflows/specs.yml b/.github/workflows/specs.yml index 8eb5a7be..2d93ce7f 100644 --- a/.github/workflows/specs.yml +++ b/.github/workflows/specs.yml @@ -57,4 +57,4 @@ jobs: run: | export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}" $CCTR sum-coverage coverage/codeclimate.*.json - $CCTR upload-coverage --id "$CC_TEST_REPORTER_ID" + $CCTR upload-coverage --id "${{ secrets.CC_TEST_REPORTER_ID }}" diff --git a/features/admin.feature b/features/admin.feature index 5b5486be..8f8208fa 100644 --- a/features/admin.feature +++ b/features/admin.feature @@ -147,26 +147,6 @@ Feature: basic admin functionality And I press "Update" Then I should not have sent out any emails - Scenario: Updating application status persists changes in database - Given the following schools exist: - | name | country | city | state | website | grade_level | school_type | - | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | - Given the following teachers exist: - | first_name | last_name | admin | email | school | snap | application_status | - | Bobby | John | false | testteacher@berkeley.edu | UC Berkeley | bobby | denied | - Given I am on the BJC home page - And I have an admin email - And I follow "Log In" - Then I can log in with Google - When I go to the teachers page - And I go to the edit page for Bobby John - And I set my application status as "Validated" - And I press "Update" - Then I see a confirmation "Saved" - When I go to the teachers page - And I check "Validated" - Then I should see "Bobby John" - Scenario: Deny teacher as an admin Given the following schools exist: | name | country | city | state | website | grade_level | school_type | @@ -199,30 +179,6 @@ Feature: basic admin functionality When I go to the edit page for Joseph Mamoa Then should see "You need to log in to access this." - Scenario: Filter all teacher info as an admin - Given the following schools exist: - | name | country | city | state | website | grade_level | school_type | - | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | - Given the following teachers exist: - | first_name | last_name | admin | email | school | application_status | - | Victor | Validateme | false | testteacher1@berkeley.edu | UC Berkeley | Validated | - | Danny | Denyme | false | testteacher2@berkeley.edu | UC Berkeley | Denied | - | Peter | Pendme | false | testteacher3@berkeley.edu | UC Berkeley | Not Reviewed | - Given I am on the BJC home page - Given I have an admin email - And I follow "Log In" - Then I can log in with Google - When I go to the teachers page - And I check "Not Reviewed" - And I uncheck "Validated" - Then I should see "Peter" - Then I should not see "Victor" - Then I should not see "Danny" - And I check "Validated" - Then I should see "Peter" - Then I should see "Victor" - Then I should not see "Danny" - Scenario: View teacher info as an admin Given the following schools exist: | name | country | city | state | website | grade_level | school_type | diff --git a/features/data_tables.feature b/features/data_tables.feature new file mode 100644 index 00000000..072bf825 --- /dev/null +++ b/features/data_tables.feature @@ -0,0 +1,54 @@ +Feature: Admin Data Tables functionality + + As an admin + So that I can see how many people are teaching BJC + I can use interactive datatables + + Background: Has an Admin in DB + Given the following teachers exist: + | first_name | last_name | admin | email | + | Admin | User | true | testadminuser@berkeley.edu | + + # Scenario: Updating application status persists changes in database + # Given the following schools exist: + # | name | country | city | state | website | grade_level | school_type | + # | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | + # Given the following teachers exist: + # | first_name | last_name | admin | email | school | snap | application_status | + # | Bobby | John | false | testteacher@berkeley.edu | UC Berkeley | bobby | denied | + # Given I am on the BJC home page + # And I have an admin email + # And I follow "Log In" + # Then I can log in with Google + # When I go to the teachers page + # And I go to the edit page for Bobby John + # And I set my application status as "Validated" + # And I press "Update" + # Then I see a confirmation "Saved" + # When I go to the teachers page + # And I check "Validated" + # Then I should see "Bobby John" + + # Scenario: Filter all teacher info as an admin + # Given the following schools exist: + # | name | country | city | state | website | grade_level | school_type | + # | UC Berkeley | US | Berkeley | CA | https://www.berkeley.edu | university | public | + # Given the following teachers exist: + # | first_name | last_name | admin | email | school | application_status | + # | Victor | Validateme | false | testteacher1@berkeley.edu | UC Berkeley | Validated | + # | Danny | Denyme | false | testteacher2@berkeley.edu | UC Berkeley | Denied | + # | Peter | Pendme | false | testteacher3@berkeley.edu | UC Berkeley | Not Reviewed | + # Given I am on the BJC home page + # Given I have an admin email + # And I follow "Log In" + # Then I can log in with Google + # When I go to the teachers page + # And I check "Not Reviewed" + # And I uncheck "Validated" + # Then I should see "Peter" + # Then I should not see "Victor" + # Then I should not see "Danny" + # And I check "Validated" + # Then I should see "Peter" + # Then I should see "Victor" + # Then I should not see "Danny"