<?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=Sbose2</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=Sbose2"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Sbose2"/>
	<updated>2026-07-01T19:35:09Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=145637</id>
		<title>CSC/ECE 517 Spring 2022 - E2241: Heatgrid fixes and improvements</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=145637"/>
		<updated>2022-05-02T04:46:41Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides information about the documentation of E2241: Heatgrid fixes and improvements as part of CSC/ECE 517 Spring 2022 Final project.&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Team &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Mentor &amp;lt;/h3&amp;gt;&lt;br /&gt;
*Nicholas Himes (nnhimes)&lt;br /&gt;
&amp;lt;h3&amp;gt; Team Members (PinkPatterns) &amp;lt;/h3&amp;gt;&lt;br /&gt;
* Eshwar Chandra Vidhyasagar Thedla (ethedla)&lt;br /&gt;
* Gokul Krishna Koganti (gkogant)&lt;br /&gt;
* Jyothi Sumer Goud Maduru (jmaduru)&lt;br /&gt;
* Suneha Bose (sbose2)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Heat Grid &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heat Grid refers to a part of view in Expertiza that shows review scores of all the reviews done for a particular assignment. It shows scores given for each rubric by peer reviewers. This is used by instructors to assign scores to individual assignments and by students to view review scores of their assignment. Our project scope involves dealing with fixing issues related to the heat grid and any subsequent bugs that might arrive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Issues identified &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; There are some instances where a student was shown as reviewing his/her team even though the &amp;quot;Allow Self Review&amp;quot; checkbox was not checked by the instructor. This situation should not arise for practical purposes. Test cases must be extensively added so that we can be notified if the bug occurs again. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.37.56 PM.png|center|450px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;metric-1&amp;lt;/b&amp;gt; column name in the heat grid follows bad naming convention. It doesn't explain what the column refers to. This must be changed to make the column name more apt.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; As of now, the heat grid uses only one metric (metric-1). We must facilitate the system for addition of new metrics. Instructors should be able to toggle between various metrics as per their preferences. This can be done by the use of a drop down menu.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.34.47 PM.png|center|550px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Design Principle &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
For Issue #1869 we plan to use the Factory Design Pattern since we are dealing with the creation of multiple kinds of metrics. As part of our implementation, we plan on using a metric interface, which can be implemented by different concrete metric classes. A factory class acts as a middleman between the implementations and the main class that instantiates the objects. Based on the instructor's selection, the main class requests the metric object from the factory class, rather than dealing with the creation logic on its own. This pattern, therefore, enforces encapsulation and results in the low coupling, the principle which is our primary target for this project scope.  &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The previous implementation has dealt with issue #1869. But the drawback with the implementation is that it renders a code that is highly coupled. Whenever a new metric is added two files (assignments/edit/_general.html.erb and grades/view_team.html.erb) are to be changed, resulting in high coupling. As a consequence, tests pertaining to the highly coupled codes require new tests as a new metric is added. This is undesirable. So, the principle of low coupling is the main focus of our implementation. This principle will enable a common set of tests that would be valid for any number of metrics that will potentially be added in the future.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Files to be targeted &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #2019&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; Test file for adding test cases to implement self-reviews checks &amp;lt;/p&amp;gt;&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #1869&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;For Heat grid view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/grades/_view_heatgrid.html.erb&lt;br /&gt;
* app/views/grades/view_team.html.erb&lt;br /&gt;
* app/helpers/grades_helper.rb&lt;br /&gt;
* app/controllers/grades_controller.rb&lt;br /&gt;
* app/models/vm_question_response.rb&lt;br /&gt;
* app/models/vm_question_row.rb&lt;br /&gt;
* assets/view_team_in_grades.js&lt;br /&gt;
&amp;lt;p&amp;gt;For Assignment view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/assignment/edit/_general.html.erb&lt;br /&gt;
* app/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Implementation of Issue 1869&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Previous team’s implementation &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; The previous team has dealt with the issue by changing “metric-1” to “verbose comment count”, which is relevant to what metric-1 refers to. For the latter half of the issue, they have provided a metric dropdown for the instructor to select while creating the assignment. This consequently requires only one metric to be displayed on the heat grid for which they’ve given a toggle option to show and hide the metric.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Changes reflected in the UI &amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt; &lt;br /&gt;
  &amp;lt;li&amp;gt; &amp;lt;b&amp;gt; metric-1 &amp;lt;/b&amp;gt; changed to verbose comment count &amp;lt;/li&amp;gt;&lt;br /&gt;
  [[File:Heatgrid-metric.png|600px]]&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;li&amp;gt; Metric dropdown provided while creating an assignment &amp;lt;/li&amp;gt;&lt;br /&gt;
  [[File:Assignment General page.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Issue with previous team's implementation &amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; The critical problem with their changes was, when in future a new metric is added, it forces a change in two view files: one time in assignments/edit/_general.html.erb and  two times  in grades/view_team.html.erb. Requiring these changes in view files that have little relevance to the heat grid is essentially causing high coupling. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Current implementation &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Issue Goal &amp;lt;/h4&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; Our mentor has required us to display metrics in the heat grid with a toggle option for the user to select only the required metrics according to their preferences. This should be done keeping in mind low coupling as the primary design goal. These changes should be accompanied by minor changes such as adding comments and changing the name of “metric-1” to a self-indicative name. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Implementation details &amp;lt;/h4&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
  In the original beta implementation, whenever the relevant view file is loaded, it is calling the method &amp;quot;populate_view_model&amp;quot; present in the &amp;quot;grades_controller.rb&amp;quot; file. This method, is explicitly calling another model method to calculate metric. Whenever a new metric is added, we will have to make a call to that metric in the populate view model. This is not ideal as each new metric added is introducing a new line of code in the controller body. It is also not possible to determine the metrics present dynamically. To deal with this problem, we introduced a new parent method &amp;quot;calculate_metrics&amp;quot; in model file &amp;quot;vm_question_response.rb&amp;quot;. This method is responsible for calling other individual methods that calculate metrics. The call to this method is replacing the explicit calls to metric calculation in the controller. This essentially is breaking the dependency between new metric introduction and the controller. Now, whenever a new metric is added, there is no need to introduce any code changes in the controller, instead we just have to change the code in relevant model file.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-10.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-11.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-13.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;A new hashmap is introduced to store the values of the metrics in the form of key value pairs. Instead of explicitly calling metrics by name in the view file, this hashmap is used to iterate over the metrics and displayed&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-20.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-21.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-22.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Toggle feature is implemented in &amp;quot;view_team_in_grades.js&amp;quot; file. When the checkbox is clicked, function in javascript file is called and appropriate elements are hidden.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-23.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Adding a new metric in future &amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; To introduce new metric, a new method should be added in &amp;quot;vm_question_response.rb&amp;quot; file. This newly added method should be called from &amp;quot;calculate_metrics&amp;quot; method &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-30.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-31.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt;Changes reflected in the UI&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-40.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-41.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Heatgrid-2022-43.png|600px]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Manual Testing &amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of all the unchecked metric checkboxes in View Scores view&lt;br /&gt;
Given user has logged in&lt;br /&gt;
When user visits View Scores page&lt;br /&gt;
Then all the unchecked  metric checkboxes are present above the heat grid&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Default invisibility of metric columns in View Scores view&lt;br /&gt;
Given user has logged in &lt;br /&gt;
When user visits View Scores page&lt;br /&gt;
Then metric columns are not visible in the heat grid&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Checking a metric checkbox displays the corresponding metric column&lt;br /&gt;
Given user  has logged in&lt;br /&gt;
When user visits  View Scores page and &lt;br /&gt;
When user clicks on unchecked comments#10 metric&lt;br /&gt;
Then column with column name &amp;quot; comments#10&amp;quot; gets displayed with corresponding values&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Unchecking a metric checkbox hides the corresponding metric column&lt;br /&gt;
Given user  has logged in&lt;br /&gt;
When user visits  View Scores page and &lt;br /&gt;
When user clicks on checked comments#10 metric&lt;br /&gt;
Then column with column name &amp;quot; comments#10&amp;quot; and corresponding values get hidden&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Unit Testing &amp;lt;/h4&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;As our project does not deal with actually adding new metrics, but just facilitating a low-coupling addition of new metrics, we need not add any unit test cases for metric implementations. There is only one metric in the system as of now for which test cases are already written.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Implementation of Issue 2019&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; This issue encompasses many problems such as review reports not displaying correctly and a user being able to review his/her work. Each problem has been dealt with individually. Main problems identified as part of this issue and relevant observations and corrections are jotted down in this section. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Problem 1 : A user being able to review his/her own work.&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Problem comment &amp;lt;/h4&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; On Madeup Problem 3, assignment 1055, there are several anomalies in the review report. User 9277 reviewed Team_2323 and gave this comment: &amp;quot;This question seems a little suspicious. It is nearly identical to Question 4a on page 327 in the 2016 edition book. The only thing change was variable name A to B and value 2 to 3.&amp;quot; However, according to the View Submissions page, User 9277 is the only member of Team_2323. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Issue Reproduction and Observations &amp;lt;/h4&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; We tried reproducing the issue as specified in the issue comment, but we could not find Madeup Problem 3, assignment 1055. So, we have created two assignments with different parameters to check if the instructor is able to assign a reviewer his/her own work. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; We have created an assignment &amp;quot;Noself review&amp;quot; with allow self review option unchecked. Then, from the instructor page, we have created a team with student13 and student 14 as teammates. Then we logged into student14 account and submitted a hyperlink for that assignment. After that, from the instructor page we clicked on the assign review button and tried assigning student13 as the reviewer for that work and then tried the same with student14. In both the cases, the assignment failed by rendering a flash error message, &amp;quot;You cannot assign this student to review his/her own artifact.&amp;quot; &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Unchecked allow self-review option in &amp;quot;Noself review&amp;quot; assignment &amp;lt;/li&amp;gt;&lt;br /&gt;
[[File:self-review-option-unchecked.png|600px]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Participants page containing add reviewer button &amp;lt;/li&amp;gt;&lt;br /&gt;
[[File:Duo-team-submission.png|600px]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Adding student13 as reviewer for his/her own work &amp;lt;/li&amp;gt;&lt;br /&gt;
[[File:Self-assign-review.png|600px]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Flash error message displayed&amp;lt;/li&amp;gt;&lt;br /&gt;
[[File:self-review-unchecked.png|600px]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; We followed the same process for &amp;quot;self_review assignment&amp;quot;, which gave student an option to self review his/her own work immediately after submitting their work. However, when the instructor tried assigning the user with his/her own work, same flash error message was displayed, not allowing the user to review their work.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Checked allow self-review option in &amp;quot;self_review assignment&amp;quot; &amp;lt;/li&amp;gt;&lt;br /&gt;
[[File:Self-review-checked.png|600px]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Participants page of self review assignment&amp;lt;/li&amp;gt;&lt;br /&gt;
[[File:Participants_page_for_self-review_assignment.png|600px]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Assigning student13 as reviewer for own work&amp;lt;/li&amp;gt;&lt;br /&gt;
[[File:Student-13-self-review.png|600px]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Display of error message after assigning own artifact&amp;lt;/li&amp;gt;&lt;br /&gt;
[[File: Error-message-checked.png|600px]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Test case added&amp;lt;/h4&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; Previously implemented test cases of review_map controller have covered most of the tests pertaining to a user being assigned review work for his own artifact. These test cases primarily focused on the add_reviewer function of the review_mapping controller. However a test case checking for the display of flash error message on trying to assign reviewer to his/her own work was not covered, which we have added in the respective spec file. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   Scenario: Display of flash error message when instructor tries student their own artifact for reviewing&lt;br /&gt;
   Given instructor has logged in &lt;br /&gt;
   When the instructor visits the assignment page and&lt;br /&gt;
   When the instructor clicks on assign reviewer for an assignment and&lt;br /&gt;
   when the instructor tries to assign the owner of the artifact as the reviewer&lt;br /&gt;
   Then a flash error message is displayed saying &amp;quot;You cannot assign this student to review his/her own artifact.&amp;quot; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
       context 'when instructor tries to assign a student their own artifact for reviewing' do&lt;br /&gt;
       it 'flashes an error message' do&lt;br /&gt;
         allow(TeamsUser).to receive(:exists?).with(team_id: '1', user_id: 1).and_return(true)&lt;br /&gt;
         post :add_reviewer, @params&lt;br /&gt;
         expect(flash[:error]).to eq('You cannot assign this student to review his/her own artifact.')&lt;br /&gt;
         expect(response).to redirect_to '/review_mapping/list_mappings?id=1'&lt;br /&gt;
       end&lt;br /&gt;
     end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;h3&amp;gt; Problem 2 : Review comments from the first round not being displayed&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Problem comment &amp;lt;/h4&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; The Round 1 review (and the Round 1 heat grid) are missing when the instructor (instructor6) goes to Assign Grade for Student 9277. The Round 1 review should be in the first heat grid on the Assign Grades page. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Issue Reproduction and Observations &amp;lt;/h4&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; For this problem, we have tried the similar thing as the first problem. We have observed that if the instructor checks the option &amp;quot;review rubric varies by round&amp;quot; when the instructor creates an assignment, reviews from all the rounds are displayed in the heat grid. When the instructor unchecks that option, only the most recent review set is being displayed. As this is dependent on the user preference, we identified this not to be a problem.  &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Review rubric varies by round option, which is unchecked by default &amp;lt;/li&amp;gt;&lt;br /&gt;
[[File: Unchecked-rubric-varies.jpeg|600px]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Display of only the reviews of latest round when &amp;quot;Review rubric varies by round&amp;quot; is unchecked&amp;lt;/li&amp;gt;&lt;br /&gt;
[[File:Latest_review_on_uncheck.jpeg|600px]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; Display of reviews of all the rounds when &amp;quot;Review rubric varies by round&amp;quot; is checked&amp;lt;/li&amp;gt;&lt;br /&gt;
[[File:All-round-display.jpeg|600px]]&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Important Links &amp;lt;/h2&amp;gt;&lt;br /&gt;
* [https://youtu.be/K8rCxSZZOho/ Demo Video] &lt;br /&gt;
* [https://github.com/EshwarCVS/expertiza/ GitHub repository link]&lt;br /&gt;
* [https://docs.google.com/document/d/1H0BjzMBz5it7Wckhegq4LXhMi8RVctTwVzP2x9gnFCo/edit#heading=h.tqdrrd12xs4x/ Project Description Document]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/issues/1869/ GitHub Issue #1869]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/issues/2019/ GitHub Issue #2019]&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144971</id>
		<title>CSC/ECE 517 Spring 2022 - E2241: Heatgrid fixes and improvements</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144971"/>
		<updated>2022-04-12T03:38:34Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides information about the documentation of E2241: Heatgrid fixes and improvements as part of CSC/ECE 517 Spring 2022 Final project.&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Team &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Mentor &amp;lt;/h3&amp;gt;&lt;br /&gt;
*Nicholas Himes (nnhimes)&lt;br /&gt;
&amp;lt;h3&amp;gt; Team Members (PinkPatterns) &amp;lt;/h3&amp;gt;&lt;br /&gt;
* Eshwar Chandra Vidhyasagar Thedla (ethedla)&lt;br /&gt;
* Gokul Krishna Koganti (gkogant)&lt;br /&gt;
* Jyothi Sumer Goud Maduru (jmaduru)&lt;br /&gt;
* Suneha Bose (sbose2)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Heat Grid &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heat Grid refers to a part of view in Expertiza that shows review scores of all the reviews done for a particular assignment. It shows scores given for each rubric by peer reviewers. This is used by instructors to assign scores to individual assignments and by students to view review scores of their assignment. Our project scope involves dealing with fixing issues related to the heat grid and any subsequent bugs that might arrive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Issues identified &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; There are some instances where a student was shown as reviewing his/her team even though the &amp;quot;Allow Self Review&amp;quot; checkbox was not checked by the instructor. This situation should not arise for practical purposes. Test cases must be extensively added so that we can be notified if the bug occurs again. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.37.56 PM.png|center|450px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;metric-1&amp;lt;/b&amp;gt; column name in the heat grid follows bad naming convention. It doesn't explain what the column refers to. This must be changed to make the column name more apt.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; As of now, the heat grid uses only one metric (metric-1). We must facilitate the system for addition of new metrics. Instructors should be able to toggle between various metrics as per their preferences. This can be done by the use of a drop down menu.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.34.47 PM.png|center|550px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Plan of work &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work &amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Relevant bug of this issue can’t be reproduced to deal with it. So comprehensive test cases must be written to be notified if the bug arises again. We are planning to add rspec unit tests covering the following cases:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor unchecks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor checks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid &amp;lt;/h3&amp;gt; &lt;br /&gt;
&amp;lt;p&amp;gt;The new metrics can be added to the Metrics table that we will create. While creating an assignment/ editing an assignment, the instructor can select a metric from the Metrics table which will be available as a dropdown menu. We will retrieve the metric selected for the assignment by the instructor and display it in the Heatgrid Map of reviews.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In create/edit assignment, the instructor will see ‘Metric Type’ drop down which has list of metrics based on the values in the database&lt;br /&gt;
* Save the selected metric type and update the value in the database&lt;br /&gt;
* Retrieve the metric type from the assignment and calculate the value of the metric&lt;br /&gt;
* Display the values of the metric in the Heatgrid view&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Proposed Control Flow &amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Proposed_Control_Flow.drawio.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt;UML Diagram &amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:UML diagram E2241.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Design Principle &amp;lt;/h2&amp;gt;&lt;br /&gt;
For Issue #1869 we plan to use the Factory Design Pattern since we are dealing with the creation of multiple kinds of metrics. As part of our implementation, we plan on using a metric interface, which can be implemented by different concrete metric classes. A factory class acts as a middleman between the implementations and the main class that instantiates the objects. Based on the instructor's selection, the main class requests the metric object from the factory class, rather than dealing with the creation logic on its own. This pattern, therefore, enforces encapsulation and results in the low coupling, the principle which is our primary target for this project scope.  &lt;br /&gt;
&amp;lt;h2&amp;gt; Files to be targeted &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #2019&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; Test file for adding test cases to implement self-reviews checks &amp;lt;/p&amp;gt;&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #1869&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;For Heat grid view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/grades/_view_heatgrid.html.erb&lt;br /&gt;
* app/views/grades/view_team.html.erb&lt;br /&gt;
* app/helpers/grades_helper.rb&lt;br /&gt;
* app/controllers/grades_controller.rb&lt;br /&gt;
* app/models/vm_question_response.rb&lt;br /&gt;
* app/models/vm_question_row.rb&lt;br /&gt;
* assets/view_team_in_grades.js&lt;br /&gt;
&amp;lt;p&amp;gt;For Assignment view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/assignment/edit/_general.html.erb&lt;br /&gt;
* app/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Test Plan &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Video Demo&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The video link will be provided after the final submission.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Primary Goal of Testing&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capybara Test cases for testing the UI of heat grid view with the expected metric for the respective assignment and the UI of team view with relevant metric selected with all other metrics in the dropdown&lt;br /&gt;
* Spec test cases for testing the grades controller and assignment controller to check if they are returning the values as expected&lt;br /&gt;
* Unit test cases will be added to verify the logic behind the methods to calculate the values for their metrics&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;RSpec Tests&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt;Functional Tests&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of Metric dropdown list in New Assignment&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor visits New Assignment page&lt;br /&gt;
Then Metric dropdown list is visible&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of Metric dropdown list in Edit Assignment&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor visits Edit Assignment page&lt;br /&gt;
Then Metric dropdown list is visible&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of selected metric in instructor's Assign Grade view&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor visits on Assign Grade page&lt;br /&gt;
Then Selected metric is visible in heatgrid map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of selected metric in student's View Scores view&lt;br /&gt;
Given Student has logged in&lt;br /&gt;
When Student visits View Scores page&lt;br /&gt;
Then Selected metric is visible in heatgrid map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt;Unit Tests&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: The output for the metric “Comment Count”&lt;br /&gt;
Given: Instructor is logged in&lt;br /&gt;
When: Instructor selects metric as “Comment Count” for an assignment&lt;br /&gt;
Then: outputs 15 for the comment “The team has documented everything on the wiki page very properly following all the guidelines”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: The output for the metric “Comment Count”&lt;br /&gt;
Given: Instructor is logged in&lt;br /&gt;
When: Instructor selects metric as “Comment Count” for an assignment&lt;br /&gt;
Then: outputs 0 for the comment “”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Regression Tests&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the new functionalities are implemented and added, make sure the existing functionalities and test cases still pass. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Important Links &amp;lt;/h2&amp;gt;&lt;br /&gt;
* GitHub repository link: https://github.com/EshwarCVS/expertiza&lt;br /&gt;
* Project Description Document: https://docs.google.com/document/d/1H0BjzMBz5it7Wckhegq4LXhMi8RVctTwVzP2x9gnFCo/edit#heading=h.tqdrrd12xs4x&lt;br /&gt;
* GitHub Issue #1869: https://github.com/expertiza/expertiza/issues/1869&lt;br /&gt;
* GitHub Issue #2019: https://github.com/expertiza/expertiza/issues/2019&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144790</id>
		<title>CSC/ECE 517 Spring 2022 - E2241: Heatgrid fixes and improvements</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144790"/>
		<updated>2022-04-12T00:55:09Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides information about the documentation of E2241: Heatgrid fixes and improvements as part of CSC/ECE 517 Spring 2022 Final project.&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Team &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Mentor &amp;lt;/h3&amp;gt;&lt;br /&gt;
*Nicholas Himes (nnhimes)&lt;br /&gt;
&amp;lt;h3&amp;gt; Team Members (PinkPatterns) &amp;lt;/h3&amp;gt;&lt;br /&gt;
* Eshwar Chandra Vidhyasagar Thedla (ethedla)&lt;br /&gt;
* Gokul Krishna Koganti (gkogant)&lt;br /&gt;
* Jyothi Sumer Goud Maduru (jmaduru)&lt;br /&gt;
* Suneha Bose (sbose2)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Heat Grid &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heat Grid refers to a part of view in Expertiza that shows review scores of all the reviews done for a particular assignment. It shows scores given for each rubric by peer reviewers. This is used by instructors to assign scores to individual assignments and by students to view review scores of their assignment. Our project scope involves dealing with fixing issues related to the heat grid and any subsequent bugs that might arrive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Issues identified &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; There are some instances where a student was shown as reviewing his/her team even though the &amp;quot;Allow Self Review&amp;quot; checkbox was not checked by the instructor. This situation should not arise for practical purposes. Test cases must be extensively added so that we can be notified if the bug occurs again. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.37.56 PM.png|center|450px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;metric-1&amp;lt;/b&amp;gt; column name in the heat grid follows bad naming convention. It doesn't explain what the column refers to. This must be changed to make the column name more apt.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; As of now, the heat grid uses only one metric (metric-1). We must facilitate the system for addition of new metrics. Instructors should be able to toggle between various metrics as per their preferences. This can be done by the use of a drop down menu.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.34.47 PM.png|center|550px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Plan of work &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work &amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Relevant bug of this issue can’t be reproduced to deal with it. So comprehensive test cases must be written to be notified if the bug arises again. We are planning to add rspec unit tests covering the following cases:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor unchecks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor checks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid &amp;lt;/h3&amp;gt; &lt;br /&gt;
&amp;lt;p&amp;gt;The new metrics can be added to the Metrics table that we will create. While creating an assignment/ editing an assignment, the instructor can select a metric from the Metrics table which will be available as a dropdown menu. We will retrieve the metric selected for the assignment by the instructor and display it in the Heatgrid Map of reviews.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In create/edit assignment, the instructor will see ‘Metric Type’ drop down which has list of metrics based on the values in the database&lt;br /&gt;
* Save the selected metric type and update the value in the database&lt;br /&gt;
* Retrieve the metric type from the assignment and calculate the value of the metric&lt;br /&gt;
* Display the values of the metric in the Heatgrid view&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Proposed Control Flow &amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Proposed_Control_Flow.drawio.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt;UML Diagram &amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:UML diagram E2241.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Design Principle &amp;lt;/h2&amp;gt;&lt;br /&gt;
For Issue #1869 we plan to use the Factory Design Pattern since we are dealing with the creation of multiple kinds of metrics. As part of our implementation, we plan on using a metric interface, which can be implemented by different concrete metric classes. A factory class acts as a middleman between the implementations and the main class that instantiates the objects. Based on the instructor's selection, the main class requests the metric object from the factory class, rather than dealing with the creation logic on its own. This pattern, therefore, enforces encapsulation and results in the low coupling, the principle which is our primary target for this project scope.  &lt;br /&gt;
&amp;lt;h2&amp;gt; Files to be targeted &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #2019&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; Test file for adding test cases to implement self-reviews checks &amp;lt;/p&amp;gt;&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #1869&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;For Heat grid view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/grades/_view_heatgrid.html.erb&lt;br /&gt;
* app/views/grades/view_team.html.erb&lt;br /&gt;
* app/helpers/grades_helper.rb&lt;br /&gt;
* app/controllers/grades_controller.rb&lt;br /&gt;
* app/models/vm_question_response.rb&lt;br /&gt;
* app/models/vm_question_row.rb&lt;br /&gt;
* assets/view_team_in_grades.js&lt;br /&gt;
&amp;lt;p&amp;gt;For Assignment view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/assignment/edit/_general.html.erb&lt;br /&gt;
* app/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Test Plan &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Functional Tests&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario Visibility of Metric dropdown list in New Assignment&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor clicks on New Assignment button&lt;br /&gt;
Then Metric dropdown list is visible&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of Metric dropdown list in Edit Assignment&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor clicks on Edit Assignment button&lt;br /&gt;
Then Metric dropdown list is visible&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of selected metric in instructor's Assign Grade view&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor clicks on View Submission button&lt;br /&gt;
And Instructor clicks on Assign Grade button&lt;br /&gt;
Then Selected metric is visible in heatgrid map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of selected metric in student's View Scores view&lt;br /&gt;
Given Student has logged in&lt;br /&gt;
When Student clicks on View Scores button&lt;br /&gt;
Then Selected metric is visible in heatgrid map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Unit Tests&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Regression Tests&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capybara Test cases for testing the UI of heat grid view with the expected metric for the respective assignment and the UI of team view with relevant metric selected with all other metrics in the dropdown&lt;br /&gt;
* Spec test cases for testing the grades controller and assignment controller to check if they are returning the values as expected&lt;br /&gt;
* Unit test cases will be added to verify the logic behind the methods to calculate the values for their metrics&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Important Links &amp;lt;/h2&amp;gt;&lt;br /&gt;
* GitHub repository link: https://github.com/EshwarCVS/expertiza&lt;br /&gt;
* Project Description Document: https://docs.google.com/document/d/1H0BjzMBz5it7Wckhegq4LXhMi8RVctTwVzP2x9gnFCo/edit#heading=h.tqdrrd12xs4x&lt;br /&gt;
* GitHub Issue #1869: https://github.com/expertiza/expertiza/issues/1869&lt;br /&gt;
* GitHub Issue #2019: https://github.com/expertiza/expertiza/issues/2019&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144776</id>
		<title>CSC/ECE 517 Spring 2022 - E2241: Heatgrid fixes and improvements</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144776"/>
		<updated>2022-04-12T00:39:50Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides information about the documentation of E2241: Heatgrid fixes and improvements as part of CSC/ECE 517 Spring 2022 Final project.&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Team &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Mentor &amp;lt;/h3&amp;gt;&lt;br /&gt;
*Nicholas Himes (nnhimes)&lt;br /&gt;
&amp;lt;h3&amp;gt; Team Members (PinkPatterns) &amp;lt;/h3&amp;gt;&lt;br /&gt;
* Eshwar Chandra Vidhyasagar Thedla (ethedla)&lt;br /&gt;
* Gokul Krishna Koganti (gkogant)&lt;br /&gt;
* Jyothi Sumer Goud Maduru (jmaduru)&lt;br /&gt;
* Suneha Bose (sbose2)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Heat Grid &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heat Grid refers to a part of view in Expertiza that shows review scores of all the reviews done for a particular assignment. It shows scores given for each rubric by peer reviewers. This is used by instructors to assign scores to individual assignments and by students to view review scores of their assignment. Our project scope involves dealing with fixing issues related to the heat grid and any subsequent bugs that might arrive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Issues identified &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; There are some instances where a student was shown as reviewing his/her team even though the &amp;quot;Allow Self Review&amp;quot; checkbox was not checked by the instructor. This situation should not arise for practical purposes. Test cases must be extensively added so that we can be notified if the bug occurs again. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.37.56 PM.png|center|450px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;metric-1&amp;lt;/b&amp;gt; column name in the heat grid follows bad naming convention. It doesn't explain what the column refers to. This must be changed to make the column name more apt.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; As of now, the heat grid uses only one metric (metric-1). We must facilitate the system for addition of new metrics. Instructors should be able to toggle between various metrics as per their preferences. This can be done by the use of a drop down menu.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.34.47 PM.png|center|550px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Plan of work &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work &amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Relevant bug of this issue can’t be reproduced to deal with it. So comprehensive test cases must be written to be notified if the bug arises again. We are planning to add rspec unit tests covering the following cases:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor unchecks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor checks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid &amp;lt;/h3&amp;gt; &lt;br /&gt;
&amp;lt;p&amp;gt;The new metrics can be added to the Metrics table that we will create. While creating an assignment/ editing an assignment, the instructor can select a metric from the Metrics table which will be available as a dropdown menu. We will retrieve the metric selected for the assignment by the instructor and display it in the Heatgrid Map of reviews.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In create/edit assignment, the instructor will see ‘Metric Type’ drop down which has list of metrics based on the values in the database&lt;br /&gt;
* Save the selected metric type and update the value in the database&lt;br /&gt;
* Retrieve the metric type from the assignment and calculate the value of the metric&lt;br /&gt;
* Display the values of the metric in the Heatgrid view&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Proposed Control Flow &amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Proposed_Control_Flow.drawio.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt;UML Diagram &amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:UML diagram E2241.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Design Pattern &amp;lt;/h2&amp;gt;&lt;br /&gt;
For Issue #1869 we plan to use the Abstract Factory Pattern since we will be dealing with different families of metrics for grading purposes. It is preferable to reveal only the interfaces of metrics but conceal their implementations to avoid high coupling between classes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Files to be targeted &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #2019&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; Test file for adding test cases to implement self-reviews checks &amp;lt;/p&amp;gt;&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #1869&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;For Heat grid view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/grades/_view_heatgrid.html.erb&lt;br /&gt;
* app/views/grades/view_team.html.erb&lt;br /&gt;
* app/helpers/grades_helper.rb&lt;br /&gt;
* app/controllers/grades_controller.rb&lt;br /&gt;
* app/models/vm_question_response.rb&lt;br /&gt;
* app/models/vm_question_row.rb&lt;br /&gt;
* assets/view_team_in_grades.js&lt;br /&gt;
&amp;lt;p&amp;gt;For Assignment view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/assignment/edit/_general.html.erb&lt;br /&gt;
* app/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Test Plan &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Functional Tests&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario Visibility of Metric dropdown list in New Assignment&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor clicks on New Assignment button&lt;br /&gt;
Then Metric dropdown list is visible&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of Metric dropdown list in Edit Assignment&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor clicks on Edit Assignment button&lt;br /&gt;
Then Metric dropdown list is visible&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of selected metric in instructor's Assign Grade view&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor clicks on View Submission button&lt;br /&gt;
And Instructor clicks on Assign Grade button&lt;br /&gt;
Then Selected metric is visible in heatgrid map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of selected metric in student's View Scores view&lt;br /&gt;
Given Student has logged in&lt;br /&gt;
When Student clicks on View Scores button&lt;br /&gt;
Then Selected metric is visible in heatgrid map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Unit Tests&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Regression Tests&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capybara Test cases for testing the UI of heat grid view with the expected metric for the respective assignment and the UI of team view with relevant metric selected with all other metrics in the dropdown&lt;br /&gt;
* Spec test cases for testing the grades controller and assignment controller to check if they are returning the values as expected&lt;br /&gt;
* Unit test cases will be added to verify the logic behind the methods to calculate the values for their metrics&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Important Links &amp;lt;/h2&amp;gt;&lt;br /&gt;
* GitHub repository link: https://github.com/EshwarCVS/expertiza&lt;br /&gt;
* Project Description Document: https://docs.google.com/document/d/1H0BjzMBz5it7Wckhegq4LXhMi8RVctTwVzP2x9gnFCo/edit#heading=h.tqdrrd12xs4x&lt;br /&gt;
* GitHub Issue #1869: https://github.com/expertiza/expertiza/issues/1869&lt;br /&gt;
* GitHub Issue #2019: https://github.com/expertiza/expertiza/issues/2019&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144760</id>
		<title>CSC/ECE 517 Spring 2022 - E2241: Heatgrid fixes and improvements</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144760"/>
		<updated>2022-04-12T00:25:37Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides information about the documentation of E2241: Heatgrid fixes and improvements as part of CSC/ECE 517 Spring 2022 Final project.&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Team &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Mentor &amp;lt;/h3&amp;gt;&lt;br /&gt;
*Nicholas Himes (nnhimes)&lt;br /&gt;
&amp;lt;h3&amp;gt; Team Members (PinkPatterns) &amp;lt;/h3&amp;gt;&lt;br /&gt;
* Eshwar Chandra Vidhyasagar Thedla (ethedla)&lt;br /&gt;
* Gokul Krishna Koganti (gkogant)&lt;br /&gt;
* Jyothi Sumer Goud Maduru (jmaduru)&lt;br /&gt;
* Suneha Bose (sbose2)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Heat Grid &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heat Grid refers to a part of view in Expertiza that shows review scores of all the reviews done for a particular assignment. It shows scores given for each rubric by peer reviewers. This is used by instructors to assign scores to individual assignments and by students to view review scores of their assignment. Our project scope involves dealing with fixing issues related to the heat grid and any subsequent bugs that might arrive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Issues identified &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; There are some instances where a student was shown as reviewing his/her team even though the &amp;quot;Allow Self Review&amp;quot; checkbox was not checked by the instructor. This situation should not arise for practical purposes. Test cases must be extensively added so that we can be notified if the bug occurs again. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.37.56 PM.png|center|450px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;metric-1&amp;lt;/b&amp;gt; column name in the heat grid follows bad naming convention. It doesn't explain what the column refers to. This must be changed to make the column name more apt.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; As of now, the heat grid uses only one metric (metric-1). We must facilitate the system for addition of new metrics. Instructors should be able to toggle between various metrics as per their preferences. This can be done by the use of a drop down menu.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.34.47 PM.png|center|550px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Plan of work &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work &amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Relevant bug of this issue can’t be reproduced to deal with it. So comprehensive test cases must be written to be notified if the bug arises again. We are planning to add rspec unit tests covering the following cases:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor unchecks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor checks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid &amp;lt;/h3&amp;gt; &lt;br /&gt;
&amp;lt;p&amp;gt;The new metrics can be added to the Metrics table that we will create. While creating an assignment/ editing an assignment, the instructor can select a metric from the Metrics table which will be available as a dropdown menu. We will retrieve the metric selected for the assignment by the instructor and display it in the Heatgrid Map of reviews.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In create/edit assignment, the instructor will see ‘Metric Type’ drop down which has list of metrics based on the values in the database&lt;br /&gt;
* Save the selected metric type and update the value in the database&lt;br /&gt;
* Retrieve the metric type from the assignment and calculate the value of the metric&lt;br /&gt;
* Display the values of the metric in the Heatgrid view&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Proposed Control Flow &amp;lt;/h4&amp;gt;&lt;br /&gt;
[[File:Proposed_Control_Flow.drawio.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;UML Diagram &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:UML diagram E2241.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Design Pattern &amp;lt;/h2&amp;gt;&lt;br /&gt;
For Issue #1869 we plan to use the Abstract Factory Pattern since we will be dealing with different families of metrics for grading purposes. It is preferable to reveal only the interfaces of metrics but conceal their implementations to avoid high coupling between classes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Files to be targeted &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #2019&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; Test file for adding test cases to implement self-reviews checks &amp;lt;/p&amp;gt;&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #1869&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;For Heat grid view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/grades/_view_heatgrid.html.erb&lt;br /&gt;
* app/views/grades/view_team.html.erb&lt;br /&gt;
* app/helpers/grades_helper.rb&lt;br /&gt;
* app/controllers/grades_controller.rb&lt;br /&gt;
* app/models/vm_question_response.rb&lt;br /&gt;
* app/models/vm_question_row.rb&lt;br /&gt;
* assets/view_team_in_grades.js&lt;br /&gt;
&amp;lt;p&amp;gt;For Assignment view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/assignment/edit/_general.html.erb&lt;br /&gt;
* app/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Test Plan &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Functional Tests&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario Visibility of Metric dropdown list in New Assignment&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor clicks on New Assignment button&lt;br /&gt;
Then Metric dropdown list is visible&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of Metric dropdown list in Edit Assignment&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor clicks on Edit Assignment button&lt;br /&gt;
Then Metric dropdown list is visible&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of selected metric in instructor's Assign Grade view&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor clicks on View Submission button&lt;br /&gt;
And Instructor clicks on Assign Grade button&lt;br /&gt;
Then Selected metric is visible in heatgrid map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of selected metric in student's View Scores view&lt;br /&gt;
Given Student has logged in&lt;br /&gt;
When Student clicks on View Scores button&lt;br /&gt;
Then Selected metric is visible in heatgrid map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Unit Tests&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Regression Tests&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capybara Test cases for testing the UI of heat grid view with the expected metric for the respective assignment and the UI of team view with relevant metric selected with all other metrics in the dropdown&lt;br /&gt;
* Spec test cases for testing the grades controller and assignment controller to check if they are returning the values as expected&lt;br /&gt;
* Unit test cases will be added to verify the logic behind the methods to calculate the values for their metrics&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Important Links &amp;lt;/h2&amp;gt;&lt;br /&gt;
* GitHub repository link: https://github.com/EshwarCVS/expertiza&lt;br /&gt;
* Project Description Document: https://docs.google.com/document/d/1H0BjzMBz5it7Wckhegq4LXhMi8RVctTwVzP2x9gnFCo/edit#heading=h.tqdrrd12xs4x&lt;br /&gt;
* GitHub Issue #1869: https://github.com/expertiza/expertiza/issues/1869&lt;br /&gt;
* GitHub Issue #2019: https://github.com/expertiza/expertiza/issues/2019&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144755</id>
		<title>CSC/ECE 517 Spring 2022 - E2241: Heatgrid fixes and improvements</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144755"/>
		<updated>2022-04-12T00:23:44Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides information about the documentation of E2241: Heatgrid fixes and improvements as part of CSC/ECE 517 Spring 2022 Final project.&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Team &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Mentor &amp;lt;/h3&amp;gt;&lt;br /&gt;
*Nicholas Himes (nnhimes)&lt;br /&gt;
&amp;lt;h3&amp;gt; Team Members (PinkPatterns) &amp;lt;/h3&amp;gt;&lt;br /&gt;
* Eshwar Chandra Vidhyasagar Thedla (ethedla)&lt;br /&gt;
* Gokul Krishna Koganti (gkogant)&lt;br /&gt;
* Jyothi Sumer Goud Maduru (jmaduru)&lt;br /&gt;
* Suneha Bose (sbose2)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Heat Grid &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heat Grid refers to a part of view in Expertiza that shows review scores of all the reviews done for a particular assignment. It shows scores given for each rubric by peer reviewers. This is used by instructors to assign scores to individual assignments and by students to view review scores of their assignment. Our project scope involves dealing with fixing issues related to the heat grid and any subsequent bugs that might arrive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Issues identified &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; There are some instances where a student was shown as reviewing his/her team even though the &amp;quot;Allow Self Review&amp;quot; checkbox was not checked by the instructor. This situation should not arise for practical purposes. Test cases must be extensively added so that we can be notified if the bug occurs again. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.37.56 PM.png|center|450px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;metric-1&amp;lt;/b&amp;gt; column name in the heat grid follows bad naming convention. It doesn't explain what the column refers to. This must be changed to make the column name more apt.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; As of now, the heat grid uses only one metric (metric-1). We must facilitate the system for addition of new metrics. Instructors should be able to toggle between various metrics as per their preferences. This can be done by the use of a drop down menu.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.34.47 PM.png|center|550px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Plan of work &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work &amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Relevant bug of this issue can’t be reproduced to deal with it. So comprehensive test cases must be written to be notified if the bug arises again. We are planning to add rspec unit tests covering the following cases:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor unchecks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor checks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid &amp;lt;/h3&amp;gt; &lt;br /&gt;
&amp;lt;p&amp;gt;The new metrics can be added to the Metrics table that we will create. While creating an assignment/ editing an assignment, the instructor can select a metric from the Metrics table which will be available as a dropdown menu. We will retrieve the metric selected for the assignment by the instructor and display it in the Heatgrid Map of reviews.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In create/edit assignment, the instructor will see ‘Metric Type’ drop down which has list of metrics based on the values in the database&lt;br /&gt;
* Save the selected metric type and update the value in the database&lt;br /&gt;
* Retrieve the metric type from the assignment and calculate the value of the metric&lt;br /&gt;
* Display the values of the metric in the Heatgrid view&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Proposed Control Flow &amp;lt;/h4&amp;gt;&lt;br /&gt;
[[File:Proposed_Control_Flow.drawio.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Design Pattern &amp;lt;/h2&amp;gt;&lt;br /&gt;
For Issue #1869 we plan to use the Abstract Factory Pattern since we will be dealing with different families of metrics for grading purposes. It is preferable to reveal only the interfaces of metrics but conceal their implementations to avoid high coupling between classes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Files to be targeted &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #2019&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; Test file for adding test cases to implement self-reviews checks &amp;lt;/p&amp;gt;&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #1869&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;For Heat grid view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/grades/_view_heatgrid.html.erb&lt;br /&gt;
* app/views/grades/view_team.html.erb&lt;br /&gt;
* app/helpers/grades_helper.rb&lt;br /&gt;
* app/controllers/grades_controller.rb&lt;br /&gt;
* app/models/vm_question_response.rb&lt;br /&gt;
* app/models/vm_question_row.rb&lt;br /&gt;
* assets/view_team_in_grades.js&lt;br /&gt;
&amp;lt;p&amp;gt;For Assignment view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/assignment/edit/_general.html.erb&lt;br /&gt;
* app/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Test Plan &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of Metric dropdown list in New Assignment&lt;br /&gt;
Given: Instructor has logged in&lt;br /&gt;
When: Instructor clicks on New Assignment button&lt;br /&gt;
Then: Metric dropdown list is visible&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of Metric dropdown list in Edit Assignment&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor clicks on Edit Assignment button&lt;br /&gt;
Then Metric dropdown list is visible&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of selected metric in instructor's Assign Grade view&lt;br /&gt;
Given Instructor has logged in&lt;br /&gt;
When Instructor clicks on View Submission button&lt;br /&gt;
And Instructor clicks on Assign Grade button&lt;br /&gt;
Then: Selected metric is visible in heatgrid map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario: Visibility of selected metric in student's View Scores view&lt;br /&gt;
Given Student has logged in&lt;br /&gt;
When Student clicks on View Scores button&lt;br /&gt;
Then: Selected metric is visible in heatgrid map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Capybara Test cases for testing the UI of heat grid view with the expected metric for the respective assignment and the UI of team view with relevant metric selected with all other metrics in the dropdown&lt;br /&gt;
* Spec test cases for testing the grades controller and assignment controller to check if they are returning the values as expected&lt;br /&gt;
* Unit test cases will be added to verify the logic behind the methods to calculate the values for their metrics&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Important Links &amp;lt;/h2&amp;gt;&lt;br /&gt;
* GitHub repository link: https://github.com/EshwarCVS/expertiza&lt;br /&gt;
* Project Description Document: https://docs.google.com/document/d/1H0BjzMBz5it7Wckhegq4LXhMi8RVctTwVzP2x9gnFCo/edit#heading=h.tqdrrd12xs4x&lt;br /&gt;
* GitHub Issue #1869: https://github.com/expertiza/expertiza/issues/1869&lt;br /&gt;
* GitHub Issue #2019: https://github.com/expertiza/expertiza/issues/2019&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144576</id>
		<title>CSC/ECE 517 Spring 2022 - E2241: Heatgrid fixes and improvements</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144576"/>
		<updated>2022-04-07T03:20:21Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides information about the documentation of E2241: Heatgrid fixes and improvements as part of CSC/ECE 517 Spring 2022 Final project.&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Team &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Mentor &amp;lt;/h3&amp;gt;&lt;br /&gt;
*Nicholas Himes (nnhimes)&lt;br /&gt;
&amp;lt;h3&amp;gt; Team Members (PinkPatterns) &amp;lt;/h3&amp;gt;&lt;br /&gt;
* Eshwar Chandra Vidhyasagar Thedla (ethedla)&lt;br /&gt;
* Gokul Krishna Koganti (gkogant)&lt;br /&gt;
* Jyothi Sumer Goud Maduru (jmaduru)&lt;br /&gt;
* Suneha Bose (sbose2)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Heat Grid &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heat Grid refers to a part of view in Expertiza that shows review scores of all the reviews done for a particular assignment. It shows scores given for each rubric by peer reviewers. This is used by instructors to assign scores to individual assignments and by students to view review scores of their assignment. Our project scope involves dealing with fixing issues related to the heat grid and any subsequent bugs that might arrive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Issues identified &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; There are some instances where a student was shown as reviewing his/her team even though the Allow Self Review checkbox was not marked by instructor. This is impossible and is classified as a bug. This must be dealt with. Test cases must be extensively added so that we can be notified if the bug occurs again. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.37.56 PM.png|center|450px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;metric-1&amp;lt;/b&amp;gt; column name in the heat grid follows bad naming convention. It doesn't explain what the column refers to. This must be changed to make the column name more apt.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; As of now, the heat grid uses only one metric (metric-1). We must facilitate the system for addition of new metrics. Instructors should be able to toggle between various metrics as per their preferences. This can be done by the use of a drop down menu.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.34.47 PM.png|center|550px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Plan of work &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work &amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Relevant bug of this issue can’t be reproduced to deal with it. So comprehensive test cases must be written to be notified if the bug arises again. We are planning to add rspec unit tests covering the following cases:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor unchecks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor checks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid &amp;lt;/h3&amp;gt; &lt;br /&gt;
&amp;lt;p&amp;gt;The new metrics can be added to the Metrics table that we will create. While creating an assignment/ editing an assignment, the instructor can select a metric from the Metrics table which will be available as a dropdown menu. We will retrieve the metric selected for the assignment by the instructor and display it in the Heatgrid Map of reviews.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In create/edit assignment, the instructor will see ‘Metric Type’ drop down which has list of metrics based on the values in the database&lt;br /&gt;
* Save the selected metric type and update the value in the database&lt;br /&gt;
* Retrieve the metric type from the assignment and calculate the value of the metric&lt;br /&gt;
* Display the values of the metric in the Heatgrid view&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Proposed Control Flow &amp;lt;/h4&amp;gt;&lt;br /&gt;
[[File:Proposed_Control_Flow.drawio.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Design Pattern &amp;lt;/h2&amp;gt;&lt;br /&gt;
For Issue #1869 we plan to use the Abstract Factory Pattern since we will be dealing with different families of metrics for grading purposes. It is preferable to reveal only the interfaces of metrics but conceal their implementations to avoid high coupling between classes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Files to be targeted &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #1869&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;For Heat grid view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/grades/_view_heatgrid.html.erb&lt;br /&gt;
* app/views/grades/view_team.html.erb&lt;br /&gt;
* app/helpers/grades_helper.rb&lt;br /&gt;
* app/controllers/grades_controller.rb&lt;br /&gt;
* app/models/vm_question_response.rb&lt;br /&gt;
* app/models/vm_question_row.rb&lt;br /&gt;
&amp;lt;p&amp;gt;For Assignment view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/assignment/edit/_general.html.erb&lt;br /&gt;
* app/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Test Plan &amp;lt;/h2&amp;gt;&lt;br /&gt;
* Capybara Test cases for testing the UI of heat grid view with the expected metric for the respective assignment and the UI of team view with relevant metric selected with all other metrics in the dropdown&lt;br /&gt;
* Spec test cases for testing the grades controller and assignment controller to check if they are returning the values as expected&lt;br /&gt;
* Unit test cases will be added to verify the logic behind the methods to calculate the values for their metrics&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Important Links &amp;lt;/h2&amp;gt;&lt;br /&gt;
* GitHub repository link: https://github.com/EshwarCVS/expertiza&lt;br /&gt;
* Project Description Document: https://docs.google.com/document/d/1H0BjzMBz5it7Wckhegq4LXhMi8RVctTwVzP2x9gnFCo/edit#heading=h.tqdrrd12xs4x&lt;br /&gt;
* GitHub Issue #1869: https://github.com/expertiza/expertiza/issues/1869&lt;br /&gt;
* GitHub Issue #2019: https://github.com/expertiza/expertiza/issues/2019&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144569</id>
		<title>CSC/ECE 517 Spring 2022 - E2241: Heatgrid fixes and improvements</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144569"/>
		<updated>2022-04-07T03:11:47Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides information about the documentation of E2241: Heatgrid fixes and improvements as part of CSC/ECE 517 Spring 2022 Final project.&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Team &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Mentor &amp;lt;/h3&amp;gt;&lt;br /&gt;
*Nicholas Himes (nnhimes)&lt;br /&gt;
&amp;lt;h3&amp;gt; Team Members (PinkPatterns) &amp;lt;/h3&amp;gt;&lt;br /&gt;
* Eshwar Chandra Vidhyasagar Thedla (ethedla)&lt;br /&gt;
* Gokul Krishna Koganti (gkogant)&lt;br /&gt;
* Jyothi Sumer Goud Maduru (jmaduru)&lt;br /&gt;
* Suneha Bose (sbose2)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Heat Grid &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heat Grid refers to a part of view in Expertiza that shows review scores of all the reviews done for a particular assignment. It shows scores given for each rubric by peer reviewers. This is used by instructors to assign scores to individual assignments and by students to view review scores of their assignment. Our project scope involves dealing with fixing issues related to the heat grid and any subsequent bugs that might arrive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Issues identified &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; There are some instances where a student was shown as reviewing his/her team even though the Allow Self Review checkbox was not marked by instructor. This is impossible and is classified as a bug. This must be dealt with. Test cases must be extensively added so that we can be notified if the bug occurs again. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.37.56 PM.png|center|450px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;metric-1&amp;lt;/b&amp;gt; column name in the heat grid follows bad naming convention. It doesn't explain what the column refers to. This must be changed to make the column name more apt.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; As of now, the heat grid uses only one metric (metric-1). We must facilitate the system for addition of new metrics. Instructors should be able to toggle between various metrics as per their preferences. This can be done by the use of a drop down menu.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.34.47 PM.png|center|550px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Plan of work &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work &amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Relevant bug of this issue can’t be reproduced to deal with it. So comprehensive test cases must be written to be notified if the bug arises again. We are planning to add rspec unit tests covering the following cases:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor unchecks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor checks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid &amp;lt;/h3&amp;gt; &lt;br /&gt;
&amp;lt;p&amp;gt;The new metrics can be added to the Metrics table that we will create. While creating an assignment/ editing an assignment, the instructor can select a metric from the Metrics table which will be available as a dropdown menu. We will retrieve the metric selected for the assignment by the instructor and display it in the Heatgrid Map of reviews.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In create/edit assignment, the instructor will see ‘Metric Type’ drop down which has list of metrics based on the values in the database&lt;br /&gt;
* Save the selected metric type and update the value in the database&lt;br /&gt;
* Retrieve the metric type from the assignment and calculate the value of the metric&lt;br /&gt;
* Display the values of the metric in the Heatgrid view&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Proposed Control Flow &amp;lt;/h4&amp;gt;&lt;br /&gt;
[[File:Proposed_Control_Flow.drawio.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Files to be targeted &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #1869&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;For Heat grid view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/grades/_view_heatgrid.html.erb&lt;br /&gt;
* app/views/grades/view_team.html.erb&lt;br /&gt;
* app/helpers/grades_helper.rb&lt;br /&gt;
* app/controllers/grades_controller.rb&lt;br /&gt;
* app/models/vm_question_response.rb&lt;br /&gt;
* app/models/vm_question_row.rb&lt;br /&gt;
&amp;lt;p&amp;gt;For Assignment view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/assignment/edit/_general.html.erb&lt;br /&gt;
* app/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Test Plan &amp;lt;/h2&amp;gt;&lt;br /&gt;
* Capybara Test cases for testing the UI of heat grid view with the expected metric for the respective assignment and the UI of team view with relevant metric selected with all other metrics in the dropdown&lt;br /&gt;
* Spec test cases for testing the grades controller and assignment controller to check if they are returning the values as expected&lt;br /&gt;
* Unit test cases will be added to verify the logic behind the methods to calculate the values for their metrics&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Important Links &amp;lt;/h2&amp;gt;&lt;br /&gt;
* GitHub repository link: https://github.com/EshwarCVS/expertiza&lt;br /&gt;
* Project Description Document: https://docs.google.com/document/d/1H0BjzMBz5it7Wckhegq4LXhMi8RVctTwVzP2x9gnFCo/edit#heading=h.tqdrrd12xs4x&lt;br /&gt;
* GitHub Issue #1869: https://github.com/expertiza/expertiza/issues/1869&lt;br /&gt;
* GitHub Issue #2019: https://github.com/expertiza/expertiza/issues/2019&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144567</id>
		<title>CSC/ECE 517 Spring 2022 - E2241: Heatgrid fixes and improvements</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144567"/>
		<updated>2022-04-07T03:10:24Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides information about the documentation of E2241: Heatgrid fixes and improvements as part of CSC/ECE 517 Spring 2022 Final project.&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Team &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Mentor &amp;lt;/h3&amp;gt;&lt;br /&gt;
*Nicholas Himes (nnhimes)&lt;br /&gt;
&amp;lt;h3&amp;gt; Team Members (PinkPatterns) &amp;lt;/h3&amp;gt;&lt;br /&gt;
* Eshwar Chandra Vidhyasagar Thedla (ethedla)&lt;br /&gt;
* Gokul Krishna Koganti (gkogant)&lt;br /&gt;
* Jyothi Sumer Goud Maduru (jmaduru)&lt;br /&gt;
* Suneha Bose (sbose2)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Heat Grid &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heat Grid refers to a part of view in Expertiza that shows review scores of all the reviews done for a particular assignment. It shows scores given for each rubric by peer reviewers. This is used by instructors to assign scores to individual assignments and by students to view review scores of their assignment. Our project scope involves dealing with fixing issues related to the heat grid and any subsequent bugs that might arrive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Issues identified &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; There are some instances where a student was shown as reviewing his/her team. This is impossible and is classified as a bug. This must be dealt with. Test cases must be extensively added so that we can be notified if the bug occurs again. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.37.56 PM.png|center|450px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;metric-1&amp;lt;/b&amp;gt; column name in the heat grid follows bad naming convention. It doesn't explain what the column refers to. This must be changed to make the column name more apt.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; As of now, the heat grid uses only one metric (metric-1). We must facilitate the system for addition of new metrics. Instructors should be able to toggle between various metrics as per their preferences. This can be done by the use of a drop down menu.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.34.47 PM.png|center|550px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Plan of work &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #2019: Restrict teammates from reviewing their own work &amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Relevant bug of this issue can’t be reproduced to deal with it. So comprehensive test cases must be written to be notified if the bug arises again. We are planning to add rspec unit tests covering the following cases:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor unchecks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor checks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Issue #1869: Deal with the metrics of the heat grid &amp;lt;/h3&amp;gt; &lt;br /&gt;
&amp;lt;p&amp;gt;The new metrics can be added to the Metrics table that we will create. While creating an assignment/ editing an assignment, the instructor can select a metric from the Metrics table which will be available as a dropdown menu. We will retrieve the metric selected for the assignment by the instructor and display it in the Heatgrid Map of reviews.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In create/edit assignment, the instructor will see ‘Metric Type’ drop down which has list of metrics based on the values in the database&lt;br /&gt;
* Save the selected metric type and update the value in the database&lt;br /&gt;
* Retrieve the metric type from the assignment and calculate the value of the metric&lt;br /&gt;
* Display the values of the metric in the Heatgrid view&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Proposed Control Flow &amp;lt;/h4&amp;gt;&lt;br /&gt;
[[File:Proposed_Control_Flow.drawio.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Files to be targeted &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #1869&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;For Heat grid view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/grades/_view_heatgrid.html.erb&lt;br /&gt;
* app/views/grades/view_team.html.erb&lt;br /&gt;
* app/helpers/grades_helper.rb&lt;br /&gt;
* app/controllers/grades_controller.rb&lt;br /&gt;
* app/models/vm_question_response.rb&lt;br /&gt;
* app/models/vm_question_row.rb&lt;br /&gt;
&amp;lt;p&amp;gt;For Assignment view&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/assignment/edit/_general.html.erb&lt;br /&gt;
* app/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Test Plan &amp;lt;/h2&amp;gt;&lt;br /&gt;
* Capybara Test cases for testing the UI of heat grid view with the expected metric for the respective assignment and the UI of team view with relevant metric selected with all other metrics in the dropdown&lt;br /&gt;
* Spec test cases for testing the grades controller and assignment controller to check if they are returning the values as expected&lt;br /&gt;
* Unit test cases will be added to verify the logic behind the methods to calculate the values for their metrics&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Important Links &amp;lt;/h2&amp;gt;&lt;br /&gt;
* GitHub repository link: https://github.com/EshwarCVS/expertiza&lt;br /&gt;
* Project Description Document: https://docs.google.com/document/d/1H0BjzMBz5it7Wckhegq4LXhMi8RVctTwVzP2x9gnFCo/edit#heading=h.tqdrrd12xs4x&lt;br /&gt;
* GitHub Issue #1869: https://github.com/expertiza/expertiza/issues/1869&lt;br /&gt;
* GitHub Issue #2019: https://github.com/expertiza/expertiza/issues/2019&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144553</id>
		<title>CSC/ECE 517 Spring 2022 - E2241: Heatgrid fixes and improvements</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144553"/>
		<updated>2022-04-07T02:46:51Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides information about the refactoring work done on the reputation web service controller as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Team &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Mentor &amp;lt;/h3&amp;gt;&lt;br /&gt;
*Nicholas Himes (nnhimes)&lt;br /&gt;
&amp;lt;h3&amp;gt; Team Members (PinkPatterns) &amp;lt;/h3&amp;gt;&lt;br /&gt;
* Eshwar Chandra Vidhyasagar Thedla (ethedla)&lt;br /&gt;
* Gokul Krishna Koganti (gkogant)&lt;br /&gt;
* Jyothi Sumer Goud Maduru (jmaduru)&lt;br /&gt;
* Suneha Bose (sbose2)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Heat Grid &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heat Grid refers to a part of view in expertiza that shows review scores of all the reviews done for a particular assignment. It shows scores given for each rubric by peer reviewers. This is used by instructors to assign scores to individual assignments and by students to view review scores of their assignment. Our project scope involves dealing with fixing issues related to the heat grid and any subsequent bugs that might arrive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Issues identified &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Restrict teammates from reviewing their own work (Issue #2019)&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; There are some instances where a student was shown as reviewing his/her team. This is impossible and is classified as a bug. This must be dealt with. Test cases must be extensively added so that we can be notified if the bug occurs again. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.37.56 PM.png|center|450px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Deal with the metrics of the heat grid (Issue #1869)&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;metric-1&amp;lt;/b&amp;gt; column name in the heat grid follows bad naming convention. It doesn't explain what the column refers to. This must be changed to make the column name more apt.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; As of now, the heat grid uses only one metric (metric-1). We must facilitate the system for addition of new metrics. Instructors should be able to toggle between various metrics as per their preferences. This can be done by the use of a drop down menu.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2022-04-06 at 10.34.47 PM.png|center|550px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Plan of work &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Restrict teammates from reviewing their own work (Issue #2019)&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Relevant bug of this issue can’t be reproduced to deal with it. So comprehensive test cases must be written to be notified if the bug arises again. We are planning to add rspec unit tests covering the following cases:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor unchecks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor checks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Deal with the metrics of the heat grid (Issue #1869)&amp;lt;/h3&amp;gt; &lt;br /&gt;
&amp;lt;p&amp;gt;The new metrics can be added to the Metrics table that we will create. While creating an assignment/ editing an assignment, the instructor can select a metric from the Metrics table which will be available as a dropdown menu. We will retrieve the metric selected for the assignment by the instructor and display it in the Heatgrid Map of reviews.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Proposed Control Flow &amp;lt;/h4&amp;gt;&lt;br /&gt;
[[File:Proposed_Control_Flow.drawio.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Files to be targeted &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #1869&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;For Heat grid&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/grades/_view_heatgrid.html.erb&lt;br /&gt;
* app/views/grades/view_team.html.erb&lt;br /&gt;
* app/helpers/grades_helper.rb&lt;br /&gt;
* app/controllers/grades_controller.rb&lt;br /&gt;
* app/models/vm_question_response.rb&lt;br /&gt;
* app/models/vm_question_row.rb&lt;br /&gt;
&amp;lt;p&amp;gt;For Assignment&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/assignment/edit/_general.html.erb&lt;br /&gt;
* app/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Test Plan &amp;lt;/h2&amp;gt;&lt;br /&gt;
* Capybara Test cases for testing the UI of heat grid view with the expected metric for the respective assignment and the UI of team view with relevant metric selected with all other metrics in the dropdown&lt;br /&gt;
* Spec test cases for testing the grades controller and assignment controller to check if they are returning the values as expected&lt;br /&gt;
* Unit test cases will be added to verify the logic behind the methods to calculate the values for their metrics&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Important Links &amp;lt;/h2&amp;gt;&lt;br /&gt;
* GitHub repository link: https://github.com/EshwarCVS/expertiza&lt;br /&gt;
* Project Description Document: https://docs.google.com/document/d/1H0BjzMBz5it7Wckhegq4LXhMi8RVctTwVzP2x9gnFCo/edit#heading=h.tqdrrd12xs4x&lt;br /&gt;
* GitHub Issue #1869: https://github.com/expertiza/expertiza/issues/1869&lt;br /&gt;
* GitHub Issue #2019: https://github.com/expertiza/expertiza/issues/2019&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screen_Shot_2022-04-06_at_10.37.56_PM.png&amp;diff=144545</id>
		<title>File:Screen Shot 2022-04-06 at 10.37.56 PM.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screen_Shot_2022-04-06_at_10.37.56_PM.png&amp;diff=144545"/>
		<updated>2022-04-07T02:39:51Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: Self review screenshot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Self review screenshot&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screen_Shot_2022-04-06_at_10.34.47_PM.png&amp;diff=144544</id>
		<title>File:Screen Shot 2022-04-06 at 10.34.47 PM.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screen_Shot_2022-04-06_at_10.34.47_PM.png&amp;diff=144544"/>
		<updated>2022-04-07T02:38:46Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: Heatgrid Screenshot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Heatgrid Screenshot&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144542</id>
		<title>CSC/ECE 517 Spring 2022 - E2241: Heatgrid fixes and improvements</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2241:_Heatgrid_fixes_and_improvements&amp;diff=144542"/>
		<updated>2022-04-07T02:34:15Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides information about the refactoring work done on the reputation web service controller as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Team &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Mentor &amp;lt;/h3&amp;gt;&lt;br /&gt;
*Nicholas Himes (nnhimes)&lt;br /&gt;
&amp;lt;h3&amp;gt; Team Members (PinkPatterns) &amp;lt;/h3&amp;gt;&lt;br /&gt;
* Eshwar Chandra Vidhyasagar Thedla (ethedla)&lt;br /&gt;
* Gokul Krishna Koganti (gkogant)&lt;br /&gt;
* Jyothi Sumer Goud Maduru (jmaduru)&lt;br /&gt;
* Suneha Bose (sbose2)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Heat Grid &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heat Grid refers to a part of view in expertiza that shows review scores of all the reviews done for a particular assignment. It shows scores given for each rubric by peer reviewers. This is used by instructors to assign scores to individual assignments and by students to view review scores of their assignment. Our project scope involves dealing with fixing issues related to the heat grid and any subsequent bugs that might arrive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Issues identified &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Restrict teammates from reviewing their own work (Issue #2019)&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; There are some instances where a student was shown as reviewing his/her team. This is impossible and is classified as a bug. This must be dealt with. Test cases must be extensively added so that we can be notified if the bug occurs again. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Deal with the metrics of the heat grid (Issue #1869)&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;metric-1&amp;lt;/b&amp;gt; column name in the heat grid follows bad naming convention. It doesn't explain what the column refers to. This must be changed to make the column name more apt.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; As of now, the heat grid uses only one metric (metric-1). We must facilitate the system for addition of new metrics. Instructors should be able to toggle between various metrics as per their preferences. This can be done by the use of a drop down menu.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Plan of work &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt; Restrict teammates from reviewing their own work (Issue #2019)&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Relevant bug of this issue can’t be reproduced to deal with it. So comprehensive test cases must be written to be notified if the bug arises again. We are planning to add rspec unit tests covering the following cases:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor unchecks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should not be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should not be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;b&amp;gt; If the instructor checks “ Allow self review” option&amp;lt;/b&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that he/she has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Instructor should be able to assign a student to review work that their teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work he/she has submitted. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Students should be able to review work a teammate has submitted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3&amp;gt; Deal with the metrics of the heat grid (Issue #1869)&amp;lt;/h3&amp;gt; &lt;br /&gt;
&amp;lt;p&amp;gt;The new metrics can be added to the Metrics table that we will create. While creating an assignment/ editing an assignment, the instructor can select a metric from the Metrics table which will be available as a dropdown menu. We will retrieve the metric selected for the assignment by the instructor and display it in the Heatgrid Map of reviews.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h4&amp;gt; Proposed Control Flow &amp;lt;/h4&amp;gt;&lt;br /&gt;
[[File:Proposed_Control_Flow.drawio.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Files to be targeted &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Issue #1869&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;For Heat grid&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/grades/_view_heatgrid.html.erb&lt;br /&gt;
* app/views/grades/view_team.html.erb&lt;br /&gt;
* app/helpers/grades_helper.rb&lt;br /&gt;
* app/controllers/grades_controller.rb&lt;br /&gt;
* app/models/vm_question_response.rb&lt;br /&gt;
* app/models/vm_question_row.rb&lt;br /&gt;
&amp;lt;p&amp;gt;For Assignment&amp;lt;/p&amp;gt;&lt;br /&gt;
* app/views/assignment/edit/_general.html.erb&lt;br /&gt;
* app/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Test Plan &amp;lt;/h2&amp;gt;&lt;br /&gt;
* Capybara Test cases for testing the UI of heat grid view with the expected metric for the respective assignment and the UI of team view with relevant metric selected with all other metrics in the dropdown&lt;br /&gt;
* Spec test cases for testing the grades controller and assignment controller to check if they are returning the values as expected&lt;br /&gt;
* Unit test cases will be added to verify the logic behind the methods to calculate the values for their metrics&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Important Links &amp;lt;/h2&amp;gt;&lt;br /&gt;
* GitHub repository link: https://github.com/EshwarCVS/expertiza&lt;br /&gt;
* Project Description Document: https://docs.google.com/document/d/1H0BjzMBz5it7Wckhegq4LXhMi8RVctTwVzP2x9gnFCo/edit#heading=h.tqdrrd12xs4x&lt;br /&gt;
* GitHub Issue #1869: https://github.com/expertiza/expertiza/issues/1869&lt;br /&gt;
* GitHub Issue #2019: https://github.com/expertiza/expertiza/issues/2019&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Proposed_Control_Flow.drawio.png&amp;diff=144540</id>
		<title>File:Proposed Control Flow.drawio.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Proposed_Control_Flow.drawio.png&amp;diff=144540"/>
		<updated>2022-04-07T02:29:06Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143608</id>
		<title>CSC/ECE 517 Spring 2022 - E2202- Testing for badges controller, publishing controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143608"/>
		<updated>2022-03-27T21:20:11Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: /* Running Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is the software benefits for both instructors and students by supporting various types of submissions and providing reusable objects for peer review. It is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. It allows the instructors not only to create and customize new or existing assignments but also to create a list of topics the students can sign up for. Students can form teams to work on various projects and assignments. Expertiza also lets students peer-review other students' submissions, enabling them to work together to improve others' learning experiences.&lt;br /&gt;
&lt;br /&gt;
== Description about project ==&lt;br /&gt;
This page is a description of Expertiza OSS project E2202 which is adding test cases for badges_controller.rb and publishing_controller.rb. The badges controller allows users to create badges by entering the badge name, description and an image that serves as the badge icon. The publishing controller enables the students to grant/revoke publishing rights to past assignments. It does this by either allowing the students to grant and deny rights individually or all of them together. It makes use of the private key to verify the digital signature of the user granting the rights.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/controllers/publishing_controller_spec.rb spec/controllers/badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If you're having any difficulty in running the tests, please drop an email to sbose2@ncsu.edu, apatil25@ncsu.edu or kkhulla@ncsu.edu.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
After setting up the development environment, we ran the original test cases for the badges_controller. However the test cases were very limited and only partially covered one of the methods. We wrote additional test cases to cover all the 5 methods badges controller and expanded the existing test case.&lt;br /&gt;
For the publishing_controller no tests were available so we had to write every test from scratch. We have written tests to cover all the 6 methods in the publishing_controller. In total we wrote 27 test cases for both the controllers. We used object mocking for creating the unit test cases.&lt;br /&gt;
&lt;br /&gt;
====Badges Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*new&lt;br /&gt;
*redirect_to_assignment&lt;br /&gt;
*create&lt;br /&gt;
*badge_params&lt;br /&gt;
&lt;br /&gt;
====Publishing Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*view&lt;br /&gt;
*set_publish_permission&lt;br /&gt;
*update_publish_permissions&lt;br /&gt;
*grant&lt;br /&gt;
*grant_with_private_key&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Badges Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to access the badges this method is called to check if the current user is authorized to view this page. All the users except the user with student privileges has access to perform actions in badges.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'refuses student from performing certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_falsey&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows teaching assisstant to perform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end    &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. New - When user tries to create a new badge it redirects to the new create badge page and allow the user to enter details for the badge creation.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#new' do&lt;br /&gt;
    context 'when user wants to create a new badge' do&lt;br /&gt;
      it 'should call the new#badge page url' do&lt;br /&gt;
        get :new&lt;br /&gt;
        expect(get: 'badges/new').to route_to('badges#new')&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it 'should render the create new form and allow the user to enter details' do&lt;br /&gt;
        allow(Badge).to receive(:new).and_return(badge)&lt;br /&gt;
        params = {}&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. redirect_to_assignment - When the user has successfully created a badge it redirects to the assignment page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe 'redirect_to_assignment' do&lt;br /&gt;
    context 'after user successfully creates a badge' do&lt;br /&gt;
      it 'calls the redirect_to_assignment url' do&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        expect(get: 'badges/redirect_to_assignment').to route_to('badges#redirect_to_assignment')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'redirects to the assignment page' do&lt;br /&gt;
        stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        response.should redirect_to(&amp;quot;http://test.host/assignments/844/edit&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. create - When the user tries to create a badge by entering all the required details, it saves the badge. If there are any missing required details for badge creation it throws an error for missing fields.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#create' do&lt;br /&gt;
    context 'when user enters all the required badge details correctly' do&lt;br /&gt;
        it 'should save the badge successfully' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to redirect_to 'http://test.host/assignments/844/edit'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when user forgets to enter few of the required badge details' do&lt;br /&gt;
      it 'should throw an error for missing image file' do&lt;br /&gt;
        @file = nil&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge name' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: '',&lt;br /&gt;
          description: 'test badge',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge description' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: 'test',&lt;br /&gt;
          description: '',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')   &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Publishing Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to grant or view publishing rights this method is called to check if the current user is authorized to perform the action. All users with student privileges have access to perform actions for publishing.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows student to perform certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows teaching assisstant to peform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. view - When user visits the publishing rights page, it displays all past assignment participants.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'view' do&lt;br /&gt;
    context 'user visits the publishing rights page' do&lt;br /&gt;
      it 'displays all the assignment participants' do&lt;br /&gt;
          stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
          params = { id: 21 }&lt;br /&gt;
          get :view, params&lt;br /&gt;
          expect(assigns(:user)).to eq(student1)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. set_publish_permission - When the user matches with the participant and the user clicks on the grant button next to the assignment, it redirects to the grant page. &lt;br /&gt;
When the user matches with the participant and the assignment is already granted permission, it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'set_publish_permission' do&lt;br /&gt;
    context 'user matches with participant and user clicks on the grant button next to the assignment' do&lt;br /&gt;
      it 'redirects to the grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 1, allow: 1}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'user matches with participant and the assignment is already granted permission' do&lt;br /&gt;
      it 'redirects to the view page' do&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        allow(assignment_participant1).to receive(:update_attribute).and_return(true)&lt;br /&gt;
        params ={id: 1, allow: '0'}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. update_publish_permissions - When a user clicks on the grant publishing rights to all past assignments button it redirects to the grant page. &lt;br /&gt;
When a user clicks on the deny publishing rights to all past assignments button it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'update_publish_permissions' do&lt;br /&gt;
    context 'user clicks on the grant publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 1}&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
    context 'user clicks on the deny publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to view page' do&lt;br /&gt;
          allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 0}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:update_attribute).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:save).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end      &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. grant - When a user clicks on the grant publishing option, it displays the page where the user can supply their private key and grant publishing rights.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant' do&lt;br /&gt;
    context 'user clicks on grant option' do&lt;br /&gt;
      it 'displays the page where the user can supply their private key and grant publishing rights' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3}&lt;br /&gt;
        get :grant, params&lt;br /&gt;
        expect(assigns(:user)).to eq(student1)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. grant_with_private_key - When a user visits the grant page without id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant page. &lt;br /&gt;
When a user visits the grant page with id and enters correct RSA private key, it verifies key to be successful for all past assignments and redirects to view page.&lt;br /&gt;
When a user visits the grant page with id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant_with_private_key' do&lt;br /&gt;
&lt;br /&gt;
    context 'user visits the grant page without id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params = {}&lt;br /&gt;
        private_key = double(:private_key)&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(private_key).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(private_key).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
            &lt;br /&gt;
    context 'user visits the grant page with id and enters correct RSA private key' do&lt;br /&gt;
      it 'verifies to be successful for all past assignments and redirect to view' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end &lt;br /&gt;
      &lt;br /&gt;
    context 'user visits the grant page with id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant,params:{id:2})&lt;br /&gt;
      end&lt;br /&gt;
    end          &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
&lt;br /&gt;
The total coverage of the tests is 100%. We covered all the edges cases to ensure maximum coverage.&lt;br /&gt;
&lt;br /&gt;
The screenshot for test coverage can be found [https://drive.google.com/file/d/1sYOvWfxMEUI3i81ir7Yaw49ilEFvryfg/view?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
==Related Links==&lt;br /&gt;
&lt;br /&gt;
A video of all the tests running can be found [https://drive.google.com/file/d/1yKN_zzzkNGzkVpwnLCh_WPBknZKfOr2t/view?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
The pull request can be accessed [https://github.com/expertiza/expertiza/pull/2321 here]&lt;br /&gt;
&lt;br /&gt;
The forked git repository for this project can be found [https://github.com/atharva1996/expertiza here]&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
We followed a behavior-driven approach to write unit tests for badges_controller and publishing_controller. We considered all edge cases to achieve 100% coverage of both the controllers.&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143605</id>
		<title>CSC/ECE 517 Spring 2022 - E2202- Testing for badges controller, publishing controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143605"/>
		<updated>2022-03-27T20:58:34Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: /* Running Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is the software benefits for both instructors and students by supporting various types of submissions and providing reusable objects for peer review. It is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. It allows the instructors not only to create and customize new or existing assignments but also to create a list of topics the students can sign up for. Students can form teams to work on various projects and assignments. Expertiza also lets students peer-review other students' submissions, enabling them to work together to improve others' learning experiences.&lt;br /&gt;
&lt;br /&gt;
== Description about project ==&lt;br /&gt;
This page is a description of Expertiza OSS project E2202 which is adding test cases for badges_controller.rb and publishing_controller.rb. The badges controller allows users to create badges by entering the badge name, description and an image that serves as the badge icon. The publishing controller enables the students to grant/revoke publishing rights to past assignments. It does this by either allowing the students to grant and deny rights individually or all of them together. It makes use of the private key to verify the digital signature of the user granting the rights.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/controllers/publishing_controller_spec.rb spec/controllers/badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If you're having any difficulty in running the tests, please drop an email at sbose2@ncsu.edu, apatil25@ncsu.edu or kkhulla@ncsu.edu.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
After setting up the development environment, we ran the original test cases for the badges_controller. However the test cases were very limited and only partially covered one of the methods. We wrote additional test cases to cover all the 5 methods badges controller and expanded the existing test case.&lt;br /&gt;
For the publishing_controller no tests were available so we had to write every test from scratch. We have written tests to cover all the 6 methods in the publishing_controller. In total we wrote 27 test cases for both the controllers. We used object mocking for creating the unit test cases.&lt;br /&gt;
&lt;br /&gt;
====Badges Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*new&lt;br /&gt;
*redirect_to_assignment&lt;br /&gt;
*create&lt;br /&gt;
*badge_params&lt;br /&gt;
&lt;br /&gt;
====Publishing Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*view&lt;br /&gt;
*set_publish_permission&lt;br /&gt;
*update_publish_permissions&lt;br /&gt;
*grant&lt;br /&gt;
*grant_with_private_key&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Badges Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to access the badges this method is called to check if the current user is authorized to view this page. All the users except the user with student privileges has access to perform actions in badges.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'refuses student from performing certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_falsey&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows teaching assisstant to perform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end    &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. New - When user tries to create a new badge it redirects to the new create badge page and allow the user to enter details for the badge creation.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#new' do&lt;br /&gt;
    context 'when user wants to create a new badge' do&lt;br /&gt;
      it 'should call the new#badge page url' do&lt;br /&gt;
        get :new&lt;br /&gt;
        expect(get: 'badges/new').to route_to('badges#new')&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it 'should render the create new form and allow the user to enter details' do&lt;br /&gt;
        allow(Badge).to receive(:new).and_return(badge)&lt;br /&gt;
        params = {}&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. redirect_to_assignment - When the user has successfully created a badge it redirects to the assignment page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe 'redirect_to_assignment' do&lt;br /&gt;
    context 'after user successfully creates a badge' do&lt;br /&gt;
      it 'calls the redirect_to_assignment url' do&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        expect(get: 'badges/redirect_to_assignment').to route_to('badges#redirect_to_assignment')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'redirects to the assignment page' do&lt;br /&gt;
        stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        response.should redirect_to(&amp;quot;http://test.host/assignments/844/edit&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. create - When the user tries to create a badge by entering all the required details, it saves the badge. If there are any missing required details for badge creation it throws an error for missing fields.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#create' do&lt;br /&gt;
    context 'when user enters all the required badge details correctly' do&lt;br /&gt;
        it 'should save the badge successfully' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to redirect_to 'http://test.host/assignments/844/edit'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when user forgets to enter few of the required badge details' do&lt;br /&gt;
      it 'should throw an error for missing image file' do&lt;br /&gt;
        @file = nil&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge name' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: '',&lt;br /&gt;
          description: 'test badge',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge description' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: 'test',&lt;br /&gt;
          description: '',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')   &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Publishing Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to grant or view publishing rights this method is called to check if the current user is authorized to perform the action. All users with student privileges have access to perform actions for publishing.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows student to perform certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows teaching assisstant to peform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. view - When user visits the publishing rights page, it displays all past assignment participants.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'view' do&lt;br /&gt;
    context 'user visits the publishing rights page' do&lt;br /&gt;
      it 'displays all the assignment participants' do&lt;br /&gt;
          stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
          params = { id: 21 }&lt;br /&gt;
          get :view, params&lt;br /&gt;
          expect(assigns(:user)).to eq(student1)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. set_publish_permission - When the user matches with the participant and the user clicks on the grant button next to the assignment, it redirects to the grant page. &lt;br /&gt;
When the user matches with the participant and the assignment is already granted permission, it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'set_publish_permission' do&lt;br /&gt;
    context 'user matches with participant and user clicks on the grant button next to the assignment' do&lt;br /&gt;
      it 'redirects to the grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 1, allow: 1}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'user matches with participant and the assignment is already granted permission' do&lt;br /&gt;
      it 'redirects to the view page' do&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        allow(assignment_participant1).to receive(:update_attribute).and_return(true)&lt;br /&gt;
        params ={id: 1, allow: '0'}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. update_publish_permissions - When a user clicks on the grant publishing rights to all past assignments button it redirects to the grant page. &lt;br /&gt;
When a user clicks on the deny publishing rights to all past assignments button it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'update_publish_permissions' do&lt;br /&gt;
    context 'user clicks on the grant publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 1}&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
    context 'user clicks on the deny publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to view page' do&lt;br /&gt;
          allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 0}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:update_attribute).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:save).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end      &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. grant - When a user clicks on the grant publishing option, it displays the page where the user can supply their private key and grant publishing rights.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant' do&lt;br /&gt;
    context 'user clicks on grant option' do&lt;br /&gt;
      it 'displays the page where the user can supply their private key and grant publishing rights' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3}&lt;br /&gt;
        get :grant, params&lt;br /&gt;
        expect(assigns(:user)).to eq(student1)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. grant_with_private_key - When a user visits the grant page without id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant page. &lt;br /&gt;
When a user visits the grant page with id and enters correct RSA private key, it verifies key to be successful for all past assignments and redirects to view page.&lt;br /&gt;
When a user visits the grant page with id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant_with_private_key' do&lt;br /&gt;
&lt;br /&gt;
    context 'user visits the grant page without id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params = {}&lt;br /&gt;
        private_key = double(:private_key)&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(private_key).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(private_key).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
            &lt;br /&gt;
    context 'user visits the grant page with id and enters correct RSA private key' do&lt;br /&gt;
      it 'verifies to be successful for all past assignments and redirect to view' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end &lt;br /&gt;
      &lt;br /&gt;
    context 'user visits the grant page with id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant,params:{id:2})&lt;br /&gt;
      end&lt;br /&gt;
    end          &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
&lt;br /&gt;
The total coverage of the tests is 100%. We covered all the edges cases to ensure maximum coverage.&lt;br /&gt;
&lt;br /&gt;
The screenshot for test coverage can be found [https://drive.google.com/file/d/1sYOvWfxMEUI3i81ir7Yaw49ilEFvryfg/view?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
==Related Links==&lt;br /&gt;
&lt;br /&gt;
A video of all the tests running can be found [https://drive.google.com/file/d/1yKN_zzzkNGzkVpwnLCh_WPBknZKfOr2t/view?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
The pull request can be accessed [https://github.com/expertiza/expertiza/pull/2321 here]&lt;br /&gt;
&lt;br /&gt;
The forked git repository for this project can be found [https://github.com/atharva1996/expertiza here]&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
We followed a behavior-driven approach to write unit tests for badges_controller and publishing_controller. We considered all edge cases to achieve 100% coverage of both the controllers.&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143260</id>
		<title>CSC/ECE 517 Spring 2022 - E2202- Testing for badges controller, publishing controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143260"/>
		<updated>2022-03-21T22:05:42Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is the software benefits for both instructors and students by supporting various types of submissions and providing reusable objects for peer review. It is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. It allows the instructors not only to create and customize new or existing assignments but also to create a list of topics the students can sign up for. Students can form teams to work on various projects and assignments. Expertiza also lets students peer-review other students' submissions, enabling them to work together to improve others' learning experiences.&lt;br /&gt;
&lt;br /&gt;
== Description about project ==&lt;br /&gt;
This page is a description of Expertiza OSS project E2202 which is adding test cases for badges_controller.rb and publishing_controller.rb. The badges controller allows users to create badges by entering the badge name, description and an image that serves as the badge icon. The publishing controller enables the students to grant/revoke publishing rights to past assignments. It does this by either allowing the students to grant and deny rights individually or all of them together. It makes use of the private key to verify the digital signature of the user granting the rights.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/controllers/publishing_controller_spec.rb spec/controllers/badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
After setting up the development environment, we ran the original test cases for the badges_controller. However the test cases were very limited and only partially covered one of the methods. We wrote additional test cases to cover all the 5 methods badges controller and expanded the existing test case.&lt;br /&gt;
For the publishing_controller no tests were available so we had to write every test from scratch. We have written tests to cover all the 6 methods in the publishing_controller. In total we wrote 27 test cases for both the controllers. We used object mocking for creating the unit test cases.&lt;br /&gt;
&lt;br /&gt;
====Badges Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*new&lt;br /&gt;
*redirect_to_assignment&lt;br /&gt;
*create&lt;br /&gt;
*badge_params&lt;br /&gt;
&lt;br /&gt;
====Publishing Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*view&lt;br /&gt;
*set_publish_permission&lt;br /&gt;
*update_publish_permissions&lt;br /&gt;
*grant&lt;br /&gt;
*grant_with_private_key&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Badges Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to access the badges this method is called to check if the current user is authorized to view this page. All the users except the user with student privileges has access to perform actions in badges.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'refuses student from performing certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_falsey&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows teaching assisstant to perform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end    &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. New - When user tries to create a new badge it redirects to the new create badge page and allow the user to enter details for the badge creation.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#new' do&lt;br /&gt;
    context 'when user wants to create a new badge' do&lt;br /&gt;
      it 'should call the new#badge page url' do&lt;br /&gt;
        get :new&lt;br /&gt;
        expect(get: 'badges/new').to route_to('badges#new')&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it 'should render the create new form and allow the user to enter details' do&lt;br /&gt;
        allow(Badge).to receive(:new).and_return(badge)&lt;br /&gt;
        params = {}&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. redirect_to_assignment - When the user has successfully created a badge it redirects to the assignment page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe 'redirect_to_assignment' do&lt;br /&gt;
    context 'after user successfully creates a badge' do&lt;br /&gt;
      it 'calls the redirect_to_assignment url' do&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        expect(get: 'badges/redirect_to_assignment').to route_to('badges#redirect_to_assignment')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'redirects to the assignment page' do&lt;br /&gt;
        stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        response.should redirect_to(&amp;quot;http://test.host/assignments/844/edit&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. create - When the user tries to create a badge by entering all the required details, it saves the badge. If there are any missing required details for badge creation it throws an error for missing fields.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#create' do&lt;br /&gt;
    context 'when user enters all the required badge details correctly' do&lt;br /&gt;
        it 'should save the badge successfully' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to redirect_to 'http://test.host/assignments/844/edit'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when user forgets to enter few of the required badge details' do&lt;br /&gt;
      it 'should throw an error for missing image file' do&lt;br /&gt;
        @file = nil&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge name' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: '',&lt;br /&gt;
          description: 'test badge',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge description' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: 'test',&lt;br /&gt;
          description: '',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')   &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Publishing Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to grant or view publishing rights this method is called to check if the current user is authorized to perform the action. All users with student privileges have access to perform actions for publishing.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows student to perform certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows teaching assisstant to peform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. view - When user visits the publishing rights page, it displays all past assignment participants.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'view' do&lt;br /&gt;
    context 'user visits the publishing rights page' do&lt;br /&gt;
      it 'displays all the assignment participants' do&lt;br /&gt;
          stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
          params = { id: 21 }&lt;br /&gt;
          get :view, params&lt;br /&gt;
          expect(assigns(:user)).to eq(student1)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. set_publish_permission - When the user matches with the participant and the user clicks on the grant button next to the assignment, it redirects to the grant page. &lt;br /&gt;
When the user matches with the participant and the assignment is already granted permission, it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'set_publish_permission' do&lt;br /&gt;
    context 'user matches with participant and user clicks on the grant button next to the assignment' do&lt;br /&gt;
      it 'redirects to the grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 1, allow: 1}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'user matches with participant and the assignment is already granted permission' do&lt;br /&gt;
      it 'redirects to the view page' do&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        allow(assignment_participant1).to receive(:update_attribute).and_return(true)&lt;br /&gt;
        params ={id: 1, allow: '0'}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. update_publish_permissions - When a user clicks on the grant publishing rights to all past assignments button it redirects to the grant page. &lt;br /&gt;
When a user clicks on the deny publishing rights to all past assignments button it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'update_publish_permissions' do&lt;br /&gt;
    context 'user clicks on the grant publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 1}&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
    context 'user clicks on the deny publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to view page' do&lt;br /&gt;
          allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 0}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:update_attribute).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:save).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end      &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. grant - When a user clicks on the grant publishing option, it displays the page where the user can supply their private key and grant publishing rights.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant' do&lt;br /&gt;
    context 'user clicks on grant option' do&lt;br /&gt;
      it 'displays the page where the user can supply their private key and grant publishing rights' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3}&lt;br /&gt;
        get :grant, params&lt;br /&gt;
        expect(assigns(:user)).to eq(student1)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. grant_with_private_key - When a user visits the grant page without id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant page. &lt;br /&gt;
When a user visits the grant page with id and enters correct RSA private key, it verifies key to be successful for all past assignments and redirects to view page.&lt;br /&gt;
When a user visits the grant page with id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant_with_private_key' do&lt;br /&gt;
&lt;br /&gt;
    context 'user visits the grant page without id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params = {}&lt;br /&gt;
        private_key = double(:private_key)&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(private_key).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(private_key).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
            &lt;br /&gt;
    context 'user visits the grant page with id and enters correct RSA private key' do&lt;br /&gt;
      it 'verifies to be successful for all past assignments and redirect to view' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end &lt;br /&gt;
      &lt;br /&gt;
    context 'user visits the grant page with id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant,params:{id:2})&lt;br /&gt;
      end&lt;br /&gt;
    end          &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
&lt;br /&gt;
The total coverage of the tests is 100%. We covered all the edges cases to ensure maximum coverage.&lt;br /&gt;
&lt;br /&gt;
==Related Links==&lt;br /&gt;
&lt;br /&gt;
A video of all the tests running can be found [https://drive.google.com/file/d/1yKN_zzzkNGzkVpwnLCh_WPBknZKfOr2t/view?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
The pull request can be accessed [https://github.com/expertiza/expertiza/pull/2321 here]&lt;br /&gt;
&lt;br /&gt;
The forked git repository for this project can be found [https://github.com/atharva1996/expertiza here]&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
We followed a behavior-driven approach to write unit tests for badges_controller and publishing_controller. We considered all edge cases to achieve 100% coverage of both the controllers.&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143257</id>
		<title>CSC/ECE 517 Spring 2022 - E2202- Testing for badges controller, publishing controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143257"/>
		<updated>2022-03-21T22:03:30Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: /* Related Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is the software benefits for both instructors and students by supporting various types of submissions and providing reusable objects for peer review. It is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. It allows the instructors not only to create and customize new or existing assignments but also to create a list of topics the students can sign up for. Students can form teams to work on various projects and assignments. Expertiza also lets students peer-review other students' submissions, enabling them to work together to improve others' learning experiences.&lt;br /&gt;
&lt;br /&gt;
== Description about project ==&lt;br /&gt;
This page is a description of Expertiza OSS project E2202 which is adding test cases for badges_controller.rb and publishing_controller.rb. The badges controller allows users to create badges by entering the badge name, description and an image that serves as the badge icon. The publishing controller enables the students to grant/revoke publishing rights to past assignments. It does this by either allowing the students to grant and deny rights individually or all of them together. It makes use of the private key to verify the digital signature of the user granting the rights.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/controllers/publishing_controller_spec.rb spec/controllers/badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
After setting up the development environment, we ran the original test cases for the badges_controller. However the test cases were very limited and only partially covered one of the methods. We wrote additional test cases to cover all the 5 methods badges controller and expanded the existing test case.&lt;br /&gt;
For the publishing_controller no tests were available so we had to write every test from scratch. We have written tests to cover all the 6 methods in the publishing_controller. In total we wrote 27 test cases for both the controllers. We used object mocking for creating the unit test cases.&lt;br /&gt;
&lt;br /&gt;
====Badges Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*new&lt;br /&gt;
*redirect_to_assignment&lt;br /&gt;
*create&lt;br /&gt;
*badge_params&lt;br /&gt;
&lt;br /&gt;
====Publishing Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*view&lt;br /&gt;
*set_publish_permission&lt;br /&gt;
*update_publish_permissions&lt;br /&gt;
*grant&lt;br /&gt;
*grant_with_private_key&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Badges Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to access the badges this method is called to check if the current user is authorized to view this page. All the users except the user with student privileges has access to perform actions in badges.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'refuses student from performing certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_falsey&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows teaching assisstant to perform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end    &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. New - When user tries to create a new badge it redirects to the new create badge page and allow the user to enter details for the badge creation.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#new' do&lt;br /&gt;
    context 'when user wants to create a new badge' do&lt;br /&gt;
      it 'should call the new#badge page url' do&lt;br /&gt;
        get :new&lt;br /&gt;
        expect(get: 'badges/new').to route_to('badges#new')&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it 'should render the create new form and allow the user to enter details' do&lt;br /&gt;
        allow(Badge).to receive(:new).and_return(badge)&lt;br /&gt;
        params = {}&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. redirect_to_assignment - When the user has successfully created a badge it redirects to the assignment page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe 'redirect_to_assignment' do&lt;br /&gt;
    context 'after user successfully creates a badge' do&lt;br /&gt;
      it 'calls the redirect_to_assignment url' do&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        expect(get: 'badges/redirect_to_assignment').to route_to('badges#redirect_to_assignment')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'redirects to the assignment page' do&lt;br /&gt;
        stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        response.should redirect_to(&amp;quot;http://test.host/assignments/844/edit&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. create - When the user tries to create a badge by entering all the required details, it saves the badge. If there are any missing required details for badge creation it throws an error for missing fields.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#create' do&lt;br /&gt;
    context 'when user enters all the required badge details correctly' do&lt;br /&gt;
        it 'should save the badge successfully' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to redirect_to 'http://test.host/assignments/844/edit'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when user forgets to enter few of the required badge details' do&lt;br /&gt;
      it 'should throw an error for missing image file' do&lt;br /&gt;
        @file = nil&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge name' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: '',&lt;br /&gt;
          description: 'test badge',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge description' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: 'test',&lt;br /&gt;
          description: '',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')   &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Publishing Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to grant or view publishing rights this method is called to check if the current user is authorized to perform the action. All users with student privileges have access to perform actions for publishing.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows student to perform certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows teaching assisstant to peform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. view - When user visits the publishing rights page, it displays all past assignment participants.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'view' do&lt;br /&gt;
    context 'user visits the publishing rights page' do&lt;br /&gt;
      it 'displays all the assignment participants' do&lt;br /&gt;
          stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
          params = { id: 21 }&lt;br /&gt;
          get :view, params&lt;br /&gt;
          expect(assigns(:user)).to eq(student1)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. set_publish_permission - When the user matches with the participant and the user clicks on the grant button next to the assignment, it redirects to the grant page. &lt;br /&gt;
When the user matches with the participant and the assignment is already granted permission, it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'set_publish_permission' do&lt;br /&gt;
    context 'user matches with participant and user clicks on the grant button next to the assignment' do&lt;br /&gt;
      it 'redirects to the grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 1, allow: 1}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'user matches with participant and the assignment is already granted permission' do&lt;br /&gt;
      it 'redirects to the view page' do&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        allow(assignment_participant1).to receive(:update_attribute).and_return(true)&lt;br /&gt;
        params ={id: 1, allow: '0'}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. update_publish_permissions - When a user clicks on the grant publishing rights to all past assignments button it redirects to the grant page. &lt;br /&gt;
When a user clicks on the deny publishing rights to all past assignments button it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'update_publish_permissions' do&lt;br /&gt;
    context 'user clicks on the grant publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 1}&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
    context 'user clicks on the deny publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to view page' do&lt;br /&gt;
          allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 0}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:update_attribute).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:save).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end      &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. grant - When a user clicks on the grant publishing option, it displays the page where the user can supply their private key and grant publishing rights.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant' do&lt;br /&gt;
    context 'user clicks on grant option' do&lt;br /&gt;
      it 'displays the page where the user can supply their private key and grant publishing rights' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3}&lt;br /&gt;
        get :grant, params&lt;br /&gt;
        expect(assigns(:user)).to eq(student1)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. grant_with_private_key - When a user visits the grant page without id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant page. &lt;br /&gt;
When a user visits the grant page with id and enters correct RSA private key, it verifies key to be successful for all past assignments and redirects to view page.&lt;br /&gt;
When a user visits the grant page with id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant_with_private_key' do&lt;br /&gt;
&lt;br /&gt;
    context 'user visits the grant page without id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params = {}&lt;br /&gt;
        private_key = double(:private_key)&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(private_key).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(private_key).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
            &lt;br /&gt;
    context 'user visits the grant page with id and enters correct RSA private key' do&lt;br /&gt;
      it 'verifies to be successful for all past assignments and redirect to view' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end &lt;br /&gt;
      &lt;br /&gt;
    context 'user visits the grant page with id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant,params:{id:2})&lt;br /&gt;
      end&lt;br /&gt;
    end          &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
&lt;br /&gt;
The total coverage of the tests is 100%. We covered all the edges cases to ensure maximum coverage.&lt;br /&gt;
&lt;br /&gt;
==Related Links==&lt;br /&gt;
&lt;br /&gt;
A video of all the tests running can be found [https://drive.google.com/file/d/1yKN_zzzkNGzkVpwnLCh_WPBknZKfOr2t/view?usp=sharing here]&lt;br /&gt;
&lt;br /&gt;
The pull request can be accessed [https://github.com/expertiza/expertiza/pull/2321 here]&lt;br /&gt;
&lt;br /&gt;
The forked git repository for this project can be found [https://github.com/atharva1996/expertiza here]&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143254</id>
		<title>CSC/ECE 517 Spring 2022 - E2202- Testing for badges controller, publishing controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143254"/>
		<updated>2022-03-21T22:02:45Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is the software benefits for both instructors and students by supporting various types of submissions and providing reusable objects for peer review. It is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. It allows the instructors not only to create and customize new or existing assignments but also to create a list of topics the students can sign up for. Students can form teams to work on various projects and assignments. Expertiza also lets students peer-review other students' submissions, enabling them to work together to improve others' learning experiences.&lt;br /&gt;
&lt;br /&gt;
== Description about project ==&lt;br /&gt;
This page is a description of Expertiza OSS project E2202 which is adding test cases for badges_controller.rb and publishing_controller.rb. The badges controller allows users to create badges by entering the badge name, description and an image that serves as the badge icon. The publishing controller enables the students to grant/revoke publishing rights to past assignments. It does this by either allowing the students to grant and deny rights individually or all of them together. It makes use of the private key to verify the digital signature of the user granting the rights.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/controllers/publishing_controller_spec.rb spec/controllers/badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
After setting up the development environment, we ran the original test cases for the badges_controller. However the test cases were very limited and only partially covered one of the methods. We wrote additional test cases to cover all the 5 methods badges controller and expanded the existing test case.&lt;br /&gt;
For the publishing_controller no tests were available so we had to write every test from scratch. We have written tests to cover all the 6 methods in the publishing_controller. In total we wrote 27 test cases for both the controllers. We used object mocking for creating the unit test cases.&lt;br /&gt;
&lt;br /&gt;
====Badges Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*new&lt;br /&gt;
*redirect_to_assignment&lt;br /&gt;
*create&lt;br /&gt;
*badge_params&lt;br /&gt;
&lt;br /&gt;
====Publishing Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*view&lt;br /&gt;
*set_publish_permission&lt;br /&gt;
*update_publish_permissions&lt;br /&gt;
*grant&lt;br /&gt;
*grant_with_private_key&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Badges Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to access the badges this method is called to check if the current user is authorized to view this page. All the users except the user with student privileges has access to perform actions in badges.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'refuses student from performing certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_falsey&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows teaching assisstant to perform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end    &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. New - When user tries to create a new badge it redirects to the new create badge page and allow the user to enter details for the badge creation.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#new' do&lt;br /&gt;
    context 'when user wants to create a new badge' do&lt;br /&gt;
      it 'should call the new#badge page url' do&lt;br /&gt;
        get :new&lt;br /&gt;
        expect(get: 'badges/new').to route_to('badges#new')&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it 'should render the create new form and allow the user to enter details' do&lt;br /&gt;
        allow(Badge).to receive(:new).and_return(badge)&lt;br /&gt;
        params = {}&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. redirect_to_assignment - When the user has successfully created a badge it redirects to the assignment page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe 'redirect_to_assignment' do&lt;br /&gt;
    context 'after user successfully creates a badge' do&lt;br /&gt;
      it 'calls the redirect_to_assignment url' do&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        expect(get: 'badges/redirect_to_assignment').to route_to('badges#redirect_to_assignment')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'redirects to the assignment page' do&lt;br /&gt;
        stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        response.should redirect_to(&amp;quot;http://test.host/assignments/844/edit&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. create - When the user tries to create a badge by entering all the required details, it saves the badge. If there are any missing required details for badge creation it throws an error for missing fields.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#create' do&lt;br /&gt;
    context 'when user enters all the required badge details correctly' do&lt;br /&gt;
        it 'should save the badge successfully' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to redirect_to 'http://test.host/assignments/844/edit'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when user forgets to enter few of the required badge details' do&lt;br /&gt;
      it 'should throw an error for missing image file' do&lt;br /&gt;
        @file = nil&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge name' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: '',&lt;br /&gt;
          description: 'test badge',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge description' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: 'test',&lt;br /&gt;
          description: '',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')   &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Publishing Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to grant or view publishing rights this method is called to check if the current user is authorized to perform the action. All users with student privileges have access to perform actions for publishing.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows student to perform certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows teaching assisstant to peform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. view - When user visits the publishing rights page, it displays all past assignment participants.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'view' do&lt;br /&gt;
    context 'user visits the publishing rights page' do&lt;br /&gt;
      it 'displays all the assignment participants' do&lt;br /&gt;
          stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
          params = { id: 21 }&lt;br /&gt;
          get :view, params&lt;br /&gt;
          expect(assigns(:user)).to eq(student1)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. set_publish_permission - When the user matches with the participant and the user clicks on the grant button next to the assignment, it redirects to the grant page. &lt;br /&gt;
When the user matches with the participant and the assignment is already granted permission, it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'set_publish_permission' do&lt;br /&gt;
    context 'user matches with participant and user clicks on the grant button next to the assignment' do&lt;br /&gt;
      it 'redirects to the grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 1, allow: 1}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'user matches with participant and the assignment is already granted permission' do&lt;br /&gt;
      it 'redirects to the view page' do&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        allow(assignment_participant1).to receive(:update_attribute).and_return(true)&lt;br /&gt;
        params ={id: 1, allow: '0'}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. update_publish_permissions - When a user clicks on the grant publishing rights to all past assignments button it redirects to the grant page. &lt;br /&gt;
When a user clicks on the deny publishing rights to all past assignments button it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'update_publish_permissions' do&lt;br /&gt;
    context 'user clicks on the grant publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 1}&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
    context 'user clicks on the deny publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to view page' do&lt;br /&gt;
          allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 0}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:update_attribute).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:save).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end      &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. grant - When a user clicks on the grant publishing option, it displays the page where the user can supply their private key and grant publishing rights.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant' do&lt;br /&gt;
    context 'user clicks on grant option' do&lt;br /&gt;
      it 'displays the page where the user can supply their private key and grant publishing rights' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3}&lt;br /&gt;
        get :grant, params&lt;br /&gt;
        expect(assigns(:user)).to eq(student1)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. grant_with_private_key - When a user visits the grant page without id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant page. &lt;br /&gt;
When a user visits the grant page with id and enters correct RSA private key, it verifies key to be successful for all past assignments and redirects to view page.&lt;br /&gt;
When a user visits the grant page with id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant_with_private_key' do&lt;br /&gt;
&lt;br /&gt;
    context 'user visits the grant page without id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params = {}&lt;br /&gt;
        private_key = double(:private_key)&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(private_key).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(private_key).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
            &lt;br /&gt;
    context 'user visits the grant page with id and enters correct RSA private key' do&lt;br /&gt;
      it 'verifies to be successful for all past assignments and redirect to view' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end &lt;br /&gt;
      &lt;br /&gt;
    context 'user visits the grant page with id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant,params:{id:2})&lt;br /&gt;
      end&lt;br /&gt;
    end          &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
&lt;br /&gt;
The total coverage of the tests is 100%. We covered all the edges cases to ensure maximum coverage.&lt;br /&gt;
&lt;br /&gt;
==Related Links==&lt;br /&gt;
&lt;br /&gt;
A video of all the tests running can be found here [https://drive.google.com/file/d/1yKN_zzzkNGzkVpwnLCh_WPBknZKfOr2t/view?usp=sharing]&lt;br /&gt;
&lt;br /&gt;
The pull request can be accessed here [https://github.com/expertiza/expertiza/pull/2321]&lt;br /&gt;
&lt;br /&gt;
The forked git repository for this project can be found at [https://github.com/atharva1996/expertiza]&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143244</id>
		<title>CSC/ECE 517 Spring 2022 - E2202- Testing for badges controller, publishing controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143244"/>
		<updated>2022-03-21T21:49:45Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: /* Test Frame for Publishing Controller */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is the software benefits for both instructors and students by supporting various types of submissions and providing reusable objects for peer review. It is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. It allows the instructors not only to create and customize new or existing assignments but also to create a list of topics the students can sign up for. Students can form teams to work on various projects and assignments. Expertiza also lets students peer-review other students' submissions, enabling them to work together to improve others' learning experiences.&lt;br /&gt;
&lt;br /&gt;
== Description about project ==&lt;br /&gt;
This page is a description of Expertiza OSS project E2202 which is adding test cases for badges_controller.rb and publishing_controller.rb. The badges controller allows users to create badges by entering the badge name, description and an image that serves as the badge icon. The publishing controller enables the students to grant/revoke publishing rights to past assignments. It does this by either allowing the students to grant and deny rights individually or all of them together. It makes use of the private key to verify the digital signature of the user granting the rights.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/controllers/publishing_controller_spec.rb spec/controllers/badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
After setting up the development environment, we ran the original test cases for the badges_controller. However the test cases were very limited and only partially covered one of the methods. We wrote additional test cases to cover all the 5 methods badges controller and expanded the existing test case.&lt;br /&gt;
For the publishing_controller no tests were available so we had to write every test from scratch. We have written tests to cover all the 6 methods in the publishing_controller. In total we wrote 27 test cases for both the controllers. We used object mocking for creating the unit test cases.&lt;br /&gt;
&lt;br /&gt;
====Badges Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*new&lt;br /&gt;
*redirect_to_assignment&lt;br /&gt;
*create&lt;br /&gt;
*badge_params&lt;br /&gt;
&lt;br /&gt;
====Publishing Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*view&lt;br /&gt;
*set_publish_permission&lt;br /&gt;
*update_publish_permissions&lt;br /&gt;
*grant&lt;br /&gt;
*grant_with_private_key&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Badges Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to access the badges this method is called to check if the current user is authorized to view this page. All the users except the user with student privileges has access to perform actions in badges.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'refuses student from performing certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_falsey&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows teaching assisstant to perform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end    &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. New - When user tries to create a new badge it redirects to the new create badge page and allow the user to enter details for the badge creation.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#new' do&lt;br /&gt;
    context 'when user wants to create a new badge' do&lt;br /&gt;
      it 'should call the new#badge page url' do&lt;br /&gt;
        get :new&lt;br /&gt;
        expect(get: 'badges/new').to route_to('badges#new')&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it 'should render the create new form and allow the user to enter details' do&lt;br /&gt;
        allow(Badge).to receive(:new).and_return(badge)&lt;br /&gt;
        params = {}&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. redirect_to_assignment - When the user has successfully created a badge it redirects to the assignment page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe 'redirect_to_assignment' do&lt;br /&gt;
    context 'after user successfully creates a badge' do&lt;br /&gt;
      it 'calls the redirect_to_assignment url' do&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        expect(get: 'badges/redirect_to_assignment').to route_to('badges#redirect_to_assignment')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'redirects to the assignment page' do&lt;br /&gt;
        stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        response.should redirect_to(&amp;quot;http://test.host/assignments/844/edit&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. create - When the user tries to create a badge by entering all the required details, it saves the badge. If there are any missing required details for badge creation it throws an error for missing fields.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#create' do&lt;br /&gt;
    context 'when user enters all the required badge details correctly' do&lt;br /&gt;
        it 'should save the badge successfully' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to redirect_to 'http://test.host/assignments/844/edit'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when user forgets to enter few of the required badge details' do&lt;br /&gt;
      it 'should throw an error for missing image file' do&lt;br /&gt;
        @file = nil&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge name' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: '',&lt;br /&gt;
          description: 'test badge',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge description' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: 'test',&lt;br /&gt;
          description: '',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')   &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Publishing Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to grant or view publishing rights this method is called to check if the current user is authorized to perform the action. All users with student privileges have access to perform actions for publishing.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows student to perform certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows teaching assisstant to peform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. view - When user visits the publishing rights page, it displays all past assignment participants.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'view' do&lt;br /&gt;
    context 'user visits the publishing rights page' do&lt;br /&gt;
      it 'displays all the assignment participants' do&lt;br /&gt;
          stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
          params = { id: 21 }&lt;br /&gt;
          get :view, params&lt;br /&gt;
          expect(assigns(:user)).to eq(student1)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. set_publish_permission - When the user matches with the participant and the user clicks on the grant button next to the assignment, it redirects to the grant page. &lt;br /&gt;
When the user matches with the participant and the assignment is already granted permission, it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'set_publish_permission' do&lt;br /&gt;
    context 'user matches with participant and user clicks on the grant button next to the assignment' do&lt;br /&gt;
      it 'redirects to the grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 1, allow: 1}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'user matches with participant and the assignment is already granted permission' do&lt;br /&gt;
      it 'redirects to the view page' do&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        allow(assignment_participant1).to receive(:update_attribute).and_return(true)&lt;br /&gt;
        params ={id: 1, allow: '0'}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. update_publish_permissions - When a user clicks on the grant publishing rights to all past assignments button it redirects to the grant page. &lt;br /&gt;
When a user clicks on the deny publishing rights to all past assignments button it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'update_publish_permissions' do&lt;br /&gt;
    context 'user clicks on the grant publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 1}&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
    context 'user clicks on the deny publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to view page' do&lt;br /&gt;
          allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 0}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:update_attribute).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:save).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end      &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. grant - When a user clicks on the grant publishing option, it displays the page where the user can supply their private key and grant publishing rights.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant' do&lt;br /&gt;
    context 'user clicks on grant option' do&lt;br /&gt;
      it 'displays the page where the user can supply their private key and grant publishing rights' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3}&lt;br /&gt;
        get :grant, params&lt;br /&gt;
        expect(assigns(:user)).to eq(student1)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. grant_with_private_key - When a user visits the grant page without id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant page. &lt;br /&gt;
When a user visits the grant page with id and enters correct RSA private key, it verifies key to be successful for all past assignments and redirects to view page.&lt;br /&gt;
When a user visits the grant page with id and enters incorrect RSA private key, it throws StandardError, displays notice and redirects to grant.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant_with_private_key' do&lt;br /&gt;
&lt;br /&gt;
    context 'user visits the grant page without id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params = {}&lt;br /&gt;
        private_key = double(:private_key)&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(private_key).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(private_key).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
            &lt;br /&gt;
    context 'user visits the grant page with id and enters correct RSA private key' do&lt;br /&gt;
      it 'verifies to be successful for all past assignments and redirect to view' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end &lt;br /&gt;
      &lt;br /&gt;
    context 'user visits the grant page with id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant,params:{id:2})&lt;br /&gt;
      end&lt;br /&gt;
    end          &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143243</id>
		<title>CSC/ECE 517 Spring 2022 - E2202- Testing for badges controller, publishing controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143243"/>
		<updated>2022-03-21T21:47:40Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is the software benefits for both instructors and students by supporting various types of submissions and providing reusable objects for peer review. It is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. It allows the instructors not only to create and customize new or existing assignments but also to create a list of topics the students can sign up for. Students can form teams to work on various projects and assignments. Expertiza also lets students peer-review other students' submissions, enabling them to work together to improve others' learning experiences.&lt;br /&gt;
&lt;br /&gt;
== Description about project ==&lt;br /&gt;
This page is a description of Expertiza OSS project E2202 which is adding test cases for badges_controller.rb and publishing_controller.rb. The badges controller allows users to create badges by entering the badge name, description and an image that serves as the badge icon. The publishing controller enables the students to grant/revoke publishing rights to past assignments. It does this by either allowing the students to grant and deny rights individually or all of them together. It makes use of the private key to verify the digital signature of the user granting the rights.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/controllers/publishing_controller_spec.rb spec/controllers/badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
After setting up the development environment, we ran the original test cases for the badges_controller. However the test cases were very limited and only partially covered one of the methods. We wrote additional test cases to cover all the 5 methods badges controller and expanded the existing test case.&lt;br /&gt;
For the publishing_controller no tests were available so we had to write every test from scratch. We have written tests to cover all the 6 methods in the publishing_controller. In total we wrote 27 test cases for both the controllers. We used object mocking for creating the unit test cases.&lt;br /&gt;
&lt;br /&gt;
====Badges Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*new&lt;br /&gt;
*redirect_to_assignment&lt;br /&gt;
*create&lt;br /&gt;
*badge_params&lt;br /&gt;
&lt;br /&gt;
====Publishing Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*view&lt;br /&gt;
*set_publish_permission&lt;br /&gt;
*update_publish_permissions&lt;br /&gt;
*grant&lt;br /&gt;
*grant_with_private_key&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Badges Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to access the badges this method is called to check if the current user is authorized to view this page. All the users except the user with student privileges has access to perform actions in badges.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'refuses student from performing certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_falsey&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows teaching assisstant to perform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end    &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. New - When user tries to create a new badge it redirects to the new create badge page and allow the user to enter details for the badge creation.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#new' do&lt;br /&gt;
    context 'when user wants to create a new badge' do&lt;br /&gt;
      it 'should call the new#badge page url' do&lt;br /&gt;
        get :new&lt;br /&gt;
        expect(get: 'badges/new').to route_to('badges#new')&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it 'should render the create new form and allow the user to enter details' do&lt;br /&gt;
        allow(Badge).to receive(:new).and_return(badge)&lt;br /&gt;
        params = {}&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. redirect_to_assignment - When the user has successfully created a badge it redirects to the assignment page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe 'redirect_to_assignment' do&lt;br /&gt;
    context 'after user successfully creates a badge' do&lt;br /&gt;
      it 'calls the redirect_to_assignment url' do&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        expect(get: 'badges/redirect_to_assignment').to route_to('badges#redirect_to_assignment')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'redirects to the assignment page' do&lt;br /&gt;
        stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        response.should redirect_to(&amp;quot;http://test.host/assignments/844/edit&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. create - When the user tries to create a badge by entering all the required details, it saves the badge. If there are any missing required details for badge creation it throws an error for missing fields.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#create' do&lt;br /&gt;
    context 'when user enters all the required badge details correctly' do&lt;br /&gt;
        it 'should save the badge successfully' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to redirect_to 'http://test.host/assignments/844/edit'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when user forgets to enter few of the required badge details' do&lt;br /&gt;
      it 'should throw an error for missing image file' do&lt;br /&gt;
        @file = nil&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge name' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: '',&lt;br /&gt;
          description: 'test badge',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge description' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: 'test',&lt;br /&gt;
          description: '',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')   &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Publishing Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to grant or view publishing rights this method is called to check if the current user is authorized to perform the action. All users with student privileges have access to perform actions for publishing.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows student to perform certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows teaching assisstant to peform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. view - When user visits the publishing rights page, it displays all past assignment participants.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'view' do&lt;br /&gt;
    context 'user visits the publishing rights page' do&lt;br /&gt;
      it 'displays all the assignment participants' do&lt;br /&gt;
          stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
          params = { id: 21 }&lt;br /&gt;
          get :view, params&lt;br /&gt;
          expect(assigns(:user)).to eq(student1)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. set_publish_permission - When the user matches with the participant and the user clicks on the grant button next to the assignment, it redirects to the grant page. &lt;br /&gt;
When the user matches with the participant and the assignment is already granted permission, it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'set_publish_permission' do&lt;br /&gt;
    context 'user matches with participant and user clicks on the grant button next to the assignment' do&lt;br /&gt;
      it 'redirects to the grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 1, allow: 1}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'user matches with participant and the assignment is already granted permission' do&lt;br /&gt;
      it 'redirects to the view page' do&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        allow(assignment_participant1).to receive(:update_attribute).and_return(true)&lt;br /&gt;
        params ={id: 1, allow: '0'}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. update_publish_permissions - When a user clicks on the grant publishing rights to all past assignments button it redirects to the grant page. &lt;br /&gt;
When a user clicks on the deny publishing rights to all past assignments button it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'update_publish_permissions' do&lt;br /&gt;
    context 'user clicks on the grant publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 1}&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
    context 'user clicks on the deny publishing rights to all past assignments button' do&lt;br /&gt;
      it 'redirects to view page' do&lt;br /&gt;
          allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3, allow: 0}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:update_attribute).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:save).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :update_publish_permissions, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end      &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. grant - When a user clicks on the grant publishing option, it displays the page where the user can supply their private key and grant publishing rights.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant' do&lt;br /&gt;
    context 'user clicks on grant option' do&lt;br /&gt;
      it 'displays the page where the user can supply their private key and grant publishing rights' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('3').and_return(assignment_participant2)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 3}&lt;br /&gt;
        get :grant, params&lt;br /&gt;
        expect(assigns(:user)).to eq(student1)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. grant_with_private_key - When a user visits the grant page without id and enters incorrect RSA private key, it displays notice and redirects to grant page. &lt;br /&gt;
When a user visits the grant page with id and enters correct RSA private key, it verifies key to be successful for all past assignments and redirects to view page.&lt;br /&gt;
When a user visits the grant page with id and enters incorrect RSA private key, it displays notice and redirects to grant.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'grant_with_private_key' do&lt;br /&gt;
&lt;br /&gt;
    context 'user visits the grant page without id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:where).with(user_id: 21).and_return([assignment_participant1])&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params = {}&lt;br /&gt;
        private_key = double(:private_key)&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(private_key).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(private_key).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
      &lt;br /&gt;
            &lt;br /&gt;
    context 'user visits the grant page with id and enters correct RSA private key' do&lt;br /&gt;
      it 'verifies to be successful for all past assignments and redirect to view' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_return(true)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end &lt;br /&gt;
      &lt;br /&gt;
    context 'user visits the grant page with id and enters incorrect RSA private key' do&lt;br /&gt;
      it 'displays notice and redirects to grant' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('2').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        private_key = OpenSSL::PKey::RSA.new 2048&lt;br /&gt;
        params = {id: 2, private_key: private_key}&lt;br /&gt;
        [assignment_participant1].each do |participant|&lt;br /&gt;
          allow(participant).to receive(:verify_digital_signature).with(any_args).and_return(true)&lt;br /&gt;
          allow(participant).to receive(:assign_copyright).with(any_args).and_raise('The private key you inputted was invalid.', StandardError)&lt;br /&gt;
        end&lt;br /&gt;
        post :grant_with_private_key, params&lt;br /&gt;
        expect(flash[:notice]).to eq('The private key you inputted was invalid.')&lt;br /&gt;
        expect(response).to redirect_to(action: :grant,params:{id:2})&lt;br /&gt;
      end&lt;br /&gt;
    end          &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143226</id>
		<title>CSC/ECE 517 Spring 2022 - E2202- Testing for badges controller, publishing controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2202-_Testing_for_badges_controller,_publishing_controller&amp;diff=143226"/>
		<updated>2022-03-21T21:28:24Z</updated>

		<summary type="html">&lt;p&gt;Sbose2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is the software benefits for both instructors and students by supporting various types of submissions and providing reusable objects for peer review. It is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. It allows the instructors not only to create and customize new or existing assignments but also to create a list of topics the students can sign up for. Students can form teams to work on various projects and assignments. Expertiza also lets students peer-review other students' submissions, enabling them to work together to improve others' learning experiences.&lt;br /&gt;
&lt;br /&gt;
== Description about project ==&lt;br /&gt;
This page is a description of Expertiza OSS project E2202 which is adding test cases for badges_controller.rb and publishing_controller.rb. The badges controller allows users to create badges by entering the badge name, description and an image that serves as the badge icon. The publishing controller enables the students to grant/revoke publishing rights to past assignments. It does this by either allowing the students to grant and deny rights individually or all of them together. It makes use of the private key to verify the digital signature of the user granting the rights.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller.rb&lt;br /&gt;
&lt;br /&gt;
publishing_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=== Running Tests ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
rspec spec/controllers/publishing_controller_spec.rb spec/controllers/badges_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
After setting up the development environment, we ran the original test cases for the badges_controller. However the test cases were very limited and only partially covered one of the methods. We wrote additional test cases to cover all the 5 methods badges controller and expanded the existing test case.&lt;br /&gt;
For the publishing_controller no tests were available so we had to write every test from scratch. We have written tests to cover all the 6 methods in the publishing_controller. In total we wrote 27 test cases for both the controllers. We used object mocking for creating the unit test cases.&lt;br /&gt;
&lt;br /&gt;
====Badges Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*new&lt;br /&gt;
*redirect_to_assignment&lt;br /&gt;
*create&lt;br /&gt;
*badge_params&lt;br /&gt;
&lt;br /&gt;
====Publishing Controller Methods====&lt;br /&gt;
The methods in the controller are:&lt;br /&gt;
&lt;br /&gt;
*action_allowed?&lt;br /&gt;
*view&lt;br /&gt;
*set_publish_permission&lt;br /&gt;
*update_publish_permissions&lt;br /&gt;
*grant&lt;br /&gt;
*grant_with_private_key&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Badges Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to access the badges this method is called to check if the current user is authorized to view this page. All the users except the user with student privileges has access to perform actions in badges.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'refuses student from performing certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_falsey&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows teaching assisstant to perform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end    &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. New - When user tries to create a new badge it redirects to the new create badge page and allow the user to enter details for the badge creation.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#new' do&lt;br /&gt;
    context 'when user wants to create a new badge' do&lt;br /&gt;
      it 'should call the new#badge page url' do&lt;br /&gt;
        get :new&lt;br /&gt;
        expect(get: 'badges/new').to route_to('badges#new')&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it 'should render the create new form and allow the user to enter details' do&lt;br /&gt;
        allow(Badge).to receive(:new).and_return(badge)&lt;br /&gt;
        params = {}&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        get :new, params, session&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. redirect_to_assignment - When the user has successfully created a badge it redirects to the assignment page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe 'redirect_to_assignment' do&lt;br /&gt;
    context 'after user successfully creates a badge' do&lt;br /&gt;
      it 'calls the redirect_to_assignment url' do&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        expect(get: 'badges/redirect_to_assignment').to route_to('badges#redirect_to_assignment')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'redirects to the assignment page' do&lt;br /&gt;
        stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        get :redirect_to_assignment&lt;br /&gt;
        response.should redirect_to(&amp;quot;http://test.host/assignments/844/edit&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. create - When the user tries to create a badge by entering all the required details, it saves the badge. If there are any missing required details for badge creation it throws an error for missing fields.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 describe '#create' do&lt;br /&gt;
    context 'when user enters all the required badge details correctly' do&lt;br /&gt;
        it 'should save the badge successfully' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to redirect_to 'http://test.host/assignments/844/edit'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when user forgets to enter few of the required badge details' do&lt;br /&gt;
      it 'should throw an error for missing image file' do&lt;br /&gt;
        @file = nil&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
          badge:{&lt;br /&gt;
            name: 'test',&lt;br /&gt;
            description: 'test badge',&lt;br /&gt;
            image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge name' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: '',&lt;br /&gt;
          description: 'test badge',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')&lt;br /&gt;
      end&lt;br /&gt;
    &lt;br /&gt;
      it 'should throw an error for missing badge description' do&lt;br /&gt;
        @file = fixture_file_upload('app/assets/images/badges/test.png', 'image/png')&lt;br /&gt;
        allow(@file).to receive(:original_filename).and_return(&amp;quot;test.png&amp;quot;)&lt;br /&gt;
        session = { user: instructor1 }&lt;br /&gt;
        params = {&lt;br /&gt;
        badge:{&lt;br /&gt;
          name: 'test',&lt;br /&gt;
          description: '',&lt;br /&gt;
          image_name: 'test.png',&lt;br /&gt;
          image_file: @file&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
        session[:return_to] ||= 'http://test.host/assignments/844/edit'&lt;br /&gt;
        allow(Badge).to receive(:get_id_from_name).with('test').and_return(badge)&lt;br /&gt;
        allow(Badge).to receive(:get_image_name_from_name).with('test').and_return(badge)&lt;br /&gt;
        post :create, params, session, &amp;quot;file&amp;quot; =&amp;gt; @file&lt;br /&gt;
        expect(response).to render_template('new')   &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Test Frame for Publishing Controller====&lt;br /&gt;
&lt;br /&gt;
1. action_allowed? - When user tries to grant or view publishing rights this method is called to check if the current user is authorized to perform the action. All users with student privileges have access to perform actions for publishing.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#action_allowed?' do&lt;br /&gt;
    it 'allows super_admin to perform certain action' do&lt;br /&gt;
      stub_current_user(super_admin, super_admin.role.name, super_admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows instructor to perform certain action' do&lt;br /&gt;
      stub_current_user(instructor1, instructor1.role.name, instructor1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows student to perform certain action' do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows teaching assisstant to peform certain action' do&lt;br /&gt;
      stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'allows admin to perform certain action' do&lt;br /&gt;
      stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
      expect(controller.send(:action_allowed?)).to be_truthy&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. view - When user visits the publishing rights page, it displays all past assignment participants.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'view' do&lt;br /&gt;
    context 'user visits the publishing rights page' do&lt;br /&gt;
      it 'displays all the assignment participants' do&lt;br /&gt;
          stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
          params = { id: 21 }&lt;br /&gt;
          get :view, params&lt;br /&gt;
          expect(assigns(:user)).to eq(student1)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. set_publish_permission - When the user matches with the participant and the user clicks on the grant button next to the assignment, it redirects to the grant page. &lt;br /&gt;
When the user matches with the participant and the assignment is already granted permission, it redirects to the view page.&lt;br /&gt;
&lt;br /&gt;
Code Snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'set_publish_permission' do&lt;br /&gt;
    context 'user matches with participant and user clicks on the grant button next to the assignment' do&lt;br /&gt;
      it 'redirects to the grant page' do&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        params ={id: 1, allow: 1}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :grant)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'user matches with participant and the assignment is already granted permission' do&lt;br /&gt;
      it 'redirects to the view page' do&lt;br /&gt;
        stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
        allow(AssignmentParticipant).to receive(:find).with('1').and_return(assignment_participant1)&lt;br /&gt;
        allow(assignment_participant1).to receive(:update_attribute).and_return(true)&lt;br /&gt;
        params ={id: 1, allow: '0'}&lt;br /&gt;
        post :set_publish_permission, params&lt;br /&gt;
        expect(response).to redirect_to(action: :view)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbose2</name></author>
	</entry>
</feed>