CSC/ECE 517 Spring 2017/E1724: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:


Expertiza is an open source web application project based on Ruby on Rails framework. It provides an online interactive platform for instructors to post and grade assignments, and for students to contribute to team-based projects as well as individual assignments.
Expertiza is an open source web application project based on Ruby on Rails framework. It provides an online interactive platform for instructors to post and grade assignments, and for students to contribute to team-based projects as well as individual assignments.
'''Problem Statement'''
Remove duplicated code in feature tests and improve the overall Code Climate.
'''Refactoring Delayed_mailer Method'''
Delayed_mailer_spec method covers testing scenarios with the email reminder feature targeting various users and tasks.
These methods were taking timestamps using time_parse, which would create issues when users change their time zones. Calling time_zone_parse instead of time_parse solves the issue.
These method were and involved with massive similar code. Helper methods enqueue_delayed_job(stage) and enqueue_scheduled_tasks(stage) are used to modularize the same repetitive tasks being performed.
After refactoring using these methods:
In delayed_mailer_spec.rb:
def enqueue_delayed_job(stage)
#enqueue a delayed job using current stage’s timestamp
end
describe '<stage> deadline reminder email' do
                it 'is able to send reminder email for <stage> deadline to <stage_users> ' do
    enqueue_delayed_job(stage)
    expect(Delayed::Job.count).to eq(1)
                expect(Delayed::Job.last.handler).to include("deadline_type: <stage>")
                end
end

Revision as of 15:17, 23 March 2017

E1724 - Refactoring Feature Tests

About Expertiza

Expertiza is an open source web application project based on Ruby on Rails framework. It provides an online interactive platform for instructors to post and grade assignments, and for students to contribute to team-based projects as well as individual assignments.

Problem Statement

Remove duplicated code in feature tests and improve the overall Code Climate.

Refactoring Delayed_mailer Method

Delayed_mailer_spec method covers testing scenarios with the email reminder feature targeting various users and tasks. These methods were taking timestamps using time_parse, which would create issues when users change their time zones. Calling time_zone_parse instead of time_parse solves the issue. These method were and involved with massive similar code. Helper methods enqueue_delayed_job(stage) and enqueue_scheduled_tasks(stage) are used to modularize the same repetitive tasks being performed.

After refactoring using these methods: In delayed_mailer_spec.rb: def enqueue_delayed_job(stage) #enqueue a delayed job using current stage’s timestamp end

describe '<stage> deadline reminder email' do

               it 'is able to send reminder email for <stage> deadline to <stage_users> ' do
   enqueue_delayed_job(stage)
   expect(Delayed::Job.count).to eq(1)
               expect(Delayed::Job.last.handler).to include("deadline_type: <stage>")
               end

end