CSC/ECE 517 Fall 2019 - E1995. Tests for email functionality

From Expertiza_Wiki
Jump to navigation Jump to search



Expertiza Background

Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and the code is available on Github. It allows students to review each other’s work and improve their work upon this feedback. Students and Instructors (including TA's) use this application though their credentials. Instructors can add new projects, assignments etc as well edit the previous ones and at a later stage can see the student submission and grade them. They can even put a time limit (deadline) for submitting the assignment. Students can form teams for the projects, submit their work through handles (Wiki page, link to a video etc). Students can even review their teammates and other peers, as well give them any suggestions if required


Problem Statement

Expertiza system requires sending emails to students and instructors on occurrence of various events or to facilitate actions further.

Email notifications are sent out when the following events occur:

  1. The author of a submission gets notified via email when a reviewer has reviewed their work and the feedback is available to view.
  2. The reviewer receives an email when work has been submitted/resubmitted by an author whose work needs to reviewed.
  3. An account holder is emailed when a new account is created.
  4. A confirmation email is sent to a user of the system when they reset their Expertiza account password

In the current scenario, it has been identified that not all emailing functionalities are working as desired. Also, presently, there is little evidence to claim that the existing implementation is covering all cases and handling all necessary conditions.

Our project is to build robust test suite for mailer functionality that is currently implemented in Expertiza. Developing this would ensure that all the mailing features are backed up with a stronger set of test features.

Approach Chosen and Why?

In this project we have first identified all the set of scenarios where the user of the system will get an email. Each of the four scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that each of the mailers will be robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this mailing feature is in resonance with the other features and works coherently.

Implementation

Scenario 1

Whenever someone reviews other student or team’s work, then that student or all the members of that team should get notified through the email stating that new peer review is available for your work. Even when the reviewer updates the reviews, then also that student or all the team members should get notified that updated comments are present on their submitted work.

Files associated with this functionality:

  1. app/controllers/response_controller.rb
  2. app/models/review_response_map.rb

Following parameters need to be tested:

  • Whenever reviewer reviews some team’s work, in that case all the team members should receive an email. So, number of emails delivered should be number of participants assigned to that work.

Cases Tested

Outcome

Code Snippet

Scenario 2

This will be mainly the case when there will be more than one round of the submission. After the first submission, some users will be assigned to review the submitted work. Now, in second round of the submission, whenever author resubmits or edit their work, then in that case all the reviewers assigned to that author should get email notification stating new submission is available for them to review.

Files associated with this functionality:

  1. app/controllers/submitted_content_controller.rb
  2. app/helpers/mailer_helper.rb

Cases Tested

Outcome

Code Snippet

Creating a new user Account

There are many ways to create new user account in Expertiza. Irrespective of the method of creating user, that user should get notified via email whenever an account is created stating this is your username and will also provide randomized password to allow them to login for the first time.

Cases Tested

Below given are the ways to create new user to system.

1. Instructor can add users to the system by filling the sign-up form for user.

2. Instructor can also import CSV file containing the user information to add user to the system.

The following features were checked as part of user creating user in case (i) and case (ii) mentioned above

  1. Mail delivery count increased by 1 after the mail triggered by the scenario is sent
  2. Sender email-id is verified. The sender mail-id is verified to be 'expertiza.development@gmail.com'
  3. Receiver email id is checked to be equal to 'expertiza.development@gmail.com' . Since all mails triggered have a record in 'expertiza.development@gmail.com' when executed in test environment.
  4. The subject is checked to be equal to 'Your Expertiza account and password has been created'

3. Instructor can add user as the participant of the assignment by importing details through CSV file. While doing that, if there are any user credentials present in the CSV file but is not registered in the system, then in that case new user account will be created.


4. There is also way to request user account without any help of the instructor. In that case, actual account will not be created but the details will be stored in the requested users table. Whenever instructor authorizes the requested user, actual user account will be created, and the user of that account should receive email notification stating your account request has been approved.



We considered the following cases as it blocks while testing specific to scenario ii:

  1. no email should be sent if new account requested with invalid email address
  2. super admin should receive email about new account request with a valid email address
  3. email notification should be sent to requester when super admin approves account creation request
  4. email notification should be sent to requester when super admin rejects account creation request


Outcome

We used Capybara to model the scenario as follows:
i) create user through instructor filling up the form:

Admin user is created using factory class.
1.visit expertiza

2.login_as 'admin_user'

3.visit list of users

4.click New User link

5.fill user_name with 'teststudent'

6.fill user_fullname with 'test student'

7.fill user_email with 'test@student.com'

8.check checkbox to send email to user on review

9.click 'Create' button.


ii) create user through instructor filling up the form:
super admin is created using factory class.
1.visit expertiza
2.click Request Account link
3.select instructor from dropdown
4.fill user name with 'requester1'
5.fill user fullname with 'requester1, requester1'
6.fill user email with 'test.com'
7.fill user_email with 'test@student.com'
8.select 'North Carolina State University' from user institution
9.click 'Create' button.
10.visit list of pending requests from users
11.Requested user's status is first 'Under Review'
12.Set status as Approved or Rejected
13.click on 'Submit' button


-- result x test cases passed image --

Code Snippet

Resetting Password

When the user tries to login, and the password entered is wrong, the user is redirected to reset password page.

Here the email-id entered is searched through the database, If such user account is found: url for reset is generated, with random token set as password is sent to the user.

Files associated with this functionality:

  1. spec/controllers/PasswordRetrievalController
  2. app/controllers/PasswordRetrievalController
  3. app/mailers/mailer.rb
  4. app/helper/mailer_helper.rb

Flowchart:

Cases Tested

  1. User enters email id which is not associated with any account

No e-mail should be sent

  1. User enters email id that's present in the user database

The following features were checked inside 'it blocks' as part of verifying email functionality
1. Mail delivery count increased by 1 after the mail triggered by the scenario is sent
2. The sender mail-id is verified to be 'expertiza.development@gmail.com'
3. Receiver email id is checked to be equal to 'expertiza.development@gmail.com' . Since all mails triggered have a record in 'expertiza.development@gmail.com' when executed in test environment.
4. The subject is checked to be equal to 'Expertiza password reset'

Outcome

We used Capybara to model the scenario with following steps:
1. visit expertiza home page
2. click 'Forgot password?' link
3. after rediection to password retrieval page
4. fill in user email field with 'expertiza@mailinator.com'
5. click on 'Request password' button

-- result x test cases passed image --

Code Snippet

Fixing out of scope bugs

Account Creation

What we fixed

Outcome

Code Snippet

Author Review

What we fixed

Outcome

Code Snippet

Developed By

  1. Mohit Jain(mentor)
  2. Vishva Shah (vpshah@ncsu.edu)
  3. Urvish Vasani (uvasani@ncsu.edu)
  4. Tanvi Pandit(tmpandi2@ncsu.edu)
  5. Swathi Dinakaran(sdinaka@ncsu.edu)

References

Demo link

Expertiza on GitHub click here

To visit our forked repo, click here

View our pull request here