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..e1301823 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 @@ -146,6 +146,7 @@ def deny @teacher.denied! if !params[:skip_email].present? # TODO: Update dropdown to select the email template. + puts params[:denial_reason] TeacherMailer.deny_email(@teacher, params[:denial_reason]).deliver_now end redirect_to root_path 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 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}}
{{request_reason}}
Actions | -
---|
-
- <%= button_to("✔️", validate_teacher_path(teacher.id),
- class: 'btn-group btn btn-outline-success', type: 'button') %>
-
-
+
+
-
- |
-
Status | Count | -
---|---|
<%= key.humanize.titlecase %> | <%= value %> |
School | Location | Teachers | -
---|---|---|
<%= link_to(school.name, school_path(school)) %> | <%= school.location %> | <%= school.teachers_count %> |
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:
+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 [ { @@ -95,7 +118,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", 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| 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