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 several 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 the 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. Deleting all topics of microtask assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a microtask 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.
      2.     it 'deletes all topics for the microtask assignment and redirects to edit assignment page' do
              create(:topic, id: 6000, assignment_id: 6000)
              create(:topic, id: 7000, assignment_id: 6000)
              params = {assignment_id: 6000}
              post :delete_all_topics_for_assignment, params.merge(format: :html)
              topics_exist = SignUpTopic.where(assignment_id: 6000).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/6000/edit')
            end
        
      3. Deleting multiple topics of microtask assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a microtask 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 '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
        
      5. Deleting single topic of microtask assignments. We first create a topic that is to be deleted afterward. Then, assign this topic to a microtask 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.
      6.     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
        
    2. When the assignment is not microtask assignment and staggered and private flags are True.
      1. Deleting single topic of non-microtask assignments. We first create a topic that is to be deleted afterward. Then, assign this topic to a non-microtask 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 'delete_all_selected_topics for not microtask assignment and redirects to edit assignment page with single topic selected' do
              create(:topic, id: 6000, assignment_id: 7000, topic_identifier: 'topic6000')
              params = {assignment_id: 7000, 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: 7000).count
              expect(topics_exist).to be_eql 0
              expect(response).to redirect_to('/assignments/7000/edit#tabs-2')
            end
        
      3. Deleting multiple topics of non-microtask assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a non-microtask 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 '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
        
      5. Deleting all topics of non-microtask assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a non-microtask 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 not microtask assignment and redirects to edit assignment page' do
              create(:topic, id: 6000, assignment_id: 7000)
              create(:topic, id: 7000, assignment_id: 7000)
              params = {assignment_id: 7000}
              post :delete_all_topics_for_assignment, params.merge(format: :html)
              topics_exist = SignUpTopic.where(assignment_id: 7000).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/7000/edit')
            end
        
    3. 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
        
    4. 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
        
      3. Deleting multiple topics of non-staggered deadline assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a non-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 not a staggered deadline assignment and redirects to edit assignment page with multiple topic selected' do
              create(:topic, id: 30, assignment_id: 30, topic_identifier: 'E1735')
              create(:topic, id: 40, assignment_id: 30, topic_identifier: 'E1736')
              create(:topic, id: 50, assignment_id: 30, topic_identifier: 'E1737')
              create(:topic, id: 60, assignment_id: 30, topic_identifier: 'E1738')
              create(:topic, id: 70, assignment_id: 30, topic_identifier: 'E1739')
              params = {assignment_id: 30, 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: 30).count
              expect(topics_exist).to be_eql 3
              expect(response).to redirect_to('/assignments/30/edit#tabs-2')
        
              params = {assignment_id: 30, 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: 30).count
              expect(topics_exist).to be_eql 1
              expect(response).to redirect_to('/assignments/30/edit#tabs-2')
        
              params = {assignment_id: 30, 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: 30).count
              expect(topics_exist).to be_eql 0
              expect(response).to redirect_to('/assignments/30/edit#tabs-2')
            end
        
      5. Deleting all topics of non-staggered deadline assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a non-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 non-staggered deadline assignment and redirects to edit assignment page' do
              create(:topic, id: 30, assignment_id: 30, topic_identifier: 'E1740')
              create(:topic, id: 40, assignment_id: 30, topic_identifier: 'E1741')
              create(:topic, id: 50, assignment_id: 30, topic_identifier: 'E1742')
              params = {assignment_id: 30}
              post :delete_all_topics_for_assignment, params
              topics_exist = SignUpTopic.where(assignment_id: 30).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/30/edit')
            end
        


    5. When the assignment is private and other flags are False.
      1. Test deleting a single topic in private assignments. We first create a topic that is to be deleted afterwards. Then, assign this topic to a private 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 'delete_all_selected_topics for a private assignment and redirects to edit assignment page with single topic selected' do
              create(:topic, id: 2, assignment_id: 2, topic_identifier: 'topic2')
              params = {assignment_id: 2, topic_ids: ['topic2']}
              post :delete_all_selected_topics, params
              expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
              topics_exist = SignUpTopic.where(assignment_id: 2).count
              expect(topics_exist).to be_eql 0
              expect(response).to redirect_to('/assignments/2/edit#tabs-2')
            end
        
      3. Deleting multiple topics of private assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a private 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 'delete_all_selected_topics for a private assignment and redirects to edit assignment page with multiple topic selected' do
              create(:topic, id: 2, assignment_id: 2, topic_identifier: 'topic2')
              create(:topic, id: 3, assignment_id: 2, topic_identifier: 'topic3')
              create(:topic, id: 4, assignment_id: 2, topic_identifier: 'topic4')
              params = {assignment_id: 2, topic_ids: ['topic2', 'topic3']}
              post :delete_all_selected_topics, params
              expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
              topics_exist = SignUpTopic.where(assignment_id: 2).count
              expect(topics_exist).to be_eql 1
              expect(response).to redirect_to('/assignments/2/edit#tabs-2')
        
              params = {assignment_id: 2, topic_ids: ['topic4']}
              post :delete_all_selected_topics, params
              expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
              topics_exist = SignUpTopic.where(assignment_id: 2).count
              expect(topics_exist).to be_eql 0
              expect(response).to redirect_to('/assignments/2/edit#tabs-2')
            end
        
      5. Deleting all topics of private assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a private 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 private assignment and redirects to edit assignment page' do
              create(:topic, id: 2, assignment_id: 2)
              create(:topic, id: 3, assignment_id: 2)
              params = {assignment_id: 2}
              post :delete_all_topics_for_assignment, params.merge(format: :html)
              topics_exist = SignUpTopic.where(assignment_id: 2).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/2/edit')
            end
        
    6. When the assignment is non-private and other flags are True.
      1. Deleting single topic of non-private assignments. We first create a topic that is to be deleted afterward. Then, assign this topic to a non-private 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 'delete_all_selected_topics for a non private assignment and redirects to edit assignment page with single topic selected' do
              create(:topic, id: 2, assignment_id: 3, topic_identifier: 'topic2')
              params = {assignment_id: 3, topic_ids: ['topic2']}
              post :delete_all_selected_topics, params
              expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
              topics_exist = SignUpTopic.where(assignment_id: 3).count
              expect(topics_exist).to be_eql 0
              expect(response).to redirect_to('/assignments/3/edit#tabs-2')
            end
        
      3. Deleting multiple topics of non-private assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a non-private 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 'delete_all_selected_topics for a non private assignment and redirects to edit assignment page with multiple topic selected' do
              create(:topic, id: 2, assignment_id: 3, topic_identifier: 'topic2')
              create(:topic, id: 3, assignment_id: 3, topic_identifier: 'topic3')
              create(:topic, id: 8, assignment_id: 3, topic_identifier: 'topic4')
              params = {assignment_id: 3, topic_ids: ['topic2', 'topic3']}
              post :delete_all_selected_topics, params
              expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
              topics_exist = SignUpTopic.where(assignment_id: 3).count
              expect(topics_exist).to be_eql 1
              expect(response).to redirect_to('/assignments/3/edit#tabs-2')
        
              params = {assignment_id: 3, topic_ids: ['topic4']}
              post :delete_all_selected_topics, params
              expect(flash[:success]).to eq('All selected topics have been deleted successfully.')
              topics_exist = SignUpTopic.where(assignment_id: 3).count
              expect(topics_exist).to be_eql 0
              expect(response).to redirect_to('/assignments/3/edit#tabs-2')
            end
        
      5. Deleting all topics of non-private assignments. We first create some topics that are to be deleted afterward. Then, assign these topics to a non-private 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 non private assignment and redirects to edit assignment page' do
              create(:topic, id: 2, assignment_id: 3)
              create(:topic, id: 3, assignment_id: 3)
              params = {assignment_id: 3}
              post :delete_all_topics_for_assignment, params.merge(format: :html)
              topics_exist = SignUpTopic.where(assignment_id: 3).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/3/edit')
            end
        


    Test Results

  • We have created a demo video for showing that all the test cases are passing. It can be accessed through this link: https://www.youtube.com/watch?v=hSmAGUMuzHQ
  • Although our main task was to add test cases, still the deployed version can be accessed through this link: http://152.7.176.206:8080/
  • Our pull request link: https://github.com/expertiza/expertiza/pull/2108
  • Repository Link

    https://github.com/hvudeshi/expertiza/tree/beta