CSC/ECE 517 Fall 2022 - E2273.Refactor delayed mailer.rb and scheduled task.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 40: Line 40:
  * '''Proposed Solution''': Add more tests to increase test coverage.
  * '''Proposed Solution''': Add more tests to increase test coverage.
  * '''Solution Implemented''': Added the following tests:
  * '''Solution Implemented''': Added the following tests:
1. Test to check an email is not sent when there is deadline with outstanding reviews.
1. Test to check an email is not sent when there is deadline with outstanding reviews.



Revision as of 23:23, 16 November 2022

Background

Expertiza uses Sidekiq gem for asynchronous processing of email tasks. It has a queue system to hold and then process jobs. Sidekiq’s queue replaces DelayedMailer’s queue. The previous team that worked on this also created a method perform() to gather email IDs of all participants in an assignment and send them an email reminder. Some test cases exist for this work.

History: Previous projects

* E2253 [1]
* E2144 [2]

About Assignment Controller

This class is responsible for the creation and implementation of assignment forms. This includes due dates, questionnaires and assigning reviews.

Previous Information can be found here E2144

Files Involved (some changed should not have been changed):

  • app/controllers/assignments_controller.rb
  • app/mailers/mail_worker.rb
  • app/models/assignment_form.rb
  • config/sidekiq.yml
  • spec/models/assignment_form_spec.rb
  • spec/sidekiq_mail_worker_spec.rb
  • spec/spec_helper.rb

Problems and planned changes

We are planning to accomplish the following tasks in this project:

Problem 1: Add insightful comments to the methods in mail_worker.rb

* Proposed Solution: Add insightful comments to each method.

Problem 2: Fix Bugs in sidekiq_mail_worker_spec.rb

* Proposed Solution: Comment out or Fix the failing existing tests.

Problem 3: Increase the test coverage for sidekiq_mail_worker_spec.rb

* Proposed Solution: Add more tests to increase test coverage.
* Solution Implemented: Added the following tests:

1. Test to check an email is not sent when there is deadline with outstanding reviews.

it "should not return email if deadline is drop_outstanding_reviews" do
      Sidekiq::Testing.inline!
      Mailer.deliveries.clear
      worker = MailWorker.new
      worker.perform("1", "drop_outstanding_reviews", "2018-12-31 00:00:01")
      expect(Mailer.deliveries.size).to eq(0)
end

Test Plan

Automated Testing using RSPEC

The current version of expertiza included tests for the assignments_form and the mail_worker, but they were far from extensive. Thus we added a few tests of our own.

To run the tests, run the following commands from the expertiza directory

rspec ./spec/workers/sidekiq_mail_worker_spec.rb

Testing from UI

No changes were made to the functionality of the project, however you can access it through the setup below.

To Test via UI

1) Login with the login above

2) Click on Manage...

3) Click on Assignments

4) On the right side click the +

5) Once you've added a name, scroll to the bottom and click create

6) Repeat steps 2 and 3, to view the assignment added to the list

References

  1. Expertiza on GitHub
  2. GitHub Project Repository Fork
  3. E2273 Pull Request
  4. The live Expertiza website