CSC/CSC 517 Fall 2016/oss E1667
About Expertiza
Expertiza is an open source application developed on the Ruby on Rails framework. It allows instructors to create assignments, set deadlines and give grades to the assignments. In this application, students can submit their assignments by providing links to their sites or repositories or upload files and folders. The students can also review assignments submitted by their peers.
Problem Statement
Goal: The aim of the project was to write a feature test that mocks the Heat Map that a student views for an assignment of his. The following tasks were performed to accomplish the goal:
- Understanding the flow of the creation of Assignment by instructor.
- Understanding the flow of the submission of an assignment by a student and then the flow of submitting reviews to an assignment uploaded by a student.
- Understanding the flow of viewing the Heat Map related to an assignment by a student.
- Mock the above steps using capybara.
Project Links
- Github repo Github repo
- [ Expertiza pull request]
Instructions for Reviewer
Clone the reopsitory
git clone (repository URL)
Repository URL can be found by visiting this Github repo.
Installing Gems (ruby dependencies)
Go to your cloned expertiza directory in terminal and run the following command:
bundle install
Setting up the databses
- Run the Expertiza database migrations. This should populate your database with the current tables of the schema.
rake db:migrate
Running the tests
- Go to your cloned expertiza directory and run the following command for the tests:
rspec spec/features/heat_map_spec.rb
Note : Travis CI build fails because we are directly using the development database for our tests, thus Travis CI is not able to locate the login information. This was done because it was not possible to create factories or fixtures for our tests. So, please don’t consider the build failure in the pull request to be a valid error.
Classes Involved
The heat_map_spce.rb contains the feature tests written to test the creation of the assignment. The rails_helper is copied to spec/ when you run 'rails generate rspec:install'. All the rspec-expectations config goes into the spec_helper_file. We have used Capybara and RSpec to test our application. Capybara helps you test web applications by simulating how a real user would interact with your app. One of the major reasons for selecting Capybara to write our tests was that it has an intuitive API which mimics the language an actual user would use and also we can run tests from fast headless mode to an actual browser with no changes to our tests.
Flow of our test
Code
heat_map_spec.rb
require 'rails_helper' describe "HeatMapTest", type: :feature do
before(:each) do
create(:assignment, name: "TestAssignment", directory_path: 'test_assignment')
create_list(:participant, 3)
create(:assignment_node)
create(:deadline_type, name: "submission")
create(:deadline_type, name: "review")
create(:deadline_type, name: "metareview")
create(:deadline_type, name: "drop_topic")
create(:deadline_type, name: "signup")
create(:deadline_type, name: "team_formation")
create(:deadline_right)
create(:deadline_right, name: 'Late')
create(:deadline_right, name: 'OK')
create(:assignment_due_date, deadline_type: DeadlineType.where(name: 'review').first, due_at: Time.now + (100 * 24 * 60 * 60))
create(:topic)
create(:topic, topic_name: "TestReview")
create(:team_user, user: User.where(role_id: 2).first)
create(:team_user, user: User.where(role_id: 2).second)
create(:assignment_team)
create(:team_user, user: User.where(role_id: 2).third, team: AssignmentTeam.second)
create(:signed_up_team)
create(:signed_up_team, team_id: 2, topic: SignUpTopic.second)
create(:assignment_questionnaire)
create(:question)
#create(:review_response_map, reviewer_id: User.where(role_id: 2).third.id)
#create(:review_response_map, reviewer_id: User.where(role_id: 2).second.id, reviewee: AssignmentTeam.second)
#create(:response, additional_comment:'Round 1 - Good job', round:1)
#create(:response, additional_comment:'Round 2 - not so good job', round:2)
#sleep(100)
end
def createReviews
user = User.find_by_name("student2066")
stub_current_user(user, user.role.name, user.role)
visit '/student_task/list'
expect(page).to have_content "User: student2066"
expect(page).to have_content "TestAssignment"
click_link "TestAssignment"
expect(page).to have_content "Submit or Review work for TestAssignment"
click_link('Your work')
expect(page).to have_content "Submit work"
fill_in "submission", with: "https://www.idonothing.com"
expect(page).to have_content "Submit work"
click_button('Upload link')
user = User.find_by_name("student2065")
stub_current_user(user, user.role.name, user.role)
visit '/student_task/list'
expect(page).to have_content "User: student2065"
expect(page).to have_content "TestAssignment"
click_link "TestAssignment"
expect(page).to have_content "Submit or Review work for TestAssignment"
expect(page).to have_content "Others' work"
click_link "Others' work"
expect(page).to have_content 'Reviews for "TestAssignment"'
choose "topic_id"
click_button "Request a new submission to review"
click_link "Begin"
fill_in "responses[0][comment]", with: "HelloWorld"
select 5, from: "responses[0][score]"
fill_in "review[comments]", with: "Excellent work done!"
click_button "Submit Review"
expect(page).to have_content 'Your response was successfully saved.'
user = User.find_by_name("student2064")
stub_current_user(user, user.role.name, user.role)
visit '/student_task/list'
expect(page).to have_content "User: student2064"
expect(page).to have_content "TestAssignment"
click_link "TestAssignment"
expect(page).to have_content "Submit or Review work for TestAssignment"
expect(page).to have_content "Others' work"
click_link "Others' work"
expect(page).to have_content 'Reviews for "TestAssignment"'
choose "topic_id"
click_button "Request a new submission to review"
click_link "Begin"
fill_in "responses[0][comment]", with: "HelloWorld"
select 5, from: "responses[0][score]"
fill_in "review[comments]", with: "Excellent work done!"
click_button "Submit Review"
expect(page).to have_content 'Your response was successfully saved.'
end
def load_questionnaire
user = User.find_by_name("student2066")
stub_current_user(user, user.role.name, user.role)
visit '/student_task/list'
expect(page).to have_content "User: student2066"
expect(page).to have_content "TestAssignment"
click_link "TestAssignment"
expect(page).to have_content "Submit or Review work for TestAssignment"
expect(page).to have_content "Others' work"
click_link "Alternate View"
end
xit "Loads Heat Map page" do
load_questionnaire
expect(page).to have_content "Summary Report for assignment"
end
it "See submitted review in the page" do
createReviews
load_questionnaire
expect(page).to have_content "Review 1"
end
end
