From 4ce4a2d1f2913b925195f55c865eda1d59751a5f Mon Sep 17 00:00:00 2001 From: Jingchao Zhong <92573736+perryzjc@users.noreply.github.com> Date: Tue, 20 Feb 2024 07:31:02 -0800 Subject: [PATCH 1/8] Add request reason email template --- db/seed_data.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/db/seed_data.rb b/db/seed_data.rb index deccbc0d..934512f8 100644 --- a/db/seed_data.rb +++ b/db/seed_data.rb @@ -59,6 +59,15 @@ module SeedData DENY_EMAIL3 + @request_info_email = <<-REQUEST_INFO_EMAIL +

+ Here is an update to your application to BJC:
+ We need more information from you:
+ {{ request_reason | strip_tags }}
+ To update your application, please login to your account and update your application. +

+ REQUEST_INFO_EMAIL + def self.emails [ { @@ -95,7 +104,7 @@ def self.emails subject: "Deny Email" }, { - body: @basic_email_with_reason, + body: @request_info_email, path: "teacher_mailer/request_info_email", locale: nil, handler: "liquid", From 15da9b5f3b84aa558928c6a5801d9351fbb2de67 Mon Sep 17 00:00:00 2001 From: Jingchao Zhong <92573736+perryzjc@users.noreply.github.com> Date: Tue, 20 Feb 2024 07:31:32 -0800 Subject: [PATCH 2/8] Fix reason naming --- app/controllers/pages_controller.rb | 1 + app/controllers/teachers_controller.rb | 2 +- app/mailers/teacher_mailer.rb | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 87ad89cd..0a913198 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -95,6 +95,7 @@ def page_params # teacher_school_website: @teacher.school.website, # piazza_password: Rails.application.secrets[:piazza_password], # denial_reason: @denial_reason + # request_reason: @request_reason # }.with_indifferent_access # end diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb index cbcf35ba..a45dd188 100644 --- a/app/controllers/teachers_controller.rb +++ b/app/controllers/teachers_controller.rb @@ -130,7 +130,7 @@ def update def request_info @teacher.info_needed! if !params[:skip_email].present? - TeacherMailer.request_info_email(@teacher, params[:denial_reason]).deliver_now + TeacherMailer.request_info_email(@teacher, params[:request_reason]).deliver_now end redirect_to root_path end diff --git a/app/mailers/teacher_mailer.rb b/app/mailers/teacher_mailer.rb index 4acb1634..83c8c003 100644 --- a/app/mailers/teacher_mailer.rb +++ b/app/mailers/teacher_mailer.rb @@ -48,7 +48,9 @@ def liquid_assigns base_rules = { bjc_password: Rails.application.secrets[:bjc_password], piazza_password: Rails.application.secrets[:piazza_password], - denial_reason: @denial_reason + # TODO: Review if below two are needed, or can they be refractored? + denial_reason: @denial_reason, + request_reason: @request_reason } base_rules.merge!(@teacher.email_attributes) base_rules.with_indifferent_access From 5da7ca624dd236eee523a775a4f6fdbc10ba3b78 Mon Sep 17 00:00:00 2001 From: Jingchao Zhong <92573736+perryzjc@users.noreply.github.com> Date: Tue, 20 Feb 2024 07:33:32 -0800 Subject: [PATCH 3/8] Add request reason to liquid template engine --- app/views/email_templates/_liquid_fields.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/email_templates/_liquid_fields.erb b/app/views/email_templates/_liquid_fields.erb index 715f93d6..774f3cce 100644 --- a/app/views/email_templates/_liquid_fields.erb +++ b/app/views/email_templates/_liquid_fields.erb @@ -27,5 +27,9 @@ {{denial_reason}} (Only on denial emails.) + + {{request_reason}} + (Only on request emails.) + From 725ae8404d5e4f6254f372984882b71daac41fc1 Mon Sep 17 00:00:00 2001 From: MT Date: Wed, 21 Feb 2024 10:44:19 -0800 Subject: [PATCH 4/8] fix request info email template --- db/seed_data.rb | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/db/seed_data.rb b/db/seed_data.rb index 934512f8..05a7dea9 100644 --- a/db/seed_data.rb +++ b/db/seed_data.rb @@ -60,14 +60,28 @@ module SeedData DENY_EMAIL3 @request_info_email = <<-REQUEST_INFO_EMAIL -

- Here is an update to your application to BJC:
- We need more information from you:
- {{ request_reason | strip_tags }}
- To update your application, please login to your account and update your application. -

+

Dear {{teacher_first_name}},

+ +

We hope this message finds you well. We're writing to you regarding your ongoing application with BJC. As part of our review process, we've identified that some additional information is required to move forward.

+ +

Required Information:
+ We kindly ask you to provide the following details to complete your application:

+

{{ request_reason | strip_tags }}

+ +

To submit the requested information, please follow these steps:

+
    +
  1. Log into your BJC account using your registered email and password.
  2. +
  3. Locate your current application and update the information.
  4. +
  5. Fill in the necessary details in the provided fields and submit the update.
  6. +
+ +

Thank you for your attention to this matter. We look forward to receiving the additional information and advancing your application process.

+ +

Warm regards,

+

[Your Name]

REQUEST_INFO_EMAIL + def self.emails [ { From f99087d7f2ebe9274f7176497b7d19e5fb207414 Mon Sep 17 00:00:00 2001 From: Jingchao Zhong <92573736+perryzjc@users.noreply.github.com> Date: Wed, 21 Feb 2024 10:55:49 -0800 Subject: [PATCH 5/8] Add rspec test for request reason email --- spec/mailers/teacher_mailer_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/mailers/teacher_mailer_spec.rb b/spec/mailers/teacher_mailer_spec.rb index d9db4aab..b6293eec 100644 --- a/spec/mailers/teacher_mailer_spec.rb +++ b/spec/mailers/teacher_mailer_spec.rb @@ -36,4 +36,17 @@ expect(email.to[0]).to eq("lmock@berkeley.edu") expect(email.body.encoded).to include("Short Long") end + + it "Sends Request Info Email" do + teacher = teachers(:long) + email = TeacherMailer.request_info_email(teacher, "Request Reason") + email.deliver_now + expect(email.from[0]).to eq("contact@bjc.berkeley.edu") + expect(email.to[0]).to eq("short@long.com") + expect(email.subject).to eq("Request Info Email") + # Test appearance of first_name + expect(email.body.encoded).to include("Short") + expect(email.body.encoded).to include("Request Reason") + expect(email.body.encoded).to include("We're writing to you regarding your ongoing application with BJC.") + end end From 9248494ccbe925f6394a527d0f3b884391397d29 Mon Sep 17 00:00:00 2001 From: razztech Date: Mon, 26 Feb 2024 00:00:54 -0800 Subject: [PATCH 6/8] Added button UI, modified UI logic, added comments for backend --- app/controllers/teachers_controller.rb | 8 ++++++++ app/views/main/_deny_modal.html.erb | 11 +++++++++-- app/views/main/dashboard.html.erb | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb index a45dd188..5ab7b761 100644 --- a/app/controllers/teachers_controller.rb +++ b/app/controllers/teachers_controller.rb @@ -130,6 +130,10 @@ def update def request_info @teacher.info_needed! if !params[:skip_email].present? + + # This is not printing the right thing. However, if you do "puts params[:reason]" it actually + # prints the reason. Route has to be updated I think? + puts params[:request_reason] TeacherMailer.request_info_email(@teacher, params[:request_reason]).deliver_now end redirect_to root_path @@ -146,6 +150,10 @@ def deny @teacher.denied! if !params[:skip_email].present? # TODO: Update dropdown to select the email template. + + # This is not printing the right thing. However, if you do "puts params[:reason]" it actually + # prints the reason. Route has to be updated I think? + puts params[:denial_reason] TeacherMailer.deny_email(@teacher, params[:denial_reason]).deliver_now end redirect_to root_path diff --git a/app/views/main/_deny_modal.html.erb b/app/views/main/_deny_modal.html.erb index fa76cc00..ebade46f 100644 --- a/app/views/main/_deny_modal.html.erb +++ b/app/views/main/_deny_modal.html.erb @@ -8,7 +8,8 @@ <%= form_tag deny_teacher_path(0), method: :post, class: "form-horizontal" do %> diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index ca4d6840..bb83db7c 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -1,44 +1,44 @@ <% provide(:title, "BJC Teacher Dashboard") %>

New Requests

- - - - <%= render 'teachers/table_headers' %> - - - - - <% @unreviewed_teachers.each do |teacher| %> - - <%= render 'teachers/teacher', teacher: teacher %> - + <% end %> + +
Actions
-
- <%= button_to("✔️", validate_teacher_path(teacher.id), - class: 'btn-group btn btn-outline-success', type: 'button') %> - + + + + <%= render 'teachers/table_headers' %> + + + + + <% @unreviewed_teachers.each do |teacher| %> + + <%= render 'teachers/teacher', teacher: teacher %> + - - <% end %> - -
Actions
+
+ <%= button_to("✔️", validate_teacher_path(teacher.id), + class: 'btn-group btn btn-outline-success', type: 'button') %> + - + -
-
- <% if @unreviewed_teachers.empty? %> - +
+
+ <% if @unreviewed_teachers.empty? %> + + <% end %>
<%= render 'deny_modal' %> @@ -52,65 +52,65 @@

Course Statistics

- + - + - <% @statuses.each do |key, value| %> + <% @statuses.each do |key, value| %> - <% end %> + <% end %> -
Status Count
<%= key.humanize.titlecase %> <%= value %>
+

School Statistics

- + - + - <% @schools.each do |school| %> + <% @schools.each do |school| %> - <% end %> + <% end %>
School Location Teachers
<%= link_to(school.name, school_path(school)) %> <%= school.location %> <%= school.teachers_count %>
diff --git a/features/admin.feature b/features/admin.feature index 15bae961..3c066a9f 100644 --- a/features/admin.feature +++ b/features/admin.feature @@ -4,34 +4,34 @@ Feature: basic admin functionality So that I can see how many people are teaching BJC I can login in an see the dashboard -Background: Has an Admin in DB - Given the following teachers exist: - | first_name | last_name | admin | email | - | Joseph | Mamoa | true | testadminuser@berkeley.edu | + Background: Has an Admin in DB + Given the following teachers exist: + | first_name | last_name | admin | email | + | Joseph | Mamoa | true | testadminuser@berkeley.edu | -Scenario: Logging in as an admin - 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 - And I should see "BJC Teacher Dashboard" + Scenario: Logging in as an admin + 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 + And I should see "BJC Teacher Dashboard" -Scenario: Logging out as an admin - 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 - And I follow "Logout" - Then I should see "Request Access to BJC Teacher Materials" - Then I should see "Log In" + Scenario: Logging out as an admin + 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 + And I follow "Logout" + Then I should see "Request Access to BJC Teacher Materials" + Then I should see "Log In" -Scenario: Viewing Teachers as an admin - 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 - Then I should see "BJC Teachers" + Scenario: Viewing Teachers as an admin + 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 + Then I should see "BJC Teachers" # TODO: Add steps to check basic dashboard functions # A search field should be visible on the index pages @@ -39,198 +39,221 @@ Scenario: Viewing Teachers as an admin # TODO: Checks for validation and deny belong here. -Scenario: Logging in with non-admin, unregistered Google Account should fail - Given I have a non-admin, unregistered Google email - Given I am on the BJC home page - And I follow "Log In" - Then I can log in with Google - And I should see "Please submit a new request." + Scenario: Logging in with non-admin, unregistered Google Account should fail + Given I have a non-admin, unregistered Google email + Given I am on the BJC home page + And I follow "Log In" + Then I can log in with Google + And I should see "Please submit a new request." -Scenario: Logging in with non-admin, unregistered Microsoft Account should fail - Given I have a non-admin, unregistered Microsoft email - Given I am on the BJC home page - And I follow "Log In" - Then I can log in with Microsoft - And I should see "Please submit a new request." + Scenario: Logging in with non-admin, unregistered Microsoft Account should fail + Given I have a non-admin, unregistered Microsoft email + Given I am on the BJC home page + And I follow "Log In" + Then I can log in with Microsoft + And I should see "Please submit a new request." -Scenario: Logging in with non-admin, unregistered Snap Account should fail - Given I have a non-admin, unregistered Snap email - Given I am on the BJC home page - And I follow "Log In" - Then I can log in with Snap - And I should see "Please submit a new request." + Scenario: Logging in with non-admin, unregistered Snap Account should fail + Given I have a non-admin, unregistered Snap email + Given I am on the BJC home page + And I follow "Log In" + Then I can log in with Snap + And I should see "Please submit a new request." -Scenario: Logging in with non-admin, unregistered Clever Account should fail - Given I have a non-admin, unregistered Clever email - Given I am on the BJC home page - And I follow "Log In" - Then I can log in with Clever - And I should see "Please submit a new request." + Scenario: Logging in with non-admin, unregistered Clever Account should fail + Given I have a non-admin, unregistered Clever email + Given I am on the BJC home page + And I follow "Log In" + Then I can log in with Clever + And I should see "Please submit a new request." -Scenario: Non-admin, unregistered user should not be able to see admin-only pages - Given I have a non-admin, unregistered Google email - Given I am on the BJC home page - When I go to the dashboard page - Then I should see "Only admins can access this page" - And I should be on the new teachers page + Scenario: Non-admin, unregistered user should not be able to see admin-only pages + Given I have a non-admin, unregistered Google email + Given I am on the BJC home page + When I go to the dashboard page + Then I should see "Only admins can access this page" + And I should be on the new teachers page -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 | - Given the following teachers exist: - | first_name | last_name | admin | email | school | snap | - | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | alonzo | - 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 - When I go to the edit page for Joseph Mamoa - Then I should see "Joseph" - And I enter my "First Name" as "Joe" - And I set my status as "Other - Please specify below." - And I set my education level target as "College" - And I press "Update" - Then I see a confirmation "Saved" + 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 | + Given the following teachers exist: + | first_name | last_name | admin | email | school | snap | + | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | alonzo | + 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 + When I go to the edit page for Joseph Mamoa + Then I should see "Joseph" + And I enter my "First Name" as "Joe" + And I set my status as "Other - Please specify below." + And I set my education level target as "College" + And I press "Update" + Then I see a confirmation "Saved" -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 | - Given the following teachers exist: - | first_name | last_name | admin | email | school | - | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | - Given I am on the BJC home page - Given I have an admin email - When I follow "Log In" - Then I can log in with Google - And I press "❌" within "#DataTables_Table_0 > tbody > tr:nth-child(1)" - Then I should see "Reason" - And I should see "Deny Joseph Mamoa" - And I fill in "denial_reason" with "Test" - And I press "Cancel" - And I press "❌" within "#DataTables_Table_0 > tbody > tr:nth-child(1)" - Then the "denial_reason" field should not contain "Test" - And I fill in "denial_reason" with "Denial Reason" - And I press "Submit" - Then I can send a deny email + 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 | + Given the following teachers exist: + | first_name | last_name | admin | email | school | + | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | + Given I am on the BJC home page + Given I have an admin email + When I follow "Log In" + Then I can log in with Google + And I press "❌" within "#DataTables_Table_0 > tbody > tr:nth-child(1)" + Then I should see "Reason" + And I should see "Deny Joseph Mamoa" + And I fill in "denial_reason" with "Test" + And I press "Cancel" + And I press "❌" within "#DataTables_Table_0 > tbody > tr:nth-child(1)" + Then the "denial_reason" field should not contain "Test" + And I fill in "denial_reason" with "Denial Reason" + And I press "Submit" + Then I can send a deny email -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 | - Given the following teachers exist: - | first_name | last_name | admin | email | school | - | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | - When I go to the edit page for Joseph Mamoa - Then should see "You need to log in to access this." + 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 | + Given the following teachers exist: + | first_name | last_name | admin | email | school | + | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | + 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 | city | state | website | grade_level | school_type | - | UC Berkeley | 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: 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 | + 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 | city | state | website | grade_level | school_type | - | UC Berkeley | 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 | - 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 uncheck "Validated" - When I follow "Joseph Test" - Then I should see "Joseph Test" - And I should see "Edit Information" - And I should see "School" - And I should see "School Location" - And I should see "Email" - And I should see "Personal or Course Website" + 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 | + Given the following teachers exist: + | first_name | last_name | admin | email | school | snap | + | Joseph | Test | false | testteacher@berkeley.edu | UC Berkeley | alonzo | + 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 uncheck "Validated" + When I follow "Joseph Test" + Then I should see "Joseph Test" + And I should see "Edit Information" + And I should see "School" + And I should see "School Location" + And I should see "Email" + And I should see "Personal or Course Website" -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 | - Given the following teachers exist: - | first_name | last_name | admin | email | school | snap | - | Joseph | Mamoa New | false | testteacher@berkeley.edu | UC Berkeley | alonzo | - 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 uncheck "Validated" - When I follow "Joseph Mamoa New" - Then I should see "Joseph Mamoa" - And I should see "Edit Information" - And I follow "Edit Information" - And I should see "Joseph" - And I enter my "First Name" as "Joe" - And I set my status as "Other - Please specify below." - And I set my education level target as "College" - And I press "Update" - Then I see a confirmation "Saved" + 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 | + Given the following teachers exist: + | first_name | last_name | admin | email | school | snap | + | Joseph | Mamoa New | false | testteacher@berkeley.edu | UC Berkeley | alonzo | + 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 uncheck "Validated" + When I follow "Joseph Mamoa New" + Then I should see "Joseph Mamoa" + And I should see "Edit Information" + And I follow "Edit Information" + And I should see "Joseph" + And I enter my "First Name" as "Joe" + And I set my status as "Other - Please specify below." + And I set my education level target as "College" + And I press "Update" + Then I see a confirmation "Saved" -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 | - 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 | - 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 - When I go to the edit page for Joseph Mamoa - Then I should see a button named "Resend Welcome Email" + 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 | + 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 | + 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 + When I go to the edit page for Joseph Mamoa + Then I should see a button named "Resend Welcome Email" Scenario: Admin can access new teacher button at teacher index page - 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 - And I should see "BJC Teacher Dashboard" - Given I follow "Teachers" - Then I should see "BJC Teachers" - And I press "New Teacher" - Then I should see "Request Access to BJC Teacher Materials" + 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 + And I should see "BJC Teacher Dashboard" + Given I follow "Teachers" + Then I should see "BJC Teachers" + And I press "New Teacher" + Then I should see "Request Access to BJC Teacher Materials" Scenario: Admin can access new school button at teacher index page - 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 - And I should see "BJC Teacher Dashboard" - Given I follow "Schools" - Then I should see "BJC Schools" - And I press "New School" - Then I should see "Add a School" + 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 + And I should see "BJC Teacher Dashboard" + Given I follow "Schools" + Then I should see "BJC Schools" + And I press "New School" + Then I should see "Add a School" + + 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 | + And the following teachers exist: + | first_name | last_name | admin | email | school | + | Joseph | Mamoa | false | testteacher@berkeley.edu | UC Berkeley | + And I am on the BJC home page + And I have an admin email + When I follow "Log In" + Then I can log in with Google + And I press "❓" within "#DataTables_Table_0 > tbody > tr:nth-child(1)" + Then I should see "Reason" + And I should see "Request Info from Joseph Mamoa" + And I fill in "request_reason" with "Need more details on qualifications" + And I press "Cancel" + And I press "❓" within "#DataTables_Table_0 > tbody > tr:nth-child(1)" + Then the "request_reason" field should not contain "Need more details on qualifications" + And I fill in "request_reason" with "Complete your profile details" + And I press "Submit" + Then I can send a request info email + # Scenario: Admin can import csv file. The loader should filter invalid record and create associate school. # Given the following schools exist: diff --git a/features/step_definitions/admin_steps.rb b/features/step_definitions/admin_steps.rb index 0777c8dd..d878a923 100644 --- a/features/step_definitions/admin_steps.rb +++ b/features/step_definitions/admin_steps.rb @@ -12,32 +12,32 @@ # Returns a OAuth2 token associated with email "testadminuser@berkeley.edu" Given(/I have an admin email/) do OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({ - provider: "google_oauth2", - uid: "123545", - info: { - name: "Admin User", - first_name: "Admin", - last_name: "User", - email: "testadminuser@berkeley.edu", - school: "UC Berkeley", - } - }) + provider: "google_oauth2", + uid: "123545", + info: { + name: "Admin User", + first_name: "Admin", + last_name: "User", + email: "testadminuser@berkeley.edu", + school: "UC Berkeley", + } + }) end # Returns a OAuth2 token associated with email "randomemail@gmail.com" Given(/I have a non-admin, unregistered (.*) email/) do |login| service = LOGIN_SERVICE[login] OmniAuth.config.mock_auth[service] = OmniAuth::AuthHash.new({ - provider: service, - uid: "123545", - info: { - name: "Random User", - first_name: "Random", - last_name: "User", - email: "randomemail@berkeley.edu", - school: "UC Berkeley", - } - }) + provider: service, + uid: "123545", + info: { + name: "Random User", + first_name: "Random", + last_name: "User", + email: "randomemail@berkeley.edu", + school: "UC Berkeley", + } + }) end # A wrapper around the omniauth link. @@ -64,7 +64,7 @@ last_email = ActionMailer::Base.deliveries.last last_email.to[0].should eq "testteacher@berkeley.edu" last_email.subject.should eq "Request Info Email" - last_email.body.encoded.should include "Request Info Reason" + last_email.body.encoded.should include "We kindly ask you to provide the following details to complete your application:" end Then(/I attach the csv "([^"]*)"$/) do |path|