diff --git a/app/views/main/_deny_modal.html.erb b/app/views/main/_deny_modal.html.erb index 5ebafe1a..92114fec 100644 --- a/app/views/main/_deny_modal.html.erb +++ b/app/views/main/_deny_modal.html.erb @@ -5,24 +5,25 @@ + <%= 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|