CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(51 intermediate revisions by 4 users not shown)
Line 10: Line 10:


== '''Problem Statement''' ==
== '''Problem Statement''' ==
Our files to be modified are: app/views/mailer/suggested_topic_approved_message.html.erb, suggestion_controller_spec.rb
Our files to be modified are:  
* app/views/mailer/suggested_topic_approved_message.html.erb
* spec/features/topic_suggestion2_spec.rb


The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team.  
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team.  
Line 28: Line 30:


=== Docker ===
=== Docker ===
The Docker has been set up on a Windows PC and steps are given below
<pre>
Start Docker on Windows
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016
/etc/init.d/mysql start 
mysql -uroot -p         
show databases; 
quit
git clone https://github.com/srikarpotta/expertiza.git
cd expertiza
cp config/database.yml.example config/database.yml
cp config/secrets.yml.example config/secrets.yml
bundle install
rake db:migrate
sudo apt-get install npm
npm install -g bower
sudo rm /usr/bin/node
sudo ln –s /usr/bin/nodejs /usr/bin/node
bower install --allow-root
thin start
</pre>


=== On a Local Machine ===
=== On a Local Machine ===
We have used MacOS, so the following steps are in regard to MacOS.
We have used MacOS, so the following steps are in regard to MacOS.
The following steps will help you setup Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:
 
<pre>
#Fork the git repository mentioned above
 
#Clone the repository to your local machine
Install [http://brew.sh/ Homebrew]
 
#Install RBENV
brew update
brew install rbenv
brew install ruby-build
 
#Install dependencies
brew install aspell gcc47 libxml2 libxslt graphviz
 
#Install gems
export JAVA_HOME=/etc/alternatives/java_sdk
bundle install
 
#Change yml files
 
#Go to expertiza/config and rename secrets.yml.example to secrets.yml
 
#Go to expertiza/config and rename database.yml.example to database.yml
 
#Edit database.yml to include the root password for your local MySQL in the “password” field
 
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6)
 
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)
mysql -uroot -p
 
#Create expertiza user
create user expertiza@localhost;
 
#Create the databases
create database pg_development;
create database pg_test;
 
#Set privileges for expertiza user
grant all on pg_development.to expertiza@localhost;
grant all on pg_test.to expertiza@localhost;
 
#Install javascript libraries
sudo apt-get install npm
sudo npm install bower
bower install
 
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view)
 
#Load this sql file into pg_development database created using the method mentioned here.
 
#Run bundle exec rake db:migrate
 
#Run bundle exec rake db:test:prepare
 
#Run rails s
 
#Open browser and test localhost:3000
 
#Login credentials
Username - instructor6
Password - password


* Fork the git repository mentioned above
</pre>
* Clone the repository to your local machine
* Install [http://brew.sh/ Homebrew]
* Install RBENV
** brew update
** brew install rbenv
** brew install ruby-build
* Install dependencies
** brew install aspell gcc47 libxml2 libxslt graphviz
* Install gems
** export JAVA_HOME=/etc/alternatives/java_sdk
** bundle install
* Change yml files
** Go to expertiza/config and rename secrets.yml.example to secrets.yml
** Go to expertiza/config and rename database.yml.example to database.yml
** Edit database.yml to include the root password for your local MySQL in the “password” field
* Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6)
* Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)
** mysql -uroot -p
* Create expertiza user
** create user expertiza@localhost;
* Create the databases
** create database pg_development;
** create database pg_test;
* Set privileges for expertiza user
** grant all on pg_development.* to expertiza@localhost;
** grant all on pg_test.* to expertiza@localhost;
* Install javascript libraries
** sudo apt-get install npm
** sudo npm install bower
** bower install
* Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view)
* Load this sql file into pg_development database created using the method mentioned here.
* Run bundle exec rake db:migrate
* Run bundle exec rake db:test:prepare
* Run rails s
* Open browser and test localhost:3000
* Login credentials
** Username - instructor6
** Password - password


== '''Our Implementation''' ==
== '''Our Implementation''' ==
There weren't any test cases before and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax.  
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax.
 
==='''Refactoring''' ===
Refactoring that was done for this project is:
* There were lot of trailing spaces in the code, which are removed.
* Few lines were too long and one had to scroll right to go through that line. This was taken care of as shown below.
[[File:Oss_1.PNG]]
* We have edited the flash messages making them more intuitive. Also, the subject of the email that is sent has been modified to keep it more self-explanatory.
* An unused method, "confirm_save" has been removed.
* Comments were added for future readability.
 
Note that there was nothing more in terms of refactoring, as the code has been already refactored.
 
=== '''Email functionality''' ===
The email functionality which wasn't working before has been fixed. These are the cases considered:
Instructor starts a new assignment with some topics
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval.
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.
 
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification.
 
We have used the following accounts for testing:
<pre>
* Login ID - instructor6                Password - password
* Student1 ID - student5432            Password - password
* Student2 Id - student5404            Password - password
</pre>
 
The implementation can be seen in the video, where we covered few cases mentioned above.


=== '''Testing''' ===
=== '''Testing''' ===
Line 86: Line 171:
* Assignment 1
* Assignment 1


==== Scenario 1 ====
==== Scenario 1 - Check suggested topics====
Instructor6 logs in and visits assignment 1 to check suggested topics (currently empty)
This automatic test case checks the following steps:
* User (Instructor6) logins in.
* On successful login, the instructor clicks the tab for Suggestions list for a particular assignment (Assignment 1).
* On visiting that tab, a page with content "Suggested topics for Assignment 1" is rendered with the topic name. 


<pre>
<pre>
Line 101: Line 189:
</pre>
</pre>


==== Scenario 2 ====
==== Scenario 2 - New Suggestion====
 
We have considered Student2064 for this case. We test for all the following cases:
* Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying "Thank you for your suggestion! Suggested topics for Assignment 1, "Topic title" initiated",  should be rendered.
* And if view is clicked, a page with the content "View Suggested topic Computer Vision" is displayed.
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.
* Blank comment - In case a blank comment is added, an error should be generated.
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description.


Student2064 logs in -> Visits on Assignment 1 -> Clicks on new suggestion -> Submits new topic called “Computer Vision” -> Checks submission is successful -> Adds comment -> Submits comment -> Checks successful submission of comment -> Tries submitting blank comment -> Checks unsuccessful submission of blank comment -> Tries editing suggestion title and suggestion description -> Checks edit is successful -> Logs out successfully
<pre>
<pre>
# Create new suggestion (Computer Vision)
# Create new suggestion (Computer Vision)
Line 140: Line 234:
</pre>
</pre>


==== Scenario 3 - Suggestion Accepted====
This scenario accounts for the testing the following:
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1.
* Instructor6 logs in and checks on Assignment 1.
* After logging in, instructor checks that “Computer Vision” is submitted by student2064
* Also the comment by the student can be viewed.
* After looking at the topic, the instructor approves the suggestion.
* Then, when the Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.
==== Scenario 4 - Suggestion Rejected====
The steps mentioned below are tested in this scenario:
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1.
* The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 for Assignment 1.
* After checking the comment by student2064, Instructor6 rejects the suggestion.
* The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.
==== Scenario 5 - Suggestion Voted ====
This scenario accounts for testing the following steps:
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1.
* Instructor6 logs in and should be able to check that “Computer Vision” is submitted by student2064 for Assignment 1.
* After checking the comment by student2064, Instructor votes for the suggestion.
* Then the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.


Other scenarios that were tested are given below
==== Scenario 6 - Suggestion with no Signup approved ====
The scenario comprises of testing the following steps:
* The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic.
* After suggesting, the student selects “No” for suggestion signup preference and submits suggestion.
* The Instructor6 logs in, visits Assignment 1 suggestions to approve the suggestion “Computer Vision”.
* On approving the suggestion, a page saying "suggestion approved successfully" is rendered for the instructor.


==== Scenario 3 ====
=== Why these scenarios? ===
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -> Instructor6 logs in and checks on Assignment 1 -> Checks that “Computer Vision” is submitted by student2064 -> Checks comment by student2064 -> Instructor6 approves the suggestion -> Student2064 logs in -> Visits Assignment 1 ->
Checks suggestion “Computer Vision” is accepted


==== Scenario 4 ====
The scenarios are carefully designed to fulfill the following criteria:
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -> Instructor6 logs in and checks on Assignment 1 -> Checks that “Computer Vision” is submitted by student2064 -> Checks comment by student2064 -> Instructor6 rejects the suggestion -> Student2064 logs in -> Visits Assignment 1 -> Checks suggestion “Computer Vision” is rejected
*Test the integration of core functionalities of suggestion controller
*Have maximum code coverage
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb


==== Scenario 5 ====
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 ->Instructor6 logs in and checks on Assignment 1 -> Checks that “Computer Vision” is submitted by student2064 -> Checks comment by student2064  -> Instructor votes for the suggestion  -> Student2064 logs in -> Visits Assignment 1 -> Checks Instructor6 has voted for the suggestion


=== Scenario 6 ===
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''


Student2064 logs in and visits Assignment 1 -> Suggests “Computer Vision” -> Select “No” for suggestion signup preference -> Submits suggestion -> Instructor6 logs in and visits Assignment 1 suggestions -> Approves suggestion “Computer Vision” -> Checks suggestion approved successfully


=== Why these scenarios? ===
=== Working in UI ===
The steps are given as follows:
# Sign in Expertiza using the instructor account (login credentials mentioned above)
# Go to Manage tab, then click Assignments, and click New Public Assignment
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course
# Login from student credentials (mentioned earlier) and go to the assignment that was created
# Either sign up for the topic or suggest a new one directly
# Now to instructor account and view suggestions against the assignment created
# The instructor can approve or decline
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved.


The scenarios are carefully designed to fulfil the following criteria:
This can be verified through the uploaded videos on [https://www.youtube.com/watch?v=TOhofFEjgcM&feature=youtu.be tests] and [https://vimeo.com/190331266 functioning].
Test the integration of core functionalities of suggestion controller
Have maximum code coverage
Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb


== Conclusions ==
== Conclusions ==
Line 175: Line 300:
=== What’s next? ===
=== What’s next? ===


“Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.” - Edsger Dijkstra
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra
 
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.

Latest revision as of 02:26, 11 December 2016

E1643. Refactor and Test Suggestion Controller

This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.

Introduction

Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.

Motivation

This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.

Problem Statement

Our files to be modified are:

  • app/views/mailer/suggested_topic_approved_message.html.erb
  • spec/features/topic_suggestion2_spec.rb

The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team.

Our problem statement includes:

1. Modifying the code in accordance to rails 4 syntax

2. Send email code which was duplicated needs to be replaced by a single method

3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)

4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)

Setup

Before starting off with working on the Expertiza project, we need to fork the existing code from expertiza/master branch. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.

Docker

The Docker has been set up on a Windows PC and steps are given below


Start Docker on Windows

docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016

/etc/init.d/mysql start   
mysql -uroot -p           
show databases;  
quit

git clone https://github.com/srikarpotta/expertiza.git
cd expertiza
cp config/database.yml.example config/database.yml
cp config/secrets.yml.example config/secrets.yml

bundle install
rake db:migrate
sudo apt-get install npm
npm install -g bower

sudo rm /usr/bin/node
sudo ln –s /usr/bin/nodejs /usr/bin/node
bower install --allow-root
thin start

On a Local Machine

We have used MacOS, so the following steps are in regard to MacOS. The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in Development Setup, the documentprovided and also few steps that were missed in both. The order we followed:

#Fork the git repository mentioned above

#Clone the repository to your local machine
Install [http://brew.sh/ Homebrew]

#Install RBENV
brew update
brew install rbenv
brew install ruby-build

#Install dependencies
brew install aspell gcc47 libxml2 libxslt graphviz

#Install gems
export JAVA_HOME=/etc/alternatives/java_sdk
bundle install

#Change yml files

#Go to expertiza/config and rename secrets.yml.example to secrets.yml

#Go to expertiza/config and rename database.yml.example to database.yml

#Edit database.yml to include the root password for your local MySQL in the “password” field

#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) 

#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)
mysql -uroot -p

#Create expertiza user
create user expertiza@localhost;

#Create the databases
create database pg_development;
create database pg_test;

#Set privileges for expertiza user
grant all on pg_development.to expertiza@localhost;
grant all on pg_test.to expertiza@localhost;

#Install javascript libraries
sudo apt-get install npm
sudo npm install bower
bower install

#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) 

#Load this sql file into pg_development database created using the method mentioned here.

#Run bundle exec rake db:migrate

#Run bundle exec rake db:test:prepare

#Run rails s

#Open browser and test localhost:3000

#Login credentials
Username - instructor6
Password - password

Our Implementation

There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax.

Refactoring

Refactoring that was done for this project is:

  • There were lot of trailing spaces in the code, which are removed.
  • Few lines were too long and one had to scroll right to go through that line. This was taken care of as shown below.

  • We have edited the flash messages making them more intuitive. Also, the subject of the email that is sent has been modified to keep it more self-explanatory.
  • An unused method, "confirm_save" has been removed.
  • Comments were added for future readability.

Note that there was nothing more in terms of refactoring, as the code has been already refactored.

Email functionality

The email functionality which wasn't working before has been fixed. These are the cases considered: Instructor starts a new assignment with some topics

  • Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.
  • Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval.
  • It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.
  • A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.

Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification.

We have used the following accounts for testing:

* Login ID - instructor6                Password - password
* Student1 ID - student5432             Password - password
* Student2 Id - student5404             Password - password

The implementation can be seen in the video, where we covered few cases mentioned above.

Testing

We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found here.

Prerequisite

All the scenarios uses the following:

  • Instructor6
  • Student2064
  • Assignment 1

Scenario 1 - Check suggested topics

This automatic test case checks the following steps:

  • User (Instructor6) logins in.
  • On successful login, the instructor clicks the tab for Suggestions list for a particular assignment (Assignment 1).
  • On visiting that tab, a page with content "Suggested topics for Assignment 1" is rendered with the topic name.

scenario "allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1" do	
   user = User.find_by_name('instructor6')
   stub_current_user(user, user.role.name, user.role)
   visit '/suggestion/list?id=1&type=Assignment'
   expect(page).to have_content "Suggested topics for Assignment 1" 
   expect(page).to have_no_content "Computer Vision"	
end

Scenario 2 - New Suggestion

We have considered Student2064 for this case. We test for all the following cases:

  • Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying "Thank you for your suggestion! Suggested topics for Assignment 1, "Topic title" initiated", should be rendered.
  • And if view is clicked, a page with the content "View Suggested topic Computer Vision" is displayed.
  • Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.
  • Blank comment - In case a blank comment is added, an error should be generated.
  • Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description.
# Create new suggestion (Computer Vision)
fill_in 'suggestion_title', with: 'Computer Vision'
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'
select "N", :from => "suggestion_signup_preference"
click_button 'Submit'
expect(page).to have_content "Thank you for your suggestion!"
expect(page).to have_content "Suggested topics for Assignment 1"	
expect(page).to have_content "Computer Vision"	
expect(page).to have_content "Initiated"	
		
# View the suggestion
find_link('View').click
expect(page).to have_content "View Suggested topic Computer Vision"

# Add comment
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'
click_button 'Submit comment'
expect(page).to have_content "Your comment has been successfully added."
expect(page).to have_content "Student2064 commenting on Computer Vision"

# Try adding blank comment
click_button 'Submit comment'
expect(page).to have_content "There was an error adding your comment."

# Edit title and description
find_link('Edit').click
expect(page).to have_content "Edit Suggested topic Computer Vision"
fill_in 'suggestion_title', with: 'Computer Vision 2'
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'
select "Y", :from => "suggestion_signup_preference"
click_button 'Submit'
expect(page).to have_content "Suggested topics for Assignment 1"
expect(page).to have_content "Computer Vision 2"	

Scenario 3 - Suggestion Accepted

This scenario accounts for the testing the following:

  • Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1.
  • Instructor6 logs in and checks on Assignment 1.
  • After logging in, instructor checks that “Computer Vision” is submitted by student2064
  • Also the comment by the student can be viewed.
  • After looking at the topic, the instructor approves the suggestion.
  • Then, when the Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.

Scenario 4 - Suggestion Rejected

The steps mentioned below are tested in this scenario:

  • Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1.
  • The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 for Assignment 1.
  • After checking the comment by student2064, Instructor6 rejects the suggestion.
  • The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.

Scenario 5 - Suggestion Voted

This scenario accounts for testing the following steps:

  • Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1.
  • Instructor6 logs in and should be able to check that “Computer Vision” is submitted by student2064 for Assignment 1.
  • After checking the comment by student2064, Instructor votes for the suggestion.
  • Then the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.

Scenario 6 - Suggestion with no Signup approved

The scenario comprises of testing the following steps:

  • The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic.
  • After suggesting, the student selects “No” for suggestion signup preference and submits suggestion.
  • The Instructor6 logs in, visits Assignment 1 suggestions to approve the suggestion “Computer Vision”.
  • On approving the suggestion, a page saying "suggestion approved successfully" is rendered for the instructor.

Why these scenarios?

The scenarios are carefully designed to fulfill the following criteria:

  • Test the integration of core functionalities of suggestion controller
  • Have maximum code coverage
  • Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb


' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. '


Working in UI

The steps are given as follows:

  1. Sign in Expertiza using the instructor account (login credentials mentioned above)
  2. Go to Manage tab, then click Assignments, and click New Public Assignment
  3. Give all the necessary details (Name of assignment, rubrics, due dates etc..) Do not forget to click on Allow students to suggest topic
  4. Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course
  5. Login from student credentials (mentioned earlier) and go to the assignment that was created
  6. Either sign up for the topic or suggest a new one directly
  7. Now to instructor account and view suggestions against the assignment created
  8. The instructor can approve or decline
  9. Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved.

This can be verified through the uploaded videos on tests and functioning.

Conclusions

What we learnt

  • How to read existing codebases
  • Understand other people’s code before contributing
  • Refactor existing code without breaking existing functionalities
  • Write integration test cases


What’s next?

Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.” - Edsger Dijkstra

Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.