CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time

From Expertiza_Wiki
Jump to navigation Jump to search

About Expertiza

Expertiza is a Ruby on Rails based open source project that allows users to submit a variety of document types, including URLs and wiki pages. It allows the instructor to create and customize new or existing assignments as well as a list of topics for which students can sign up. Expertiza allows students to form groups to work on various projects and assignments. It also allows students to peer review the work of other students.

Project Description

Expertiza has Assignment objects, which represent an assignment that is done by a number of users. For some assignments, students need to select a topic before submitting work. For deleting a topic, there is a checkbox beside each topic that can be selected and then the instructor or TA can delete the selected topics from the assignment. The feature needs to be tested thoroughly for various scenarios where different kinds of flags for the assignment are checked like staggered deadline, private assignment, micro task assignment. Also, we need to test the feature when all topics are deleted, some topics are deleted and only one topic is deleted.

Team Members

Divyang Doshi Hardik Udeshi Shlok Sayani

Files Involved

spec/controllers/sign_up_sheet_controller_spec.rb

Running test cases

run the command :- rspec spec/controllers/sign_up_sheet_controller_spec.rb

Testing scenarios

  1. When the assignment is a microtask and all other flags are False.
    1. Testing deleting all topics for microtask assignment. We test the delete all functionality by creating few topics associated with a microtask assignment and then do a post request on delete_all_selected_topics. We then expect the number of topics related to this assignment should be 0. We also assert that redirect to edit assignment page is successful after deletion of topics.
    2.     it 'delete_all_selected_topics for a microtask assignment and redirects to edit assignment page with single topic selected' do
            create(:topic, id: 6000, assignment_id: 6000, topic_identifier: 'topic6000')
            params = {assignment_id: 6000, topic_ids: ['topic6000']}
            post :delete_all_selected_topics, params
            expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
            topics_exist = SignUpTopic.where(assignment_id: 6000).count
            expect(topics_exist).to be_eql 0
            expect(response).to redirect_to('/assignments/6000/edit#tabs-2')
          end
      
    3. Testing deleting multiple topics for microtask assignment. We test the delete multiple functionality by creating few topics associated with a microtask assignment and then do a post request on delete_all_selected_topics. We then expect the number of topics related to this assignment should be number of topics created - number of topics deleted. We also assert that redirect to edit assignment page is successful after deletion of topics.
    4.     it 'delete_all_selected_topics for not microtask assignment and redirects to edit assignment page with multiple topic selected' do
            create(:topic, id: 6000, assignment_id: 7000, topic_identifier: 'topic6000')
            create(:topic, id: 7000, assignment_id: 7000, topic_identifier: 'topic7000')
            create(:topic, id: 8000, assignment_id: 7000, topic_identifier: 'topic8000')
            params = {assignment_id: 7000, topic_ids: ['topic6000', 'topic7000']}
            post :delete_all_selected_topics, params
            expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
            topics_exist = SignUpTopic.where(assignment_id: 7000).count
            expect(topics_exist).to be_eql 1
            expect(response).to redirect_to('/assignments/7000/edit#tabs-2')
      
            params = {assignment_id: 7000, topic_ids: ['topic8000']}
            post :delete_all_selected_topics, params
            expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
            topics_exist = SignUpTopic.where(assignment_id: 7000).count
            expect(topics_exist).to be_eql 0
            expect(response).to redirect_to('/assignments/7000/edit#tabs-2')
          end
      
  2. When the assignment is a staggered deadline and microtask and private flags are False.
    1. Deleting single topic of staggered deadline assignments. We first create a topic that is to be deleted afterward. Then, assign this topic to a staggered deadline assignment. Then, we pass this topic to delete_all_selected_topics. As of now, this topic needs to be deleted by the method, we fire a query to check the topic with the same topic_id exists in the database or not. If it is successfully deleted, the count should be returned 0 by the query. We also assert that redirect to edit assignment page is successful after deletion of topics.
    2.     it 'create topic and delete_all_selected_topics for a staggered deadline assignment and redirects to edit assignment page with single topic selected' do
            create(:topic, id: 40, assignment_id: 40, topic_identifier: 'E1733')
            params = {assignment_id: 40, topic_ids: ['E1733']}
            post :delete_all_selected_topics, params
            expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
            topics_exist = SignUpTopic.where(assignment_id: 40).count
            expect(topics_exist).to be_eql 0
            expect(response).to redirect_to('/assignments/40/edit#tabs-2')
          end
      
    3. Deleting multiple topics of staggered deadline assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a staggered deadline assignment. Then, we pass these topics multiple at a time to the delete_all_selected_topics method. As of now, these topics need to be deleted by the method, we fire a query to check the topics with the same topic_ids exist in the database or not. If it is successfully deleted, the count should be returned with the topic remaining by the query. We also assert that redirect to edit assignment page is successful after deletion of topics.
    4.     it 'create topic and delete_all_selected_topics for a staggered deadline assignment and redirects to edit assignment page with multiple topic selected' do
            create(:topic, id: 30, assignment_id: 40, topic_identifier: 'E1735')
            create(:topic, id: 40, assignment_id: 40, topic_identifier: 'E1736')
            create(:topic, id: 50, assignment_id: 40, topic_identifier: 'E1737')
            create(:topic, id: 60, assignment_id: 40, topic_identifier: 'E1738')
            create(:topic, id: 70, assignment_id: 40, topic_identifier: 'E1739')
            params = {assignment_id: 40, topic_ids: ['E1735', 'E1736']}
            post :delete_all_selected_topics, params
            expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
            topics_exist = SignUpTopic.where(assignment_id: 40).count
            expect(topics_exist).to be_eql 3
            expect(response).to redirect_to('/assignments/40/edit#tabs-2')
      
            params = {assignment_id: 40, topic_ids: ['E1737', 'E1738']}
            post :delete_all_selected_topics, params
            expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
            topics_exist = SignUpTopic.where(assignment_id: 40).count
            expect(topics_exist).to be_eql 1
            expect(response).to redirect_to('/assignments/40/edit#tabs-2')
      
            params = {assignment_id: 40, topic_ids: ['E1739']}
            post :delete_all_selected_topics, params
            expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
            topics_exist = SignUpTopic.where(assignment_id: 40).count
            expect(topics_exist).to be_eql 0
            expect(response).to redirect_to('/assignments/40/edit#tabs-2')
          end
      
    5. Deleting all topics of staggered deadline assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a staggered deadline assignment. Then, we pass these topics all at a time to the delete_all_topics_for_assignment method. As of now, these topics need to be deleted by the method, we fire a query to check the topics with the same topic_ids exist in the database or not. If it is successfully deleted, the count should be returned with 0 by the query. We also assert that redirect to edit assignment page is successful after deletion of topics.
    6.     it 'deletes all topics for the staggered deadline assignment and redirects to edit assignment page' do
            create(:topic, id: 30, assignment_id: 40, topic_identifier: 'E1740')
            create(:topic, id: 40, assignment_id: 40, topic_identifier: 'E1741')
            create(:topic, id: 50, assignment_id: 40, topic_identifier: 'E1742')
            params = {assignment_id: 40}
            post :delete_all_topics_for_assignment, params
            topics_exist = SignUpTopic.where(assignment_id: 40).count
            expect(topics_exist).to be_eql 0
            expect(flash[:success]).to eq('All topics have been deleted successfully.')
            expect(response).to redirect_to('/assignments/40/edit')
          end
      
  3. When the assignment is a non-staggered deadline and microtask and private flags are True.
    1. Deleting single topic of non-staggered deadline assignments. We first create a topic that is to be deleted afterward. Then, assign this topic to a non-staggered deadline assignment. Then, we pass this topic to delete_all_selected_topics. As of now, this topic needs to be deleted by the method, we fire a query to check the topic with the same topic_id exists in the database or not. If it is successfully deleted, the count should be returned 0 by the query. We also assert that redirect to edit assignment page is successful after deletion of topics.
    2.     it 'create topic and delete_all_selected_topics for not a staggered deadline assignment and redirects to edit assignment page with single topic selected' do
            create(:topic, id: 30, assignment_id: 30, topic_identifier: 'E1734')
            params = {assignment_id: 30, topic_ids: ['E1734']}
            post :delete_all_selected_topics, params
            expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
            topics_exist = SignUpTopic.where(assignment_id: 30).count
            expect(topics_exist).to be_eql 0
            expect(response).to redirect_to('/assignments/30/edit#tabs-2')
          end
      

Test Results

Repository Link