CSC/ECE 517 Fall 2020 - E2059. Email notification to reviewers and instructors.rb

From Expertiza_Wiki
Jump to navigation Jump to search

This project is a contribution to the opensource project Experteiza which was built using Ruby on Rails. The project was created for North Carolina State University's CSC/ECE 517 course to introduce and expose students to a large open-source project. The web application is designed where students can submit and be peer-review various assignments.

Introduction

The purpose of this project is to improve and test the email handling systems in Experteiza. The project's primary goals are to solve the following issues; unreliable student email receipts, and unreliable instructor email notices. Expertiza is intended to send students email notices when they receive a project submission for review, when their own work is reviewed, or when their reviews are reviewed. However, this functionality has proven to be unreliable and inconsistent. Additionally, instructors are intended to receive email copies of all emails being sent from the system. This functionality is also inconsistent and unreliable. This issue aims to address these errors and the remainder of this page describes how this is accomplished.

Identified Tasks

The following are identified tasks to be accomplished for the project:

Email Queue Appropriate tests for the following:

  • Check queues to ensure that emails are being sent out.
  • Check to see that the recipient of this message is the correct recipient
  • Check to see that the body of the message has the correct content.

Instructor Email Notifier

  1. The .
  2. Appropriate tests instructor should be able to get copies of emails:
    • Rails message that queues the email to the instructor
    • Check to see that emails sent by the system are also sent to the professor.

Merge in PR1604 to address Issues

This pull request was the last attempt to address the changes made that are required to be tested above.

Currently Completed

  1. PR 1604 merged

Running Tests

  rspec spec/helpers/mailerhelper_spec.rb
  rspec spec/helpers/mailer_helper.rb


Implementation

All tests are written using rspec. A list of all files changed are found at the bottom of the report and the following section explains each test.

generic_message

This method is used to send a generic email to user by passing the email, subject and the contents of the message. The RSpec test for this method first creates an generic_message object and verifies if the correct parameters were passed. Then the next test was to test if the ActionMailer successfully sent the email using generic_email. This was done by using the ActionMailer::Base.deliveries to check the outbox of the ActionMailer and ensured the contents of the outbox mached that of the mailer.

Setup

```email = Mailer.generic_message(

     to: 'tluo@ncsu.edu',
     subject: "Test",
     body: {
       partial_name: "new_submission",
       user: "John Doe",
       first_name: "John",
       password: "Password",
       new_pct: 97,
       avg_pct: 90,
       assignment: "code assignment"
     }
   )```

Test ```it 'should be able to pass parameters to generic message' do

   # Send the email, then test that it got queued
   email = Mailer.generic_message(
     to: 'tluo@ncsu.edu',
     subject: "Test",
     body: {
       partial_name: "new_submission",
       user: "John Doe",
       first_name: "John",
       password: "Password",
       new_pct: 97,
       avg_pct: 90,
       assignment: "code assignment"
     }
   )
   expect(email.from[0]).to eq("expertiza.development@gmail.com")
   expect(email.to[0]).to eq('expertiza.development@gmail.com')
   expect(email.subject).to eq('Test')
 end
 it 'should be able to send an email using generic message' do
   ActionMailer::Base.deliveries.clear
   email = Mailer.generic_message(
     to: 'tluo@ncsu.edu',
     subject: "Test",
     body: {
       partial_name: "new_submission",
       user: "John Doe",
       first_name: "John",
       password: "Password",
       new_pct: 97,
       avg_pct: 90,
       assignment: "code assignment"
     }
   ).deliver_now
   ActionMailer::Base.deliveries.last.tap do |mail|
     expect(mail.from).to eq(["expertiza.development@gmail.com"])
     expect(mail.to).to eq(["expertiza.development@gmail.com"])
     expect(mail.subject).to eq("Test")
     expect(mail.body).to eq(email.body)
   end
 end```

request_user_message

Setup

Test

request_user_message

Setup

Test

notify_reviewer_for_new_submission

Setup

Test

sync_message

Setup

Test

suggested_topic_approved_message

Setup

Test

notify_grade_conflict_message

Setup

Test

Test Result

Team

Josh Beerel (jbeerel)

Joshua Horwitz (jahorwitz)

Anjaney C Mahajan (acmahaja)