<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Asmathew</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Asmathew"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Asmathew"/>
	<updated>2026-06-06T07:34:23Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142378</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142378"/>
		<updated>2021-11-30T05:26:11Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Method 1- Declared common stubbed objects &amp;lt;/font&amp;gt;====&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Method 2 - Action_allowed?: It gives access permission to different users &amp;lt;/font&amp;gt;==== &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; How to use this shared file? &amp;lt;/font&amp;gt;====&lt;br /&gt;
# Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
# Why this file? - There are a lot of methods common in the Teams Related Files, they basically use similar / same stubbed objects and methods. Implementing the teams_shared.rb file keeps the code DRY and makes use of good design principles.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; How to run the test? &amp;lt;/font&amp;gt;====&lt;br /&gt;
 rspec spec/controllers/teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'create teams method' do&lt;br /&gt;
    context 'when everything is right' do&lt;br /&gt;
      it 'creates teams with random names' do&lt;br /&gt;
        allow(Object).to receive_message_chain(:const_get, :find).with(any_args).and_return(assignment1)&lt;br /&gt;
        allow(Version).to receive_message_chain(:where, :last).with(any_args).and_return(0.1)&lt;br /&gt;
        para = {id: assignment1.id, team_size: 2}&lt;br /&gt;
        session = {user: instructor, team_type: &amp;quot;Assignment&amp;quot;}&lt;br /&gt;
        result = get :create_teams, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check the team type passed in params to see if it is Assignment or Course type&lt;br /&gt;
# Get the teams belonging to that Assignment or Course and list them all&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'list method' do&lt;br /&gt;
    before(:each) { allow(Assignment).to receive(:find_by).and_return(assignment1) }&lt;br /&gt;
    context 'when type is Assignment' do&lt;br /&gt;
      it 'lists the teams for that Assignment' do&lt;br /&gt;
        params = {id: assignment1.id, type: 'Assignment'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq assignment1&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when type is Course' do&lt;br /&gt;
      it 'lists the teams for that Course' do&lt;br /&gt;
        params = {id: course1.id, type: 'Course'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when type is wrong' do&lt;br /&gt;
      it 'throws error' do&lt;br /&gt;
        params = {id: 52, type: 'Subject'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'new method' do&lt;br /&gt;
    it 'creates a new team successfully when all parameters are provided correctly' do&lt;br /&gt;
      allow(Object).to receive_message_chain(:const_get, :find).with(any_args).and_return(assignment1)&lt;br /&gt;
      para = {id: assignment1.id}&lt;br /&gt;
      session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
      result = get :new, para, session&lt;br /&gt;
      expect(result.status).to eq 200&lt;br /&gt;
      expect(controller.instance_variable_get(:@parent)).to eq assignment1&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'update method' do&lt;br /&gt;
    it 'updates the team name' do&lt;br /&gt;
      allow(Team).to receive(:find).and_return(team1)&lt;br /&gt;
      allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
      para = { id: team1.id, team: {name: 'rando team'}}&lt;br /&gt;
      session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
      result = get :update, para, session&lt;br /&gt;
      expect(result.status).to eq 302&lt;br /&gt;
      expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
    end&lt;br /&gt;
    # this test will fail even though it should normally pass, that's because it runs into an error at @team.save&lt;br /&gt;
    # RumtimeError: stubbed models are not allowed to access the database - AssignmentTeam#save()&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'delete method' do&lt;br /&gt;
    before(:each) { request.env['HTTP_REFERER'] = root_url }&lt;br /&gt;
    context 'when called and team is nil' do&lt;br /&gt;
      it 'simply redirects' do&lt;br /&gt;
        allow(Team).to receive(:find_by).and_return(nil)&lt;br /&gt;
        para = {id: 5}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :delete, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to :back&lt;br /&gt;
        expect(controller.instance_variable_get(:@team)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called and team is not nil and it does not hold a topic' do&lt;br /&gt;
      it 'deletes the team' do&lt;br /&gt;
        allow(Team).to receive(:find_by).and_return(team5)&lt;br /&gt;
        allow(Object).to receive_message_chain(:const_get, :find).and_return(course1)&lt;br /&gt;
        allow(team5).to receive(:destroy).and_return(nil)&lt;br /&gt;
        para = {id: 5}&lt;br /&gt;
        session = {user: instructor, team_type: 'CourseTeam'}&lt;br /&gt;
        result = get :delete, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(controller.instance_variable_get(:@team)).to eq team5&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'inherit method' do&lt;br /&gt;
    context 'called when assignment belongs to course and team is not empty' do&lt;br /&gt;
      it 'runs successfully' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        allow(course1).to receive(:get_teams).and_return([team5, team6])&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment belongs to course but team is empty' do&lt;br /&gt;
      it 'flashes note' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment belongs to no course' do&lt;br /&gt;
      let(:fasg) { build_stubbed(:assignment, id: 1074, course_id: -2) }&lt;br /&gt;
      # a temporary assigment object is created with an abnormal course_id so that we can check the fail condition of the method&lt;br /&gt;
      it 'flashes error' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(fasg)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; fasg.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'bequeath method' do&lt;br /&gt;
    context 'called when assignment has a course' do&lt;br /&gt;
      it 'runs successfully' do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find).and_return(team2)&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team2.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :bequeath, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment does not have a course' do&lt;br /&gt;
      let(:fasg) { build_stubbed(:assignment, id: 1074, course_id: -2) }&lt;br /&gt;
      # a temporary assigment object is created with an abnormal course_id so that we can check the fail condition of the method&lt;br /&gt;
      it 'fails' do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find).and_return(team2)&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(fasg)&lt;br /&gt;
        para = {id: team2.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :bequeath, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; fasg.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 8: Edit method &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team with the 'id' present in params&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'edit method' do&lt;br /&gt;
    it 'passes the test' do&lt;br /&gt;
      allow(Team).to receive(:find).and_return(team1)&lt;br /&gt;
      para = {id: team1.id}&lt;br /&gt;
      session = {user: ta}&lt;br /&gt;
      result = get :edit, para, session&lt;br /&gt;
      expect(result.status).to eq 200&lt;br /&gt;
      expect(controller.instance_variable_get(:@team)).to eq team1&lt;br /&gt;
    end&lt;br /&gt;
    # this method has only 1 line which is just to look up a team with the id present in the params&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 9: Create an empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the parent (Assignment or Course) based on the team type which starts the session&lt;br /&gt;
# It checks whether a team with the same exists in that category&lt;br /&gt;
# If team exists, it throws TeamExistsError and redirects to 'new' team form page&lt;br /&gt;
# If team doesn't exist, it creates a new team&lt;br /&gt;
# Successful message is displayed and user is redirected to 'list' teams page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'create method' do&lt;br /&gt;
    context 'when invoked with a team which does not exist' do&lt;br /&gt;
      it 'creates it' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        para = { id: assignment1.id, team: {name: 'rando team'}}&lt;br /&gt;
        session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
        result = get :create, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams test.PNG]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams controller.PNG]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest coverage.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# All tests, except 1 pass. &lt;br /&gt;
# The test that fails is for the &amp;quot;get index&amp;quot; method. We have identified that there is no route the view/index is going to.&lt;br /&gt;
 def respond_after(request)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html&lt;br /&gt;
      format.xml { render xml: request }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
[[File:E2167 JoinTeamRequest test.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model.&lt;br /&gt;
  &lt;br /&gt;
describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when it is valid&amp;quot; do&lt;br /&gt;
      it &amp;quot;will create an advertisement&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
          id: team1.id,&lt;br /&gt;
          team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :create, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
  &lt;br /&gt;
 context &amp;quot;when advertisement is updated&amp;quot; do&lt;br /&gt;
      it &amp;quot;the advertisement is updated&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :update, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;the advertisement is not updated due to error&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_raise(StandardError)&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :update, params, session&lt;br /&gt;
        expect(flash[:error]).to eq &amp;quot;An error occurred and your advertisement was not updated!&amp;quot;&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;POST #remove&amp;quot; do&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when advertisement is removed&amp;quot; do&lt;br /&gt;
      it &amp;quot;the advertisement is removed&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :remove, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;the advertisement is not removed due to error&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_raise(StandardError)&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :remove, params, session&lt;br /&gt;
        expect(flash[:error]).to eq &amp;quot;An error occurred and your advertisement was not removed!&amp;quot;&lt;br /&gt;
        expect(result).to redirect_to(request.env['HTTP_REFERER'] ? :back : (:root))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage. &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 AdvertisePartner.PNG]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2127 Advertise run file.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Github Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest git.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu (mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142377</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142377"/>
		<updated>2021-11-30T05:25:24Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Method 1- Declared common stubbed objects &amp;lt;/font&amp;gt;====&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Method 2 - Action_allowed?: It gives access permission to different users &amp;lt;/font&amp;gt;==== &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; How to use this shared file? &amp;lt;/font&amp;gt;====&lt;br /&gt;
# Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
# Why this file? - There are a lot of methods common in the Teams Related Files, they basically use similar / same stubbed objects and methods. Implementing the teams_shared.rb file keeps the code DRY and makes use of good design principles.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; How to run the test? &amp;lt;/font&amp;gt;====&lt;br /&gt;
 rspec spec/controllers/teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'create teams method' do&lt;br /&gt;
    context 'when everything is right' do&lt;br /&gt;
      it 'creates teams with random names' do&lt;br /&gt;
        allow(Object).to receive_message_chain(:const_get, :find).with(any_args).and_return(assignment1)&lt;br /&gt;
        allow(Version).to receive_message_chain(:where, :last).with(any_args).and_return(0.1)&lt;br /&gt;
        para = {id: assignment1.id, team_size: 2}&lt;br /&gt;
        session = {user: instructor, team_type: &amp;quot;Assignment&amp;quot;}&lt;br /&gt;
        result = get :create_teams, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check the team type passed in params to see if it is Assignment or Course type&lt;br /&gt;
# Get the teams belonging to that Assignment or Course and list them all&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'list method' do&lt;br /&gt;
    before(:each) { allow(Assignment).to receive(:find_by).and_return(assignment1) }&lt;br /&gt;
    context 'when type is Assignment' do&lt;br /&gt;
      it 'lists the teams for that Assignment' do&lt;br /&gt;
        params = {id: assignment1.id, type: 'Assignment'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq assignment1&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when type is Course' do&lt;br /&gt;
      it 'lists the teams for that Course' do&lt;br /&gt;
        params = {id: course1.id, type: 'Course'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when type is wrong' do&lt;br /&gt;
      it 'throws error' do&lt;br /&gt;
        params = {id: 52, type: 'Subject'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'new method' do&lt;br /&gt;
    it 'creates a new team successfully when all parameters are provided correctly' do&lt;br /&gt;
      allow(Object).to receive_message_chain(:const_get, :find).with(any_args).and_return(assignment1)&lt;br /&gt;
      para = {id: assignment1.id}&lt;br /&gt;
      session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
      result = get :new, para, session&lt;br /&gt;
      expect(result.status).to eq 200&lt;br /&gt;
      expect(controller.instance_variable_get(:@parent)).to eq assignment1&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'update method' do&lt;br /&gt;
    it 'updates the team name' do&lt;br /&gt;
      allow(Team).to receive(:find).and_return(team1)&lt;br /&gt;
      allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
      para = { id: team1.id, team: {name: 'rando team'}}&lt;br /&gt;
      session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
      result = get :update, para, session&lt;br /&gt;
      expect(result.status).to eq 302&lt;br /&gt;
      expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
    end&lt;br /&gt;
    # this test will fail even though it should normally pass, that's because it runs into an error at @team.save&lt;br /&gt;
    # RumtimeError: stubbed models are not allowed to access the database - AssignmentTeam#save()&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'delete method' do&lt;br /&gt;
    before(:each) { request.env['HTTP_REFERER'] = root_url }&lt;br /&gt;
    context 'when called and team is nil' do&lt;br /&gt;
      it 'simply redirects' do&lt;br /&gt;
        allow(Team).to receive(:find_by).and_return(nil)&lt;br /&gt;
        para = {id: 5}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :delete, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to :back&lt;br /&gt;
        expect(controller.instance_variable_get(:@team)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called and team is not nil and it does not hold a topic' do&lt;br /&gt;
      it 'deletes the team' do&lt;br /&gt;
        allow(Team).to receive(:find_by).and_return(team5)&lt;br /&gt;
        allow(Object).to receive_message_chain(:const_get, :find).and_return(course1)&lt;br /&gt;
        allow(team5).to receive(:destroy).and_return(nil)&lt;br /&gt;
        para = {id: 5}&lt;br /&gt;
        session = {user: instructor, team_type: 'CourseTeam'}&lt;br /&gt;
        result = get :delete, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(controller.instance_variable_get(:@team)).to eq team5&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'inherit method' do&lt;br /&gt;
    context 'called when assignment belongs to course and team is not empty' do&lt;br /&gt;
      it 'runs successfully' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        allow(course1).to receive(:get_teams).and_return([team5, team6])&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment belongs to course but team is empty' do&lt;br /&gt;
      it 'flashes note' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment belongs to no course' do&lt;br /&gt;
      let(:fasg) { build_stubbed(:assignment, id: 1074, course_id: -2) }&lt;br /&gt;
      # a temporary assigment object is created with an abnormal course_id so that we can check the fail condition of the method&lt;br /&gt;
      it 'flashes error' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(fasg)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; fasg.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'bequeath method' do&lt;br /&gt;
    context 'called when assignment has a course' do&lt;br /&gt;
      it 'runs successfully' do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find).and_return(team2)&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team2.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :bequeath, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment does not have a course' do&lt;br /&gt;
      let(:fasg) { build_stubbed(:assignment, id: 1074, course_id: -2) }&lt;br /&gt;
      # a temporary assigment object is created with an abnormal course_id so that we can check the fail condition of the method&lt;br /&gt;
      it 'fails' do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find).and_return(team2)&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(fasg)&lt;br /&gt;
        para = {id: team2.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :bequeath, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; fasg.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 8: Edit method &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team with the 'id' present in params&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'edit method' do&lt;br /&gt;
    it 'passes the test' do&lt;br /&gt;
      allow(Team).to receive(:find).and_return(team1)&lt;br /&gt;
      para = {id: team1.id}&lt;br /&gt;
      session = {user: ta}&lt;br /&gt;
      result = get :edit, para, session&lt;br /&gt;
      expect(result.status).to eq 200&lt;br /&gt;
      expect(controller.instance_variable_get(:@team)).to eq team1&lt;br /&gt;
    end&lt;br /&gt;
    # this method has only 1 line which is just to look up a team with the id present in the params&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 9: Create an empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the parent (Assignment or Course) based on the team type which starts the session&lt;br /&gt;
# It checks whether a team with the same exists in that category&lt;br /&gt;
# If team exists, it throws TeamExistsError and redirects to 'new' team form page&lt;br /&gt;
# If team doesn't exist, it creates a new team&lt;br /&gt;
# Successful message is displayed and user is redirected to 'list' teams page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'create method' do&lt;br /&gt;
    context 'when invoked with a team which does not exist' do&lt;br /&gt;
      it 'creates it' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        para = { id: assignment1.id, team: {name: 'rando team'}}&lt;br /&gt;
        session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
        result = get :create, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams test.PNG]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams controller.PNG]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest coverage.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# All tests, except 1 pass. &lt;br /&gt;
# The test that fails is for the &amp;quot;get index&amp;quot; method. We have identified that there is no route the view/index is going to.&lt;br /&gt;
 def respond_after(request)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html&lt;br /&gt;
      format.xml { render xml: request }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
[[File:E2167 JoinTeamRequest test.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model.&lt;br /&gt;
  &lt;br /&gt;
describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when it is valid&amp;quot; do&lt;br /&gt;
      it &amp;quot;will create an advertisement&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
          id: team1.id,&lt;br /&gt;
          team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :create, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
  &lt;br /&gt;
 context &amp;quot;when advertisement is updated&amp;quot; do&lt;br /&gt;
      it &amp;quot;the advertisement is updated&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :update, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;the advertisement is not updated due to error&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_raise(StandardError)&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :update, params, session&lt;br /&gt;
        expect(flash[:error]).to eq &amp;quot;An error occurred and your advertisement was not updated!&amp;quot;&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;POST #remove&amp;quot; do&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when advertisement is removed&amp;quot; do&lt;br /&gt;
      it &amp;quot;the advertisement is removed&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :remove, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;the advertisement is not removed due to error&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_raise(StandardError)&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :remove, params, session&lt;br /&gt;
        expect(flash[:error]).to eq &amp;quot;An error occurred and your advertisement was not removed!&amp;quot;&lt;br /&gt;
        expect(result).to redirect_to(request.env['HTTP_REFERER'] ? :back : (:root))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage. &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 AdvertisePartner.PNG]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2127 Advertise run file.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest git.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu (mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142376</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142376"/>
		<updated>2021-11-30T05:24:20Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Method 1- Declared common stubbed objects &amp;lt;/font&amp;gt;====&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Method 2 - Action_allowed?: It gives access permission to different users &amp;lt;/font&amp;gt;==== &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; How to use this shared file? &amp;lt;/font&amp;gt;====&lt;br /&gt;
# Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
# Why this file? - There are a lot of methods common in the Teams Related Files, they basically use similar / same stubbed objects and methods. Implementing the teams_shared.rb file keeps the code DRY and makes use of good design principles.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; How to run the test? &amp;lt;/font&amp;gt;====&lt;br /&gt;
 rspec spec/controllers/teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'create teams method' do&lt;br /&gt;
    context 'when everything is right' do&lt;br /&gt;
      it 'creates teams with random names' do&lt;br /&gt;
        allow(Object).to receive_message_chain(:const_get, :find).with(any_args).and_return(assignment1)&lt;br /&gt;
        allow(Version).to receive_message_chain(:where, :last).with(any_args).and_return(0.1)&lt;br /&gt;
        para = {id: assignment1.id, team_size: 2}&lt;br /&gt;
        session = {user: instructor, team_type: &amp;quot;Assignment&amp;quot;}&lt;br /&gt;
        result = get :create_teams, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check the team type passed in params to see if it is Assignment or Course type&lt;br /&gt;
# Get the teams belonging to that Assignment or Course and list them all&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'list method' do&lt;br /&gt;
    before(:each) { allow(Assignment).to receive(:find_by).and_return(assignment1) }&lt;br /&gt;
    context 'when type is Assignment' do&lt;br /&gt;
      it 'lists the teams for that Assignment' do&lt;br /&gt;
        params = {id: assignment1.id, type: 'Assignment'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq assignment1&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when type is Course' do&lt;br /&gt;
      it 'lists the teams for that Course' do&lt;br /&gt;
        params = {id: course1.id, type: 'Course'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when type is wrong' do&lt;br /&gt;
      it 'throws error' do&lt;br /&gt;
        params = {id: 52, type: 'Subject'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'new method' do&lt;br /&gt;
    it 'creates a new team successfully when all parameters are provided correctly' do&lt;br /&gt;
      allow(Object).to receive_message_chain(:const_get, :find).with(any_args).and_return(assignment1)&lt;br /&gt;
      para = {id: assignment1.id}&lt;br /&gt;
      session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
      result = get :new, para, session&lt;br /&gt;
      expect(result.status).to eq 200&lt;br /&gt;
      expect(controller.instance_variable_get(:@parent)).to eq assignment1&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'update method' do&lt;br /&gt;
    it 'updates the team name' do&lt;br /&gt;
      allow(Team).to receive(:find).and_return(team1)&lt;br /&gt;
      allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
      para = { id: team1.id, team: {name: 'rando team'}}&lt;br /&gt;
      session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
      result = get :update, para, session&lt;br /&gt;
      expect(result.status).to eq 302&lt;br /&gt;
      expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
    end&lt;br /&gt;
    # this test will fail even though it should normally pass, that's because it runs into an error at @team.save&lt;br /&gt;
    # RumtimeError: stubbed models are not allowed to access the database - AssignmentTeam#save()&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'delete method' do&lt;br /&gt;
    before(:each) { request.env['HTTP_REFERER'] = root_url }&lt;br /&gt;
    context 'when called and team is nil' do&lt;br /&gt;
      it 'simply redirects' do&lt;br /&gt;
        allow(Team).to receive(:find_by).and_return(nil)&lt;br /&gt;
        para = {id: 5}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :delete, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to :back&lt;br /&gt;
        expect(controller.instance_variable_get(:@team)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called and team is not nil and it does not hold a topic' do&lt;br /&gt;
      it 'deletes the team' do&lt;br /&gt;
        allow(Team).to receive(:find_by).and_return(team5)&lt;br /&gt;
        allow(Object).to receive_message_chain(:const_get, :find).and_return(course1)&lt;br /&gt;
        allow(team5).to receive(:destroy).and_return(nil)&lt;br /&gt;
        para = {id: 5}&lt;br /&gt;
        session = {user: instructor, team_type: 'CourseTeam'}&lt;br /&gt;
        result = get :delete, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(controller.instance_variable_get(:@team)).to eq team5&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'inherit method' do&lt;br /&gt;
    context 'called when assignment belongs to course and team is not empty' do&lt;br /&gt;
      it 'runs successfully' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        allow(course1).to receive(:get_teams).and_return([team5, team6])&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment belongs to course but team is empty' do&lt;br /&gt;
      it 'flashes note' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment belongs to no course' do&lt;br /&gt;
      let(:fasg) { build_stubbed(:assignment, id: 1074, course_id: -2) }&lt;br /&gt;
      # a temporary assigment object is created with an abnormal course_id so that we can check the fail condition of the method&lt;br /&gt;
      it 'flashes error' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(fasg)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; fasg.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'bequeath method' do&lt;br /&gt;
    context 'called when assignment has a course' do&lt;br /&gt;
      it 'runs successfully' do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find).and_return(team2)&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team2.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :bequeath, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment does not have a course' do&lt;br /&gt;
      let(:fasg) { build_stubbed(:assignment, id: 1074, course_id: -2) }&lt;br /&gt;
      # a temporary assigment object is created with an abnormal course_id so that we can check the fail condition of the method&lt;br /&gt;
      it 'fails' do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find).and_return(team2)&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(fasg)&lt;br /&gt;
        para = {id: team2.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :bequeath, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; fasg.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 8: Edit method &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team with the 'id' present in params&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'edit method' do&lt;br /&gt;
    it 'passes the test' do&lt;br /&gt;
      allow(Team).to receive(:find).and_return(team1)&lt;br /&gt;
      para = {id: team1.id}&lt;br /&gt;
      session = {user: ta}&lt;br /&gt;
      result = get :edit, para, session&lt;br /&gt;
      expect(result.status).to eq 200&lt;br /&gt;
      expect(controller.instance_variable_get(:@team)).to eq team1&lt;br /&gt;
    end&lt;br /&gt;
    # this method has only 1 line which is just to look up a team with the id present in the params&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 9: Create an empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the parent (Assignment or Course) based on the team type which starts the session&lt;br /&gt;
# It checks whether a team with the same exists in that category&lt;br /&gt;
# If team exists, it throws TeamExistsError and redirects to 'new' team form page&lt;br /&gt;
# If team doesn't exist, it creates a new team&lt;br /&gt;
# Successful message is displayed and user is redirected to 'list' teams page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'create method' do&lt;br /&gt;
    context 'when invoked with a team which does not exist' do&lt;br /&gt;
      it 'creates it' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        para = { id: assignment1.id, team: {name: 'rando team'}}&lt;br /&gt;
        session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
        result = get :create, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams test.PNG]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams controller.PNG]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest coverage.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# All tests, except 1 pass. &lt;br /&gt;
# The test that fails is for the &amp;quot;get index&amp;quot; method. We have identified that there is no route the view/index is going to.&lt;br /&gt;
 def respond_after(request)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html&lt;br /&gt;
      format.xml { render xml: request }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
[[File:E2167 JoinTeamRequest test.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model.&lt;br /&gt;
  &lt;br /&gt;
describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when it is valid&amp;quot; do&lt;br /&gt;
      it &amp;quot;will create an advertisement&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
          id: team1.id,&lt;br /&gt;
          team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :create, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
  &lt;br /&gt;
 context &amp;quot;when advertisement is updated&amp;quot; do&lt;br /&gt;
      it &amp;quot;the advertisement is updated&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :update, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;the advertisement is not updated due to error&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_raise(StandardError)&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :update, params, session&lt;br /&gt;
        expect(flash[:error]).to eq &amp;quot;An error occurred and your advertisement was not updated!&amp;quot;&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;POST #remove&amp;quot; do&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when advertisement is removed&amp;quot; do&lt;br /&gt;
      it &amp;quot;the advertisement is removed&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :remove, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;the advertisement is not removed due to error&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_raise(StandardError)&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :remove, params, session&lt;br /&gt;
        expect(flash[:error]).to eq &amp;quot;An error occurred and your advertisement was not removed!&amp;quot;&lt;br /&gt;
        expect(result).to redirect_to(request.env['HTTP_REFERER'] ? :back : (:root))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage. &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 AdvertisePartner.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest git.PNG]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 AdvertisePartner.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu (mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2127_Advertise_run_file.PNG&amp;diff=142375</id>
		<title>File:E2127 Advertise run file.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2127_Advertise_run_file.PNG&amp;diff=142375"/>
		<updated>2021-11-30T05:23:51Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_AdvertisePartner.PNG&amp;diff=142374</id>
		<title>File:E2167 AdvertisePartner.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_AdvertisePartner.PNG&amp;diff=142374"/>
		<updated>2021-11-30T05:18:42Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142373</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142373"/>
		<updated>2021-11-30T05:13:20Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Method 1- Declared common stubbed objects &amp;lt;/font&amp;gt;====&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Method 2 - Action_allowed?: It gives access permission to different users &amp;lt;/font&amp;gt;==== &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; How to use this shared file? &amp;lt;/font&amp;gt;====&lt;br /&gt;
# Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
# Why this file? - There are a lot of methods common in the Teams Related Files, they basically use similar / same stubbed objects and methods. Implementing the teams_shared.rb file keeps the code DRY and makes use of good design principles.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; How to run the test? &amp;lt;/font&amp;gt;====&lt;br /&gt;
 rspec spec/controllers/teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'create teams method' do&lt;br /&gt;
    context 'when everything is right' do&lt;br /&gt;
      it 'creates teams with random names' do&lt;br /&gt;
        allow(Object).to receive_message_chain(:const_get, :find).with(any_args).and_return(assignment1)&lt;br /&gt;
        allow(Version).to receive_message_chain(:where, :last).with(any_args).and_return(0.1)&lt;br /&gt;
        para = {id: assignment1.id, team_size: 2}&lt;br /&gt;
        session = {user: instructor, team_type: &amp;quot;Assignment&amp;quot;}&lt;br /&gt;
        result = get :create_teams, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check the team type passed in params to see if it is Assignment or Course type&lt;br /&gt;
# Get the teams belonging to that Assignment or Course and list them all&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'list method' do&lt;br /&gt;
    before(:each) { allow(Assignment).to receive(:find_by).and_return(assignment1) }&lt;br /&gt;
    context 'when type is Assignment' do&lt;br /&gt;
      it 'lists the teams for that Assignment' do&lt;br /&gt;
        params = {id: assignment1.id, type: 'Assignment'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq assignment1&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when type is Course' do&lt;br /&gt;
      it 'lists the teams for that Course' do&lt;br /&gt;
        params = {id: course1.id, type: 'Course'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when type is wrong' do&lt;br /&gt;
      it 'throws error' do&lt;br /&gt;
        params = {id: 52, type: 'Subject'}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :list, params, session&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
        expect(controller.instance_variable_get(:@assignment)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'new method' do&lt;br /&gt;
    it 'creates a new team successfully when all parameters are provided correctly' do&lt;br /&gt;
      allow(Object).to receive_message_chain(:const_get, :find).with(any_args).and_return(assignment1)&lt;br /&gt;
      para = {id: assignment1.id}&lt;br /&gt;
      session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
      result = get :new, para, session&lt;br /&gt;
      expect(result.status).to eq 200&lt;br /&gt;
      expect(controller.instance_variable_get(:@parent)).to eq assignment1&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'update method' do&lt;br /&gt;
    it 'updates the team name' do&lt;br /&gt;
      allow(Team).to receive(:find).and_return(team1)&lt;br /&gt;
      allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
      para = { id: team1.id, team: {name: 'rando team'}}&lt;br /&gt;
      session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
      result = get :update, para, session&lt;br /&gt;
      expect(result.status).to eq 302&lt;br /&gt;
      expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
    end&lt;br /&gt;
    # this test will fail even though it should normally pass, that's because it runs into an error at @team.save&lt;br /&gt;
    # RumtimeError: stubbed models are not allowed to access the database - AssignmentTeam#save()&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'delete method' do&lt;br /&gt;
    before(:each) { request.env['HTTP_REFERER'] = root_url }&lt;br /&gt;
    context 'when called and team is nil' do&lt;br /&gt;
      it 'simply redirects' do&lt;br /&gt;
        allow(Team).to receive(:find_by).and_return(nil)&lt;br /&gt;
        para = {id: 5}&lt;br /&gt;
        session = {user: instructor}&lt;br /&gt;
        result = get :delete, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to :back&lt;br /&gt;
        expect(controller.instance_variable_get(:@team)).to eq nil&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'when called and team is not nil and it does not hold a topic' do&lt;br /&gt;
      it 'deletes the team' do&lt;br /&gt;
        allow(Team).to receive(:find_by).and_return(team5)&lt;br /&gt;
        allow(Object).to receive_message_chain(:const_get, :find).and_return(course1)&lt;br /&gt;
        allow(team5).to receive(:destroy).and_return(nil)&lt;br /&gt;
        para = {id: 5}&lt;br /&gt;
        session = {user: instructor, team_type: 'CourseTeam'}&lt;br /&gt;
        result = get :delete, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(controller.instance_variable_get(:@team)).to eq team5&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'inherit method' do&lt;br /&gt;
    context 'called when assignment belongs to course and team is not empty' do&lt;br /&gt;
      it 'runs successfully' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        allow(course1).to receive(:get_teams).and_return([team5, team6])&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment belongs to course but team is empty' do&lt;br /&gt;
      it 'flashes note' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment belongs to no course' do&lt;br /&gt;
      let(:fasg) { build_stubbed(:assignment, id: 1074, course_id: -2) }&lt;br /&gt;
      # a temporary assigment object is created with an abnormal course_id so that we can check the fail condition of the method&lt;br /&gt;
      it 'flashes error' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(fasg)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team5.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :inherit, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; fasg.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'bequeath method' do&lt;br /&gt;
    context 'called when assignment has a course' do&lt;br /&gt;
      it 'runs successfully' do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find).and_return(team2)&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        allow(Course).to receive(:find).and_return(course1)&lt;br /&gt;
        para = {id: team2.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :bequeath, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context 'called when assignment does not have a course' do&lt;br /&gt;
      let(:fasg) { build_stubbed(:assignment, id: 1074, course_id: -2) }&lt;br /&gt;
      # a temporary assigment object is created with an abnormal course_id so that we can check the fail condition of the method&lt;br /&gt;
      it 'fails' do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find).and_return(team2)&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(fasg)&lt;br /&gt;
        para = {id: team2.id}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :bequeath, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:controller =&amp;gt; 'teams', :action =&amp;gt; 'list', :id =&amp;gt; fasg.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 8: Edit method &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team with the 'id' present in params&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'edit method' do&lt;br /&gt;
    it 'passes the test' do&lt;br /&gt;
      allow(Team).to receive(:find).and_return(team1)&lt;br /&gt;
      para = {id: team1.id}&lt;br /&gt;
      session = {user: ta}&lt;br /&gt;
      result = get :edit, para, session&lt;br /&gt;
      expect(result.status).to eq 200&lt;br /&gt;
      expect(controller.instance_variable_get(:@team)).to eq team1&lt;br /&gt;
    end&lt;br /&gt;
    # this method has only 1 line which is just to look up a team with the id present in the params&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 9: Create an empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the parent (Assignment or Course) based on the team type which starts the session&lt;br /&gt;
# It checks whether a team with the same exists in that category&lt;br /&gt;
# If team exists, it throws TeamExistsError and redirects to 'new' team form page&lt;br /&gt;
# If team doesn't exist, it creates a new team&lt;br /&gt;
# Successful message is displayed and user is redirected to 'list' teams page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'create method' do&lt;br /&gt;
    context 'when invoked with a team which does not exist' do&lt;br /&gt;
      it 'creates it' do&lt;br /&gt;
        allow(Assignment).to receive(:find).and_return(assignment1)&lt;br /&gt;
        para = { id: assignment1.id, team: {name: 'rando team'}}&lt;br /&gt;
        session = {user: ta, team_type: 'Assignment'}&lt;br /&gt;
        result = get :create, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams test.PNG]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams controller.PNG]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest coverage.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# All tests, except 1 pass. &lt;br /&gt;
# The test that fails is for the &amp;quot;get index&amp;quot; method. We have identified that there is no route the view/index is going to.&lt;br /&gt;
 def respond_after(request)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html&lt;br /&gt;
      format.xml { render xml: request }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
[[File:E2167 JoinTeamRequest test.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model.&lt;br /&gt;
  &lt;br /&gt;
describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when it is valid&amp;quot; do&lt;br /&gt;
      it &amp;quot;will create an advertisement&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
          id: team1.id,&lt;br /&gt;
          team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :create, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
  &lt;br /&gt;
 context &amp;quot;when advertisement is updated&amp;quot; do&lt;br /&gt;
      it &amp;quot;the advertisement is updated&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :update, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;the advertisement is not updated due to error&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_raise(StandardError)&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :update, params, session&lt;br /&gt;
        expect(flash[:error]).to eq &amp;quot;An error occurred and your advertisement was not updated!&amp;quot;&lt;br /&gt;
        expect(result.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;POST #remove&amp;quot; do&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when advertisement is removed&amp;quot; do&lt;br /&gt;
      it &amp;quot;the advertisement is removed&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_return(true)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :remove, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path(:student_id =&amp;gt; 1))&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;the advertisement is not removed due to error&amp;quot; do&lt;br /&gt;
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)&lt;br /&gt;
        allow(team1).to receive(:assignment).and_return(assignment1)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find_by).and_return(participant)&lt;br /&gt;
        allow(team1).to receive(:update_attributes).and_raise(StandardError)&lt;br /&gt;
        params  = {&lt;br /&gt;
            id: team1.id,&lt;br /&gt;
            team_id: team1.id,&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :remove, params, session&lt;br /&gt;
        expect(flash[:error]).to eq &amp;quot;An error occurred and your advertisement was not removed!&amp;quot;&lt;br /&gt;
        expect(result).to redirect_to(request.env['HTTP_REFERER'] ? :back : (:root))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Github Coverage. &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest git.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu (mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142308</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142308"/>
		<updated>2021-11-30T04:11:35Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Method 1- Declared common stubbed objects &amp;lt;/font&amp;gt;====&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Method 2 - Action_allowed?: It gives access permission to different users &amp;lt;/font&amp;gt;==== &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; How to use this shared file? &amp;lt;/font&amp;gt;====&lt;br /&gt;
# Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
# Why this file? - There are a lot of methods common in the Teams Related Files, they basically use similar / same stubbed objects and methods. Implementing the teams_shared.rb file keeps the code DRY and makes use of good design principles.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; How to run the test? &amp;lt;/font&amp;gt;====&lt;br /&gt;
 rspec spec/controllers/teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = 1&amp;gt;&lt;br /&gt;
  describe 'create teams method' do&lt;br /&gt;
    context 'when everything is right' do&lt;br /&gt;
      it 'creates teams with random names' do&lt;br /&gt;
        allow(Object).to receive_message_chain(:const_get, :find).with(any_args).and_return(assignment1)&lt;br /&gt;
        allow(Version).to receive_message_chain(:where, :last).with(any_args).and_return(0.1)&lt;br /&gt;
        para = {id: assignment1.id, team_size: 2}&lt;br /&gt;
        session = {user: instructor, team_type: &amp;quot;Assignment&amp;quot;}&lt;br /&gt;
        result = get :create_teams, para, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
        expect(result).to redirect_to(:action =&amp;gt; 'list', :id =&amp;gt; assignment1.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if the current list to display is at assignment or course level&lt;br /&gt;
# Display the teams according to the level&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams test.PNG]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams controller.PNG]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest coverage.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# All tests, except 1 pass. &lt;br /&gt;
# The test that fails is for the &amp;quot;get index&amp;quot; method. We have identified that there is no route the view/index is going to.&lt;br /&gt;
 def respond_after(request)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html&lt;br /&gt;
      format.xml { render xml: request }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
[[File:E2167 JoinTeamRequest test.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Github Coverage. &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest git.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu (mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142305</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142305"/>
		<updated>2021-11-30T04:04:56Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
Method 1- Declared common stubbed objects&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
Method 2 - Action_allowed?: It gives access permission to different users &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
How to use this shared file?&lt;br /&gt;
# Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
# Why this file? - There are a lot of methods common in the Teams Related Files, they basically use similar / same stubbed objects and methods. Implementing the teams_shared.rb file keeps the code DRY and makes use of good design principles.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; How to run the test? &amp;lt;/font&amp;gt;====&lt;br /&gt;
 rspec spec/controllers/teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if the current list to display is at assignment or course level&lt;br /&gt;
# Display the teams according to the level&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams test.PNG]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams controller.PNG]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest coverage.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# All tests, except 1 pass. &lt;br /&gt;
# The test that fails is for the &amp;quot;get index&amp;quot; method. We have identified that there is no route the view/index is going to.&lt;br /&gt;
 def respond_after(request)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html&lt;br /&gt;
      format.xml { render xml: request }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
[[File:E2167 JoinTeamRequest test.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Github Coverage. &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest git.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu (mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142301</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142301"/>
		<updated>2021-11-30T04:02:17Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
Method 1- Declared common stubbed objects&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
Method 2 - Action_allowed?: It gives access permission to different users &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
How to use this shared file?&lt;br /&gt;
# Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
# Why this file? - There are a lot of methods common in the Teams Related Files, they basically use similar / same stubbed objects and methods. Implementing the teams_shared.rb file keeps the code DRY and makes use of good design principles.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if the current list to display is at assignment or course level&lt;br /&gt;
# Display the teams according to the level&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams test.PNG]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 Teams controller.PNG]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest coverage.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# All tests, except 1 pass. &lt;br /&gt;
# The test that fails is for the &amp;quot;get index&amp;quot; method. We have identified that there is no route the view/index is going to.&lt;br /&gt;
 def respond_after(request)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html&lt;br /&gt;
      format.xml { render xml: request }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
[[File:E2167 JoinTeamRequest test.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Github Coverage. &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest git.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu (mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_Teams_test.PNG&amp;diff=142295</id>
		<title>File:E2167 Teams test.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_Teams_test.PNG&amp;diff=142295"/>
		<updated>2021-11-30T03:56:45Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_Teams_controller.PNG&amp;diff=142289</id>
		<title>File:E2167 Teams controller.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_Teams_controller.PNG&amp;diff=142289"/>
		<updated>2021-11-30T03:53:35Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142000</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=142000"/>
		<updated>2021-11-29T22:14:45Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
Method 1- Declared common stubbed objects&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
Method 2 - Action_allowed?: It gives access permission to different users &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
How to use this shared file?&lt;br /&gt;
# Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
# Why this file? - There are a lot of methods common in the Teams Related Files, they basically use similar / same stubbed objects and methods. Implementing the teams_shared.rb file keeps the code DRY and makes use of good design principles.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if the current list to display is at assignment or course level&lt;br /&gt;
# Display the teams according to the level&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest coverage.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# All tests, except 1 pass. &lt;br /&gt;
# The test that fails is for the &amp;quot;get index&amp;quot; method. We have identified that there is no route the view/index is going to.&lt;br /&gt;
 def respond_after(request)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html&lt;br /&gt;
      format.xml { render xml: request }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
[[File:E2167 JoinTeamRequest test.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Github Coverage. &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest git.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu (mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_JoinTeamRequest_git.PNG&amp;diff=141998</id>
		<title>File:E2167 JoinTeamRequest git.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_JoinTeamRequest_git.PNG&amp;diff=141998"/>
		<updated>2021-11-29T22:12:15Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141979</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141979"/>
		<updated>2021-11-29T21:48:23Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
Method 1- Declared common stubbed objects&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
Method 2 - Action_allowed?: It gives access permission to different users &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
How to use this shared file?&lt;br /&gt;
# Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
# Why this file? - There are a lot of methods common in the Teams Related Files, they basically use similar / same stubbed objects and methods. Implementing the teams_shared.rb file keeps the code DRY and makes use of good design principles.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if the current list to display is at assignment or course level&lt;br /&gt;
# Display the teams according to the level&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest coverage.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Test Pass/ Fail &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# All tests, except 1 pass. &lt;br /&gt;
# The test that fails is for the &amp;quot;get index&amp;quot; method. We have identified that there is no route the view/index is going to.&lt;br /&gt;
 def respond_after(request)&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html&lt;br /&gt;
      format.xml { render xml: request }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
[[File:E2167 JoinTeamRequest test.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu (mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_JoinTeamRequest_test.PNG&amp;diff=141970</id>
		<title>File:E2167 JoinTeamRequest test.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_JoinTeamRequest_test.PNG&amp;diff=141970"/>
		<updated>2021-11-29T21:43:42Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141964</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141964"/>
		<updated>2021-11-29T21:40:38Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
Method 1- Declared common stubbed objects&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
Method 2 - Action_allowed?: It gives access permission to different users &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
How to use this shared file?&lt;br /&gt;
# Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
# Why this file? - There are a lot of methods common in the Teams Related Files, they basically use similar / same stubbed objects and methods. Implementing the teams_shared.rb file keeps the code DRY and makes use of good design principles.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if the current list to display is at assignment or course level&lt;br /&gt;
# Display the teams according to the level&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:E2167 JoinTeamRequest coverage.PNG]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu (mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_JoinTeamRequest_coverage.PNG&amp;diff=141960</id>
		<title>File:E2167 JoinTeamRequest coverage.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2167_JoinTeamRequest_coverage.PNG&amp;diff=141960"/>
		<updated>2021-11-29T21:37:19Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141955</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141955"/>
		<updated>2021-11-29T21:33:22Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
Method 1- Declared common stubbed objects&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
Method 2 - Action_allowed?: It gives access permission to different users &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
How to use this shared file?&lt;br /&gt;
# Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
# Why this file? - There are a lot of methods common in the Teams Related Files, they basically use similar / same stubbed objects and methods. Implementing the teams_shared.rb file keeps the code DRY and makes use of good design principles.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if the current list to display is at assignment or course level&lt;br /&gt;
# Display the teams according to the level&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Coverage &amp;lt;/font&amp;gt;====&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu(mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141926</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141926"/>
		<updated>2021-11-29T21:18:33Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_shared.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# This controller can be found in spec/support&lt;br /&gt;
# It has all shared methods to be included in Teams related files.&lt;br /&gt;
 ## Method 1- Declared common stubbed objects&lt;br /&gt;
 &amp;lt;font size =1&amp;gt;&lt;br /&gt;
 shared_context 'object initializations' do&lt;br /&gt;
  let(:superadmin) { build_stubbed(:superadmin) }&lt;br /&gt;
  let(:admin) { build_stubbed(:admin) }&lt;br /&gt;
  let(:instructor) { build_stubbed(:instructor, id: 1) }&lt;br /&gt;
  let(:ta) { build_stubbed(:teaching_assistant) }&lt;br /&gt;
  let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') }&lt;br /&gt;
  let(:student2) { build_stubbed(:student, id: 2) }&lt;br /&gt;
  let(:course1) { build_stubbed(:course, name: 'TestCourse', id:1, instructor_id: instructor.id) }&lt;br /&gt;
  let(:assignment1) { build_stubbed(:assignment, name: 'TestAssignment', id: 1) }&lt;br /&gt;
  let(:team1) { build_stubbed(:assignment_team, id: 1, name: 'wolfers',parent_id: assignment1.id) }&lt;br /&gt;
  let(:team2) { build_stubbed(:assignment_team, id: 2, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team3) { build_stubbed(:assignment_team, id: 3, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team4) { build_stubbed(:assignment_team, id: 4, parent_id: assignment1.id) }&lt;br /&gt;
  let(:team5) { build_stubbed(:course_team, id: 5, parent_id: course1.id) }&lt;br /&gt;
  let(:team6) { build_stubbed(:course_team, id: 6, parent_id: course1.id) }&lt;br /&gt;
  let(:team7) { build_stubbed(:assignment_team, name: 'test',  parent_id: course1.id) }&lt;br /&gt;
  let(:join_team_request1) { build_stubbed(:join_team_request, id: 1, team_id: team1.id, status: 'P') }&lt;br /&gt;
  let(:join_team_request2) { build_stubbed(:join_team_request, id: 2, team_id: team2.id, status: 'P',comments: &amp;quot;Any comment&amp;quot;) }&lt;br /&gt;
  let(:join_team_request3) { build_stubbed(:join_team_request, id: 3, team_id: team2.id, status: 'D',comments: &amp;quot;Updated&amp;quot;) }&lt;br /&gt;
  let(:invalidrequest) { build_stubbed(:join_team_request) }&lt;br /&gt;
  let(:participant) { build_stubbed(:participant, id: 1) }&lt;br /&gt;
  let(:node1) { build_stubbed(:assignment_node,  node_object_id: 1) }&lt;br /&gt;
  let(:team_user1) { build_stubbed(:team_user, team_id:1, user_id:1)}&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
  Method 2 - Action_allowed?: It gives access permission to different users &lt;br /&gt;
 &amp;lt;font size = 1&amp;gt;&lt;br /&gt;
 shared_context 'authorization check', :shared_context =&amp;gt; :metadata do&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'superadmin credentials' do&lt;br /&gt;
    stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Admin access&lt;br /&gt;
  it 'admin credentials' do&lt;br /&gt;
    stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check TA access&lt;br /&gt;
  it 'ta credentials' do&lt;br /&gt;
    stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
  # Testing to check Instructor access&lt;br /&gt;
  it 'instructor credentials' do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
  end&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
# How to use this shared file?&lt;br /&gt;
 ## Add a require statement:&lt;br /&gt;
 require './spec/support/teams_shared.rb'&lt;br /&gt;
# Add include_context statements in the controller.&lt;br /&gt;
 include_context &amp;quot;object initializations&amp;quot;&lt;br /&gt;
 include_context 'authorization check'&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if the current list to display is at assignment or course level&lt;br /&gt;
# Display the teams according to the level&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu(mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141911</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141911"/>
		<updated>2021-11-29T21:04:17Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: Hello&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if the current list to display is at assignment or course level&lt;br /&gt;
# Display the teams according to the level&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &lt;br /&gt;
# Test the controller :&lt;br /&gt;
 rspec spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt; &lt;br /&gt;
  describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      # Stubbing participant to receive an object with id = 1&lt;br /&gt;
      allow(Participant).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(participant)&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when resource is not saved!&amp;quot; do&lt;br /&gt;
      it &amp;quot;renders new page&amp;quot; do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(invalidrequest)&lt;br /&gt;
        params = {participant_id: participant.id, team_id: -2}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template(&amp;quot;new&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Testing when the object is being saved to the database&lt;br /&gt;
    context &amp;quot;when resource is saved&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:new).and_return(join_team_request2)&lt;br /&gt;
        allow(Team).to receive(:find).with(&amp;quot;1&amp;quot;).and_return(team1)&lt;br /&gt;
        allow(Assignment).to receive(:find).with(1).and_return(assignment1)&lt;br /&gt;
        allow(Participant).to receive(:where).with(user_id: 1,parent_id: '1').and_return([participant])&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;valid response&amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 2,&lt;br /&gt;
          join_team_request2: {&lt;br /&gt;
            status: 'P'&lt;br /&gt;
          },&lt;br /&gt;
          team_id: 1,&lt;br /&gt;
          assignment_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        post :create, params, session&lt;br /&gt;
        expect(response.status).to eq 302&lt;br /&gt;
        expect(join_team_request2.status).to eq('P')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    context &amp;quot;when it is not created&amp;quot; do&lt;br /&gt;
      it &amp;quot;will page for new &amp;quot; do&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(false)&lt;br /&gt;
        params = {action: 'new'}&lt;br /&gt;
        session = {user: student1}&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response.status).to eq 200&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
 &lt;br /&gt;
 describe &amp;quot;#decline&amp;quot; do&lt;br /&gt;
    context &amp;quot;when join team request is declined&amp;quot; do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        allow(JoinTeamRequest).to receive(:find).and_return(join_team_request2)&lt;br /&gt;
        allow(join_team_request2).to receive(:save).and_return(true)&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will change status to 'D'&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result.status).to eq 302&lt;br /&gt;
      end&lt;br /&gt;
      it &amp;quot;will redirect to view student teams path&amp;quot; do&lt;br /&gt;
        params = {action: 'decline'}&lt;br /&gt;
        session = {user: ta}&lt;br /&gt;
        result = get :decline, params, session&lt;br /&gt;
        expect(result).to redirect_to(view_student_teams_path)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Since this method is private there is no test case written for it.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu(mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141585</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141585"/>
		<updated>2021-11-10T02:19:20Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if the current list to display is at assignment or course level&lt;br /&gt;
# Display the teams according to the level&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
= Old Page Link =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
We have created a new page due to a title error at the new one.&lt;br /&gt;
Link to the old page : https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu(mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141576</id>
		<title>CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files&amp;diff=141576"/>
		<updated>2021-11-09T21:50:31Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: Created page with &amp;quot;__TOC__  = Relevant links = Github Repo : [https://github.com/MathewAaron/expertiza Repository]  = About Expertiza = [http://expertiza.ncsu.edu/ Expertiza] is an open source p...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
Github Repo : [https://github.com/MathewAaron/expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Create teams with random names &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After checking for the team type and team size, call function to randomize the teams&lt;br /&gt;
# Print message &amp;quot;Random teams have been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list of teams&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: List the teams assignment wise or course wise &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if the current list to display is at assignment or course level&lt;br /&gt;
# Display the teams according to the level&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Create a new empty team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team already exists with the same name&lt;br /&gt;
# If it doesn’t, create a new team with a name&lt;br /&gt;
# If a team is created, print &amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully created.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to create a new team and redirect to new team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Update an existing team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if a team with new suggested name already exists&lt;br /&gt;
# If it doesn’t, update and save the new team name&lt;br /&gt;
# Print &amp;quot;The team &amp;lt;new_team_name&amp;gt; has been successfully updated.&amp;quot;&lt;br /&gt;
# Redirect to list team page&lt;br /&gt;
# If error is there, fail to update team and redirect to edit team form page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 5: Delete a team &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Check if there is a team in waitlist for the topic that the team to be deleted holds&lt;br /&gt;
# If there is a team on the waitlist, assign the topic to that team. If multiple teams are there, assign the topic to the first team in the waitlist.&lt;br /&gt;
# Delete the team’s records in team, teams_users and sign_up_team tables&lt;br /&gt;
# Print “&amp;quot;The team &amp;lt;team_name&amp;gt; has been successfully deleted.&amp;quot;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 6: Copy existing teams from a course down to an assignment &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the course that the assignment belongs to&lt;br /&gt;
# If a course for the assignment doesn’t exist, give the error message &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
# Otherwise fetch all the teams that exist in the course&lt;br /&gt;
# If no teams exist, give the error message &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
# Else copy all teams and assign them the new assignment id&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 7: Copy existing team from assignment to course &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the assignment id to which the team belongs&lt;br /&gt;
# Find the course to which the assignment belongs&lt;br /&gt;
# If assignment doesn’t belong to a course, give the error message &amp;quot;This assignment is not &amp;lt;assignment_name&amp;gt; with a course.&amp;quot;&lt;br /&gt;
# Otherwise copy team from assignment and assign it the course id&lt;br /&gt;
# Print success message &amp;quot;The team &amp;lt;team_name&amp;gt; was successfully copied to &amp;lt;course_name&amp;gt;&amp;quot;&lt;br /&gt;
# Redirect to list page&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;teams_users_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#Given user is not defined: When given user is defined, link is provided to create the user.&lt;br /&gt;
#Selected team to which user is being added belongs to an assignment: When user is not a participant of the assignment, link is provided to add the user to the assignment. When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed.&lt;br /&gt;
#Selected team to which user is being added belongs to a course: When user is not a participant of the course, link is provided to add the user to the course. When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#User under assignment or course team is deleted: user association to the respective team is deleted and hence user is no longer part of the team.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;student_teams_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Create Student teams &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Update team name: &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 4: Remove team participants &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;join_team_requests_controller.rb&amp;lt;/font&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;P = Pending status &amp;lt;br&amp;gt;&lt;br /&gt;
D = Denied status &amp;lt;br&amp;gt;&lt;br /&gt;
A = Accepted status &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating a team request &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Decline a team request. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Check team status. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;advertise_partner_controller.rb &amp;lt;/font&amp;gt;===&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 1: Creating new advertisement for partners. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 2: Updating the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
====&amp;lt;font size = '3'&amp;gt; Scenario 3: Remove the advertisement. &amp;lt;/font&amp;gt;====&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
[[File:Teams adv remove.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Our Team =&lt;br /&gt;
&amp;lt;font size = '2'&amp;gt;&lt;br /&gt;
Yi Qiu(mentor)&amp;lt;br&amp;gt;&lt;br /&gt;
Aaron Mathew (asmathew@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Priya Jakhar (pjakhar@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Supriya Krishna (sbkrishn@ncsu.edu)&amp;lt;br&amp;gt;&lt;br /&gt;
Snehapriyaa Mathiyalaghan (smathiy@ncsu.edu)&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=141575</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=141575"/>
		<updated>2021-11-09T21:49:48Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2129. Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2123. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2140. Create new late policy successfully and fix Bank link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2144. Refactor delayed mailer and scheduled task]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2145. OSS Project Beige]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2135. Email notification to reviewers and instructors]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades#Description_about_project CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring_and_Grades]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2150._Integrate_suggestion_detection_algorithm#Description_about_project CSC/ECE 517 Fall 2021 - E2150. Integrate suggestion detection algorithm]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2152._Revision_planning_tool#Description_about_project CSC/ECE 517 Fall 2021 - E2152. Revision_planning_tool]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2170._Testing_-_Response_Maps#Description_about_project CSC/ECE 517 Fall 2021 - E2170. Testing - Response Maps]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2153._Improving_search_facility_in_Expertiza#Description_about_project CSC/ECE 517 Fall 2021 - E2153. Improving search facility in Expertiza]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper CSC/ECE 517 Fall 2021 - E2162. Further refactoring and improvement of review mapping helper]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality CSC/ECE 517 Fall 2021 - E2163.  Refactor waitlist functionality]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2165._Fix_teammate-review_view CSC/ECE 517 Fall 2021 - E2165. Fix teammate review view ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2155._Calibration_submissions_should_be_copied_along_with_calibration_assignments CSC/ECE 517 Fall 2021 - E2155. Calibration submissions should be copied along with calibration assignments]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2148._Completion/Progress_View CSC/ECE 517 Fall 2021 - E2148. Completion/Progress view]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2158._Grading_audit_trail CSC/ECE 517 Fall 2021 - E2158. Grading audit trail ]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2160._Implementing_and_testing_import_export_controllers#Description_about_project CSC/ECE 517 Fall 2021 - E2160. Implementing and testing import and export controllers]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2164._Heatgrid_fixes_and_improvements#Description_about_project CSC/ECE 517 Fall 2021 - E2164. Heatgrid fixes and improvements]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2168. Testing - Reputations]]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2156._Issues_related_to_meta-reviewing#Description_about_project CSC/ECE 517 Fall 2021 - E2156. Issues related to meta-reviewing]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2169. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
* [[E2157. Fix issues related to deadlines and late policies]]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files]&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=141574</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=141574"/>
		<updated>2021-11-09T21:48:12Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2129. Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2123. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2140. Create new late policy successfully and fix Bank link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2144. Refactor delayed mailer and scheduled task]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2145. OSS Project Beige]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2135. Email notification to reviewers and instructors]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades#Description_about_project CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring_and_Grades]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2150._Integrate_suggestion_detection_algorithm#Description_about_project CSC/ECE 517 Fall 2021 - E2150. Integrate suggestion detection algorithm]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2152._Revision_planning_tool#Description_about_project CSC/ECE 517 Fall 2021 - E2152. Revision_planning_tool]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2170._Testing_-_Response_Maps#Description_about_project CSC/ECE 517 Fall 2021 - E2170. Testing - Response Maps]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2153._Improving_search_facility_in_Expertiza#Description_about_project CSC/ECE 517 Fall 2021 - E2153. Improving search facility in Expertiza]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper CSC/ECE 517 Fall 2021 - E2162. Further refactoring and improvement of review mapping helper]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality CSC/ECE 517 Fall 2021 - E2163.  Refactor waitlist functionality]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2165._Fix_teammate-review_view CSC/ECE 517 Fall 2021 - E2165. Fix teammate review view ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2155._Calibration_submissions_should_be_copied_along_with_calibration_assignments CSC/ECE 517 Fall 2021 - E2155. Calibration submissions should be copied along with calibration assignments]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2148._Completion/Progress_View CSC/ECE 517 Fall 2021 - E2148. Completion/Progress view]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2158._Grading_audit_trail CSC/ECE 517 Fall 2021 - E2158. Grading audit trail ]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2160._Implementing_and_testing_import_export_controllers#Description_about_project CSC/ECE 517 Fall 2021 - E2160. Implementing and testing import and export controllers]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2164._Heatgrid_fixes_and_improvements#Description_about_project CSC/ECE 517 Fall 2021 - E2164. Heatgrid fixes and improvements]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2168. Testing - Reputations]]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2156._Issues_related_to_meta-reviewing#Description_about_project CSC/ECE 517 Fall 2021 - E2156. Issues related to meta-reviewing]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2169. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
* [[E2157. Fix issues related to deadlines and late policies]]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2167._Testing_-_Team_Related_Files#Description_about_project CSC/ECE 517 Fall 2021 - E2167. Testing - Team Related Files]&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140764</id>
		<title>CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140764"/>
		<updated>2021-11-04T01:01:48Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
== teams_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== teams_users_controller.rb ==&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt; Given user is not defined.&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
When given user is defined, link is provided to create the user. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt; Selected team to which user is being added belongs to an assignment:&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
When user is not a participant of the assignment, link is provided to add the user to the assignment. &amp;lt;br/&amp;gt;&lt;br /&gt;
When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &amp;lt;br/&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt;Selected team to which user is being added belongs to a course:&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
When user is not a participant of the course, link is provided to add the user to the course. &amp;lt;br/&amp;gt;&lt;br /&gt;
When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt;User under assignment or course team is deleted.&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
user association to the respective team is deleted and hence user is no longer part of the team. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
== student_teams_controller.rb ==&lt;br /&gt;
&amp;lt;font size = '4'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Create Student teams&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Update team name:&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 4: Remove team participants&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
== join_team_requests_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
P = Pending status&lt;br /&gt;
&lt;br /&gt;
D = Denied status&lt;br /&gt;
&lt;br /&gt;
A = Accepted status&lt;br /&gt;
&lt;br /&gt;
Scenario 1: Creating a team request&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Decline a team request.&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Check team status.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; .&lt;br /&gt;
&lt;br /&gt;
== advertise_partner_controller.rb ==&lt;br /&gt;
Scenario 1: Creating new advertisement for partners.&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Updating the advertisement.&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path .&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Remove the advertisement.&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path . &lt;br /&gt;
[[File:Teams adv remove.png]]&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140760</id>
		<title>CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140760"/>
		<updated>2021-11-04T00:57:28Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
== teams_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== teams_users_controller.rb ==&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt; Given user is not defined.&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
When given user is defined, link is provided to create the user. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt; Selected team to which user is being added belongs to an assignment:&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
When user is not a participant of the assignment, link is provided to add the user to the assignment. &amp;lt;br/&amp;gt;&lt;br /&gt;
When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &amp;lt;br/&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt;Selected team to which user is being added belongs to a course:&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
When user is not a participant of the course, link is provided to add the user to the course. &amp;lt;br/&amp;gt;&lt;br /&gt;
When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt;User under assignment or course team is deleted.&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
user association to the respective team is deleted and hence user is no longer part of the team. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
== student_teams_controller.rb ==&lt;br /&gt;
&amp;lt;font size = '4'&amp;gt; Scenario 1: Set the variables for view &amp;lt;/font&amp;gt;&lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Create Student teams&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Update team name:&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 4: Remove team participants&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
== join_team_requests_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
P = Pending status&lt;br /&gt;
&lt;br /&gt;
D = Denied status&lt;br /&gt;
&lt;br /&gt;
A = Accepted status&lt;br /&gt;
&lt;br /&gt;
Scenario 1: Creating a team request&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Decline a team request.&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Check team status.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; .&lt;br /&gt;
&lt;br /&gt;
Scenario 4: CRUD for join team request&lt;br /&gt;
[Flow]&lt;br /&gt;
&lt;br /&gt;
== advertise_partner_controller.rb ==&lt;br /&gt;
Scenario 1: Creating new advertisement for partners.&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Updating the advertisement.&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path .&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Remove the advertisement.&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path . &lt;br /&gt;
[[File:Teams adv remove.png]]&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140757</id>
		<title>CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140757"/>
		<updated>2021-11-04T00:56:17Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
== teams_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== teams_users_controller.rb ==&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;Scenario 1: Add new user to the selected team.&amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt; Given user is not defined.&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
When given user is defined, link is provided to create the user. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt; Selected team to which user is being added belongs to an assignment:&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
When user is not a participant of the assignment, link is provided to add the user to the assignment. &amp;lt;br/&amp;gt;&lt;br /&gt;
When the assignment team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &amp;lt;br/&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt;Selected team to which user is being added belongs to a course:&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
When user is not a participant of the course, link is provided to add the user to the course. &amp;lt;br/&amp;gt;&lt;br /&gt;
When the course team already has maximum number of users, &amp;quot;Maximum users reached&amp;quot; notification is flashed. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_create.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;font size = '4'&amp;gt;Scenario 2: Delete user from the selected team.&amp;lt;/font&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;font size = '3'&amp;gt;User under assignment or course team is deleted.&amp;lt;/font&amp;gt; &amp;lt;br/&amp;gt;&lt;br /&gt;
user association to the respective team is deleted and hence user is no longer part of the team. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:user_remove.png]]&lt;br /&gt;
&lt;br /&gt;
== student_teams_controller.rb ==&lt;br /&gt;
Scenario 1: Set the variables for view &lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Create Student teams&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Update team name:&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 4: Remove team participants&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
== join_team_requests_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
P = Pending status&lt;br /&gt;
&lt;br /&gt;
D = Denied status&lt;br /&gt;
&lt;br /&gt;
A = Accepted status&lt;br /&gt;
&lt;br /&gt;
Scenario 1: Creating a team request&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Decline a team request.&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Check team status.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; .&lt;br /&gt;
&lt;br /&gt;
Scenario 4: CRUD for join team request&lt;br /&gt;
[Flow]&lt;br /&gt;
&lt;br /&gt;
== advertise_partner_controller.rb ==&lt;br /&gt;
Scenario 1: Creating new advertisement for partners.&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Updating the advertisement.&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path .&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Remove the advertisement.&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path . &lt;br /&gt;
[[File:Teams adv remove.png]]&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140753</id>
		<title>CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140753"/>
		<updated>2021-11-04T00:53:58Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
== teams_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== teams_users_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== student_teams_controller.rb ==&lt;br /&gt;
Scenario 1: Set the variables for view &lt;br /&gt;
#If the current user is student and their User Ids match, then the following values are set: @send_invs, @received_invs,  @current_due_date, @users_on_waiting_list, @teammate_review_allowed&lt;br /&gt;
# If the current user is not student or the User Ids do not match, then the return from method&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Create Student teams&lt;br /&gt;
# If team name is empty, flash an error message saying &amp;quot;Team name missing while creating team&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name already in use, &amp;quot;Team name being created was already in use&amp;quot; and redirect to view_student_teams_path&lt;br /&gt;
# If team name is not empty and team name not in use, save team data, add logged in student to team and redirect to view_student_teams_path.&lt;br /&gt;
[[File:Team stud create.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Update team name:&lt;br /&gt;
# Find the team that should be updated.&lt;br /&gt;
# If there are no matching teams, call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there is exactly one match, then call team_created_successfully and redirect to view_student_teams_path&lt;br /&gt;
# If there are more than one team, then show the following error message &amp;quot;Team name being updated to was already in use&amp;quot; and redirect to edit_student_teams_path&lt;br /&gt;
[[File:Team student update.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 4: Remove team participants&lt;br /&gt;
# Find the user who has to be removed.&lt;br /&gt;
# Remove the user from team.&lt;br /&gt;
# If the team does not have any more participants, remove the team record from database.&lt;br /&gt;
# If the assignment has sign up sheet, then add the topic back to topics pool or assign the topic to a new team from waitlist&lt;br /&gt;
# Remove all the invitations sent and redirect to view_student_teams_path&lt;br /&gt;
[[File:Team stud remove.png]]&lt;br /&gt;
&lt;br /&gt;
== join_team_requests_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
P = Pending status&lt;br /&gt;
&lt;br /&gt;
D = Denied status&lt;br /&gt;
&lt;br /&gt;
A = Accepted status&lt;br /&gt;
&lt;br /&gt;
Scenario 1: Creating a team request&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Decline a team request.&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Check team status.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; .&lt;br /&gt;
&lt;br /&gt;
Scenario 4: CRUD for join team request&lt;br /&gt;
[Flow]&lt;br /&gt;
&lt;br /&gt;
== advertise_partner_controller.rb ==&lt;br /&gt;
Scenario 1: Creating new advertisement for partners.&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Updating the advertisement.&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path .&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Remove the advertisement.&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path . &lt;br /&gt;
[[File:Teams adv remove.png]]&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Team_stud_remove.png&amp;diff=140752</id>
		<title>File:Team stud remove.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Team_stud_remove.png&amp;diff=140752"/>
		<updated>2021-11-04T00:53:24Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Team_student_update.png&amp;diff=140751</id>
		<title>File:Team student update.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Team_student_update.png&amp;diff=140751"/>
		<updated>2021-11-04T00:52:27Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Team_stud_create.png&amp;diff=140749</id>
		<title>File:Team stud create.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Team_stud_create.png&amp;diff=140749"/>
		<updated>2021-11-04T00:51:11Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140744</id>
		<title>CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140744"/>
		<updated>2021-11-04T00:46:55Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
== teams_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== teams_users_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== student_teams_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== join_team_requests_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
P = Pending status&lt;br /&gt;
&lt;br /&gt;
D = Denied status&lt;br /&gt;
&lt;br /&gt;
A = Accepted status&lt;br /&gt;
&lt;br /&gt;
Scenario 1: Creating a team request&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Decline a team request.&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Check team status.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; .&lt;br /&gt;
&lt;br /&gt;
Scenario 4: CRUD for join team request&lt;br /&gt;
[Flow]&lt;br /&gt;
&lt;br /&gt;
== advertise_partner_controller.rb ==&lt;br /&gt;
Scenario 1: Creating new advertisement for partners.&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Updating the advertisement.&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path .&lt;br /&gt;
&lt;br /&gt;
[[File:Teams adv create.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Remove the advertisement.&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path . &lt;br /&gt;
[[File:Teams adv remove.png]]&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Teams_adv_remove.png&amp;diff=140742</id>
		<title>File:Teams adv remove.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Teams_adv_remove.png&amp;diff=140742"/>
		<updated>2021-11-04T00:45:46Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Teams_adv_create.png&amp;diff=140741</id>
		<title>File:Teams adv create.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Teams_adv_create.png&amp;diff=140741"/>
		<updated>2021-11-04T00:44:55Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140740</id>
		<title>CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140740"/>
		<updated>2021-11-04T00:42:33Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
== teams_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== teams_users_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== student_teams_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== join_team_requests_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
P = Pending status&lt;br /&gt;
&lt;br /&gt;
D = Denied status&lt;br /&gt;
&lt;br /&gt;
A = Accepted status&lt;br /&gt;
&lt;br /&gt;
Scenario 1: Creating a team request&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Decline a team request.&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Check team status.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; .&lt;br /&gt;
&lt;br /&gt;
Scenario 4: CRUD for join team request&lt;br /&gt;
[Flow]&lt;br /&gt;
&lt;br /&gt;
== advertise_partner_controller.rb ==&lt;br /&gt;
Scenario 1: Creating new advertisement for partners.&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
[[File:Teams adv1.png]]&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Updating the advertisement.&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path .&lt;br /&gt;
&lt;br /&gt;
[Flow diagram here]&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Remove the advertisement.&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path . &lt;br /&gt;
[Flow diagram here]&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Teams_adv1.png&amp;diff=140739</id>
		<title>File:Teams adv1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Teams_adv1.png&amp;diff=140739"/>
		<updated>2021-11-04T00:39:01Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140667</id>
		<title>CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files&amp;diff=140667"/>
		<updated>2021-11-03T21:58:27Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: Created page with &amp;quot;__TOC__  = Relevant links =  = About Expertiza = [http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework....&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
= Relevant links =&lt;br /&gt;
&lt;br /&gt;
= About Expertiza =&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
= Problem statement and background =&lt;br /&gt;
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller.  They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team&lt;br /&gt;
&lt;br /&gt;
= Approach Chosen &amp;amp; Why? =&lt;br /&gt;
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. &lt;br /&gt;
We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
&lt;br /&gt;
== teams_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== teams_users_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== student_teams_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== join_team_requests_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
P = Pending status&lt;br /&gt;
&lt;br /&gt;
D = Denied status&lt;br /&gt;
&lt;br /&gt;
A = Accepted status&lt;br /&gt;
&lt;br /&gt;
Scenario 1: Creating a team request&lt;br /&gt;
# If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .&lt;br /&gt;
# If error occurs, flash error message.&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Decline a team request.&lt;br /&gt;
# After verifying team_user_id, change @join_team_request.status = 'D' .&lt;br /&gt;
# Redirect to view_student_teams_path&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Check team status.&lt;br /&gt;
# If team if full. Print error message &amp;quot;This team is full.&amp;quot; .&lt;br /&gt;
# If team is not empty, print message &amp;quot;You are already a member of this team.&amp;quot; .&lt;br /&gt;
&lt;br /&gt;
Scenario 4: CRUD for join team request&lt;br /&gt;
[Flow]&lt;br /&gt;
&lt;br /&gt;
== advertise_partner_controller.rb ==&lt;br /&gt;
Scenario 1: Creating new advertisement for partners.&lt;br /&gt;
# We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
[Flow diagram here]&lt;br /&gt;
&lt;br /&gt;
Scenario 2: Updating the advertisement.&lt;br /&gt;
# We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Update Unsuccessful : If there is an error during update then the following error message is thrown &amp;quot;An error occurred and your advertisement was not updated.&amp;quot; and edit page is rendered.&lt;br /&gt;
# Update Successful : If the advertisement is successfully updated in the database then the &amp;quot;Your advertisement was successfully updated!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path .&lt;br /&gt;
&lt;br /&gt;
[Flow diagram here]&lt;br /&gt;
&lt;br /&gt;
Scenario 3: Remove the advertisement.&lt;br /&gt;
# We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model. &lt;br /&gt;
# Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown &amp;quot;An error occurred and your advertisement was not removed.&amp;quot; and the previous page is rendered.&lt;br /&gt;
# Remove Successful : If the advertisement is successfully removed in the database then the &amp;quot;Your advertisement was successfully removed!&amp;quot; message is prompted and the user is redirected to the view_student_teams_path . &lt;br /&gt;
[Flow diagram here]&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140666</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140666"/>
		<updated>2021-11-03T21:57:40Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2129. Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2123. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2140. Create new late policy successfully and fix Bank link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2144. Refactor delayed mailer and scheduled task]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2145. OSS Project Beige]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2135. Email notification to reviewers and instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2168. Testing - Reputations]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades#Description_about_project CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring_and_Grades]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2150._Integrate_suggestion_detection_algorithm#Description_about_project CSC/ECE 517 Fall 2021 - E2150. Integrate suggestion detection algorithm]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2152._Revision_planning_tool#Description_about_project CSC/ECE 517 Fall 2021 - E2152. Revision_planning_tool]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2170._Testing_-_Response_Maps#Description_about_project CSC/ECE 517 Fall 2021 - E2170. Testing - Response Maps]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2153._Improving_search_facility_in_Expertiza#Description_about_project CSC/ECE 517 Fall 2021 - E2153. Improving search facility in Expertiza]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper CSC/ECE 517 Fall 2021 - E2162. Further refactoring and improvement of review mapping helper]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality CSC/ECE 517 Fall 2021 - E2163.  Refactor waitlist functionality]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2165._Fix_teammate-review_view CSC/ECE 517 Fall 2021 - E2165. Fix teammate review view ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2155._Calibration_submissions_should_be_copied_along_with_calibration_assignments CSC/ECE 517 Fall 2021 - E2155. Calibration submissions should be copied along with calibration assignments]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2148._Completion/Progress_View CSC/ECE 517 Fall 2021 - E2148. Completion/Progress view]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2158._Grading_audit_trail CSC/ECE 517 Fall 2021 - E2158. Grading audit trail ]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2160._Implementing_and_testing_import_export_controllers#Description_about_project CSC/ECE 517 Fall 2021 - E2160. Implementing and testing import and export controllers]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2164._Heatgrid_fixes_and_improvements#Description_about_project CSC/ECE 517 Fall 2021 - E2164. Heatgrid fixes and improvements]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files]&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=140103</id>
		<title>CSC/ECE 517 Fall 2021 - E2129. Refactor auth controller.rb &amp; password retrieval controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=140103"/>
		<updated>2021-10-26T18:58:04Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2129: Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb  ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Relevant links ==&lt;br /&gt;
#Github : https://github.com/smanishs175/expertiza.git&lt;br /&gt;
#Github pull request: https://github.com/expertiza/expertiza/pull/2084&lt;br /&gt;
#VCL Deployment: http://152.7.176.119:8080&lt;br /&gt;
##Deployment is scheduled to be available until November 13, 2021&lt;br /&gt;
##In the case of a VCL timeout before then, please contact the group so they can reboot the server.  This is a known issue with VCL that is out of their control.&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
== Description Of Current Project ==&lt;br /&gt;
Our goal for this project is to refactor certain files (auth_controller.rb and password_retrieval_controller.rb) to follow essential Ruby on Rails design principles.  Since this is a refactoring project, all [https://rspec.info/ RSpec] test cases must result in the same behavior as before, with no changes to the overall functionality of the code.&lt;br /&gt;
&lt;br /&gt;
== Files Modified/Added ==&lt;br /&gt;
Two controller files were modified for this project:&amp;lt;br/&amp;gt;&lt;br /&gt;
# auth_controller.rb (expertiza/app/controllers/auth_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
# password_retrieval_controller.rb (expertiza/app/controllers/password_retrieval_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One RSpec file was added to help test filters: &amp;lt;br/&amp;gt;&lt;br /&gt;
# filters.rb (expertiza/spec/support/matchers/filters.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
The auth_controller deals with user authentication when they try and login.  Spelling needed to be adjusted to American style.  Some comments were added and logger call locations were moved to before/after filters.&lt;br /&gt;
&lt;br /&gt;
=====About Filters=====&lt;br /&gt;
Rails filters are methods that run before or after a controller's action method is executed. They are helpful when you want to ensure that a given block of code runs with whatever action method is called.&lt;br /&gt;
&lt;br /&gt;
Rails support three types of filter methods:&lt;br /&gt;
&lt;br /&gt;
Before filters- before_action filter is executed before the code in action controller is executed.&lt;br /&gt;
After filters- after_action filter is executed after the code in action controller is executed.&lt;br /&gt;
Around filters- around_action filter is executed before and after the code in action controller is executed.&lt;br /&gt;
&lt;br /&gt;
=====Reason for the need of Filters in Authentication Controller=====&lt;br /&gt;
Calls to logger should be written as filters is that a call to a logger tends to be a full line of code.  If we put the full line of code everywhere that the logger needs to be called, the logger text tends to distract from the rest of the work done by the method.  It tends to pollute the code.  If it is an after_action, then it gets called automatically when the method finishes, without having to appear in the method at all.  It is a cleaner way of calling the logger.  It is a case of the Separation of Responsibility principle.&lt;br /&gt;
&lt;br /&gt;
Filter loggers are added to prioritize the method calls in function: &amp;lt;br/&amp;gt;&lt;br /&gt;
#These filters are added for specific reasons: When the action_allowed? controller deals with authorizing the actions such as login, logout, login failed etc. &lt;br /&gt;
1. before_action :action_allowed?, only:[:login,:login_failed,:google_login] &amp;lt;br/&amp;gt;&lt;br /&gt;
2. after_action :action_allowed?, only:[:logout]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
The password_retrieval_controller deals with the process of updating and resetting the password for users, in case they have forgotten their password.  Comments were needed in many places in this file, and some comments that were there before had to be modified.  A user alert had to be modified to be more clear, and a hard-coded value had to be moved to a parameter.&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
All previous tests for Authentication_Controller  are working. Authentication_Controller with filters is working fine. We created filters.rb file in spec/support/matchers/ directory. This was additional functionality which we tried to do.This filters.rb file was to be called from Authentication controller. We were not able to solve error raised for this additional part&lt;br /&gt;
&lt;br /&gt;
== List Of Changes ==&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
Spelling was adjusted from authorised to authorized: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix_2.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a comment to explain the branches of a conjunction: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Branch_conjunction_comment.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add filters for loggers: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Auth_controller_filters_before.PNG]]&lt;br /&gt;
[[File:E2129_Auth_controller_filters_after.png]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
Method check_reset_url was renamed to a more descriptive check_token_validity: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Check_token_validity.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A parameter was created for the token expiration time instead of hardcoding it: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Token_time.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Descriptive comments were added to send_password: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Send_password_comments.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A statement inside the reset_password method that was copied from the forgotten method was replaced with a call to the forgotten method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A code block inside the check_reset_url method that was copied from the reset_password method was replaced with a call to the reset_password method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An error message in the check_reset_url method was updated to be more descriptive to a user: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Invalid_token_user_message.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
The contents of the new file support/matchers/filters.rb is shown below &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_filters.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Since this is just a refactoring project. No test cases have been written. &lt;br /&gt;
Although, we wrote a file which will test the functionality of the filters.&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
=== 1. The auth_controller.rb : === &lt;br /&gt;
The file has been tested using rspec. &amp;lt;br/&amp;gt;&lt;br /&gt;
Run the code:&lt;br /&gt;
rspec spec/helpers/authorization_helper_spec.rb . All test cases are passing as expected.&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_testing_auth_controller.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. The password_retrieval_controller.rb ===&lt;br /&gt;
The file has been tested using rspec.&amp;lt;br/&amp;gt;&lt;br /&gt;
Run the code:&lt;br /&gt;
rspec spec/helpers/password_retrieval_controller.rb . All test cases are passing as expected.&lt;br /&gt;
[[File:E2129_password_retrieval_controller.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The Team ==&lt;br /&gt;
Aaron Mathew - asmathew@ncsu.edu &amp;lt;br/&amp;gt;&lt;br /&gt;
Manish Shinde - msshinde@ncsu.edu &amp;lt;br/&amp;gt;&lt;br /&gt;
Quinn Dibble - qdibble@ncsu.edu &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139935</id>
		<title>CSC/ECE 517 Fall 2021 - E2129. Refactor auth controller.rb &amp; password retrieval controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139935"/>
		<updated>2021-10-23T20:50:30Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2129: Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb  ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Relevant links ==&lt;br /&gt;
#Github : https://github.com/smanishs175/expertiza.git&lt;br /&gt;
#VCL Deployment: http://152.7.176.119:8080&lt;br /&gt;
##Deployment is scheduled to be available until November 13, 2021&lt;br /&gt;
##In the case of a VCL timeout before then, please contact the group so they can reboot the server.  This is a known issue with VCL that is out of their control.&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
== Description Of Current Project ==&lt;br /&gt;
Our goal for this project is to refactor certain files (auth_controller.rb and password_retrieval_controller.rb) to follow essential Ruby on Rails design principles.  Since this is a refactoring project, all [https://rspec.info/ RSpec] test cases must result in the same behavior as before, with no changes to the overall functionality of the code.&lt;br /&gt;
&lt;br /&gt;
== Files Modified/Added ==&lt;br /&gt;
Two controller files were modified for this project:&amp;lt;br/&amp;gt;&lt;br /&gt;
# auth_controller.rb (expertiza/app/controllers/auth_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
# password_retrieval_controller.rb (expertiza/app/controllers/password_retrieval_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One RSpec file was added to help test filters: &amp;lt;br/&amp;gt;&lt;br /&gt;
# filters.rb (expertiza/spec/support/matchers/filters.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
The auth_controller deals with user authentication when they try and login.  Spelling needed to be adjusted to American style.  Some comments were added and logger call locations were moved to before/after filters.&lt;br /&gt;
&lt;br /&gt;
=====About Filters=====&lt;br /&gt;
Rails filters are methods that run before or after a controller's action method is executed. They are helpful when you want to ensure that a given block of code runs with whatever action method is called.&lt;br /&gt;
&lt;br /&gt;
Rails support three types of filter methods:&lt;br /&gt;
&lt;br /&gt;
Before filters- before_action filter is executed before the code in action controller is executed.&lt;br /&gt;
After filters- after_action filter is executed after the code in action controller is executed.&lt;br /&gt;
Around filters- around_action filter is executed before and after the code in action controller is executed.&lt;br /&gt;
&lt;br /&gt;
=====Reason for the need of Filters in Authentication Controller=====&lt;br /&gt;
Calls to logger should be written as filters is that a call to a logger tends to be a full line of code.  If we put the full line of code everywhere that the logger needs to be called, the logger text tends to distract from the rest of the work done by the method.  It tends to pollute the code.  If it is an after_action, then it gets called automatically when the method finishes, without having to appear in the method at all.  It is a cleaner way of calling the logger.  It is a case of the Separation of Responsibility principle.&lt;br /&gt;
&lt;br /&gt;
Filter loggers are added to prioritize the method calls in function: &amp;lt;br/&amp;gt;&lt;br /&gt;
#These filters are added for specific reasons: When the action_allowed? controller deals with authorizing the actions such as login, logout, login failed etc. &lt;br /&gt;
1. before_action :action_allowed?, only:[:login,:login_failed,:google_login] &amp;lt;br/&amp;gt;&lt;br /&gt;
2. after_action :action_allowed?, only:[:logout]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
The password_retrieval_controller deals with the process of updating and resetting the password for users, in case they have forgotten their password.  Comments were needed in many places in this file, and some comments that were there before had to be modified.  A user alert had to be modified to be more clear, and a hard-coded value had to be moved to a parameter.&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
All previous tests for Authentication_Controller  are working. Authentication_Controller with filters is working fine. We created filters.rb file in spec/support/matchers/ directory. This was additional functionality which we tried to do.This filters.rb file was to be called from Authentication controller. We were not able to solve error raised for this additional part&lt;br /&gt;
&lt;br /&gt;
== List Of Changes ==&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
Spelling was adjusted from authorised to authorized: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix_2.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a comment to explain the branches of a conjunction: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Branch_conjunction_comment.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add filters for loggers: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Auth_controller_filters_before.PNG]]&lt;br /&gt;
[[File:E2129_Auth_controller_filters_after.png]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
Method check_reset_url was renamed to a more descriptive check_token_validity: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Check_token_validity.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A parameter was created for the token expiration time instead of hardcoding it: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Token_time.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Descriptive comments were added to send_password: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Send_password_comments.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A statement inside the reset_password method that was copied from the forgotten method was replaced with a call to the forgotten method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A code block inside the check_reset_url method that was copied from the reset_password method was replaced with a call to the reset_password method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An error message in the check_reset_url method was updated to be more descriptive to a user: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Invalid_token_user_message.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
The contents of the new file support/matchers/filters.rb is shown below &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_filters.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Since this is just a refactoring project. No test cases have been written. &lt;br /&gt;
Although, we wrote a file which will test the functionality of the filters.&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
=== 1. The auth_controller.rb : === &lt;br /&gt;
The file has been tested using rspec. &amp;lt;br/&amp;gt;&lt;br /&gt;
Run the code:&lt;br /&gt;
rspec spec/helpers/authorization_helper_spec.rb . All test cases are passing as expected.&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_testing_auth_controller.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. The password_retrieval_controller.rb ===&lt;br /&gt;
The file has been tested using rspec.&amp;lt;br/&amp;gt;&lt;br /&gt;
Run the code:&lt;br /&gt;
rspec spec/helpers/password_retrieval_controller.rb . All test cases are passing as expected.&lt;br /&gt;
[[File:E2129_password_retrieval_controller.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The Team ==&lt;br /&gt;
Aaron Mathew - asmathew@ncsu.edu &amp;lt;br/&amp;gt;&lt;br /&gt;
Manish Shinde - msshinde@ncsu.edu &amp;lt;br/&amp;gt;&lt;br /&gt;
Quinn Dibble - qdibble@ncsu.edu &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139927</id>
		<title>CSC/ECE 517 Fall 2021 - E2129. Refactor auth controller.rb &amp; password retrieval controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139927"/>
		<updated>2021-10-23T20:21:47Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2129: Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb  ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Relevant links ==&lt;br /&gt;
#Github : https://github.com/smanishs175/expertiza.git&lt;br /&gt;
#VCL Deployment: http://152.7.176.119:8080&lt;br /&gt;
##Deployment is scheduled to be available until November 13, 2021&lt;br /&gt;
##In the case of a VCL timeout before then, please contact the group so they can reboot the server.  This is a known issue with VCL that is out of their control.&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
== Description Of Current Project ==&lt;br /&gt;
Our goal for this project is to refactor certain files (auth_controller.rb and password_retrieval_controller.rb) to follow essential Ruby on Rails design principles.  Since this is a refactoring project, all [https://rspec.info/ RSpec] test cases must result in the same behavior as before, with no changes to the overall functionality of the code.&lt;br /&gt;
&lt;br /&gt;
== Files Modified/Added ==&lt;br /&gt;
Two controller files were modified for this project:&amp;lt;br/&amp;gt;&lt;br /&gt;
# auth_controller.rb (expertiza/app/controllers/auth_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
# password_retrieval_controller.rb (expertiza/app/controllers/password_retrieval_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One RSpec file was added to help test filters: &amp;lt;br/&amp;gt;&lt;br /&gt;
# filters.rb (expertiza/spec/support/matchers/filters.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
The auth_controller deals with user authentication when they try and login.  Spelling needed to be adjusted to American style.  Some comments were added and logger call locations were moved to before/after filters.&lt;br /&gt;
&lt;br /&gt;
=====About Filters=====&lt;br /&gt;
Rails filters are methods that run before or after a controller's action method is executed. They are helpful when you want to ensure that a given block of code runs with whatever action method is called.&lt;br /&gt;
&lt;br /&gt;
Rails support three types of filter methods:&lt;br /&gt;
&lt;br /&gt;
Before filters- before_action filter is executed before the code in action controller is executed.&lt;br /&gt;
After filters- after_action filter is executed after the code in action controller is executed.&lt;br /&gt;
Around filters- around_action filter is executed before and after the code in action controller is executed.&lt;br /&gt;
&lt;br /&gt;
=====Reason for the need of Filters in Authentication Controller=====&lt;br /&gt;
Calls to logger should be written as filters is that a call to a logger tends to be a full line of code.  If we put the full line of code everywhere that the logger needs to be called, the logger text tends to distract from the rest of the work done by the method.  It tends to pollute the code.  If it is an after_action, then it gets called automatically when the method finishes, without having to appear in the method at all.  It is a cleaner way of calling the logger.  It is a case of the Separation of Responsibility principle.&lt;br /&gt;
&lt;br /&gt;
Filter loggers are added to prioritize the method calls in function: &amp;lt;br/&amp;gt;&lt;br /&gt;
#These filters are added for specific reasons: When the action_allowed? controller deals with authorizing the actions such as login, logout, login failed etc. &lt;br /&gt;
1. before_action :action_allowed?, only:[:login,:login_failed,:google_login] &amp;lt;br/&amp;gt;&lt;br /&gt;
2. after_action :action_allowed?, only:[:logout]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
The password_retrieval_controller deals with the process of updating and resetting the password for users, in case they have forgotten their password.  Comments were needed in many places in this file, and some comments that were there before had to be modified.  A user alert had to be modified to be more clear, and a hard-coded value had to be moved to a parameter.&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
All previous tests for Authentication_Controller  are working. Authentication_Controller with filters is working fine. We created filters.rb file in spec/support/matchers/ directory. This was additional functionality which we tried to do.This filters.rb file was to be called from Authentication controller. We were not able to solve error raised for this additional part&lt;br /&gt;
&lt;br /&gt;
== List Of Changes ==&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
Spelling was adjusted from authorised to authorized: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix_2.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a comment to explain the branches of a conjunction: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Branch_conjunction_comment.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add filters for loggers: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Auth_controller_filters_before.PNG]]&lt;br /&gt;
[[File:E2129_Auth_controller_filters_after.png]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
Method check_reset_url was renamed to a more descriptive check_token_validity: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Check_token_validity.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A parameter was created for the token expiration time instead of hardcoding it: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Token_time.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Descriptive comments were added to send_password: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Send_password_comments.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A statement inside the reset_password method that was copied from the forgotten method was replaced with a call to the forgotten method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A code block inside the check_reset_url method that was copied from the reset_password method was replaced with a call to the reset_password method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An error message in the check_reset_url method was updated to be more descriptive to a user: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Invalid_token_user_message.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
The contents of the new file support/matchers/filters.rb is shown below &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_filters.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Since this is just a refactoring project. No test cases have been written. &lt;br /&gt;
Although, we wrote a file which will test the functionality of the filters.&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
=== 1. The auth_controller.rb : === &lt;br /&gt;
The file has been tested using rspec. &amp;lt;br/&amp;gt;&lt;br /&gt;
rspec spec/helpers/authorization_helper_spec.rb . All test cases are passing as expected.&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_testing_auth_controller.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. The password_retrieval_controller.rb ===&lt;br /&gt;
The file has been tested using rspec.&amp;lt;br/&amp;gt;&lt;br /&gt;
rspec spec/helpers/password_retrieval_controller.rb . All test cases are passing as expected.&lt;br /&gt;
[[File:E2129_password_retrieval_controller.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The Team ==&lt;br /&gt;
Aaron Mathew - asmathew@ncsu.edu &amp;lt;br/&amp;gt;&lt;br /&gt;
Manish Shinde - msshinde@ncsu.edu &amp;lt;br/&amp;gt;&lt;br /&gt;
Quinn Dibble - qdibble@ncsu.edu &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139801</id>
		<title>CSC/ECE 517 Fall 2021 - E2129. Refactor auth controller.rb &amp; password retrieval controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139801"/>
		<updated>2021-10-21T03:05:16Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2129: Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb  ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Relevant links ==&lt;br /&gt;
#Github : https://github.com/smanishs175/expertiza.git&lt;br /&gt;
#VCL Deployment: http://152.7.176.119:8080&lt;br /&gt;
##Deployment is scheduled to be available until November 13, 2021&lt;br /&gt;
##In the case of a VCL timeout before then, please contact the group so they can reboot the server.  This is a known issue with VCL that is out of their control.&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
== Description Of Current Project ==&lt;br /&gt;
Our goal for this project is to refactor certain files (auth_controller.rb and password_retrieval_controller.rb) to follow essential Ruby on Rails design principles.  Since this is a refactoring project, all [https://rspec.info/ RSpec] test cases must result in the same behavior as before, with no changes to the overall functionality of the code.&lt;br /&gt;
&lt;br /&gt;
== Files Modified/Added ==&lt;br /&gt;
Two controller files were modified for this project:&amp;lt;br/&amp;gt;&lt;br /&gt;
# auth_controller.rb (expertiza/app/controllers/auth_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
# password_retrieval_controller.rb (expertiza/app/controllers/password_retrieval_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One RSpec file was added to help test filters: &amp;lt;br/&amp;gt;&lt;br /&gt;
# filters.rb (expertiza/spec/support/matchers/filters.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
The auth_controller deals with user authentication when they try and login.  Spelling needed to be adjusted to American style.  Some comments were added and logger call locations were moved to before/after filters.&lt;br /&gt;
&lt;br /&gt;
=====About Filters=====&lt;br /&gt;
Rails filters are methods that run before or after a controller's action method is executed. They are helpful when you want to ensure that a given block of code runs with whatever action method is called.&lt;br /&gt;
&lt;br /&gt;
Rails support three types of filter methods:&lt;br /&gt;
&lt;br /&gt;
Before filters- before_action filter is executed before the code in action controller is executed.&lt;br /&gt;
After filters- after_action filter is executed after the code in action controller is executed.&lt;br /&gt;
Around filters- around_action filter is executed before and after the code in action controller is executed.&lt;br /&gt;
&lt;br /&gt;
=====Reason for the need of Filters in Authentication Controller=====&lt;br /&gt;
Calls to logger should be written as filters is that a call to a logger tends to be a full line of code.  If we put the full line of code everywhere that the logger needs to be called, the logger text tends to distract from the rest of the work done by the method.  It tends to pollute the code.  If it is an after_action, then it gets called automatically when the method finishes, without having to appear in the method at all.  It is a cleaner way of calling the logger.  It is a case of the Separation of Responsibility principle.&lt;br /&gt;
&lt;br /&gt;
Filter loggers are added to prioritize the method calls in function: &amp;lt;br/&amp;gt;&lt;br /&gt;
#These filters are added for specific reasons: When the action_allowed? controller deals with authorizing the actions such as login, logout, login failed etc. &lt;br /&gt;
1. before_action :action_allowed?, only:[:login,:login_failed,:google_login] &amp;lt;br/&amp;gt;&lt;br /&gt;
2. after_action :action_allowed?, only:[:logout]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
The password_retrieval_controller deals with the process of updating and resetting the password for users, in case they have forgotten their password.  Comments were needed in many places in this file, and some comments that were there before had to be modified.  A user alert had to be modified to be more clear, and a hard-coded value had to be moved to a parameter.&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
All previous tests for Authentication_Controller  are working. Authentication_Controller with filters is working fine. We created filters.rb file in spec/support/matchers/ directory. This was additional functionality which we tried to do.This filters.rb file was to be called from Authentication controller. We were not able to solve error raised for this additional part&lt;br /&gt;
&lt;br /&gt;
== List Of Changes ==&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
Spelling was adjusted from authorised to authorized: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix_2.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a comment to explain the branches of a conjunction: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Branch_conjunction_comment.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add filters for loggers: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Auth_controller_filters_before.PNG]]&lt;br /&gt;
[[File:E2129_Auth_controller_filters_after.png]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
Method check_reset_url was renamed to a more descriptive check_token_validity: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Check_token_validity.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A parameter was created for the token expiration time instead of hardcoding it: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Token_time.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Descriptive comments were added to send_password: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Send_password_comments.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A statement inside the reset_password method that was copied from the forgotten method was replaced with a call to the forgotten method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A code block inside the check_reset_url method that was copied from the reset_password method was replaced with a call to the reset_password method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An error message in the check_reset_url method was updated to be more descriptive to a user: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Invalid_token_user_message.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
The contents of the new file support/matchers/filters.rb is shown below &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_filters.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
=== 1. The auth_controller.rb : === &lt;br /&gt;
The file has been tested using rspec. &amp;lt;br/&amp;gt;&lt;br /&gt;
rspec spec/helpers/authorization_helper_spec.rb . All test cases are passing as expected.&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_testing_auth_controller.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. The password_retrieval_controller.rb ===&lt;br /&gt;
The file has been tested using rspec.&amp;lt;br/&amp;gt;&lt;br /&gt;
rspec spec/helpers/password_retrieval_controller.rb . All test cases are passing as expected.&lt;br /&gt;
[[File:E2129_password_retrieval_controller.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The Team ==&lt;br /&gt;
Aaron Mathew - asmathew@ncsu.edu &amp;lt;br/&amp;gt;&lt;br /&gt;
Manish Shinde - msshinde@ncsu.edu &amp;lt;br/&amp;gt;&lt;br /&gt;
Quinn Dibble - qdibble@ncsu.edu &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139659</id>
		<title>CSC/ECE 517 Fall 2021 - E2129. Refactor auth controller.rb &amp; password retrieval controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139659"/>
		<updated>2021-10-21T01:34:41Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2129: Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb  ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Relevant links ==&lt;br /&gt;
#Github : https://github.com/smanishs175/expertiza.git&lt;br /&gt;
#VCL Deployment: http://152.7.176.119:8080&lt;br /&gt;
##Deployment is scheduled to be available until November 13, 2021&lt;br /&gt;
##In the case of a VCL timeout before then, please contact the group so they can reboot the server.  This is a known issue with VCL that is out of their control.&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
== Description Of Current Project ==&lt;br /&gt;
Our goal for this project is to refactor certain files (auth_controller.rb and password_retrieval_controller.rb) to follow essential Ruby on Rails design principles.  Since this is a refactoring project, all [https://rspec.info/ RSpec] test cases must result in the same behavior as before, with no changes to the overall functionality of the code.&lt;br /&gt;
&lt;br /&gt;
== Files Modified/Added ==&lt;br /&gt;
Two controller files were modified for this project:&amp;lt;br/&amp;gt;&lt;br /&gt;
# auth_controller.rb (expertiza/app/controllers/auth_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
# password_retrieval_controller.rb (expertiza/app/controllers/password_retrieval_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One RSpec file was added to help test filters: &amp;lt;br/&amp;gt;&lt;br /&gt;
# filters.rb (expertiza/spec/support/matchers/filters.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
The auth_controller deals with user authentication when they try and login.  Spelling needed to be adjusted to American style.  Some comments were added and logger call locations were moved to before/after filters.&lt;br /&gt;
&lt;br /&gt;
=====About Filters=====&lt;br /&gt;
Rails filters are methods that run before or after a controller's action method is executed. They are helpful when you want to ensure that a given block of code runs with whatever action method is called.&lt;br /&gt;
&lt;br /&gt;
Rails support three types of filter methods:&lt;br /&gt;
&lt;br /&gt;
Before filters- before_action filter is executed before the code in action controller is executed.&lt;br /&gt;
After filters- after_action filter is executed after the code in action controller is executed.&lt;br /&gt;
Around filters- around_action filter is executed before and after the code in action controller is executed.&lt;br /&gt;
&lt;br /&gt;
=====Reason for the need of Filters in Authentication Controller=====&lt;br /&gt;
Calls to logger should be written as filters is that a call to a logger tends to be a full line of code.  If we put the full line of code everywhere that the logger needs to be called, the logger text tends to distract from the rest of the work done by the method.  It tends to pollute the code.  If it is an after_action, then it gets called automatically when the method finishes, without having to appear in the method at all.  It is a cleaner way of calling the logger.  It is a case of the Separation of Responsibility principle.&lt;br /&gt;
&lt;br /&gt;
Filter loggers are added to prioritize the method calls in function: &amp;lt;br/&amp;gt;&lt;br /&gt;
#These filters are added for specific reasons: When the action_allowed? controller deals with authorizing the actions such as login, logout, login failed etc. &lt;br /&gt;
1. before_action :action_allowed?, only:[:login,:login_failed,:google_login] &amp;lt;br/&amp;gt;&lt;br /&gt;
2. after_action :action_allowed?, only:[:logout]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
The password_retrieval_controller deals with the process of updating and resetting the password for users, in case they have forgotten their password.  Comments were needed in many places in this file, and some comments that were there before had to be modified.  A user alert had to be modified to be more clear, and a hard-coded value had to be moved to a parameter.&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
All previous tests for Authentication_Controller  are working. Authentication_Controller with filters is working fine. We created filters.rb file in spec/support/matchers/ directory. This was additional functionality which we tried to do.This filters.rb file was to be called from Authentication controller. We were not able to solve error raised for this additional part&lt;br /&gt;
&lt;br /&gt;
== List Of Changes ==&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
Spelling was adjusted from authorised to authorized: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix_2.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a comment to explain the branches of a conjunction: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Branch_conjunction_comment.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add filters for loggers: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Auth_controller_filters_before.PNG]]&lt;br /&gt;
[[File:E2129_Auth_controller_filters_after.png]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
Method check_reset_url was renamed to a more descriptive check_token_validity: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Check_token_validity.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A parameter was created for the token expiration time instead of hardcoding it: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Token_time.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Descriptive comments were added to send_password: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Send_password_comments.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A statement inside the reset_password method that was copied from the forgotten method was replaced with a call to the forgotten method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A code block inside the check_reset_url method that was copied from the reset_password method was replaced with a call to the reset_password method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An error message in the check_reset_url method was updated to be more descriptive to a user: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Invalid_token_user_message.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
The contents of the new file support/matchers/filters.rb is shown below &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_filters.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
1. The auth_controller.rb : &amp;lt;br/&amp;gt;&lt;br /&gt;
The file has been tested using rspec. &amp;lt;br/&amp;gt;&lt;br /&gt;
rspec spec/helpers/authorization_helper_spec.rb . All test cases are passing as expected.&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_testing_auth_controller.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. The password_retrieval_controller.rb&lt;br /&gt;
The file has been tested using rspec.&amp;lt;br/&amp;gt;&lt;br /&gt;
rspec spec/helpers/password_retrieval_controller.rb . All test cases are passing as expected.&lt;br /&gt;
[[File:E2129_password_retrieval_controller.png]]&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2129_password_retrieval_controller.png&amp;diff=139656</id>
		<title>File:E2129 password retrieval controller.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2129_password_retrieval_controller.png&amp;diff=139656"/>
		<updated>2021-10-21T01:32:10Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139655</id>
		<title>CSC/ECE 517 Fall 2021 - E2129. Refactor auth controller.rb &amp; password retrieval controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139655"/>
		<updated>2021-10-21T01:30:46Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2129: Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb  ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Relevant links ==&lt;br /&gt;
#Github : https://github.com/smanishs175/expertiza.git&lt;br /&gt;
#VCL Deployment: http://152.7.176.119:8080&lt;br /&gt;
##Deployment is scheduled to be available until November 13, 2021&lt;br /&gt;
##In the case of a VCL timeout before then, please contact the group so they can reboot the server.  This is a known issue with VCL that is out of their control.&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
== Description Of Current Project ==&lt;br /&gt;
Our goal for this project is to refactor certain files (auth_controller.rb and password_retrieval_controller.rb) to follow essential Ruby on Rails design principles.  Since this is a refactoring project, all [https://rspec.info/ RSpec] test cases must result in the same behavior as before, with no changes to the overall functionality of the code.&lt;br /&gt;
&lt;br /&gt;
== Files Modified/Added ==&lt;br /&gt;
Two controller files were modified for this project:&amp;lt;br/&amp;gt;&lt;br /&gt;
# auth_controller.rb (expertiza/app/controllers/auth_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
# password_retrieval_controller.rb (expertiza/app/controllers/password_retrieval_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One RSpec file was added to help test filters: &amp;lt;br/&amp;gt;&lt;br /&gt;
# filters.rb (expertiza/spec/support/matchers/filters.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
The auth_controller deals with user authentication when they try and login.  Spelling needed to be adjusted to American style.  Some comments were added and logger call locations were moved to before/after filters.&lt;br /&gt;
&lt;br /&gt;
=====About Filters=====&lt;br /&gt;
Rails filters are methods that run before or after a controller's action method is executed. They are helpful when you want to ensure that a given block of code runs with whatever action method is called.&lt;br /&gt;
&lt;br /&gt;
Rails support three types of filter methods:&lt;br /&gt;
&lt;br /&gt;
Before filters- before_action filter is executed before the code in action controller is executed.&lt;br /&gt;
After filters- after_action filter is executed after the code in action controller is executed.&lt;br /&gt;
Around filters- around_action filter is executed before and after the code in action controller is executed.&lt;br /&gt;
&lt;br /&gt;
=====Reason for the need of Filters in Authentication Controller=====&lt;br /&gt;
Calls to logger should be written as filters is that a call to a logger tends to be a full line of code.  If we put the full line of code everywhere that the logger needs to be called, the logger text tends to distract from the rest of the work done by the method.  It tends to pollute the code.  If it is an after_action, then it gets called automatically when the method finishes, without having to appear in the method at all.  It is a cleaner way of calling the logger.  It is a case of the Separation of Responsibility principle.&lt;br /&gt;
&lt;br /&gt;
Filter loggers are added to prioritize the method calls in function: &amp;lt;br/&amp;gt;&lt;br /&gt;
#These filters are added for specific reasons: When the action_allowed? controller deals with authorizing the actions such as login, logout, login failed etc. &lt;br /&gt;
1. before_action :action_allowed?, only:[:login,:login_failed,:google_login] &amp;lt;br/&amp;gt;&lt;br /&gt;
2. after_action :action_allowed?, only:[:logout]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
The password_retrieval_controller deals with the process of updating and resetting the password for users, in case they have forgotten their password.  Comments were needed in many places in this file, and some comments that were there before had to be modified.  A user alert had to be modified to be more clear, and a hard-coded value had to be moved to a parameter.&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
All previous tests for Authentication_Controller  are working. Authentication_Controller with filters is working fine. We created filters.rb file in spec/support/matchers/ directory. This was additional functionality which we tried to do.This filters.rb file was to be called from Authentication controller. We were not able to solve error raised for this additional part&lt;br /&gt;
&lt;br /&gt;
== List Of Changes ==&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
Spelling was adjusted from authorised to authorized: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix_2.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a comment to explain the branches of a conjunction: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Branch_conjunction_comment.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add filters for loggers: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Auth_controller_filters_before.PNG]]&lt;br /&gt;
[[File:E2129_Auth_controller_filters_after.png]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
Method check_reset_url was renamed to a more descriptive check_token_validity: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Check_token_validity.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A parameter was created for the token expiration time instead of hardcoding it: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Token_time.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Descriptive comments were added to send_password: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Send_password_comments.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A statement inside the reset_password method that was copied from the forgotten method was replaced with a call to the forgotten method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Forgotten.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A code block inside the check_reset_url method that was copied from the reset_password method was replaced with a call to the reset_password method: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Change_to_reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Reset_password.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An error message in the check_reset_url method was updated to be more descriptive to a user: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Invalid_token_user_message.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
The contents of the new file support/matchers/filters.rb is shown below &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_filters.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
#The auth_controller.rb : &amp;lt;br/&amp;gt;&lt;br /&gt;
The file has been tested using rspec. &amp;lt;br/&amp;gt;&lt;br /&gt;
rspec spec/helpers/authorization_helper_spec.rb . All test cases are passing as expected.&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_testing_auth_controller.png]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#The password_retrieval_controller.rb&lt;br /&gt;
The file has been tested using rspec. &amp;lt;br/&amp;gt;&lt;br /&gt;
rspec spec/helpers/password_retrieval_controller.rb . All test cases are passing as expected. &amp;lt;/br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2129_testing_auth_controller.png&amp;diff=139645</id>
		<title>File:E2129 testing auth controller.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2129_testing_auth_controller.png&amp;diff=139645"/>
		<updated>2021-10-21T01:15:44Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139634</id>
		<title>CSC/ECE 517 Fall 2021 - E2129. Refactor auth controller.rb &amp; password retrieval controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139634"/>
		<updated>2021-10-21T01:06:32Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: Added few things about filters&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2129: Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb  ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Relevant links ==&lt;br /&gt;
#Github : https://github.com/smanishs175/expertiza.git&lt;br /&gt;
#VCL Deployment: 152.7.176.119:8080 (Please note that if incase vcl gives a timeout error contact the authors)&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
== Description Of Current Project ==&lt;br /&gt;
Our goal for this project is to refactor certain files (auth_controller.rb and password_retrieval_controller.rb) to follow essential Ruby on Rails design principles.  Since this is a refactoring project, all [https://rspec.info/ RSpec] test cases must result in the same behavior as before, with no changes to the overall functionality of the code.&lt;br /&gt;
&lt;br /&gt;
== Files Modified/Added ==&lt;br /&gt;
Two controller files were modified for this project:&amp;lt;br/&amp;gt;&lt;br /&gt;
# auth_controller.rb (expertiza/app/controllers/auth_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
# password_retrieval_controller.rb (expertiza/app/controllers/password_retrieval_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One RSpec file was added to help test filters: &amp;lt;br/&amp;gt;&lt;br /&gt;
# filters.rb (expertiza/spec/support/matchers/filters.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
The auth_controller deals with user authentication when they try and login.  Spelling needed to be adjusted to American style.  Some comments were added and logger call locations were moved to before/after filters.&lt;br /&gt;
=====Problem 1=====&lt;br /&gt;
Check for the spelling. Use American spellings. For example, self.authorised? should be self.authorized?. Check for similar spelling issues.&lt;br /&gt;
=====Solution1=====&lt;br /&gt;
We have made the spelling changes as required. We changes Authorised to Authorized&lt;br /&gt;
&lt;br /&gt;
=====Problem 2=====&lt;br /&gt;
In line 79, I don’t understand why both branches of the conjunction are needed; there should be a comment explaining this.&lt;br /&gt;
=====Solution2=====&lt;br /&gt;
We have added comments as &amp;quot;Checking if both places have same params&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====Problem 3=====&lt;br /&gt;
Calls to logger should be written as before_ or after_filters on a method whenever possible.&lt;br /&gt;
=====Solution 3=====&lt;br /&gt;
=====About Filters=====&lt;br /&gt;
Rails filters are methods that run before or after a controller's action method is executed. They are helpful when you want to ensure that a given block of code runs with whatever action method is called.&lt;br /&gt;
&lt;br /&gt;
Rails support three types of filter methods:&lt;br /&gt;
&lt;br /&gt;
Before filters- before_action filter is executed before the code in action controller is executed.&lt;br /&gt;
After filters- after_action filter is executed after the code in action controller is executed.&lt;br /&gt;
Around filters- around_action filter is executed before and after the code in action controller is executed.&lt;br /&gt;
&lt;br /&gt;
=====Reason for the need of Filters in Authentication Controller=====&lt;br /&gt;
Calls to logger should be written as filters is that a call to a logger tends to be a full line of code.  If we put the full line of code everywhere that the logger needs to be called, the logger text tends to distract from the rest of the work done by the method.  It tends to pollute the code.  If it is an after_action, then it gets called automatically when the method finishes, without having to appear in the method at all.  It is a cleaner way of calling the logger.  It is a case of the Separation of Responsibility principle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Filter loggers are added to prioritize the method calls in function: &amp;lt;br/&amp;gt;&lt;br /&gt;
#These filters are added for specific reasons: When the action_allowed? controller deals with authorizing the actions such as login, logout, login failed etc. &lt;br /&gt;
1. before_action :action_allowed?, only:[:login,:login_failed,:google_login] &amp;lt;br/&amp;gt;&lt;br /&gt;
2. after_action :action_allowed?, only:[:logout]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
The password_retrieval_controller deals with the process of updating and resetting the password for users, in case they have forgotten their password.  Comments were needed in many places in this file, and some comments that were there before had to be modified.  A user alert had to be modified to be more clear, and a hard-coded value had to be moved to a parameter.&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
@Manish &lt;br /&gt;
&lt;br /&gt;
== List Of Changes ==&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
Spelling was adjusted from authorised to authorized: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Spelling_fix_2.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a comment to explain the branches of a conjunction: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Branch_conjunction_comment.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add filters for loggers: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Auth_controller_filters_before.PNG]]&lt;br /&gt;
[[File:E2129_Auth_controller_filters_after.png]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
Method check_reset_url was renamed to a more descriptive check_token_validity: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Check_token_validity.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A parameter was created for the token expiration time instead of hardcoding it: &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:E2129_Token_time.PNG]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Descriptive comments were added to send_password: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: send_password_comments.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A statement inside the reset_password method that was copied from the forgotten method was replaced with a call to the forgotten method: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: change_to_forgotten.png &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: forgotten.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A code block inside the check_reset_url method that was copied from the reset_password method was replaced with a call to the reset_password method: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: change_to_reset_password.png &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: reset_password.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An error message in the check_reset_url method was updated to be more descriptive to a user: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: invalid_token_user_message.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
&lt;br /&gt;
== Future Improvements ==&lt;br /&gt;
&lt;br /&gt;
== Important Links ==&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139611</id>
		<title>CSC/ECE 517 Fall 2021 - E2129. Refactor auth controller.rb &amp; password retrieval controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2129._Refactor_auth_controller.rb_%26_password_retrieval_controller.rb&amp;diff=139611"/>
		<updated>2021-10-21T00:55:57Z</updated>

		<summary type="html">&lt;p&gt;Asmathew: Added Links to github and vcl&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2129: Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb  ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Relevant links ==&lt;br /&gt;
#Github : https://github.com/smanishs175/expertiza.git&lt;br /&gt;
#VCL Deployment: 152.7.176.119:8080 (Please note that if incase vcl gives a timeout error contact the authors)&lt;br /&gt;
&lt;br /&gt;
== About Expertiza ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework.  It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students.  Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.&lt;br /&gt;
&lt;br /&gt;
== Description Of Current Project ==&lt;br /&gt;
Our goal for this project is to refactor certain files (auth_controller.rb and password_retrieval_controller.rb) to follow essential Ruby on Rails design principles.  Since this is a refactoring project, all [https://rspec.info/ RSpec] test cases must result in the same behavior as before, with no changes to the overall functionality of the code.&lt;br /&gt;
&lt;br /&gt;
== Files Modified/Added ==&lt;br /&gt;
Two controller files were modified for this project:&amp;lt;br/&amp;gt;&lt;br /&gt;
# auth_controller.rb (expertiza/app/controllers/auth_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
# password_retrieval_controller.rb (expertiza/app/controllers/password_retrieval_controller.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One RSpec file was added to help test filters: &amp;lt;br/&amp;gt;&lt;br /&gt;
# filters.rb (expertiza/spec/support/matchers/filters.rb)&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
The auth_controller deals with user authentication when they try and login.  Spelling needed to be adjusted to American style.  Some comments were added and logger call locations were moved to before/after filters.&lt;br /&gt;
=====Problem 1=====&lt;br /&gt;
Check for the spelling. Use American spellings. For example, self.authorised? should be self.authorized?. Check for similar spelling issues.&lt;br /&gt;
=====Solution1=====&lt;br /&gt;
We have made the spelling changes as required. We changes Authorised to Authorized&lt;br /&gt;
&lt;br /&gt;
=====Problem 2=====&lt;br /&gt;
In line 79, I don’t understand why both branches of the conjunction are needed; there should be a comment explaining this.&lt;br /&gt;
=====Solution2=====&lt;br /&gt;
We have added comments as &amp;quot;Checking if both places have same params&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====Problem 3=====&lt;br /&gt;
Calls to logger should be written as before_ or after_filters on a method whenever possible.&lt;br /&gt;
=====Solution 3=====&lt;br /&gt;
=====About Filters=====&lt;br /&gt;
Rails filters are methods that run before or after a controller's action method is executed. They are helpful when you want to ensure that a given block of code runs with whatever action method is called.&lt;br /&gt;
&lt;br /&gt;
Rails support three types of filter methods:&lt;br /&gt;
&lt;br /&gt;
Before filters,&lt;br /&gt;
After filters,&lt;br /&gt;
Around filters&lt;br /&gt;
&lt;br /&gt;
=====Reason for the need of Filters in Authentication Controller=====&lt;br /&gt;
Calls to logger should be written as filters is that a call to a logger tends to be a full line of code.  If we put the full line of code everywhere that the logger needs to be called, the logger text tends to distract from the rest of the work done by the method.  It tends to pollute the code.  If it is an after_action, then it gets called automatically when the method finishes, without having to appear in the method at all.  It is a cleaner way of calling the logger.  It is a case of the Separation of Responsibility principle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Filter loggers are added to prioritize the method calls in function: &amp;lt;br/&amp;gt;&lt;br /&gt;
1. before_action :action_allowed?, only:[:login,:login_failed,:google_login] &amp;lt;br/&amp;gt;&lt;br /&gt;
2. after_action :action_allowed?, only:[:logout]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
The password_retrieval_controller deals with the process of updating and resetting the password for users, in case they have forgotten their password.  Comments were needed in many places in this file, and some comments that were there before had to be modified.  A user alert had to be modified to be more clear, and a hard-coded value had to be moved to a parameter.&lt;br /&gt;
&lt;br /&gt;
=== filters.rb ===&lt;br /&gt;
@Manish &lt;br /&gt;
&lt;br /&gt;
== List Of Changes ==&lt;br /&gt;
&lt;br /&gt;
=== auth_controller.rb ===&lt;br /&gt;
Spelling was adjusted from authorised to authorized: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: spelling_fix.png &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: spelling_fix_2.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a comment to explain the branches of a conjunction: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: branch_conjunction_comment.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add filters for loggers: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: auth_controller_filters_before.png &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: auth_controller_filters_after.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== password_retrieval_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
Method check_reset_url was renamed to a more descriptive check_token_validity: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: check_token_validity.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A parameter was created for the token expiration time instead of hardcoding it: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: token_time.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Descriptive comments were added to send_password: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: send_password_comments.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A statement inside the reset_password method that was copied from the forgotten method was replaced with a call to the forgotten method: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: change_to_forgotten.png &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: forgotten.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A code block inside the check_reset_url method that was copied from the reset_password method was replaced with a call to the reset_password method: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: change_to_reset_password.png &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: reset_password.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An error message in the check_reset_url method was updated to be more descriptive to a user: &amp;lt;br/&amp;gt;&lt;br /&gt;
#TODO: invalid_token_user_message.png &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
&lt;br /&gt;
== Future Improvements ==&lt;br /&gt;
&lt;br /&gt;
== Important Links ==&lt;/div&gt;</summary>
		<author><name>Asmathew</name></author>
	</entry>
</feed>