<?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=Wagrocho</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=Wagrocho"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Wagrocho"/>
	<updated>2026-08-17T20:12:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160641</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160641"/>
		<updated>2024-12-04T04:18:34Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Add pull request section and link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Analyze and Refactor Current Code Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into three helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Refactor the feedback_response_report Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the original arrays used to statically represent the review rounds.&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-OriginalArrayRounds.png]]&lt;br /&gt;
&lt;br /&gt;
We can take these multiple arrays, and use dictionaries instead, where each round is called by its key value (integer value). &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArraysMain.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
The code found in the feedback_response_report method that use the arrays were moved to the two helper methods, seen as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, Rubocop was used to analyze the code and adhere to proper Ruby Guidelines. The command below was used to search for any code smells that we missed.&lt;br /&gt;
&lt;br /&gt;
   rubocop app/models/feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Originally, there were only three offenses, but this largely grew as we continued to refactor the code. All of the offenses can be seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop3.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop4.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
All of these offenses were fixed. The following three offenses were the original ones. For the first and third offenses, the colon after the method headers were simply removed. For the second offense, the “return” keyword caused errors, thus, it was removed, because a ruby method will return  its last statement. The two other private methods containing “return” also had that keyword removed. &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-RubocopOriginal.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Lastly, commenting was added throughout the files, to improve readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As planned in step 1, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). One change we made that was different from the UML diagram was the addition of an id parameter in the get_feedback_authors method, in order to access id, since it was a parameter given to feedback_response_report. Each helper method was planned in order to stick to the guideline of “A method should do only one thing and do it well.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Final UML for FeedbackResponseMap&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_FeedbackResponseMap_final.drawio.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Authors&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
This image shows the construction of the private method we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_after_1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Report&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before (this image is out of date, the return functionality for the varying rubric report rounds has since been generalized, please see the repo for the updated version) (The updated version does not include the old version comments, which is why this screenshot is used):&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
These images show the construction of the private methods we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_varying_1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_report_static_1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in both the original self.feedback_response_report method and the private methods, comments are included to explain each non-obvious step of the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Complexity changes&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Previously, Rubocop reported the following failures on behalf of the self.feedback_response_report method:&lt;br /&gt;
&lt;br /&gt;
  Metrics/PerceivedComplexity: Perceived complexity for feedback_response_report is too high. [14/8]&lt;br /&gt;
  Metrics/CyclomaticComplexity: Cyclomatic complexity for feedback_response_report is too high. [12/7]&lt;br /&gt;
  Metrics/AbcSize: Assignment Branch Condition size for feedback_response_report is too high. [&amp;lt;14, 46, 16&amp;gt; 50.68/20]&lt;br /&gt;
&lt;br /&gt;
Now, neither self.feedback_response_report nor any of its associated private methods trigger any of these Metric violations!&lt;br /&gt;
(Note that the email method does trigger a AbcSize violation when the protective comments are removed, but adjusting that method is beyond the scope of this project for reasons listed in the Implementation Plan)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Research Future Refactoring for email Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the implementation plan, the email method was left as is. Any changes would require the addition of a new class and/or major refactoring for the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. Improve Variable Naming and Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two sets of variables discussed in the plan, @temp_response_map_ids and @temp_review_responses were modified as needed. First, the @temp_response_map_ids was moved to the helper methods varying_rubrics_report and static_rubrics_report, to be initialized, and changed to response_map_ids.&lt;br /&gt;
&lt;br /&gt;
Secondly, @temp_review_responses was changed to review_responses in the helper methods that call it: varying_rubrics_report and static_rubrics_report&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Files ===&lt;br /&gt;
&lt;br /&gt;
The files that were added or modified to our repository are shown below.&lt;br /&gt;
&lt;br /&gt;
==== Models ====&lt;br /&gt;
&lt;br /&gt;
The following files were copied from the expertiza/expertiza repository:&lt;br /&gt;
* analytic/assignment_team_analytic.rb&lt;br /&gt;
* assignment_team.rb&lt;br /&gt;
* feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Added assignment_team.rb and assignment_team_analytic.rb as the existing spec tests depended on those 2 files. No changes were made to these files other than commenting out include Scoring in assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;feedback_response_map.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many comments were placed throughout the document in order to make code more readable.&lt;br /&gt;
&lt;br /&gt;
The main changes were taking feedback_response_report method and scanning it, to find different functionalities that could be taken out of it and turned into the following private helper methods: get_feedback_authors, varying_rubrics_report, static_rubrics_report.&lt;br /&gt;
&lt;br /&gt;
Additionally, the variable @temp_response_map_ids was changed into response_map_ids both inside and outside the helper methods that used this variable. The variable @temp_review_responses was not changed except for being called review_responses in the helper methods.&lt;br /&gt;
&lt;br /&gt;
==== Database ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;migrate/20241203083135_add_missing_reponse_map_fields.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One class is added, called AddMissingResponseMapFields, with a change of adding columns to response_maps and type and calibrate_to.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The only things changed in this file were a version change, as well as the addition of a t.string of &amp;quot;type&amp;quot; and a t.integer of &amp;quot;calibrate_to&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Spec ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;factories.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was modified to use single quotation marks instead of double quotation marks to adhere to RuboCop. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;factories/factories.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We populated the factory with necessary factories such as response, course, institution, and role, as well as fixing the factory formatting to function properly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;feedback_response_map.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code was updated to adhere to RuboCop guidelines. Secondly, tests and parts of tests were commented out if they were reliant on functionality that was not yet implemented in reimplementation-back-end.&lt;br /&gt;
&lt;br /&gt;
=== Video ===&lt;br /&gt;
&lt;br /&gt;
https://youtu.be/SbmDoJNm4Q4&lt;br /&gt;
&lt;br /&gt;
=== Pull Request ===&lt;br /&gt;
&lt;br /&gt;
https://github.com/expertiza/reimplementation-back-end/pull/144&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project enhances Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160526</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160526"/>
		<updated>2024-12-04T03:17:29Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Fixed uneven equals in Video header&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Analyze and Refactor Current Code Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into three helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Refactor the feedback_response_report Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the original arrays used to statically represent the review rounds.&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-OriginalArrayRounds.png]]&lt;br /&gt;
&lt;br /&gt;
We can take these multiple arrays, and use dictionaries instead, where each round is called by its key value (integer value). &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArraysMain.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
The code found in the feedback_response_report method that use the arrays were moved to the two helper methods, seen as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, Rubocop was used to analyze the code and adhere to proper Ruby Guidelines. The command below was used to search for any code smells that we missed.&lt;br /&gt;
&lt;br /&gt;
   rubocop app/models/feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Originally, there were only three offenses, but this largely grew as we continued to refactor the code. All of the offenses can be seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop3.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop4.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
All of these offenses were fixed. The following three offenses were the original ones. For the first and third offenses, the colon after the method headers were simply removed. For the second offense, the “return” keyword caused errors, thus, it was removed, because a ruby method will return  its last statement. The two other private methods containing “return” also had that keyword removed. &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-RubocopOriginal.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Lastly, commenting was added throughout the files, to improve readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As planned in step 1, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). One change we made that was different from the UML diagram was the addition of an id parameter in the get_feedback_authors method, in order to access id, since it was a parameter given to feedback_response_report. Each helper method was planned in order to stick to the guideline of “A method should do only one thing and do it well.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Final UML for FeedbackResponseMap&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_FeedbackResponseMap_final.drawio.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Authors&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
This image shows the construction of the private method we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_after_1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Report&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before (this image is out of date, the return functionality for the varying rubric report rounds has since been generalized, please see the repo for the updated version) (The updated version does not include the old version comments, which is why this screenshot is used):&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
These images show the construction of the private methods we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_varying_1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_report_static_1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in both the original self.feedback_response_report method and the private methods, comments are included to explain each non-obvious step of the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Complexity changes&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Previously, Rubocop reported the following failures on behalf of the self.feedback_response_report method:&lt;br /&gt;
&lt;br /&gt;
  Metrics/PerceivedComplexity: Perceived complexity for feedback_response_report is too high. [14/8]&lt;br /&gt;
  Metrics/CyclomaticComplexity: Cyclomatic complexity for feedback_response_report is too high. [12/7]&lt;br /&gt;
  Metrics/AbcSize: Assignment Branch Condition size for feedback_response_report is too high. [&amp;lt;14, 46, 16&amp;gt; 50.68/20]&lt;br /&gt;
&lt;br /&gt;
Now, neither self.feedback_response_report nor any of its associated private methods trigger any of these Metric violations!&lt;br /&gt;
(Note that the email method does trigger a AbcSize violation when the protective comments are removed, but adjusting that method is beyond the scope of this project for reasons listed in the Implementation Plan)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Research Future Refactoring for email Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the implementation plan, the email method was left as is. Any changes would require the addition of a new class and/or major refactoring for the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. Improve Variable Naming and Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two sets of variables discussed in the plan, @temp_response_map_ids and @temp_review_responses were modified as needed. First, the @temp_response_map_ids was moved to the helper methods varying_rubrics_report and static_rubrics_report, to be initialized, and changed to response_map_ids.&lt;br /&gt;
&lt;br /&gt;
Secondly, @temp_review_responses was changed to review_responses in the helper methods that call it: varying_rubrics_report and static_rubrics_report&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Video ===&lt;br /&gt;
&lt;br /&gt;
https://youtu.be/SbmDoJNm4Q4&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160521</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160521"/>
		<updated>2024-12-04T03:16:54Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added video section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Analyze and Refactor Current Code Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into three helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Refactor the feedback_response_report Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the original arrays used to statically represent the review rounds.&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-OriginalArrayRounds.png]]&lt;br /&gt;
&lt;br /&gt;
We can take these multiple arrays, and use dictionaries instead, where each round is called by its key value (integer value). &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArraysMain.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
The code found in the feedback_response_report method that use the arrays were moved to the two helper methods, seen as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, Rubocop was used to analyze the code and adhere to proper Ruby Guidelines. The command below was used to search for any code smells that we missed.&lt;br /&gt;
&lt;br /&gt;
   rubocop app/models/feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Originally, there were only three offenses, but this largely grew as we continued to refactor the code. All of the offenses can be seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop3.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop4.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
All of these offenses were fixed. The following three offenses were the original ones. For the first and third offenses, the colon after the method headers were simply removed. For the second offense, the “return” keyword caused errors, thus, it was removed, because a ruby method will return  its last statement. The two other private methods containing “return” also had that keyword removed. &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-RubocopOriginal.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Lastly, commenting was added throughout the files, to improve readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As planned in step 1, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). One change we made that was different from the UML diagram was the addition of an id parameter in the get_feedback_authors method, in order to access id, since it was a parameter given to feedback_response_report. Each helper method was planned in order to stick to the guideline of “A method should do only one thing and do it well.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Final UML for FeedbackResponseMap&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_FeedbackResponseMap_final.drawio.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Authors&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
This image shows the construction of the private method we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_after_1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Report&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before (this image is out of date, the return functionality for the varying rubric report rounds has since been generalized, please see the repo for the updated version) (The updated version does not include the old version comments, which is why this screenshot is used):&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
These images show the construction of the private methods we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_varying_1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_report_static_1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in both the original self.feedback_response_report method and the private methods, comments are included to explain each non-obvious step of the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Complexity changes&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Previously, Rubocop reported the following failures on behalf of the self.feedback_response_report method:&lt;br /&gt;
&lt;br /&gt;
  Metrics/PerceivedComplexity: Perceived complexity for feedback_response_report is too high. [14/8]&lt;br /&gt;
  Metrics/CyclomaticComplexity: Cyclomatic complexity for feedback_response_report is too high. [12/7]&lt;br /&gt;
  Metrics/AbcSize: Assignment Branch Condition size for feedback_response_report is too high. [&amp;lt;14, 46, 16&amp;gt; 50.68/20]&lt;br /&gt;
&lt;br /&gt;
Now, neither self.feedback_response_report nor any of its associated private methods trigger any of these Metric violations!&lt;br /&gt;
(Note that the email method does trigger a AbcSize violation when the protective comments are removed, but adjusting that method is beyond the scope of this project for reasons listed in the Implementation Plan)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Research Future Refactoring for email Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the implementation plan, the email method was left as is. Any changes would require the addition of a new class and/or major refactoring for the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. Improve Variable Naming and Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two sets of variables discussed in the plan, @temp_response_map_ids and @temp_review_responses were modified as needed. First, the @temp_response_map_ids was moved to the helper methods varying_rubrics_report and static_rubrics_report, to be initialized, and changed to response_map_ids.&lt;br /&gt;
&lt;br /&gt;
Secondly, @temp_review_responses was changed to review_responses in the helper methods that call it: varying_rubrics_report and static_rubrics_report&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Video ==&lt;br /&gt;
&lt;br /&gt;
https://youtu.be/SbmDoJNm4Q4&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159034</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159034"/>
		<updated>2024-11-12T03:34:32Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Removed inaccurate plans for the email method&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Develop Tests for Refactored and New Methods&lt;br /&gt;
&lt;br /&gt;
* Create unit tests for each refactored and newly created method, particularly focusing on feedback_response_report and any extracted functionalities.&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159029</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159029"/>
		<updated>2024-11-12T03:31:39Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Rearranged list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
&lt;br /&gt;
4. Separate and Modularize the email Method&lt;br /&gt;
&lt;br /&gt;
* Move the email method out of FeedbackResponseMap and into a separate service class. This separation will follow the Visitor pattern or a more suitable pattern identified during implementation, to better manage email-related functionality.&lt;br /&gt;
* Assign responsibility for sending feedback-related emails to a dedicated service class (e.g., FeedbackEmailService), ensuring that the core functionality of FeedbackResponseMap is isolated from email concerns.&lt;br /&gt;
* Update any dependencies to use the newly created email service.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Develop Tests for Refactored and New Methods&lt;br /&gt;
&lt;br /&gt;
* Create unit tests for each refactored and newly created method, particularly focusing on feedback_response_report and any extracted functionalities.&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159026</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159026"/>
		<updated>2024-11-12T03:28:15Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Bolded bullet points&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (wk9.doc)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Separate and Modularize the email Method&lt;br /&gt;
&lt;br /&gt;
* Move the email method out of FeedbackResponseMap and into a separate service class. This separation will follow the Visitor pattern or a more suitable pattern identified during implementation, to better manage email-related functionality.&lt;br /&gt;
* Assign responsibility for sending feedback-related emails to a dedicated service class (e.g., FeedbackEmailService), ensuring that the core functionality of FeedbackResponseMap is isolated from email concerns.&lt;br /&gt;
* Update any dependencies to use the newly created email service.&lt;br /&gt;
&lt;br /&gt;
4. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
5. Introduce Helper Methods for Reusable Logic&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Develop Tests for Refactored and New Methods&lt;br /&gt;
&lt;br /&gt;
* Create unit tests for each refactored and newly created method, particularly focusing on feedback_response_report and any extracted functionalities.&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159022</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159022"/>
		<updated>2024-11-12T03:27:06Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: shifted bold to not cover colon&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* Poor adherence to SOLID and DRY principles: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* feedback_response_report Method Issues: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* Improper Responsibility Assignment: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* Memory Inefficiencies: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* Code Smells: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (wk9.doc)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** &amp;lt;b&amp;gt;&amp;lt;b&amp;gt;&amp;lt;b&amp;gt;&amp;lt;b&amp;gt;Guideline: A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Separate and Modularize the email Method&lt;br /&gt;
&lt;br /&gt;
* Move the email method out of FeedbackResponseMap and into a separate service class. This separation will follow the Visitor pattern or a more suitable pattern identified during implementation, to better manage email-related functionality.&lt;br /&gt;
* Assign responsibility for sending feedback-related emails to a dedicated service class (e.g., FeedbackEmailService), ensuring that the core functionality of FeedbackResponseMap is isolated from email concerns.&lt;br /&gt;
* Update any dependencies to use the newly created email service.&lt;br /&gt;
&lt;br /&gt;
4. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
5. Introduce Helper Methods for Reusable Logic&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Develop Tests for Refactored and New Methods&lt;br /&gt;
&lt;br /&gt;
* Create unit tests for each refactored and newly created method, particularly focusing on feedback_response_report and any extracted functionalities.&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159015</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159015"/>
		<updated>2024-11-12T03:19:38Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Removed self-referential elements from the wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* Poor adherence to SOLID and DRY principles: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* feedback_response_report Method Issues: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* Improper Responsibility Assignment: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* Memory Inefficiencies: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* Code Smells: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Separate and Modularize the email Method&lt;br /&gt;
&lt;br /&gt;
* Move the email method out of FeedbackResponseMap and into a separate service class. This separation will follow the Visitor pattern or a more suitable pattern identified during implementation, to better manage email-related functionality.&lt;br /&gt;
* Assign responsibility for sending feedback-related emails to a dedicated service class (e.g., FeedbackEmailService), ensuring that the core functionality of FeedbackResponseMap is isolated from email concerns.&lt;br /&gt;
* Update any dependencies to use the newly created email service.&lt;br /&gt;
&lt;br /&gt;
4. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
5. Introduce Helper Methods for Reusable Logic&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Develop Tests for Refactored and New Methods&lt;br /&gt;
&lt;br /&gt;
* Create unit tests for each refactored and newly created method, particularly focusing on feedback_response_report and any extracted functionalities.&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159010</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159010"/>
		<updated>2024-11-12T03:05:29Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added ChatGPT as honorary member&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* Poor adherence to SOLID and DRY principles: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* feedback_response_report Method Issues: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* Improper Responsibility Assignment: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* Memory Inefficiencies: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* Code Smells: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Separate and Modularize the email Method&lt;br /&gt;
&lt;br /&gt;
* Move the email method out of FeedbackResponseMap and into a separate service class. This separation will follow the Visitor pattern or a more suitable pattern identified during implementation, to better manage email-related functionality.&lt;br /&gt;
* Assign responsibility for sending feedback-related emails to a dedicated service class (e.g., FeedbackEmailService), ensuring that the core functionality of FeedbackResponseMap is isolated from email concerns.&lt;br /&gt;
* Update any dependencies to use the newly created email service.&lt;br /&gt;
&lt;br /&gt;
4. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
5. Introduce Helper Methods for Reusable Logic&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Develop Tests for Refactored and New Methods&lt;br /&gt;
&lt;br /&gt;
* Create unit tests for each refactored and newly created method, particularly focusing on feedback_response_report and any extracted functionalities.&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
3. Design Document and Wiki Update&lt;br /&gt;
&lt;br /&gt;
* Prepare a design document to accompany the refactored code, outlining the goals, architecture, and design patterns used in the project.&lt;br /&gt;
* Use flowcharts and other visual aids to show the logical flow and help reviewers quickly grasp the new structure, following the style of existing Expertiza wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159009</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159009"/>
		<updated>2024-11-12T03:05:10Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Revamped testing section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* Poor adherence to SOLID and DRY principles: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* feedback_response_report Method Issues: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* Improper Responsibility Assignment: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* Memory Inefficiencies: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* Code Smells: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Separate and Modularize the email Method&lt;br /&gt;
&lt;br /&gt;
* Move the email method out of FeedbackResponseMap and into a separate service class. This separation will follow the Visitor pattern or a more suitable pattern identified during implementation, to better manage email-related functionality.&lt;br /&gt;
* Assign responsibility for sending feedback-related emails to a dedicated service class (e.g., FeedbackEmailService), ensuring that the core functionality of FeedbackResponseMap is isolated from email concerns.&lt;br /&gt;
* Update any dependencies to use the newly created email service.&lt;br /&gt;
&lt;br /&gt;
4. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
5. Introduce Helper Methods for Reusable Logic&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Develop Tests for Refactored and New Methods&lt;br /&gt;
&lt;br /&gt;
* Create unit tests for each refactored and newly created method, particularly focusing on feedback_response_report and any extracted functionalities.&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
3. Design Document and Wiki Update&lt;br /&gt;
&lt;br /&gt;
* Prepare a design document to accompany the refactored code, outlining the goals, architecture, and design patterns used in the project.&lt;br /&gt;
* Use flowcharts and other visual aids to show the logical flow and help reviewers quickly grasp the new structure, following the style of existing Expertiza wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159008</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159008"/>
		<updated>2024-11-12T03:04:18Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Revamped implementation plan&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* Poor adherence to SOLID and DRY principles: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* feedback_response_report Method Issues: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* Improper Responsibility Assignment: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* Memory Inefficiencies: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* Code Smells: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Separate and Modularize the email Method&lt;br /&gt;
&lt;br /&gt;
* Move the email method out of FeedbackResponseMap and into a separate service class. This separation will follow the Visitor pattern or a more suitable pattern identified during implementation, to better manage email-related functionality.&lt;br /&gt;
* Assign responsibility for sending feedback-related emails to a dedicated service class (e.g., FeedbackEmailService), ensuring that the core functionality of FeedbackResponseMap is isolated from email concerns.&lt;br /&gt;
* Update any dependencies to use the newly created email service.&lt;br /&gt;
&lt;br /&gt;
4. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
5. Introduce Helper Methods for Reusable Logic&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
Develop tests for all refactored code, particularly the feedback_response_report and extracted email functionalities, to validate correct functionality and error handling. Each test should assess the method’s performance under typical and edge-case scenarios.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159001</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159001"/>
		<updated>2024-11-12T02:57:11Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added more information on emails&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* Poor adherence to SOLID and DRY principles: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* feedback_response_report Method Issues: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* Improper Responsibility Assignment: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* Memory Inefficiencies: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* Code Smells: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze the feedback_response_map.rb file to identify the current structure and dependencies.&lt;br /&gt;
&lt;br /&gt;
2. Refactor feedback_response_report to generalize code for varying rounds without repeating logic.&lt;br /&gt;
&lt;br /&gt;
3. Extract the email functionality using the Visitor pattern to allow for a flexible and modular emailing solution.&lt;br /&gt;
&lt;br /&gt;
4. Refactor method names, variable names, and code structures for better readability and efficiency.&lt;br /&gt;
&lt;br /&gt;
5. Conduct comprehensive testing for each modified method, ensuring full coverage and integrating tests into the CI pipeline.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
Develop tests for all refactored code, particularly the feedback_response_report and extracted email functionalities, to validate correct functionality and error handling. Each test should assess the method’s performance under typical and edge-case scenarios.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159000</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159000"/>
		<updated>2024-11-12T02:56:07Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added information about the email method&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* Poor adherence to SOLID and DRY principles: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* feedback_response_report Method Issues: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* Improper Responsibility Assignment: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* Memory Inefficiencies: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* Code Smells: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern&lt;br /&gt;
&lt;br /&gt;
* Extract the email method from FeedbackResponseMap to comply with the Single Responsibility Principle (SRP) and introduce the Visitor pattern for handling email functionalities.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze the feedback_response_map.rb file to identify the current structure and dependencies.&lt;br /&gt;
&lt;br /&gt;
2. Refactor feedback_response_report to generalize code for varying rounds without repeating logic.&lt;br /&gt;
&lt;br /&gt;
3. Extract the email functionality using the Visitor pattern to allow for a flexible and modular emailing solution.&lt;br /&gt;
&lt;br /&gt;
4. Refactor method names, variable names, and code structures for better readability and efficiency.&lt;br /&gt;
&lt;br /&gt;
5. Conduct comprehensive testing for each modified method, ensuring full coverage and integrating tests into the CI pipeline.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
Develop tests for all refactored code, particularly the feedback_response_report and extracted email functionalities, to validate correct functionality and error handling. Each test should assess the method’s performance under typical and edge-case scenarios.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=158996</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=158996"/>
		<updated>2024-11-12T02:50:21Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: First draft (just writing words)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* Poor adherence to SOLID and DRY principles: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* feedback_response_report Method Issues: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* Improper Responsibility Assignment: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern.&lt;br /&gt;
* Code Smells: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern&lt;br /&gt;
&lt;br /&gt;
* Extract the email method from FeedbackResponseMap to comply with the Single Responsibility Principle (SRP) and introduce the Visitor pattern for handling email functionalities.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze the feedback_response_map.rb file to identify the current structure and dependencies.&lt;br /&gt;
&lt;br /&gt;
2. Refactor feedback_response_report to generalize code for varying rounds without repeating logic.&lt;br /&gt;
&lt;br /&gt;
3. Extract the email functionality using the Visitor pattern to allow for a flexible and modular emailing solution.&lt;br /&gt;
&lt;br /&gt;
4. Refactor method names, variable names, and code structures for better readability and efficiency.&lt;br /&gt;
&lt;br /&gt;
5. Conduct comprehensive testing for each modified method, ensuring full coverage and integrating tests into the CI pipeline.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
Develop tests for all refactored code, particularly the feedback_response_report and extracted email functionalities, to validate correct functionality and error handling. Each test should assess the method’s performance under typical and edge-case scenarios.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=158986</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=158986"/>
		<updated>2024-11-12T02:40:45Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Create empty page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;bottom text&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024&amp;diff=158985</id>
		<title>CSC/ECE 517 Fall 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024&amp;diff=158985"/>
		<updated>2024-11-12T02:40:23Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Add E2451. Reimplement feedback_response_map.rb&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2024 - E2450. Refactor assignments_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback_response_map.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2452. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2453. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2454. Refactor student_task.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2455. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2456. Refactor teams_user.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2456. Refactor teams_user.rb (Phase 2 - Design Document)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2458. User management and users table]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2459. View for results of bidding]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2460 Mentor-Meeting Management]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2461. UI for Courses]]&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2462._UI_for_Questionnaires CSC/ECE 517 Fall 2024 - E2462. UI for Questionnaire.rb]&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2463_Implement_Front_End_for_Student_Task_List CSC/ECE 517 Fall 2024 - E2463. UI for Student Task List]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2464 UI for Project Topics (was: Sign_up_Topics)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2465. UI for Institutions and Notification]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2466. UI for Impersonate User]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2467. UI for View Submissions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2468. Reimplement due_date]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2469. Reimplement grades/view_team]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2470. Reimplement grades_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2471. Reimplement logger]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2472. Reimplement responses_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2475. Reimplement student_task view]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2478. Reimplement the Question hierarchy as Item hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2479. Reimplement teams_users_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2481 Reimplement response_map.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2482. Reimplement heatgrid for reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2483. Reimplement Notification Controller and Model]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2484. Reimplement participants_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2485. Allow reviewers to bid on what to review]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2487. Reimplement authorization_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2492. UI for View submissions/assign grades (except heatgrid)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2493. UI for Assign Reviewers]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - G2401 Refactor Graphql API endpoint for contribution metrics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - G2402 Refactor Graphql API endpoint for repositories]]&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158692</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158692"/>
		<updated>2024-11-01T03:59:39Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Split team members onto different lines&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Added commented-out non-working previous implementation&lt;br /&gt;
|Added the previous (non-working) code that relied on the non-working app/helpers/authorization_helper.rb file (see below for notes). This was added so that in the future (when session[:user] hopefully works), action_allowed? can be easily switched over.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/14 Pull Request 14]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is currently not implemented and not possible to implement in Expertiza/reimplementation-back-end as there is no login path (see [https://stackoverflow.com/questions/22451969/rspec-set-session-object this stack overflow post for more details]). Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Copied over and fixed dependencies&lt;br /&gt;
|This was copied over and dependencies that did not exist in expertiza/reimplementation-back-end were adjusted so they lined up with files that did exist.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/2 Pull Request 2]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11], [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Add checks for missing data&lt;br /&gt;
|The prior behavior of seeds.rb was to error out whenever it was called after seeding had already been done. This did not allow for tweaks to aspects of the seeds without dropping and completely rebuilding the entire database. The new behavior checks if each entry is already in the database. Any entry already in the database is skipped, while any entry that is missing is added. This ensures that all data in seeds.rb is in the database after it completes running and avoids raising errors for actions that shouldn't raise them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Now seeds all 5 user types&lt;br /&gt;
|Instead of seeding just an admin, all 5 user types are now seeded. This enabled testing of different user types as the user factory could not set the user role at this time.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed seeding for non-admins&lt;br /&gt;
|After user factories received the ability to set roles for users, there was no need to have them pre-seeded in the database since no test ever required more than two users. The seeded users in PR6 were removed and any tests requiring them now used the factories to create them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11], [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Project Members:&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Tipton Middleton (tgmiddl2@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158691</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158691"/>
		<updated>2024-11-01T03:59:00Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added Team Information&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Added commented-out non-working previous implementation&lt;br /&gt;
|Added the previous (non-working) code that relied on the non-working app/helpers/authorization_helper.rb file (see below for notes). This was added so that in the future (when session[:user] hopefully works), action_allowed? can be easily switched over.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/14 Pull Request 14]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is currently not implemented and not possible to implement in Expertiza/reimplementation-back-end as there is no login path (see [https://stackoverflow.com/questions/22451969/rspec-set-session-object this stack overflow post for more details]). Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Copied over and fixed dependencies&lt;br /&gt;
|This was copied over and dependencies that did not exist in expertiza/reimplementation-back-end were adjusted so they lined up with files that did exist.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/2 Pull Request 2]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11], [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Add checks for missing data&lt;br /&gt;
|The prior behavior of seeds.rb was to error out whenever it was called after seeding had already been done. This did not allow for tweaks to aspects of the seeds without dropping and completely rebuilding the entire database. The new behavior checks if each entry is already in the database. Any entry already in the database is skipped, while any entry that is missing is added. This ensures that all data in seeds.rb is in the database after it completes running and avoids raising errors for actions that shouldn't raise them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Now seeds all 5 user types&lt;br /&gt;
|Instead of seeding just an admin, all 5 user types are now seeded. This enabled testing of different user types as the user factory could not set the user role at this time.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed seeding for non-admins&lt;br /&gt;
|After user factories received the ability to set roles for users, there was no need to have them pre-seeded in the database since no test ever required more than two users. The seeded users in PR6 were removed and any tests requiring them now used the factories to create them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11], [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Project Members:&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
Tipton Middleton (tgmiddl2@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158690</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158690"/>
		<updated>2024-11-01T03:55:45Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: No longer jumps to E2424 problem statement header&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Added commented-out non-working previous implementation&lt;br /&gt;
|Added the previous (non-working) code that relied on the non-working app/helpers/authorization_helper.rb file (see below for notes). This was added so that in the future (when session[:user] hopefully works), action_allowed? can be easily switched over.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/14 Pull Request 14]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is currently not implemented and not possible to implement in Expertiza/reimplementation-back-end as there is no login path (see [https://stackoverflow.com/questions/22451969/rspec-set-session-object this stack overflow post for more details]). Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Copied over and fixed dependencies&lt;br /&gt;
|This was copied over and dependencies that did not exist in expertiza/reimplementation-back-end were adjusted so they lined up with files that did exist.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/2 Pull Request 2]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11], [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Add checks for missing data&lt;br /&gt;
|The prior behavior of seeds.rb was to error out whenever it was called after seeding had already been done. This did not allow for tweaks to aspects of the seeds without dropping and completely rebuilding the entire database. The new behavior checks if each entry is already in the database. Any entry already in the database is skipped, while any entry that is missing is added. This ensures that all data in seeds.rb is in the database after it completes running and avoids raising errors for actions that shouldn't raise them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Now seeds all 5 user types&lt;br /&gt;
|Instead of seeding just an admin, all 5 user types are now seeded. This enabled testing of different user types as the user factory could not set the user role at this time.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed seeding for non-admins&lt;br /&gt;
|After user factories received the ability to set roles for users, there was no need to have them pre-seeded in the database since no test ever required more than two users. The seeded users in PR6 were removed and any tests requiring them now used the factories to create them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11], [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158689</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158689"/>
		<updated>2024-11-01T03:53:41Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added commas between subsequent pull requests&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Added commented-out non-working previous implementation&lt;br /&gt;
|Added the previous (non-working) code that relied on the non-working app/helpers/authorization_helper.rb file (see below for notes). This was added so that in the future (when session[:user] hopefully works), action_allowed? can be easily switched over.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/14 Pull Request 14]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is currently not implemented and not possible to implement in Expertiza/reimplementation-back-end as there is no login path (see [https://stackoverflow.com/questions/22451969/rspec-set-session-object this stack overflow post for more details]). Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Copied over and fixed dependencies&lt;br /&gt;
|This was copied over and dependencies that did not exist in expertiza/reimplementation-back-end were adjusted so they lined up with files that did exist.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/2 Pull Request 2]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11], [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Add checks for missing data&lt;br /&gt;
|The prior behavior of seeds.rb was to error out whenever it was called after seeding had already been done. This did not allow for tweaks to aspects of the seeds without dropping and completely rebuilding the entire database. The new behavior checks if each entry is already in the database. Any entry already in the database is skipped, while any entry that is missing is added. This ensures that all data in seeds.rb is in the database after it completes running and avoids raising errors for actions that shouldn't raise them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Now seeds all 5 user types&lt;br /&gt;
|Instead of seeding just an admin, all 5 user types are now seeded. This enabled testing of different user types as the user factory could not set the user role at this time.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed seeding for non-admins&lt;br /&gt;
|After user factories received the ability to set roles for users, there was no need to have them pre-seeded in the database since no test ever required more than two users. The seeded users in PR6 were removed and any tests requiring them now used the factories to create them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11], [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158688</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158688"/>
		<updated>2024-11-01T03:51:05Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added notes for PR14&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Added commented-out non-working previous implementation&lt;br /&gt;
|Added the previous (non-working) code that relied on the non-working app/helpers/authorization_helper.rb file (see below for notes). This was added so that in the future (when session[:user] hopefully works), action_allowed? can be easily switched over.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/14 Pull Request 14]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is currently not implemented and not possible to implement in Expertiza/reimplementation-back-end as there is no login path (see [https://stackoverflow.com/questions/22451969/rspec-set-session-object this stack overflow post for more details]). Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Copied over and fixed dependencies&lt;br /&gt;
|This was copied over and dependencies that did not exist in expertiza/reimplementation-back-end were adjusted so they lined up with files that did exist.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/2 Pull Request 2]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Add checks for missing data&lt;br /&gt;
|The prior behavior of seeds.rb was to error out whenever it was called after seeding had already been done. This did not allow for tweaks to aspects of the seeds without dropping and completely rebuilding the entire database. The new behavior checks if each entry is already in the database. Any entry already in the database is skipped, while any entry that is missing is added. This ensures that all data in seeds.rb is in the database after it completes running and avoids raising errors for actions that shouldn't raise them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Now seeds all 5 user types&lt;br /&gt;
|Instead of seeding just an admin, all 5 user types are now seeded. This enabled testing of different user types as the user factory could not set the user role at this time.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed seeding for non-admins&lt;br /&gt;
|After user factories received the ability to set roles for users, there was no need to have them pre-seeded in the database since no test ever required more than two users. The seeded users in PR6 were removed and any tests requiring them now used the factories to create them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158687</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158687"/>
		<updated>2024-11-01T03:45:07Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Switched double brackets to single brackets&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is currently not implemented and not possible to implement in Expertiza/reimplementation-back-end as there is no login path (see [https://stackoverflow.com/questions/22451969/rspec-set-session-object this stack overflow post for more details]). Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Copied over and fixed dependencies&lt;br /&gt;
|This was copied over and dependencies that did not exist in expertiza/reimplementation-back-end were adjusted so they lined up with files that did exist.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/2 Pull Request 2]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Add checks for missing data&lt;br /&gt;
|The prior behavior of seeds.rb was to error out whenever it was called after seeding had already been done. This did not allow for tweaks to aspects of the seeds without dropping and completely rebuilding the entire database. The new behavior checks if each entry is already in the database. Any entry already in the database is skipped, while any entry that is missing is added. This ensures that all data in seeds.rb is in the database after it completes running and avoids raising errors for actions that shouldn't raise them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Now seeds all 5 user types&lt;br /&gt;
|Instead of seeding just an admin, all 5 user types are now seeded. This enabled testing of different user types as the user factory could not set the user role at this time.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed seeding for non-admins&lt;br /&gt;
|After user factories received the ability to set roles for users, there was no need to have them pre-seeded in the database since no test ever required more than two users. The seeded users in PR6 were removed and any tests requiring them now used the factories to create them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158686</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158686"/>
		<updated>2024-11-01T03:43:56Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added stack overflow link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is currently not implemented and not possible to implement in Expertiza/reimplementation-back-end as there is no login path (see [https://stackoverflow.com/questions/22451969/rspec-set-session-object this stack overflow post for more details]). Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Copied over and fixed dependencies&lt;br /&gt;
|This was copied over and dependencies that did not exist in expertiza/reimplementation-back-end were adjusted so they lined up with files that did exist.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/2 Pull Request 2]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Add checks for missing data&lt;br /&gt;
|The prior behavior of seeds.rb was to error out whenever it was called after seeding had already been done. This did not allow for tweaks to aspects of the seeds without dropping and completely rebuilding the entire database. The new behavior checks if each entry is already in the database. Any entry already in the database is skipped, while any entry that is missing is added. This ensures that all data in seeds.rb is in the database after it completes running and avoids raising errors for actions that shouldn't raise them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Now seeds all 5 user types&lt;br /&gt;
|Instead of seeding just an admin, all 5 user types are now seeded. This enabled testing of different user types as the user factory could not set the user role at this time.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed seeding for non-admins&lt;br /&gt;
|After user factories received the ability to set roles for users, there was no need to have them pre-seeded in the database since no test ever required more than two users. The seeded users in PR6 were removed and any tests requiring them now used the factories to create them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158685</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158685"/>
		<updated>2024-11-01T03:37:05Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Removed extra line break&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Copied over and fixed dependencies&lt;br /&gt;
|This was copied over and dependencies that did not exist in expertiza/reimplementation-back-end were adjusted so they lined up with files that did exist.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/2 Pull Request 2]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Add checks for missing data&lt;br /&gt;
|The prior behavior of seeds.rb was to error out whenever it was called after seeding had already been done. This did not allow for tweaks to aspects of the seeds without dropping and completely rebuilding the entire database. The new behavior checks if each entry is already in the database. Any entry already in the database is skipped, while any entry that is missing is added. This ensures that all data in seeds.rb is in the database after it completes running and avoids raising errors for actions that shouldn't raise them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Now seeds all 5 user types&lt;br /&gt;
|Instead of seeding just an admin, all 5 user types are now seeded. This enabled testing of different user types as the user factory could not set the user role at this time.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed seeding for non-admins&lt;br /&gt;
|After user factories received the ability to set roles for users, there was no need to have them pre-seeded in the database since no test ever required more than two users. The seeded users in PR6 were removed and any tests requiring them now used the factories to create them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158684</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158684"/>
		<updated>2024-11-01T03:36:42Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added table entries for authorization_helper&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Copied over and fixed dependencies&lt;br /&gt;
|This was copied over and dependencies that did not exist in expertiza/reimplementation-back-end were adjusted so they lined up with files that did exist.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/2 Pull Request 2]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Add checks for missing data&lt;br /&gt;
|The prior behavior of seeds.rb was to error out whenever it was called after seeding had already been done. This did not allow for tweaks to aspects of the seeds without dropping and completely rebuilding the entire database. The new behavior checks if each entry is already in the database. Any entry already in the database is skipped, while any entry that is missing is added. This ensures that all data in seeds.rb is in the database after it completes running and avoids raising errors for actions that shouldn't raise them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Now seeds all 5 user types&lt;br /&gt;
|Instead of seeding just an admin, all 5 user types are now seeded. This enabled testing of different user types as the user factory could not set the user role at this time.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed seeding for non-admins&lt;br /&gt;
|After user factories received the ability to set roles for users, there was no need to have them pre-seeded in the database since no test ever required more than two users. The seeded users in PR6 were removed and any tests requiring them now used the factories to create them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158683</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158683"/>
		<updated>2024-11-01T03:34:25Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Fixed the descriptions for seeds.rb&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Add checks for missing data&lt;br /&gt;
|The prior behavior of seeds.rb was to error out whenever it was called after seeding had already been done. This did not allow for tweaks to aspects of the seeds without dropping and completely rebuilding the entire database. The new behavior checks if each entry is already in the database. Any entry already in the database is skipped, while any entry that is missing is added. This ensures that all data in seeds.rb is in the database after it completes running and avoids raising errors for actions that shouldn't raise them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Now seeds all 5 user types&lt;br /&gt;
|Instead of seeding just an admin, all 5 user types are now seeded. This enabled testing of different user types as the user factory could not set the user role at this time.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed seeding for non-admins&lt;br /&gt;
|After user factories received the ability to set roles for users, there was no need to have them pre-seeded in the database since no test ever required more than two users. The seeded users in PR6 were removed and any tests requiring them now used the factories to create them.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158682</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158682"/>
		<updated>2024-11-01T03:24:08Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Fixed missing User factory data&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158681</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158681"/>
		<updated>2024-11-01T03:22:50Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Finished updating factories&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial Creation&lt;br /&gt;
|The bookmark rating factory was created to assist with the testing of bookmark ratings.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158680</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158680"/>
		<updated>2024-11-01T03:20:13Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Updated factories through PR8&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Bookmarks require sign-up topics and each topic requires an assignment. In order for the functionality to be properly tested, an assignment factory needed to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Switched to Faker names&lt;br /&gt;
|In order to better reflect real-world bookmarks, Faker was used to generate fake URLs, titles, and descriptions rather than have them be static.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|Each bookmark belongs to a topic, which in turn belongs to an assignment, which in turn must belong to a course. In order for bookmarks to be created, a course factory needed to be made.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Renamed from role.rb to roles.rb&lt;br /&gt;
|Factory names should be plural.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed from topics.rb to sign_up_topics.rb&lt;br /&gt;
|This factory was renamed to better match the model it represents.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158679</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158679"/>
		<updated>2024-11-01T03:12:21Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Updated factories with PR7 changes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added ID Lookup and Name&lt;br /&gt;
|In addition to adding the role name to the factory, functionality was also added to look up the id of the student role (if it is in the database) rather than assume it will always be 5. This makes the factory more resilient to future changes.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|Changed default password, added role/institution lookup&lt;br /&gt;
|The default password was changed from 'password' to 'password123' to better match the default passwords already in use. Additionally, both the role and institution fields attempt to look up the default value for the 'Student' role and 'NCSU' institution respectively. This lack of hardcoding makes the factory more resilient to future database changes.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158678</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158678"/>
		<updated>2024-11-01T03:06:04Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Updated factories with PR6&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added id field&lt;br /&gt;
|Since roles (and their subsequent access controls) are handled by id, an id field was added to the role to facilitate having multiple roles with different access levels.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158677</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158677"/>
		<updated>2024-11-01T03:03:06Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Updated factories with information from PR4&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split bookmarks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the bookmark factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Switch from Hardcoded IDs to Associations&lt;br /&gt;
|Instead of using hardcoded user_id and topic_ids, bookmarks now use user and topic associations. This is the preferred approach as it better handles situations where the specified ID does not exist in the associated table.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as users needed to be associated with an institution for them to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split join team requests out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the join team request factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each user needed to have a role assigned in order for the user to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created initial factory&lt;br /&gt;
|Created an initial factory as each student task needed to be associated with a topic in order for the task to be created.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split student tasks out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the student task factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Split users out of singular factory file&lt;br /&gt;
|The standard RSpec file structure dictates that factories should be in their own file in /spec/factories/, but the user factory was originally in /spec/factories.rb.&lt;br /&gt;
|[[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158674</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158674"/>
		<updated>2024-11-01T02:44:32Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added notes for auth helper&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for Bookmark_Controller.rb below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.png]]&lt;br /&gt;
&lt;br /&gt;
See the coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158667</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158667"/>
		<updated>2024-11-01T02:35:44Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Updated spec_helper and rails_helper info&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for Bookmark_Controller.rb below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See the coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158666</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158666"/>
		<updated>2024-11-01T02:31:14Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Fixed description of spec_helper for PR4&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for Bookmark_Controller.rb below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See the coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158664</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158664"/>
		<updated>2024-11-01T02:27:08Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added ending characters to table&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for Bookmark_Controller.rb below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See the coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[BookmarkCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[BookmarksControllerCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158662</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158662"/>
		<updated>2024-11-01T02:25:51Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added Models &amp;amp; Controllers Header&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for Bookmark_Controller.rb below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See the coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[BookmarkCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[BookmarksControllerCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158659</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158659"/>
		<updated>2024-11-01T02:22:53Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Alphabetized each section, deleted inaccurate statements&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements).&lt;br /&gt;
&lt;br /&gt;
View the code for Bookmark_Controller.rb below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158657</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158657"/>
		<updated>2024-11-01T02:12:04Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Fixed the descriptions for files that got deleted&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is used to aid tests in logging in to different users. The action_allowed? method in bookmarks_controller.rb uses this file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed details from login_admin&lt;br /&gt;
|If there are no users in the database, there is something wrong, because there should always be an admin in the database&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was renamed from spec/factories/role.rb to spec/factories/roles.rb (originally taken from Authentication functionality from Expertiza).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/role.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158656</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158656"/>
		<updated>2024-11-01T02:10:14Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: /* Spec files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is used to aid tests in logging in to different users. The action_allowed? method in bookmarks_controller.rb uses this file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed details from login_admin&lt;br /&gt;
|If there are no users in the database, there is something wrong, because there should always be an admin in the database&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was renamed from spec/factories/role.rb to spec/factories/roles.rb (originally taken from Authentication functionality from Expertiza).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/role.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4] in an attempt to clean up unused files:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb&lt;br /&gt;
* spec/factories/factories.rb&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158655</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158655"/>
		<updated>2024-11-01T01:54:59Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Removed extra space&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is used to aid tests in logging in to different users. The action_allowed? method in bookmarks_controller.rb uses this file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed details from login_admin&lt;br /&gt;
|If there are no users in the database, there is something wrong, because there should always be an admin in the database&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Spec files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was renamed from spec/factories/role.rb to spec/factories/roles.rb (originally taken from Authentication functionality from Expertiza).&lt;br /&gt;
&lt;br /&gt;
===== Testing Factories =====&lt;br /&gt;
&lt;br /&gt;
The following factories were created to facilitate the streamlined creation of bookmarks and users with different roles in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
*''spec/factories/bookmarks.rb''&lt;br /&gt;
*''spec/factories/institution.rb''&lt;br /&gt;
*''spec/factories/join_team_requests.rb''&lt;br /&gt;
*''spec/factories/role.rb'': Added a line to make any new roles created, a Student, in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6]. Removed previously created lines, implemented finding or creating a Student's id (of 5), and sets the name to 'Student' in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7]&lt;br /&gt;
*''spec/factories/student_tasks.rb''&lt;br /&gt;
*''spec/factories/topics.rb''&lt;br /&gt;
*''spec/factories/users.rb'': Changed the password and added functionality to use existing Student roles or Institutions, or to create new ones if none exists, in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7].&lt;br /&gt;
&lt;br /&gt;
===== Authentication functionality from Expertiza=====&lt;br /&gt;
&lt;br /&gt;
The following were taken from the Expertiza repo and added into our repo for functionality purposes in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
*''spec/support/authentication_helper.rb:'' Added checks to see if User, or  Token are nil values in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6].&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4] in an attempt to clean up unused files:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb&lt;br /&gt;
* spec/factories/factories.rb&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158654</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158654"/>
		<updated>2024-11-01T01:54:32Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Removed factories from things imported from Expertiza&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is used to aid tests in logging in to different users. The action_allowed? method in bookmarks_controller.rb uses this file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed details from login_admin&lt;br /&gt;
|If there are no users in the database, there is something wrong, because there should always be an admin in the database&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Spec files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was renamed from spec/factories/role.rb to spec/factories/roles.rb (originally taken from Authentication functionality from Expertiza).&lt;br /&gt;
&lt;br /&gt;
===== Testing Factories =====&lt;br /&gt;
&lt;br /&gt;
The following factories were created to facilitate the streamlined creation of bookmarks and users with different roles in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
*''spec/factories/bookmarks.rb''&lt;br /&gt;
*''spec/factories/institution.rb''&lt;br /&gt;
*''spec/factories/join_team_requests.rb''&lt;br /&gt;
*''spec/factories/role.rb'': Added a line to make any new roles created, a Student, in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6]. Removed previously created lines, implemented finding or creating a Student's id (of 5), and sets the name to 'Student' in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7]&lt;br /&gt;
*''spec/factories/student_tasks.rb''&lt;br /&gt;
*''spec/factories/topics.rb''&lt;br /&gt;
*''spec/factories/users.rb'': Changed the password and added functionality to use existing Student roles or Institutions, or to create new ones if none exists, in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Authentication functionality from Expertiza=====&lt;br /&gt;
&lt;br /&gt;
The following were taken from the Expertiza repo and added into our repo for functionality purposes in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
*''spec/support/authentication_helper.rb:'' Added checks to see if User, or  Token are nil values in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6].&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4] in an attempt to clean up unused files:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb&lt;br /&gt;
* spec/factories/factories.rb&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158653</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158653"/>
		<updated>2024-11-01T01:46:53Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: /* Miscellaneous Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is used to aid tests in logging in to different users. The action_allowed? method in bookmarks_controller.rb uses this file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed details from login_admin&lt;br /&gt;
|If there are no users in the database, there is something wrong, because there should always be an admin in the database&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Spec files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was renamed from spec/factories/role.rb to spec/factories/roles.rb (originally taken from Authentication functionality from Expertiza).&lt;br /&gt;
&lt;br /&gt;
===== Authentication functionality from Expertiza=====&lt;br /&gt;
&lt;br /&gt;
The following were taken from the Expertiza repo and added into our repo for functionality purposes in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
*''spec/factories/bookmarks.rb''&lt;br /&gt;
*''spec/factories/institution.rb''&lt;br /&gt;
*''spec/factories/join_team_requests.rb''&lt;br /&gt;
*''spec/factories/role.rb'': Added a line to make any new roles created, a Student, in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6]. Removed previously created lines, implemented finding or creating a Student's id (of 5), and sets the name to 'Student' in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7]&lt;br /&gt;
*''spec/factories/student_tasks.rb''&lt;br /&gt;
*''spec/factories/topics.rb''&lt;br /&gt;
*''spec/factories/users.rb'': Changed the password and added functionality to use existing Student roles or Institutions, or to create new ones if none exists, in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7].&lt;br /&gt;
*''spec/support/authentication_helper.rb:'' Added checks to see if User, or  Token are nil values in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6].&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4] in an attempt to clean up unused files:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb&lt;br /&gt;
* spec/factories/factories.rb&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158652</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158652"/>
		<updated>2024-11-01T01:43:47Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: /* Deleted Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is used to aid tests in logging in to different users. The action_allowed? method in bookmarks_controller.rb uses this file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed details from login_admin&lt;br /&gt;
|If there are no users in the database, there is something wrong, because there should always be an admin in the database&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Spec files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was renamed from spec/factories/role.rb to spec/factories/roles.rb (originally taken from Authentication functionality from Expertiza).&lt;br /&gt;
&lt;br /&gt;
===== Authentication functionality from Expertiza=====&lt;br /&gt;
&lt;br /&gt;
The following were taken from the Expertiza repo and added into our repo for functionality purposes in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
*''spec/factories/bookmarks.rb''&lt;br /&gt;
*''spec/factories/institution.rb''&lt;br /&gt;
*''spec/factories/join_team_requests.rb''&lt;br /&gt;
*''spec/factories/role.rb'': Added a line to make any new roles created, a Student, in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6]. Removed previously created lines, implemented finding or creating a Student's id (of 5), and sets the name to 'Student' in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7]&lt;br /&gt;
*''spec/factories/student_tasks.rb''&lt;br /&gt;
*''spec/factories/topics.rb''&lt;br /&gt;
*''spec/factories/users.rb'': Changed the password and added functionality to use existing Student roles or Institutions, or to create new ones if none exists, in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7].&lt;br /&gt;
*''spec/support/authentication_helper.rb:'' Added checks to see if User, or  Token are nil values in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6].&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Miscellaneous Files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark_tester.sh&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Trying to automate Bookmark testing&lt;br /&gt;
|Swagger tests must be manually run, so this file attempts to automate testing for the Bookmark. &lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4] in an attempt to clean up unused files:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb&lt;br /&gt;
* spec/factories/factories.rb&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=157317</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=157317"/>
		<updated>2024-10-28T23:01:05Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added some placeholder text so the page would resolve&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Scripts.com&lt;br /&gt;
Bee Movie&lt;br /&gt;
By Jerry Seinfeld&lt;br /&gt;
&lt;br /&gt;
NARRATOR:&lt;br /&gt;
(Black screen with text; The sound of buzzing bees can be heard)&lt;br /&gt;
According to all known laws&lt;br /&gt;
of aviation,&lt;br /&gt;
 :&lt;br /&gt;
there is no way a bee&lt;br /&gt;
should be able to fly.&lt;br /&gt;
 :&lt;br /&gt;
Its wings are too small to get&lt;br /&gt;
its fat little body off the ground.&lt;br /&gt;
 :&lt;br /&gt;
The bee, of course, flies anyway&lt;br /&gt;
 :&lt;br /&gt;
because bees don't care&lt;br /&gt;
what humans think is impossible.&lt;br /&gt;
BARRY BENSON:&lt;br /&gt;
(Barry is picking out a shirt)&lt;br /&gt;
Yellow, black. Yellow, black.&lt;br /&gt;
Yellow, black. Yellow, black.&lt;br /&gt;
 :&lt;br /&gt;
Ooh, black and yellow!&lt;br /&gt;
Let's shake it up a little.&lt;br /&gt;
JANET BENSON:&lt;br /&gt;
Barry! Breakfast is ready!&lt;br /&gt;
BARRY:&lt;br /&gt;
Coming!&lt;br /&gt;
 :&lt;br /&gt;
Hang on a second.&lt;br /&gt;
(Barry uses his antenna like a phone)&lt;br /&gt;
 :&lt;br /&gt;
Hello?&lt;br /&gt;
ADAM FLAYMAN:&lt;br /&gt;
&lt;br /&gt;
(Through phone)&lt;br /&gt;
- Barry?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Adam?&lt;br /&gt;
ADAM:&lt;br /&gt;
- Can you believe this is happening?&lt;br /&gt;
BARRY:&lt;br /&gt;
- I can't. I'll pick you up.&lt;br /&gt;
(Barry flies down the stairs)&lt;br /&gt;
 :&lt;br /&gt;
MARTIN BENSON:&lt;br /&gt;
Looking sharp.&lt;br /&gt;
JANET:&lt;br /&gt;
Use the stairs. Your father&lt;br /&gt;
paid good money for those.&lt;br /&gt;
BARRY:&lt;br /&gt;
Sorry. I'm excited.&lt;br /&gt;
MARTIN:&lt;br /&gt;
Here's the graduate.&lt;br /&gt;
We're very proud of you, son.&lt;br /&gt;
 :&lt;br /&gt;
A perfect report card, all B's.&lt;br /&gt;
JANET:&lt;br /&gt;
Very proud.&lt;br /&gt;
(Rubs Barry's hair)&lt;br /&gt;
BARRY=&lt;br /&gt;
Ma! I got a thing going here.&lt;br /&gt;
JANET:&lt;br /&gt;
- You got lint on your fuzz.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Ow! That's me!&lt;br /&gt;
&lt;br /&gt;
JANET:&lt;br /&gt;
- Wave to us! We'll be in row 118,000.&lt;br /&gt;
- Bye!&lt;br /&gt;
(Barry flies out the door)&lt;br /&gt;
JANET:&lt;br /&gt;
Barry, I told you,&lt;br /&gt;
stop flying in the house!&lt;br /&gt;
(Barry drives through the hive,and is waved at by Adam who is reading a&lt;br /&gt;
newspaper)&lt;br /&gt;
BARRY==&lt;br /&gt;
- Hey, Adam.&lt;br /&gt;
ADAM:&lt;br /&gt;
- Hey, Barry.&lt;br /&gt;
(Adam gets in Barry's car)&lt;br /&gt;
 :&lt;br /&gt;
- Is that fuzz gel?&lt;br /&gt;
BARRY:&lt;br /&gt;
- A little. Special day, graduation.&lt;br /&gt;
ADAM:&lt;br /&gt;
Never thought I'd make it.&lt;br /&gt;
(Barry pulls away from the house and continues driving)&lt;br /&gt;
BARRY:&lt;br /&gt;
Three days grade school,&lt;br /&gt;
three days high school...&lt;br /&gt;
ADAM:&lt;br /&gt;
Those were awkward.&lt;br /&gt;
BARRY:&lt;br /&gt;
Three days college. I'm glad I took&lt;br /&gt;
a day and hitchhiked around the hive.&lt;br /&gt;
ADAM==&lt;br /&gt;
You did come back different.&lt;br /&gt;
(Barry and Adam pass by Artie, who is jogging)&lt;br /&gt;
ARTIE:&lt;br /&gt;
- Hi, Barry!&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
- Artie, growing a mustache? Looks good.&lt;br /&gt;
ADAM:&lt;br /&gt;
- Hear about Frankie?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Yeah.&lt;br /&gt;
ADAM==&lt;br /&gt;
- You going to the funeral?&lt;br /&gt;
BARRY:&lt;br /&gt;
- No, I'm not going to his funeral.&lt;br /&gt;
 :&lt;br /&gt;
Everybody knows,&lt;br /&gt;
sting someone, you die.&lt;br /&gt;
 :&lt;br /&gt;
Don't waste it on a squirrel.&lt;br /&gt;
Such a hothead.&lt;br /&gt;
ADAM:&lt;br /&gt;
I guess he could have&lt;br /&gt;
just gotten out of the way.&lt;br /&gt;
(The car does a barrel roll on the loop-shaped bridge and lands on the&lt;br /&gt;
highway)&lt;br /&gt;
 :&lt;br /&gt;
I love this incorporating&lt;br /&gt;
an amusement park into our regular day.&lt;br /&gt;
BARRY:&lt;br /&gt;
I guess that's why they say we don't need vacations.&lt;br /&gt;
(Barry parallel parks the car and together they fly over the graduating&lt;br /&gt;
students)&lt;br /&gt;
Boy, quite a bit of pomp...&lt;br /&gt;
under the circumstances.&lt;br /&gt;
(Barry and Adam sit down and put on their hats)&lt;br /&gt;
 :&lt;br /&gt;
- Well, Adam, today we are men.&lt;br /&gt;
&lt;br /&gt;
ADAM:&lt;br /&gt;
- We are!&lt;br /&gt;
BARRY=&lt;br /&gt;
- Bee-men.&lt;br /&gt;
=ADAM=&lt;br /&gt;
- Amen!&lt;br /&gt;
BARRY AND ADAM:&lt;br /&gt;
Hallelujah!&lt;br /&gt;
(Barry and Adam both have a happy spasm)&lt;br /&gt;
ANNOUNCER:&lt;br /&gt;
Students, faculty, distinguished bees,&lt;br /&gt;
 :&lt;br /&gt;
please welcome Dean Buzzwell.&lt;br /&gt;
DEAN BUZZWELL:&lt;br /&gt;
Welcome, New Hive Oity&lt;br /&gt;
graduating class of...&lt;br /&gt;
 :&lt;br /&gt;
...9:&lt;br /&gt;
 :&lt;br /&gt;
That concludes our ceremonies.&lt;br /&gt;
 :&lt;br /&gt;
And begins your career&lt;br /&gt;
at Honex Industries!&lt;br /&gt;
ADAM:&lt;br /&gt;
Will we pick our job today?&lt;br /&gt;
(Adam and Barry get into a tour bus)&lt;br /&gt;
BARRY=&lt;br /&gt;
I heard it's just orientation.&lt;br /&gt;
(Tour buses rise out of the ground and the students are automatically&lt;br /&gt;
loaded into the buses)&lt;br /&gt;
TOUR GUIDE:&lt;br /&gt;
Heads up! Here we go.&lt;br /&gt;
&lt;br /&gt;
ANNOUNCER:&lt;br /&gt;
Keep your hands and antennas&lt;br /&gt;
inside the tram at all times.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Wonder what it'll be like?&lt;br /&gt;
ADAM:&lt;br /&gt;
- A little scary.&lt;br /&gt;
TOUR GUIDE==&lt;br /&gt;
Welcome to Honex,&lt;br /&gt;
a division of Honesco&lt;br /&gt;
 :&lt;br /&gt;
and a part of the Hexagon Group.&lt;br /&gt;
Barry:&lt;br /&gt;
This is it!&lt;br /&gt;
BARRY AND ADAM:&lt;br /&gt;
Wow.&lt;br /&gt;
BARRY:&lt;br /&gt;
Wow.&lt;br /&gt;
(The bus drives down a road an on either side are the Bee's massive&lt;br /&gt;
complicated Honey-making machines)&lt;br /&gt;
TOUR GUIDE:&lt;br /&gt;
We know that you, as a bee,&lt;br /&gt;
have worked your whole life&lt;br /&gt;
 :&lt;br /&gt;
to get to the point where you&lt;br /&gt;
can work for your whole life.&lt;br /&gt;
 :&lt;br /&gt;
Honey begins when our valiant Pollen&lt;br /&gt;
Jocks bring the nectar to the hive.&lt;br /&gt;
 :&lt;br /&gt;
Our top-secret formula&lt;br /&gt;
 :&lt;br /&gt;
is automatically color-corrected,&lt;br /&gt;
&lt;br /&gt;
scent-adjusted and bubble-contoured&lt;br /&gt;
 :&lt;br /&gt;
into this soothing sweet syrup&lt;br /&gt;
 :&lt;br /&gt;
with its distinctive&lt;br /&gt;
golden glow you know as...&lt;br /&gt;
EVERYONE ON BUS:&lt;br /&gt;
Honey!&lt;br /&gt;
(The guide has been collecting honey into a bottle and she throws it into&lt;br /&gt;
the crowd on the bus and it is caught by a girl in the back)&lt;br /&gt;
ADAM:&lt;br /&gt;
- That girl was hot.&lt;br /&gt;
BARRY:&lt;br /&gt;
- She's my cousin!&lt;br /&gt;
ADAM==&lt;br /&gt;
- She is?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Yes, we're all cousins.&lt;br /&gt;
ADAM:&lt;br /&gt;
- Right. You're right.&lt;br /&gt;
TOUR GUIDE:&lt;br /&gt;
- At Honex, we constantly strive&lt;br /&gt;
 :&lt;br /&gt;
to improve every aspect&lt;br /&gt;
of bee existence.&lt;br /&gt;
 :&lt;br /&gt;
These bees are stress-testing&lt;br /&gt;
a new helmet technology.&lt;br /&gt;
(The bus passes by a Bee wearing a helmet who is being smashed into the&lt;br /&gt;
ground with fly-swatters, newspapers and boots. He lifts a thumbs up but&lt;br /&gt;
you can hear him groan)&lt;br /&gt;
 :&lt;br /&gt;
ADAM==&lt;br /&gt;
&lt;br /&gt;
- What do you think he makes?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Not enough.&lt;br /&gt;
TOUR GUIDE:&lt;br /&gt;
Here we have our latest advancement,&lt;br /&gt;
the Krelman.&lt;br /&gt;
(They pass by a turning wheel with Bees standing on pegs, who are each&lt;br /&gt;
wearing a finger-shaped hat)&lt;br /&gt;
Barry:&lt;br /&gt;
- Wow, What does that do?&lt;br /&gt;
TOUR GUIDE:&lt;br /&gt;
- Catches that little strand of honey&lt;br /&gt;
 :&lt;br /&gt;
that hangs after you pour it.&lt;br /&gt;
Saves us millions.&lt;br /&gt;
ADAM:&lt;br /&gt;
(Intrigued)&lt;br /&gt;
Can anyone work on the Krelman?&lt;br /&gt;
TOUR GUIDE:&lt;br /&gt;
Of course. Most bee jobs are&lt;br /&gt;
small ones.&lt;br /&gt;
But bees know that every small job,&lt;br /&gt;
if it's done well, means a lot.&lt;br /&gt;
 :&lt;br /&gt;
But choose carefully&lt;br /&gt;
 :&lt;br /&gt;
because you'll stay in the job&lt;br /&gt;
you pick for the rest of your life.&lt;br /&gt;
(Everyone claps except for Barry)&lt;br /&gt;
BARRY:&lt;br /&gt;
The same job the rest of your life?&lt;br /&gt;
I didn't know that.&lt;br /&gt;
ADAM:&lt;br /&gt;
&lt;br /&gt;
What's the difference?&lt;br /&gt;
TOUR GUIDE:&lt;br /&gt;
You'll be happy to know that bees,&lt;br /&gt;
as a species, haven't had one day off&lt;br /&gt;
 :&lt;br /&gt;
in 27 million years.&lt;br /&gt;
BARRY:&lt;br /&gt;
(Upset)&lt;br /&gt;
So you'll just work us to death?&lt;br /&gt;
 :&lt;br /&gt;
We'll sure try.&lt;br /&gt;
(Everyone on the bus laughs except Barry. Barry and Adam are walking back&lt;br /&gt;
home together)&lt;br /&gt;
ADAM:&lt;br /&gt;
Wow! That blew my mind!&lt;br /&gt;
BARRY:&lt;br /&gt;
&amp;quot;What's the difference?&amp;quot;&lt;br /&gt;
How can you say that?&lt;br /&gt;
 :&lt;br /&gt;
One job forever?&lt;br /&gt;
That's an insane choice to have to make.&lt;br /&gt;
ADAM:&lt;br /&gt;
I'm relieved. Now we only have&lt;br /&gt;
to make one decision in life.&lt;br /&gt;
BARRY:&lt;br /&gt;
But, Adam, how could they&lt;br /&gt;
never have told us that?&lt;br /&gt;
ADAM:&lt;br /&gt;
Why would you question anything?&lt;br /&gt;
We're bees.&lt;br /&gt;
 :&lt;br /&gt;
We're the most perfectly&lt;br /&gt;
functioning society on Earth.&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
You ever think maybe things&lt;br /&gt;
work a little too well here?&lt;br /&gt;
ADAM:&lt;br /&gt;
Like what? Give me one example.&lt;br /&gt;
(Barry and Adam stop walking and it is revealed to the audience that&lt;br /&gt;
hundreds of cars are speeding by and narrowly missing them in perfect&lt;br /&gt;
unison)&lt;br /&gt;
BARRY:&lt;br /&gt;
I don't know. But you know&lt;br /&gt;
what I'm talking about.&lt;br /&gt;
ANNOUNCER:&lt;br /&gt;
Please clear the gate.&lt;br /&gt;
Royal Nectar Force on approach.&lt;br /&gt;
BARRY:&lt;br /&gt;
Wait a second. Check it out.&lt;br /&gt;
(The Pollen jocks fly in, circle around and landing in line)&lt;br /&gt;
 :&lt;br /&gt;
- Hey, those are Pollen Jocks!&lt;br /&gt;
ADAM:&lt;br /&gt;
- Wow.&lt;br /&gt;
 :&lt;br /&gt;
I've never seen them this close.&lt;br /&gt;
BARRY:&lt;br /&gt;
They know what it's like&lt;br /&gt;
outside the hive.&lt;br /&gt;
ADAM:&lt;br /&gt;
Yeah, but some don't come back.&lt;br /&gt;
GIRL BEES:&lt;br /&gt;
- Hey, Jocks!&lt;br /&gt;
- Hi, Jocks!&lt;br /&gt;
(The Pollen Jocks hook up their backpacks to machines that pump the nectar&lt;br /&gt;
to trucks, which drive away)&lt;br /&gt;
&lt;br /&gt;
LOU LO DUVA:&lt;br /&gt;
You guys did great!&lt;br /&gt;
 :&lt;br /&gt;
You're monsters!&lt;br /&gt;
You're sky freaks!&lt;br /&gt;
I love it!&lt;br /&gt;
(Punching the Pollen Jocks in joy)&lt;br /&gt;
I love it!&lt;br /&gt;
ADAM:&lt;br /&gt;
- I wonder where they were.&lt;br /&gt;
BARRY:&lt;br /&gt;
- I don't know.&lt;br /&gt;
 :&lt;br /&gt;
Their day's not planned.&lt;br /&gt;
 :&lt;br /&gt;
Outside the hive, flying who knows&lt;br /&gt;
where, doing who knows what.&lt;br /&gt;
 :&lt;br /&gt;
You can't just decide to be a Pollen&lt;br /&gt;
Jock. You have to be bred for that.&lt;br /&gt;
ADAM==&lt;br /&gt;
Right.&lt;br /&gt;
(Barry and Adam are covered in some pollen that floated off of the Pollen&lt;br /&gt;
Jocks)&lt;br /&gt;
BARRY:&lt;br /&gt;
Look at that. That's more pollen&lt;br /&gt;
than you and I will see in a lifetime.&lt;br /&gt;
ADAM:&lt;br /&gt;
It's just a status symbol.&lt;br /&gt;
Bees make too much of it.&lt;br /&gt;
BARRY:&lt;br /&gt;
Perhaps. Unless you're wearing it&lt;br /&gt;
and the ladies see you wearing it.&lt;br /&gt;
(Barry waves at 2 girls standing a little away from them)&lt;br /&gt;
&lt;br /&gt;
ADAM==&lt;br /&gt;
Those ladies?&lt;br /&gt;
Aren't they our cousins too?&lt;br /&gt;
BARRY:&lt;br /&gt;
Distant. Distant.&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
Look at these two.&lt;br /&gt;
POLLEN JOCK #2:&lt;br /&gt;
- Couple of Hive Harrys.&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
- Let's have fun with them.&lt;br /&gt;
GIRL BEE #1:&lt;br /&gt;
It must be dangerous&lt;br /&gt;
being a Pollen Jock.&lt;br /&gt;
BARRY:&lt;br /&gt;
Yeah. Once a bear pinned me&lt;br /&gt;
against a mushroom!&lt;br /&gt;
 :&lt;br /&gt;
He had a paw on my throat,&lt;br /&gt;
and with the other, he was slapping me!&lt;br /&gt;
(Slaps Adam with his hand to represent his scenario)&lt;br /&gt;
GIRL BEE #2:&lt;br /&gt;
- Oh, my!&lt;br /&gt;
BARRY:&lt;br /&gt;
- I never thought I'd knock him out.&lt;br /&gt;
GIRL BEE #1:&lt;br /&gt;
(Looking at Adam)&lt;br /&gt;
What were you doing during this?&lt;br /&gt;
ADAM:&lt;br /&gt;
Obviously I was trying to alert the authorities.&lt;br /&gt;
BARRY:&lt;br /&gt;
I can autograph that.&lt;br /&gt;
&lt;br /&gt;
(The pollen jocks walk up to Barry and Adam, they pretend that Barry and&lt;br /&gt;
Adam really are pollen jocks.)&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
A little gusty out there today,&lt;br /&gt;
wasn't it, comrades?&lt;br /&gt;
BARRY:&lt;br /&gt;
Yeah. Gusty.&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
We're hitting a sunflower patch&lt;br /&gt;
six miles from here tomorrow.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Six miles, huh?&lt;br /&gt;
ADAM:&lt;br /&gt;
- Barry!&lt;br /&gt;
POLLEN JOCK #2:&lt;br /&gt;
A puddle jump for us,&lt;br /&gt;
but maybe you're not up for it.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Maybe I am.&lt;br /&gt;
ADAM:&lt;br /&gt;
- You are not!&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
We're going 0900 at J-Gate.&lt;br /&gt;
 :&lt;br /&gt;
What do you think, buzzy-boy?&lt;br /&gt;
Are you bee enough?&lt;br /&gt;
BARRY:&lt;br /&gt;
I might be. It all depends&lt;br /&gt;
on what 0900 means.&lt;br /&gt;
(The scene cuts to Barry looking out on the hive-city from his balcony at&lt;br /&gt;
night)&lt;br /&gt;
MARTIN:&lt;br /&gt;
&lt;br /&gt;
Hey, Honex!&lt;br /&gt;
BARRY:&lt;br /&gt;
Dad, you surprised me.&lt;br /&gt;
MARTIN:&lt;br /&gt;
You decide what you're interested in?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Well, there's a lot of choices.&lt;br /&gt;
- But you only get one.&lt;br /&gt;
 :&lt;br /&gt;
Do you ever get bored&lt;br /&gt;
doing the same job every day?&lt;br /&gt;
MARTIN:&lt;br /&gt;
Son, let me tell you about stirring.&lt;br /&gt;
 :&lt;br /&gt;
You grab that stick, and you just&lt;br /&gt;
move it around, and you stir it around.&lt;br /&gt;
 :&lt;br /&gt;
You get yourself into a rhythm.&lt;br /&gt;
It's a beautiful thing.&lt;br /&gt;
BARRY:&lt;br /&gt;
You know, Dad,&lt;br /&gt;
the more I think about it,&lt;br /&gt;
 :&lt;br /&gt;
maybe the honey field&lt;br /&gt;
just isn't right for me.&lt;br /&gt;
MARTIN:&lt;br /&gt;
You were thinking of what,&lt;br /&gt;
making balloon animals?&lt;br /&gt;
 :&lt;br /&gt;
That's a bad job&lt;br /&gt;
for a guy with a stinger.&lt;br /&gt;
 :&lt;br /&gt;
&lt;br /&gt;
Janet, your son's not sure&lt;br /&gt;
he wants to go into honey!&lt;br /&gt;
JANET:&lt;br /&gt;
- Barry, you are so funny sometimes.&lt;br /&gt;
BARRY:&lt;br /&gt;
- I'm not trying to be funny.&lt;br /&gt;
MARTIN:&lt;br /&gt;
You're not funny! You're going&lt;br /&gt;
into honey. Our son, the stirrer!&lt;br /&gt;
JANET:&lt;br /&gt;
- You're gonna be a stirrer?&lt;br /&gt;
BARRY:&lt;br /&gt;
- No one's listening to me!&lt;br /&gt;
MARTIN:&lt;br /&gt;
Wait till you see the sticks I have.&lt;br /&gt;
BARRY:&lt;br /&gt;
I could say anything right now.&lt;br /&gt;
I'm gonna get an ant tattoo!&lt;br /&gt;
(Barry's parents don't listen to him and continue to ramble on)&lt;br /&gt;
MARTIN:&lt;br /&gt;
Let's open some honey and celebrate!&lt;br /&gt;
BARRY:&lt;br /&gt;
Maybe I'll pierce my thorax.&lt;br /&gt;
Shave my antennae.&lt;br /&gt;
 :&lt;br /&gt;
Shack up with a grasshopper. Get&lt;br /&gt;
a gold tooth and call everybody &amp;quot;dawg&amp;quot;!&lt;br /&gt;
JANET:&lt;br /&gt;
I'm so proud.&lt;br /&gt;
(The scene cuts to Barry and Adam waiting in line to get a job)&lt;br /&gt;
ADAM:&lt;br /&gt;
- We're starting work today!&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
- Today's the day.&lt;br /&gt;
ADAM:&lt;br /&gt;
Come on! All the good jobs&lt;br /&gt;
will be gone.&lt;br /&gt;
BARRY:&lt;br /&gt;
Yeah, right.&lt;br /&gt;
JOB LISTER:&lt;br /&gt;
Pollen counting, stunt bee, pouring,&lt;br /&gt;
stirrer, front desk, hair removal...&lt;br /&gt;
BEE IN FRONT OF LINE:&lt;br /&gt;
- Is it still available?&lt;br /&gt;
JOB LISTER:&lt;br /&gt;
- Hang on. Two left!&lt;br /&gt;
 :&lt;br /&gt;
One of them's yours! Congratulations!&lt;br /&gt;
Step to the side.&lt;br /&gt;
ADAM:&lt;br /&gt;
- What'd you get?&lt;br /&gt;
BEE IN FRONT OF LINE:&lt;br /&gt;
- Picking crud out. Stellar!&lt;br /&gt;
(He walks away)&lt;br /&gt;
ADAM:&lt;br /&gt;
Wow!&lt;br /&gt;
JOB LISTER:&lt;br /&gt;
Couple of newbies?&lt;br /&gt;
ADAM:&lt;br /&gt;
Yes, sir! Our first day! We are ready!&lt;br /&gt;
JOB LISTER:&lt;br /&gt;
Make your choice.&lt;br /&gt;
(Adam and Barry look up at the job board. There are hundreds of constantly&lt;br /&gt;
changing panels that contain available or unavailable jobs. It looks very&lt;br /&gt;
confusing)&lt;br /&gt;
&lt;br /&gt;
ADAM:&lt;br /&gt;
- You want to go first?&lt;br /&gt;
BARRY:&lt;br /&gt;
- No, you go.&lt;br /&gt;
ADAM:&lt;br /&gt;
Oh, my. What's available?&lt;br /&gt;
JOB LISTER:&lt;br /&gt;
Restroom attendant's open,&lt;br /&gt;
not for the reason you think.&lt;br /&gt;
ADAM:&lt;br /&gt;
- Any chance of getting the Krelman?&lt;br /&gt;
JOB LISTER:&lt;br /&gt;
- Sure, you're on.&lt;br /&gt;
(Puts the Krelman finger-hat on Adam's head)&lt;br /&gt;
(Suddenly the sign for Krelman closes out)&lt;br /&gt;
 :&lt;br /&gt;
I'm sorry, the Krelman just closed out.&lt;br /&gt;
(Takes Adam's hat off)&lt;br /&gt;
Wax monkey's always open.&lt;br /&gt;
ADAM:&lt;br /&gt;
The Krelman opened up again.&lt;br /&gt;
 :&lt;br /&gt;
What happened?&lt;br /&gt;
JOB LISTER:&lt;br /&gt;
A bee died. Makes an opening. See?&lt;br /&gt;
He's dead. Another dead one.&lt;br /&gt;
 :&lt;br /&gt;
Deady. Deadified. Two more dead.&lt;br /&gt;
 :&lt;br /&gt;
Dead from the neck up.&lt;br /&gt;
Dead from the neck down. That's life!&lt;br /&gt;
&lt;br /&gt;
ADAM:&lt;br /&gt;
Oh, this is so hard!&lt;br /&gt;
(Barry remembers what the Pollen Jock offered him and he flies off)&lt;br /&gt;
Heating, cooling,&lt;br /&gt;
stunt bee, pourer, stirrer,&lt;br /&gt;
 :&lt;br /&gt;
humming, inspector number seven,&lt;br /&gt;
lint coordinator, stripe supervisor,&lt;br /&gt;
 :&lt;br /&gt;
mite wrangler. Barry, what&lt;br /&gt;
do you think I should... Barry?&lt;br /&gt;
(Adam turns around and sees Barry flying away)&lt;br /&gt;
 :&lt;br /&gt;
Barry!&lt;br /&gt;
POLLEN JOCK:&lt;br /&gt;
All right, we've got the sunflower patch&lt;br /&gt;
in quadrant nine...&lt;br /&gt;
ADAM:&lt;br /&gt;
(Through phone)&lt;br /&gt;
What happened to you?&lt;br /&gt;
Where are you?&lt;br /&gt;
BARRY:&lt;br /&gt;
- I'm going out.&lt;br /&gt;
ADAM:&lt;br /&gt;
- Out? Out where?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Out there.&lt;br /&gt;
ADAM:&lt;br /&gt;
- Oh, no!&lt;br /&gt;
BARRY:&lt;br /&gt;
I have to, before I go&lt;br /&gt;
to work for the rest of my life.&lt;br /&gt;
ADAM:&lt;br /&gt;
&lt;br /&gt;
You're gonna die! You're crazy!&lt;br /&gt;
(Barry hangs up)&lt;br /&gt;
Hello?&lt;br /&gt;
POLLEN JOCK #2:&lt;br /&gt;
Another call coming in.&lt;br /&gt;
 :&lt;br /&gt;
If anyone's feeling brave,&lt;br /&gt;
there's a Korean deli on 83rd&lt;br /&gt;
 :&lt;br /&gt;
that gets their roses today.&lt;br /&gt;
BARRY:&lt;br /&gt;
Hey, guys.&lt;br /&gt;
POLLEN JOCK #1 ==&lt;br /&gt;
- Look at that.&lt;br /&gt;
POLLEN JOCK #2:&lt;br /&gt;
- Isn't that the kid we saw yesterday?&lt;br /&gt;
LOU LO DUVA:&lt;br /&gt;
Hold it, son, flight deck's restricted.&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
It's OK, Lou. We're gonna take him up.&lt;br /&gt;
(Puts hand on Barry's shoulder)&lt;br /&gt;
LOU LO DUVA:&lt;br /&gt;
(To Barry) Really? Feeling lucky, are you?&lt;br /&gt;
BEE WITH CLIPBOARD:&lt;br /&gt;
(To Barry) Sign here, here. Just initial that.&lt;br /&gt;
 :&lt;br /&gt;
- Thank you.&lt;br /&gt;
LOU LO DUVA:&lt;br /&gt;
- OK.&lt;br /&gt;
 :&lt;br /&gt;
You got a rain advisory today,&lt;br /&gt;
 :&lt;br /&gt;
&lt;br /&gt;
and as you all know,&lt;br /&gt;
bees cannot fly in rain.&lt;br /&gt;
 :&lt;br /&gt;
So be careful. As always,&lt;br /&gt;
watch your brooms,&lt;br /&gt;
 :&lt;br /&gt;
hockey sticks, dogs,&lt;br /&gt;
birds, bears and bats.&lt;br /&gt;
 :&lt;br /&gt;
Also, I got a couple of reports&lt;br /&gt;
of root beer being poured on us.&lt;br /&gt;
 :&lt;br /&gt;
Murphy's in a home because of it,&lt;br /&gt;
babbling like a cicada!&lt;br /&gt;
BARRY:&lt;br /&gt;
- That's awful.&lt;br /&gt;
LOU LO DUVA:&lt;br /&gt;
(Still talking through megaphone)&lt;br /&gt;
- And a reminder for you rookies,&lt;br /&gt;
 :&lt;br /&gt;
bee law number one,&lt;br /&gt;
absolutely no talking to humans!&lt;br /&gt;
 :&lt;br /&gt;
All right, launch positions!&lt;br /&gt;
POLLEN JOCKS:&lt;br /&gt;
(The Pollen Jocks run into formation)&lt;br /&gt;
 :&lt;br /&gt;
Buzz, buzz, buzz, buzz! Buzz, buzz,&lt;br /&gt;
buzz, buzz! Buzz, buzz, buzz, buzz!&lt;br /&gt;
LOU LU DUVA:&lt;br /&gt;
Black and yellow!&lt;br /&gt;
POLLEN JOCKS:&lt;br /&gt;
&lt;br /&gt;
Hello!&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
(To Barry)You ready for this, hot shot?&lt;br /&gt;
BARRY:&lt;br /&gt;
Yeah. Yeah, bring it on.&lt;br /&gt;
POLLEN JOCK's:&lt;br /&gt;
Wind, check.&lt;br /&gt;
 :&lt;br /&gt;
- Antennae, check.&lt;br /&gt;
- Nectar pack, check.&lt;br /&gt;
 :&lt;br /&gt;
- Wings, check.&lt;br /&gt;
- Stinger, check.&lt;br /&gt;
BARRY:&lt;br /&gt;
Scared out of my shorts, check.&lt;br /&gt;
LOU LO DUVA:&lt;br /&gt;
OK, ladies,&lt;br /&gt;
 :&lt;br /&gt;
let's move it out!&lt;br /&gt;
 :&lt;br /&gt;
Pound those petunias,&lt;br /&gt;
you striped stem-suckers!&lt;br /&gt;
 :&lt;br /&gt;
All of you, drain those flowers!&lt;br /&gt;
(The pollen jocks fly out of the hive)&lt;br /&gt;
BARRY:&lt;br /&gt;
Wow! I'm out!&lt;br /&gt;
 :&lt;br /&gt;
I can't believe I'm out!&lt;br /&gt;
 :&lt;br /&gt;
So blue.&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
I feel so fast and free!&lt;br /&gt;
 :&lt;br /&gt;
Box kite!&lt;br /&gt;
(Barry flies through the kite)&lt;br /&gt;
 :&lt;br /&gt;
Wow!&lt;br /&gt;
 :&lt;br /&gt;
Flowers!&lt;br /&gt;
(A pollen jock puts on some high tech goggles that shows flowers similar to&lt;br /&gt;
heat sink goggles.)&lt;br /&gt;
POLLEN JOCK:&lt;br /&gt;
This is Blue Leader.&lt;br /&gt;
We have roses visual.&lt;br /&gt;
 :&lt;br /&gt;
Bring it around 30 degrees and hold.&lt;br /&gt;
 :&lt;br /&gt;
Roses!&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
30 degrees, roger. Bringing it around.&lt;br /&gt;
 :&lt;br /&gt;
Stand to the side, kid.&lt;br /&gt;
It's got a bit of a kick.&lt;br /&gt;
(The pollen jock fires a high-tech gun at the flower, shooting tubes that&lt;br /&gt;
suck up the nectar from the flower and collects it into a pouch on the gun)&lt;br /&gt;
BARRY:&lt;br /&gt;
That is one nectar collector!&lt;br /&gt;
POLLEN JOCK #1==&lt;br /&gt;
- Ever see pollination up close?&lt;br /&gt;
BARRY:&lt;br /&gt;
- No, sir.&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
&lt;br /&gt;
(Barry and the Pollen jock fly over the field, the pollen jock sprinkles&lt;br /&gt;
pollen as he goes)&lt;br /&gt;
 :&lt;br /&gt;
I pick up some pollen here, sprinkle it&lt;br /&gt;
over here. Maybe a dash over there,&lt;br /&gt;
 :&lt;br /&gt;
a pinch on that one.&lt;br /&gt;
See that? It's a little bit of magic.&lt;br /&gt;
BARRY:&lt;br /&gt;
That's amazing. Why do we do that?&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
That's pollen power. More pollen, more&lt;br /&gt;
flowers, more nectar, more honey for us.&lt;br /&gt;
BARRY:&lt;br /&gt;
Cool.&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
I'm picking up a lot of bright yellow.&lt;br /&gt;
could be daisies. Don't we need those?&lt;br /&gt;
POLLEN JOCK #2:&lt;br /&gt;
Copy that visual.&lt;br /&gt;
 :&lt;br /&gt;
Wait. One of these flowers&lt;br /&gt;
seems to be on the move.&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
Say again? You're reporting&lt;br /&gt;
a moving flower?&lt;br /&gt;
POLLEN JOCK #2:&lt;br /&gt;
Affirmative.&lt;br /&gt;
(The Pollen jocks land near the &amp;quot;flowers&amp;quot; which, to the audience are&lt;br /&gt;
obviously just tennis balls)&lt;br /&gt;
KEN:&lt;br /&gt;
(In the distance) That was on the line!&lt;br /&gt;
&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
This is the coolest. What is it?&lt;br /&gt;
POLLEN JOCK #2:&lt;br /&gt;
I don't know, but I'm loving this color.&lt;br /&gt;
 :&lt;br /&gt;
It smells good.&lt;br /&gt;
Not like a flower, but I like it.&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
Yeah, fuzzy.&lt;br /&gt;
(Sticks his hand on the ball but it gets stuck)&lt;br /&gt;
POLLEN JOCK #3==&lt;br /&gt;
Chemical-y.&lt;br /&gt;
(The pollen jock finally gets his hand free from the tennis ball)&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
Careful, guys. It's a little grabby.&lt;br /&gt;
(The pollen jocks turn around and see Barry lying his entire body on top of&lt;br /&gt;
one of the tennis balls)&lt;br /&gt;
POLLEN JOCK #2:&lt;br /&gt;
My sweet lord of bees!&lt;br /&gt;
POLLEN JOCK #3:&lt;br /&gt;
Candy-brain, get off there!&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
(Pointing upwards)&lt;br /&gt;
Problem!&lt;br /&gt;
(A human hand reaches down and grabs the tennis ball that Barry is stuck&lt;br /&gt;
to)&lt;br /&gt;
BARRY:&lt;br /&gt;
- Guys!&lt;br /&gt;
POLLEN JOCK #2:&lt;br /&gt;
- This could be bad.&lt;br /&gt;
POLLEN JOCK #3:&lt;br /&gt;
Affirmative.&lt;br /&gt;
(Vanessa Bloome starts bouncing the tennis ball, not knowing Barry is stick&lt;br /&gt;
to it)&lt;br /&gt;
&lt;br /&gt;
BARRY==&lt;br /&gt;
Very close.&lt;br /&gt;
 :&lt;br /&gt;
Gonna hurt.&lt;br /&gt;
 :&lt;br /&gt;
Mama's little boy.&lt;br /&gt;
(Barry is being hit back and forth by two humans playing tennis. He is&lt;br /&gt;
still stuck to the ball)&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
You are way out of position, rookie!&lt;br /&gt;
KEN:&lt;br /&gt;
Coming in at you like a MISSILE!&lt;br /&gt;
(Barry flies past the pollen jocks, still stuck to the ball)&lt;br /&gt;
BARRY:&lt;br /&gt;
(In slow motion)&lt;br /&gt;
Help me!&lt;br /&gt;
POLLEN JOCK #2:&lt;br /&gt;
I don't think these are flowers.&lt;br /&gt;
POLLEN JOCK #3:&lt;br /&gt;
- Should we tell him?&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
- I think he knows.&lt;br /&gt;
BARRY:&lt;br /&gt;
What is this?!&lt;br /&gt;
KEN:&lt;br /&gt;
Match point!&lt;br /&gt;
 :&lt;br /&gt;
You can start packing up, honey,&lt;br /&gt;
because you're about to EAT IT!&lt;br /&gt;
(A pollen jock coughs which confused Ken and he hits the ball the wrong way&lt;br /&gt;
with Barry stuck to it and it goes flying into the city)&lt;br /&gt;
BARRY:&lt;br /&gt;
&lt;br /&gt;
Yowser!&lt;br /&gt;
(Barry bounces around town and gets stuck in the engine of a car. He flies&lt;br /&gt;
into the air conditioner and sees a bug that was frozen in there)&lt;br /&gt;
BARRY:&lt;br /&gt;
Ew, gross.&lt;br /&gt;
(The man driving the car turns on the air conditioner which blows Barry&lt;br /&gt;
into the car)&lt;br /&gt;
GIRL IN CAR:&lt;br /&gt;
There's a bee in the car!&lt;br /&gt;
 :&lt;br /&gt;
- Do something!&lt;br /&gt;
DAD DRIVING CAR:&lt;br /&gt;
- I'm driving!&lt;br /&gt;
BABY GIRL:&lt;br /&gt;
(Waving at Barry)&lt;br /&gt;
- Hi, bee.&lt;br /&gt;
(Barry smiles and waves at the baby girl)&lt;br /&gt;
GUY IN BACK OF CAR:&lt;br /&gt;
- He's back here!&lt;br /&gt;
 :&lt;br /&gt;
He's going to sting me!&lt;br /&gt;
GIRL IN CAR:&lt;br /&gt;
Nobody move. If you don't move,&lt;br /&gt;
he won't sting you. Freeze!&lt;br /&gt;
(Barry freezes as well, hovering in the middle of the car)&lt;br /&gt;
 :&lt;br /&gt;
GRANDMA IN CAR==&lt;br /&gt;
He blinked!&lt;br /&gt;
(The grandma whips out some bee-spray and sprays everywhere in the car,&lt;br /&gt;
climbing into the front seat, still trying to spray Barry)&lt;br /&gt;
GIRL IN CAR:&lt;br /&gt;
Spray him, Granny!&lt;br /&gt;
DAD DRIVING THE CAR:&lt;br /&gt;
What are you doing?!&lt;br /&gt;
(Barry escapes the car through the air conditioner and is flying high above&lt;br /&gt;
&lt;br /&gt;
the ground, safe.)&lt;br /&gt;
BARRY:&lt;br /&gt;
Wow... the tension level&lt;br /&gt;
out here is unbelievable.&lt;br /&gt;
(Barry sees that storm clouds are gathering and he can see rain clouds&lt;br /&gt;
moving into this direction)&lt;br /&gt;
 :&lt;br /&gt;
I gotta get home.&lt;br /&gt;
 :&lt;br /&gt;
Can't fly in rain.&lt;br /&gt;
 :&lt;br /&gt;
Can't fly in rain.&lt;br /&gt;
(A rain drop hits Barry and one of his wings is damaged)&lt;br /&gt;
 :&lt;br /&gt;
Can't fly in rain.&lt;br /&gt;
(A second rain drop hits Barry again and he spirals downwards)&lt;br /&gt;
Mayday! Mayday! Bee going down!&lt;br /&gt;
(WW2 plane sound effects are played as he plummets, and he crash-lands on a&lt;br /&gt;
plant inside an apartment near the window)&lt;br /&gt;
VANESSA BLOOME:&lt;br /&gt;
Ken, could you close&lt;br /&gt;
the window please?&lt;br /&gt;
KEN==&lt;br /&gt;
Hey, check out my new resume.&lt;br /&gt;
I made it into a fold-out brochure.&lt;br /&gt;
 :&lt;br /&gt;
You see?&lt;br /&gt;
(Folds brochure resume out)&lt;br /&gt;
Folds out.&lt;br /&gt;
(Ken closes the window, trapping Barry inside)&lt;br /&gt;
BARRY:&lt;br /&gt;
Oh, no. More humans. I don't need this.&lt;br /&gt;
(Barry tries to fly away but smashes into the window and falls again)&lt;br /&gt;
 :&lt;br /&gt;
What was that?&lt;br /&gt;
&lt;br /&gt;
(Barry keeps trying to fly out the window but he keeps being knocked back&lt;br /&gt;
because the window is closed)&lt;br /&gt;
Maybe this time. This time. This time.&lt;br /&gt;
This time! This time! This...&lt;br /&gt;
 :&lt;br /&gt;
Drapes!&lt;br /&gt;
(Barry taps the glass. He doesn't understand what it is)&lt;br /&gt;
That is diabolical.&lt;br /&gt;
KEN:&lt;br /&gt;
It's fantastic. It's got all my special&lt;br /&gt;
skills, even my top-ten favorite movies.&lt;br /&gt;
ANDY:&lt;br /&gt;
What's number one? Star Wars?&lt;br /&gt;
KEN:&lt;br /&gt;
Nah, I don't go for that...&lt;br /&gt;
(Ken makes finger guns and makes &amp;quot;pew pew pew&amp;quot; sounds and then stops)&lt;br /&gt;
 :&lt;br /&gt;
...kind of stuff.&lt;br /&gt;
BARRY:&lt;br /&gt;
No wonder we shouldn't talk to them.&lt;br /&gt;
They're out of their minds.&lt;br /&gt;
KEN:&lt;br /&gt;
When I leave a job interview, they're&lt;br /&gt;
flabbergasted, can't believe what I say.&lt;br /&gt;
BARRY:&lt;br /&gt;
(Looking at the light on the ceiling)&lt;br /&gt;
There's the sun. Maybe that's a way out.&lt;br /&gt;
(Starts flying towards the lightbulb)&lt;br /&gt;
 :&lt;br /&gt;
I don't remember the sun&lt;br /&gt;
having a big 75 on it.&lt;br /&gt;
(Barry hits the lightbulb and falls into the dip on the table that the&lt;br /&gt;
humans are sitting at)&lt;br /&gt;
KEN:&lt;br /&gt;
&lt;br /&gt;
I predicted global warming.&lt;br /&gt;
 :&lt;br /&gt;
I could feel it getting hotter.&lt;br /&gt;
At first I thought it was just me.&lt;br /&gt;
(Andy dips a chip into the bowl and scoops up some dip with Barry on it and&lt;br /&gt;
is about to put it in his mouth)&lt;br /&gt;
 :&lt;br /&gt;
Wait! Stop! Bee!&lt;br /&gt;
(Andy drops the chip with Barry in fear and backs away. All the humans&lt;br /&gt;
freak out)&lt;br /&gt;
 :&lt;br /&gt;
Stand back. These are winter boots.&lt;br /&gt;
(Ken has winter boots on his hands and he is about to smash the bee but&lt;br /&gt;
Vanessa saves him last second)&lt;br /&gt;
VANESSA:&lt;br /&gt;
Wait!&lt;br /&gt;
 :&lt;br /&gt;
Don't kill him!&lt;br /&gt;
(Vanessa puts Barry in a glass to protect him)&lt;br /&gt;
KEN:&lt;br /&gt;
You know I'm allergic to them!&lt;br /&gt;
This thing could kill me!&lt;br /&gt;
VANESSA:&lt;br /&gt;
Why does his life have&lt;br /&gt;
less value than yours?&lt;br /&gt;
KEN:&lt;br /&gt;
Why does his life have any less value&lt;br /&gt;
than mine? Is that your statement?&lt;br /&gt;
VANESSA:&lt;br /&gt;
I'm just saying all life has value. You&lt;br /&gt;
don't know what he's capable of feeling.&lt;br /&gt;
(Vanessa picks up Ken's brochure and puts it under the glass so she can&lt;br /&gt;
carry Barry back to the window. Barry looks at Vanessa in amazement)&lt;br /&gt;
KEN:&lt;br /&gt;
&lt;br /&gt;
My brochure!&lt;br /&gt;
VANESSA:&lt;br /&gt;
There you go, little guy.&lt;br /&gt;
(Vanessa opens the window and lets Barry out but Barry stays back and is&lt;br /&gt;
still shocked that a human saved his life)&lt;br /&gt;
KEN:&lt;br /&gt;
I'm not scared of him.&lt;br /&gt;
It's an allergic thing.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Put that on your resume brochure.&lt;br /&gt;
KEN:&lt;br /&gt;
My whole face could puff up.&lt;br /&gt;
ANDY:&lt;br /&gt;
Make it one of your special skills.&lt;br /&gt;
KEN:&lt;br /&gt;
Knocking someone out&lt;br /&gt;
is also a special skill.&lt;br /&gt;
(Ken walks to the door)&lt;br /&gt;
Right. Bye, Vanessa. Thanks.&lt;br /&gt;
 :&lt;br /&gt;
- Vanessa, next week? Yogurt night?&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Sure, Ken. You know, whatever.&lt;br /&gt;
 :&lt;br /&gt;
(Vanessa tries to close door)&lt;br /&gt;
KEN==&lt;br /&gt;
- You could put carob chips on there.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Bye.&lt;br /&gt;
(Closes door but Ken opens it again)&lt;br /&gt;
KEN:&lt;br /&gt;
- Supposed to be less calories.&lt;br /&gt;
&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Bye.&lt;br /&gt;
(Closes door)&lt;br /&gt;
(Fast forward to the next day, Barry is still inside the house. He flies&lt;br /&gt;
into the kitchen where Vanessa is doing dishes)&lt;br /&gt;
BARRY==&lt;br /&gt;
(Talking to himself)&lt;br /&gt;
I gotta say something.&lt;br /&gt;
 :&lt;br /&gt;
She saved my life.&lt;br /&gt;
I gotta say something.&lt;br /&gt;
 :&lt;br /&gt;
All right, here it goes.&lt;br /&gt;
(Turns back)&lt;br /&gt;
Nah.&lt;br /&gt;
 :&lt;br /&gt;
What would I say?&lt;br /&gt;
 :&lt;br /&gt;
I could really get in trouble.&lt;br /&gt;
 :&lt;br /&gt;
It's a bee law.&lt;br /&gt;
You're not supposed to talk to a human.&lt;br /&gt;
 :&lt;br /&gt;
I can't believe I'm doing this.&lt;br /&gt;
 :&lt;br /&gt;
I've got to.&lt;br /&gt;
(Barry disguises himself as a character on a food can as Vanessa walks by&lt;br /&gt;
again)&lt;br /&gt;
 :&lt;br /&gt;
Oh, I can't do it. Come on!&lt;br /&gt;
 :&lt;br /&gt;
No. Yes. No.&lt;br /&gt;
 :&lt;br /&gt;
Do it. I can't.&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
How should I start it?&lt;br /&gt;
(Barry strikes a pose and wiggles his eyebrows)&lt;br /&gt;
&amp;quot;You like jazz?&amp;quot;&lt;br /&gt;
No, that's no good.&lt;br /&gt;
(Vanessa is about to walk past Barry)&lt;br /&gt;
Here she comes! Speak, you fool!&lt;br /&gt;
 :&lt;br /&gt;
...Hi!&lt;br /&gt;
(Vanessa gasps and drops the dishes in fright and notices Barry on the&lt;br /&gt;
counter)&lt;br /&gt;
 :&lt;br /&gt;
I'm sorry.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- You're talking.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Yes, I know.&lt;br /&gt;
VANESSA:&lt;br /&gt;
(Pointing at Barry)&lt;br /&gt;
You're talking!&lt;br /&gt;
BARRY:&lt;br /&gt;
I'm so sorry.&lt;br /&gt;
VANESSA:&lt;br /&gt;
No, it's OK. It's fine.&lt;br /&gt;
I know I'm dreaming.&lt;br /&gt;
 :&lt;br /&gt;
But I don't recall going to bed.&lt;br /&gt;
BARRY:&lt;br /&gt;
Well, I'm sure this&lt;br /&gt;
is very disconcerting.&lt;br /&gt;
VANESSA:&lt;br /&gt;
This is a bit of a surprise to me.&lt;br /&gt;
I mean, you're a bee!&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
I am. And I'm not supposed&lt;br /&gt;
to be doing this,&lt;br /&gt;
(Pointing to the living room where Ken tried to kill him last night)&lt;br /&gt;
but they were all trying to kill me.&lt;br /&gt;
 :&lt;br /&gt;
And if it wasn't for you...&lt;br /&gt;
 :&lt;br /&gt;
I had to thank you.&lt;br /&gt;
It's just how I was raised.&lt;br /&gt;
(Vanessa stabs her hand with a fork to test whether she's dreaming or not)&lt;br /&gt;
 :&lt;br /&gt;
That was a little weird.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- I'm talking with a bee.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Yeah.&lt;br /&gt;
VANESSA:&lt;br /&gt;
I'm talking to a bee.&lt;br /&gt;
And the bee is talking to me!&lt;br /&gt;
BARRY:&lt;br /&gt;
I just want to say I'm grateful.&lt;br /&gt;
I'll leave now.&lt;br /&gt;
(Barry turns to leave)&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Wait! How did you learn to do that?&lt;br /&gt;
BARRY:&lt;br /&gt;
(Flying back)&lt;br /&gt;
- What?&lt;br /&gt;
VANESSA:&lt;br /&gt;
The talking...thing.&lt;br /&gt;
BARRY:&lt;br /&gt;
&lt;br /&gt;
Same way you did, I guess.&lt;br /&gt;
&amp;quot;Mama, Dada, honey.&amp;quot; You pick it up.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- That's very funny.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Yeah.&lt;br /&gt;
 :&lt;br /&gt;
Bees are funny. If we didn't laugh,&lt;br /&gt;
we'd cry with what we have to deal with.&lt;br /&gt;
 :&lt;br /&gt;
Anyway...&lt;br /&gt;
VANESSA:&lt;br /&gt;
Can I...&lt;br /&gt;
 :&lt;br /&gt;
...get you something?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Like what?&lt;br /&gt;
VANESSA:&lt;br /&gt;
I don't know. I mean...&lt;br /&gt;
I don't know. Coffee?&lt;br /&gt;
BARRY:&lt;br /&gt;
I don't want to put you out.&lt;br /&gt;
VANESSA:&lt;br /&gt;
It's no trouble. It takes two minutes.&lt;br /&gt;
 :&lt;br /&gt;
- It's just coffee.&lt;br /&gt;
BARRY:&lt;br /&gt;
- I hate to impose.&lt;br /&gt;
(Vanessa starts making coffee)&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Don't be ridiculous!&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
- Actually, I would love a cup.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Hey, you want rum cake?&lt;br /&gt;
BARRY:&lt;br /&gt;
- I shouldn't.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Have some.&lt;br /&gt;
BARRY:&lt;br /&gt;
- No, I can't.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Come on!&lt;br /&gt;
BARRY:&lt;br /&gt;
I'm trying to lose a couple micrograms.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Where?&lt;br /&gt;
BARRY:&lt;br /&gt;
- These stripes don't help.&lt;br /&gt;
VANESSA:&lt;br /&gt;
You look great!&lt;br /&gt;
BARRY:&lt;br /&gt;
I don't know if you know&lt;br /&gt;
anything about fashion.&lt;br /&gt;
 :&lt;br /&gt;
Are you all right?&lt;br /&gt;
VANESSA:&lt;br /&gt;
(Pouring coffee on the floor and missing the cup completely)&lt;br /&gt;
No.&lt;br /&gt;
(Flash forward in time. Barry and Vanessa are sitting together at a table&lt;br /&gt;
on top of the apartment building drinking coffee)&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
BARRY==&lt;br /&gt;
He's making the tie in the cab&lt;br /&gt;
as they're flying up Madison.&lt;br /&gt;
 :&lt;br /&gt;
He finally gets there.&lt;br /&gt;
 :&lt;br /&gt;
He runs up the steps into the church.&lt;br /&gt;
The wedding is on.&lt;br /&gt;
 :&lt;br /&gt;
And he says, &amp;quot;Watermelon?&lt;br /&gt;
I thought you said Guatemalan.&lt;br /&gt;
 :&lt;br /&gt;
Why would I marry a watermelon?&amp;quot;&lt;br /&gt;
(Barry laughs but Vanessa looks confused)&lt;br /&gt;
VANESSA:&lt;br /&gt;
Is that a bee joke?&lt;br /&gt;
BARRY:&lt;br /&gt;
That's the kind of stuff we do.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Yeah, different.&lt;br /&gt;
 :&lt;br /&gt;
So, what are you gonna do, Barry?&lt;br /&gt;
(Barry stands on top of a sugar cube floating in his coffee and paddles it&lt;br /&gt;
around with a straw like it's a gondola)&lt;br /&gt;
BARRY:&lt;br /&gt;
About work? I don't know.&lt;br /&gt;
 :&lt;br /&gt;
I want to do my part for the hive,&lt;br /&gt;
but I can't do it the way they want.&lt;br /&gt;
VANESSA:&lt;br /&gt;
I know how you feel.&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
- You do?&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Sure.&lt;br /&gt;
 :&lt;br /&gt;
My parents wanted me to be a lawyer or&lt;br /&gt;
a doctor, but I wanted to be a florist.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Really?&lt;br /&gt;
VANESSA:&lt;br /&gt;
- My only interest is flowers.&lt;br /&gt;
BARRY:&lt;br /&gt;
Our new queen was just elected&lt;br /&gt;
with that same campaign slogan.&lt;br /&gt;
 :&lt;br /&gt;
Anyway, if you look...&lt;br /&gt;
(Barry points to a tree in the middle of Central Park)&lt;br /&gt;
 :&lt;br /&gt;
There's my hive right there. See it?&lt;br /&gt;
VANESSA:&lt;br /&gt;
You're in Sheep Meadow!&lt;br /&gt;
BARRY:&lt;br /&gt;
Yes! I'm right off the Turtle Pond!&lt;br /&gt;
VANESSA:&lt;br /&gt;
No way! I know that area.&lt;br /&gt;
I lost a toe ring there once.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Why do girls put rings on their toes?&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Why not?&lt;br /&gt;
BARRY:&lt;br /&gt;
&lt;br /&gt;
- It's like putting a hat on your knee.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Maybe I'll try that.&lt;br /&gt;
(A custodian installing a lightbulb looks over at them but to his&lt;br /&gt;
perspective it looks like Vanessa is talking to a cup of coffee on the&lt;br /&gt;
table)&lt;br /&gt;
CUSTODIAN:&lt;br /&gt;
- You all right, ma'am?&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Oh, yeah. Fine.&lt;br /&gt;
 :&lt;br /&gt;
Just having two cups of coffee!&lt;br /&gt;
BARRY:&lt;br /&gt;
Anyway, this has been great.&lt;br /&gt;
Thanks for the coffee.&lt;br /&gt;
VANESSA==&lt;br /&gt;
Yeah, it's no trouble.&lt;br /&gt;
BARRY:&lt;br /&gt;
Sorry I couldn't finish it. If I did,&lt;br /&gt;
I'd be up the rest of my life.&lt;br /&gt;
(Barry points towards the rum cake)&lt;br /&gt;
 :&lt;br /&gt;
Can I take a piece of this with me?&lt;br /&gt;
VANESSA:&lt;br /&gt;
Sure! Here, have a crumb.&lt;br /&gt;
(Vanessa hands Barry a crumb but it is still pretty big for Barry)&lt;br /&gt;
BARRY:&lt;br /&gt;
- Thanks!&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Yeah.&lt;br /&gt;
BARRY:&lt;br /&gt;
All right. Well, then...&lt;br /&gt;
I guess I'll see you around.&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
Or not.&lt;br /&gt;
VANESSA:&lt;br /&gt;
OK, Barry...&lt;br /&gt;
BARRY:&lt;br /&gt;
And thank you&lt;br /&gt;
so much again... for before.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Oh, that? That was nothing.&lt;br /&gt;
BARRY:&lt;br /&gt;
Well, not nothing, but... Anyway...&lt;br /&gt;
(Vanessa and Barry hold hands, but Vanessa has to hold out a finger because&lt;br /&gt;
her hands is to big and Barry holds that)&lt;br /&gt;
(The custodian looks over again and it appears Vanessa is laughing at her&lt;br /&gt;
coffee again. The lightbulb that he was screwing in sparks and he falls off&lt;br /&gt;
the ladder)&lt;br /&gt;
(Fast forward in time and we see two Bee Scientists testing out a parachute&lt;br /&gt;
in a Honex wind tunnel)&lt;br /&gt;
BEE SCIENTIST #1:&lt;br /&gt;
This can't possibly work.&lt;br /&gt;
BEE SCIENTIST #2:&lt;br /&gt;
He's all set to go.&lt;br /&gt;
We may as well try it.&lt;br /&gt;
 :&lt;br /&gt;
OK, Dave, pull the chute.&lt;br /&gt;
(Dave pulls the chute and the wind slams him against the wall and he falls&lt;br /&gt;
on his face.The camera pans over and we see Barry and Adam walking&lt;br /&gt;
together)&lt;br /&gt;
ADAM:&lt;br /&gt;
- Sounds amazing.&lt;br /&gt;
BARRY:&lt;br /&gt;
- It was amazing!&lt;br /&gt;
 :&lt;br /&gt;
It was the scariest,&lt;br /&gt;
happiest moment of my life.&lt;br /&gt;
&lt;br /&gt;
ADAM:&lt;br /&gt;
Humans! I can't believe&lt;br /&gt;
you were with humans!&lt;br /&gt;
 :&lt;br /&gt;
Giant, scary humans!&lt;br /&gt;
What were they like?&lt;br /&gt;
BARRY:&lt;br /&gt;
Huge and crazy. They talk crazy.&lt;br /&gt;
 :&lt;br /&gt;
They eat crazy giant things.&lt;br /&gt;
They drive crazy.&lt;br /&gt;
ADAM:&lt;br /&gt;
- Do they try and kill you, like on TV?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Some of them. But some of them don't.&lt;br /&gt;
ADAM:&lt;br /&gt;
- How'd you get back?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Poodle.&lt;br /&gt;
ADAM:&lt;br /&gt;
You did it, and I'm glad. You saw&lt;br /&gt;
whatever you wanted to see.&lt;br /&gt;
 :&lt;br /&gt;
You had your &amp;quot;experience.&amp;quot; Now you&lt;br /&gt;
can pick out your job and be normal.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Well...&lt;br /&gt;
ADAM:&lt;br /&gt;
- Well?&lt;br /&gt;
BARRY:&lt;br /&gt;
Well, I met someone.&lt;br /&gt;
&lt;br /&gt;
ADAM:&lt;br /&gt;
You did? Was she Bee-ish?&lt;br /&gt;
 :&lt;br /&gt;
- A wasp?! Your parents will kill you!&lt;br /&gt;
BARRY:&lt;br /&gt;
- No, no, no, not a wasp.&lt;br /&gt;
ADAM:&lt;br /&gt;
- Spider?&lt;br /&gt;
BARRY:&lt;br /&gt;
- I'm not attracted to spiders.&lt;br /&gt;
 :&lt;br /&gt;
I know, for everyone else, it's the hottest thing,&lt;br /&gt;
with the eight legs and all.&lt;br /&gt;
 :&lt;br /&gt;
I can't get by that face.&lt;br /&gt;
ADAM:&lt;br /&gt;
So who is she?&lt;br /&gt;
BARRY:&lt;br /&gt;
She's... human.&lt;br /&gt;
ADAM:&lt;br /&gt;
No, no. That's a bee law.&lt;br /&gt;
You wouldn't break a bee law.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Her name's Vanessa.&lt;br /&gt;
(Adam puts his head in his hands)&lt;br /&gt;
ADAM:&lt;br /&gt;
- Oh, boy.&lt;br /&gt;
BARRY==&lt;br /&gt;
She's so nice. And she's a florist!&lt;br /&gt;
ADAM:&lt;br /&gt;
Oh, no! You're dating a human florist!&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
We're not dating.&lt;br /&gt;
ADAM:&lt;br /&gt;
You're flying outside the hive, talking&lt;br /&gt;
to humans that attack our homes&lt;br /&gt;
 :&lt;br /&gt;
with power washers and M-80s!&lt;br /&gt;
That's one-eighth a stick of dynamite!&lt;br /&gt;
BARRY:&lt;br /&gt;
She saved my life!&lt;br /&gt;
And she understands me.&lt;br /&gt;
ADAM:&lt;br /&gt;
This is over!&lt;br /&gt;
BARRY:&lt;br /&gt;
Eat this.&lt;br /&gt;
(Barry gives Adam a piece of the crumb that he got from Vanessa. Adam eats&lt;br /&gt;
it)&lt;br /&gt;
ADAM:&lt;br /&gt;
(Adam's tone changes)&lt;br /&gt;
This is not over! What was that?&lt;br /&gt;
BARRY:&lt;br /&gt;
- They call it a crumb.&lt;br /&gt;
ADAM:&lt;br /&gt;
- It was so stingin' stripey!&lt;br /&gt;
BARRY:&lt;br /&gt;
And that's not what they eat.&lt;br /&gt;
That's what falls off what they eat!&lt;br /&gt;
 :&lt;br /&gt;
- You know what a Cinnabon is?&lt;br /&gt;
ADAM:&lt;br /&gt;
- No.&lt;br /&gt;
(Adam opens a door behind him and he pulls Barry in)&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
It's bread and cinnamon and frosting.&lt;br /&gt;
ADAM:&lt;br /&gt;
Be quiet!&lt;br /&gt;
BARRY:&lt;br /&gt;
They heat it up...&lt;br /&gt;
ADAM:&lt;br /&gt;
Sit down!&lt;br /&gt;
(Adam forces Barry to sit down)&lt;br /&gt;
BARRY:&lt;br /&gt;
(Still rambling about Cinnabons)&lt;br /&gt;
...really hot!&lt;br /&gt;
(Adam grabs Barry by the shoulders)&lt;br /&gt;
ADAM:&lt;br /&gt;
- Listen to me!&lt;br /&gt;
 :&lt;br /&gt;
We are not them! We're us.&lt;br /&gt;
There's us and there's them!&lt;br /&gt;
BARRY==&lt;br /&gt;
Yes, but who can deny&lt;br /&gt;
the heart that is yearning?&lt;br /&gt;
ADAM:&lt;br /&gt;
There's no yearning.&lt;br /&gt;
Stop yearning. Listen to me!&lt;br /&gt;
 :&lt;br /&gt;
You have got to start thinking bee,&lt;br /&gt;
my friend. Thinking bee!&lt;br /&gt;
BARRY:&lt;br /&gt;
- Thinking bee.&lt;br /&gt;
WORKER BEE:&lt;br /&gt;
- Thinking bee.&lt;br /&gt;
WORKER BEES AND ADAM:&lt;br /&gt;
Thinking bee! Thinking bee!&lt;br /&gt;
&lt;br /&gt;
Thinking bee! Thinking bee!&lt;br /&gt;
(Flash forward in time; Barry is laying on a raft in a pool full of honey.&lt;br /&gt;
He is wearing sunglasses)&lt;br /&gt;
JANET:&lt;br /&gt;
There he is. He's in the pool.&lt;br /&gt;
MARTIN:&lt;br /&gt;
You know what your problem is, Barry?&lt;br /&gt;
(Barry pulls down his sunglasses and he looks annoyed)&lt;br /&gt;
BARRY:&lt;br /&gt;
(Sarcastic)&lt;br /&gt;
I gotta start thinking bee?&lt;br /&gt;
JANET:&lt;br /&gt;
How much longer will this go on?&lt;br /&gt;
MARTIN:&lt;br /&gt;
It's been three days!&lt;br /&gt;
Why aren't you working?&lt;br /&gt;
(Puts sunglasses back on)&lt;br /&gt;
BARRY:&lt;br /&gt;
I've got a lot of big life decisions&lt;br /&gt;
to think about.&lt;br /&gt;
MARTIN:&lt;br /&gt;
What life? You have no life!&lt;br /&gt;
You have no job. You're barely a bee!&lt;br /&gt;
JANET:&lt;br /&gt;
Would it kill you&lt;br /&gt;
to make a little honey?&lt;br /&gt;
(Barry rolls off the raft and sinks into the honey pool)&lt;br /&gt;
 :&lt;br /&gt;
Barry, come out.&lt;br /&gt;
Your father's talking to you.&lt;br /&gt;
 :&lt;br /&gt;
Martin, would you talk to him?&lt;br /&gt;
MARTIN:&lt;br /&gt;
&lt;br /&gt;
Barry, I'm talking to you!&lt;br /&gt;
(Barry keeps sinking into the honey until he is suddenly in Central Park&lt;br /&gt;
having a picnic with Vanessa)&lt;br /&gt;
(Barry has a cup of honey and he clinks his glass with Vanessas. Suddenly a&lt;br /&gt;
mosquito lands on Vanessa and she slaps it, killing it. They both gasp but&lt;br /&gt;
then burst out laughing)&lt;br /&gt;
VANESSA:&lt;br /&gt;
You coming?&lt;br /&gt;
(The camera pans over and Vanessa is climbing into a small yellow airplane)&lt;br /&gt;
BARRY:&lt;br /&gt;
Got everything?&lt;br /&gt;
VANESSA:&lt;br /&gt;
All set!&lt;br /&gt;
BARRY:&lt;br /&gt;
Go ahead. I'll catch up.&lt;br /&gt;
(Vanessa lifts off and flies ahead)&lt;br /&gt;
VANESSA:&lt;br /&gt;
Don't be too long.&lt;br /&gt;
(Barry catches up with Vanessa and he sticks out his arms like ana irplane.&lt;br /&gt;
He rolls from side to side, and Vanessa copies him with the airplane)&lt;br /&gt;
VANESSA:&lt;br /&gt;
Watch this!&lt;br /&gt;
(Barry stays back and watches as Vanessa draws a heart in the air using&lt;br /&gt;
pink smoke from the plane, but on the last loop-the-loop she suddenly&lt;br /&gt;
crashes into a mountain and the plane explodes. The destroyed plane falls&lt;br /&gt;
into some rocks and explodes a second time)&lt;br /&gt;
BARRY:&lt;br /&gt;
Vanessa!&lt;br /&gt;
(As Barry is yelling his mouth fills with honey and he wakes up,&lt;br /&gt;
discovering that he was just day dreaming. He slowly sinks back into the&lt;br /&gt;
honey pool)&lt;br /&gt;
MARTIN:&lt;br /&gt;
- We're still here.&lt;br /&gt;
&lt;br /&gt;
JANET:&lt;br /&gt;
- I told you not to yell at him.&lt;br /&gt;
 :&lt;br /&gt;
He doesn't respond to yelling!&lt;br /&gt;
MARTIN:&lt;br /&gt;
- Then why yell at me?&lt;br /&gt;
JANET:&lt;br /&gt;
- Because you don't listen!&lt;br /&gt;
MARTIN:&lt;br /&gt;
I'm not listening to this.&lt;br /&gt;
BARRY:&lt;br /&gt;
Sorry, I've gotta go.&lt;br /&gt;
MARTIN:&lt;br /&gt;
- Where are you going?&lt;br /&gt;
BARRY:&lt;br /&gt;
- I'm meeting a friend.&lt;br /&gt;
JANET:&lt;br /&gt;
A girl? Is this why you can't decide?&lt;br /&gt;
BARRY:&lt;br /&gt;
Bye.&lt;br /&gt;
(Barry flies out the door and Martin shakes his head)&lt;br /&gt;
 :&lt;br /&gt;
JANET==&lt;br /&gt;
I just hope she's Bee-ish.&lt;br /&gt;
(Fast forward in time and Barry is sitting on Vanessa's shoulder and she is&lt;br /&gt;
closing up her shop)&lt;br /&gt;
BARRY:&lt;br /&gt;
They have a huge parade&lt;br /&gt;
of flowers every year in Pasadena?&lt;br /&gt;
VANESSA:&lt;br /&gt;
To be in the Tournament of Roses,&lt;br /&gt;
that's every florist's dream!&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
Up on a float, surrounded&lt;br /&gt;
by flowers, crowds cheering.&lt;br /&gt;
BARRY:&lt;br /&gt;
A tournament. Do the roses&lt;br /&gt;
compete in athletic events?&lt;br /&gt;
VANESSA:&lt;br /&gt;
No. All right, I've got one.&lt;br /&gt;
How come you don't fly everywhere?&lt;br /&gt;
BARRY:&lt;br /&gt;
It's exhausting. Why don't you&lt;br /&gt;
run everywhere? It's faster.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Yeah, OK, I see, I see.&lt;br /&gt;
All right, your turn.&lt;br /&gt;
BARRY:&lt;br /&gt;
TiVo. You can just freeze live TV?&lt;br /&gt;
That's insane!&lt;br /&gt;
VANESSA:&lt;br /&gt;
You don't have that?&lt;br /&gt;
BARRY:&lt;br /&gt;
We have Hivo, but it's a disease.&lt;br /&gt;
It's a horrible, horrible disease.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Oh, my.&lt;br /&gt;
(A human walks by and Barry narrowly avoids him)&lt;br /&gt;
PASSERBY:&lt;br /&gt;
Dumb bees!&lt;br /&gt;
VANESSA:&lt;br /&gt;
You must want to sting all those jerks.&lt;br /&gt;
BARRY:&lt;br /&gt;
We try not to sting.&lt;br /&gt;
&lt;br /&gt;
It's usually fatal for us.&lt;br /&gt;
VANESSA:&lt;br /&gt;
So you have to watch your temper&lt;br /&gt;
(They walk into a store)&lt;br /&gt;
BARRY:&lt;br /&gt;
Very carefully.&lt;br /&gt;
You kick a wall, take a walk,&lt;br /&gt;
 :&lt;br /&gt;
write an angry letter and throw it out.&lt;br /&gt;
Work through it like any emotion:&lt;br /&gt;
 :&lt;br /&gt;
Anger, jealousy, lust.&lt;br /&gt;
(Suddenly an employee(Hector) hits Barry off of Vanessa's shoulder. Hector&lt;br /&gt;
thinks he's saving Vanessa)&lt;br /&gt;
VANESSA:&lt;br /&gt;
(To Barry)&lt;br /&gt;
Oh, my goodness! Are you OK?&lt;br /&gt;
(Barry is getting up off the floor)&lt;br /&gt;
BARRY:&lt;br /&gt;
Yeah.&lt;br /&gt;
VANESSA:&lt;br /&gt;
(To Hector)&lt;br /&gt;
- What is wrong with you?!&lt;br /&gt;
HECTOR:&lt;br /&gt;
(Confused)&lt;br /&gt;
- It's a bug.&lt;br /&gt;
VANESSA:&lt;br /&gt;
He's not bothering anybody.&lt;br /&gt;
Get out of here, you creep!&lt;br /&gt;
(Vanessa hits Hector across the face with the magazine he had and then hits&lt;br /&gt;
him in the head. Hector backs away covering his head)&lt;br /&gt;
Barry:&lt;br /&gt;
What was that? A Pic 'N' Save circular?&lt;br /&gt;
(Vanessa sets Barry back on her shoulder)&lt;br /&gt;
&lt;br /&gt;
VANESSA:&lt;br /&gt;
Yeah, it was. How did you know?&lt;br /&gt;
BARRY:&lt;br /&gt;
It felt like about 10 pages.&lt;br /&gt;
Seventy-five is pretty much our limit.&lt;br /&gt;
VANESSA:&lt;br /&gt;
You've really got that&lt;br /&gt;
down to a science.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Oh, we have to. I lost a cousin to Italian Vogue.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- I'll bet.&lt;br /&gt;
(Barry looks to his right and notices there is honey for sale in the aisle)&lt;br /&gt;
BARRY:&lt;br /&gt;
What in the name&lt;br /&gt;
of Mighty Hercules is this?&lt;br /&gt;
(Barry looks at all the brands of honey, shocked)&lt;br /&gt;
How did this get here?&lt;br /&gt;
Cute Bee, Golden Blossom,&lt;br /&gt;
 :&lt;br /&gt;
Ray Liotta Private Select?&lt;br /&gt;
(Barry puts his hands up and slowly turns around, a look of disgust on his&lt;br /&gt;
face)&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Is he that actor?&lt;br /&gt;
BARRY:&lt;br /&gt;
- I never heard of him.&lt;br /&gt;
 :&lt;br /&gt;
- Why is this here?&lt;br /&gt;
VANESSA:&lt;br /&gt;
- For people. We eat it.&lt;br /&gt;
BARRY:&lt;br /&gt;
&lt;br /&gt;
You don't have&lt;br /&gt;
enough food of your own?!&lt;br /&gt;
(Hector looks back and notices that Vanessa is talking to Barry)&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Well, yes.&lt;br /&gt;
BARRY:&lt;br /&gt;
- How do you get it?&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Bees make it.&lt;br /&gt;
BARRY:&lt;br /&gt;
- I know who makes it!&lt;br /&gt;
 :&lt;br /&gt;
And it's hard to make it!&lt;br /&gt;
 :&lt;br /&gt;
There's heating, cooling, stirring.&lt;br /&gt;
You need a whole Krelman thing!&lt;br /&gt;
VANESSA:&lt;br /&gt;
- It's organic.&lt;br /&gt;
BARRY:&lt;br /&gt;
- It's our-ganic!&lt;br /&gt;
VANESSA:&lt;br /&gt;
It's just honey, Barry.&lt;br /&gt;
BARRY:&lt;br /&gt;
Just what?!&lt;br /&gt;
 :&lt;br /&gt;
Bees don't know about this!&lt;br /&gt;
This is stealing! A lot of stealing!&lt;br /&gt;
 :&lt;br /&gt;
You've taken our homes, schools,&lt;br /&gt;
hospitals! This is all we have!&lt;br /&gt;
 :&lt;br /&gt;
&lt;br /&gt;
And it's on sale?!&lt;br /&gt;
I'm getting to the bottom of this.&lt;br /&gt;
 :&lt;br /&gt;
I'm getting to the bottom&lt;br /&gt;
of all of this!&lt;br /&gt;
(Flash forward in time; Barry paints his face with black strikes like a&lt;br /&gt;
soldier and sneaks into the storage section of the store)&lt;br /&gt;
(Two men, including Hector, are loading boxes into some trucks)&lt;br /&gt;
 :&lt;br /&gt;
SUPERMARKET EMPLOYEE==&lt;br /&gt;
Hey, Hector.&lt;br /&gt;
 :&lt;br /&gt;
- You almost done?&lt;br /&gt;
HECTOR:&lt;br /&gt;
- Almost.&lt;br /&gt;
(Barry takes a step to peak around the corner)&lt;br /&gt;
(Whispering)&lt;br /&gt;
He is here. I sense it.&lt;br /&gt;
 :&lt;br /&gt;
Well, I guess I'll go home now&lt;br /&gt;
(Hector pretends to walk away by walking in place and speaking loudly)&lt;br /&gt;
 :&lt;br /&gt;
and just leave this nice honey out,&lt;br /&gt;
with no one around.&lt;br /&gt;
BARRY:&lt;br /&gt;
You're busted, box boy!&lt;br /&gt;
HECTOR:&lt;br /&gt;
I knew I heard something!&lt;br /&gt;
So you can talk!&lt;br /&gt;
BARRY:&lt;br /&gt;
I can talk.&lt;br /&gt;
And now you'll start talking!&lt;br /&gt;
 :&lt;br /&gt;
Where you getting the sweet stuff?&lt;br /&gt;
&lt;br /&gt;
Who's your supplier?&lt;br /&gt;
HECTOR:&lt;br /&gt;
I don't understand.&lt;br /&gt;
I thought we were friends.&lt;br /&gt;
 :&lt;br /&gt;
The last thing we want&lt;br /&gt;
to do is upset bees!&lt;br /&gt;
(Hector takes a thumbtack out of the board behind him and sword-fights&lt;br /&gt;
Barry. Barry is using his stinger like a sword)&lt;br /&gt;
 :&lt;br /&gt;
You're too late! It's ours now!&lt;br /&gt;
BARRY:&lt;br /&gt;
You, sir, have crossed&lt;br /&gt;
the wrong sword!&lt;br /&gt;
HECTOR:&lt;br /&gt;
You, sir, will be lunch&lt;br /&gt;
for my iguana, Ignacio!&lt;br /&gt;
(Barry hits the thumbtack out of Hectors hand and Hector surrenders)&lt;br /&gt;
Barry:&lt;br /&gt;
Where is the honey coming from?&lt;br /&gt;
 :&lt;br /&gt;
Tell me where!&lt;br /&gt;
HECTOR:&lt;br /&gt;
(Pointing to leaving truck)&lt;br /&gt;
Honey Farms! It comes from Honey Farms!&lt;br /&gt;
(Barry chases after the truck but it is getting away. He flies onto a&lt;br /&gt;
bicyclists' backpack and he catches up to the truck)&lt;br /&gt;
CAR DRIVER:&lt;br /&gt;
(To bicyclist)&lt;br /&gt;
Crazy person!&lt;br /&gt;
(Barry flies off and lands on the windshield of the Honey farms truck.&lt;br /&gt;
Barry looks around and sees dead bugs splattered everywhere)&lt;br /&gt;
BARRY:&lt;br /&gt;
What horrible thing has happened here?&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
These faces, they never knew&lt;br /&gt;
what hit them. And now&lt;br /&gt;
 :&lt;br /&gt;
they're on the road to nowhere!&lt;br /&gt;
(Barry hears a sudden whisper)&lt;br /&gt;
(Barry looks up and sees Mooseblood, a mosquito playing dead)&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
Just keep still.&lt;br /&gt;
BARRY:&lt;br /&gt;
What? You're not dead?&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
Do I look dead? They will wipe anything&lt;br /&gt;
that moves. Where you headed?&lt;br /&gt;
BARRY:&lt;br /&gt;
To Honey Farms.&lt;br /&gt;
I am onto something huge here.&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
I'm going to Alaska. Moose blood,&lt;br /&gt;
crazy stuff. Blows your head off!&lt;br /&gt;
ANOTHER BUG PLAYING DEAD:&lt;br /&gt;
I'm going to Tacoma.&lt;br /&gt;
(Barry looks at another bug)&lt;br /&gt;
BARRY:&lt;br /&gt;
- And you?&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
- He really is dead.&lt;br /&gt;
BARRY:&lt;br /&gt;
All right.&lt;br /&gt;
(Another bug hits the windshield and the drivers notice. They activate the&lt;br /&gt;
windshield wipers)&lt;br /&gt;
MOOSEBLOOD==&lt;br /&gt;
Uh-oh!&lt;br /&gt;
(The windshield wipers are slowly sliding over the dead bugs and wiping&lt;br /&gt;
&lt;br /&gt;
them off)&lt;br /&gt;
BARRY:&lt;br /&gt;
- What is that?!&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
- Oh, no!&lt;br /&gt;
 :&lt;br /&gt;
- A wiper! Triple blade!&lt;br /&gt;
BARRY:&lt;br /&gt;
- Triple blade?&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
Jump on! It's your only chance, bee!&lt;br /&gt;
(Mooseblood and Barry grab onto the wiper and they hold on as it wipes the&lt;br /&gt;
windshield)&lt;br /&gt;
Why does everything have&lt;br /&gt;
to be so doggone clean?!&lt;br /&gt;
 :&lt;br /&gt;
How much do you people need to see?!&lt;br /&gt;
(Bangs on windshield)&lt;br /&gt;
 :&lt;br /&gt;
Open your eyes!&lt;br /&gt;
Stick your head out the window!&lt;br /&gt;
RADIO IN TRUCK:&lt;br /&gt;
From NPR News in Washington,&lt;br /&gt;
I'm Carl Kasell.&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
But don't kill no more bugs!&lt;br /&gt;
(Mooseblood and Barry are washed off by the wipr fluid)&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
- Bee!&lt;br /&gt;
BARRY:&lt;br /&gt;
- Moose blood guy!!&lt;br /&gt;
(Barry starts screaming as he hangs onto the antenna)&lt;br /&gt;
(Suddenly it is revealed that a water bug is also hanging on the antenna.&lt;br /&gt;
&lt;br /&gt;
There is a pause and then Barry and the water bug both start screaming)&lt;br /&gt;
TRUCK DRIVER:&lt;br /&gt;
- You hear something?&lt;br /&gt;
GUY IN TRUCK:&lt;br /&gt;
- Like what?&lt;br /&gt;
TRUCK DRIVER:&lt;br /&gt;
Like tiny screaming.&lt;br /&gt;
GUY IN TRUCK:&lt;br /&gt;
Turn off the radio.&lt;br /&gt;
(The antenna starts to lower until it gets to low and sinks into the truck.&lt;br /&gt;
The water bug flies off and Barry is forced to let go and he is blown away.&lt;br /&gt;
He luckily lands inside a horn on top of the truck where he finds&lt;br /&gt;
Mooseblood, who was blown into the same place)&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
Whassup, bee boy?&lt;br /&gt;
BARRY:&lt;br /&gt;
Hey, Blood.&lt;br /&gt;
(Fast forward in time and we see that Barry is deep in conversation with&lt;br /&gt;
Mooseblood. They have been sitting in this truck for a while)&lt;br /&gt;
BARRY:&lt;br /&gt;
...Just a row of honey jars,&lt;br /&gt;
as far as the eye could see.&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
Wow!&lt;br /&gt;
BARRY:&lt;br /&gt;
I assume wherever this truck goes&lt;br /&gt;
is where they're getting it.&lt;br /&gt;
 :&lt;br /&gt;
I mean, that honey's ours.&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
- Bees hang tight.&lt;br /&gt;
BARRY:&lt;br /&gt;
&lt;br /&gt;
- We're all jammed in.&lt;br /&gt;
 :&lt;br /&gt;
It's a close community.&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
Not us, man. We on our own.&lt;br /&gt;
Every mosquito on his own.&lt;br /&gt;
BARRY:&lt;br /&gt;
- What if you get in trouble?&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
- You a mosquito, you in trouble.&lt;br /&gt;
 :&lt;br /&gt;
Nobody likes us. They just smack.&lt;br /&gt;
See a mosquito, smack, smack!&lt;br /&gt;
BARRY:&lt;br /&gt;
At least you're out in the world.&lt;br /&gt;
You must meet girls.&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
Mosquito girls try to trade up,&lt;br /&gt;
get with a moth, dragonfly.&lt;br /&gt;
 :&lt;br /&gt;
Mosquito girl don't want no mosquito.&lt;br /&gt;
(An ambulance passes by and it has a blood donation sign on it)&lt;br /&gt;
You got to be kidding me!&lt;br /&gt;
 :&lt;br /&gt;
Mooseblood's about to leave&lt;br /&gt;
the building! So long, bee!&lt;br /&gt;
(Mooseblood leaves and flies onto the window of the ambulance where there&lt;br /&gt;
are other mosquito's hanging out)&lt;br /&gt;
 :&lt;br /&gt;
- Hey, guys!&lt;br /&gt;
OTHER MOSQUITO:&lt;br /&gt;
- Mooseblood!&lt;br /&gt;
&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
I knew I'd catch y'all down here.&lt;br /&gt;
Did you bring your crazy straw?&lt;br /&gt;
(The truck goes out of view and Barry notices that the truck he's on is&lt;br /&gt;
pulling into a camp of some sort)&lt;br /&gt;
TRUCK DRIVER:&lt;br /&gt;
We throw it in jars, slap a label on it,&lt;br /&gt;
and it's pretty much pure profit.&lt;br /&gt;
(Barry flies out)&lt;br /&gt;
BARRY:&lt;br /&gt;
What is this place?&lt;br /&gt;
BEEKEEPER 1#:&lt;br /&gt;
A bee's got a brain&lt;br /&gt;
the size of a pinhead.&lt;br /&gt;
BEEKEEPER #2:&lt;br /&gt;
They are pinheads!&lt;br /&gt;
 :&lt;br /&gt;
Pinhead.&lt;br /&gt;
 :&lt;br /&gt;
- Check out the new smoker.&lt;br /&gt;
BEEKEEPER #1:&lt;br /&gt;
- Oh, sweet. That's the one you want.&lt;br /&gt;
 :&lt;br /&gt;
The Thomas 3000!&lt;br /&gt;
BARRY:&lt;br /&gt;
Smoker?&lt;br /&gt;
BEEKEEPER #1:&lt;br /&gt;
Ninety puffs a minute, semi-automatic.&lt;br /&gt;
Twice the nicotine, all the tar.&lt;br /&gt;
 :&lt;br /&gt;
A couple breaths of this&lt;br /&gt;
knocks them right out.&lt;br /&gt;
&lt;br /&gt;
BEEKEEPER #2:&lt;br /&gt;
They make the honey,&lt;br /&gt;
and we make the money.&lt;br /&gt;
BARRY:&lt;br /&gt;
&amp;quot;They make the honey,&lt;br /&gt;
and we make the money&amp;quot;?&lt;br /&gt;
(The Beekeeper sprays hundreds of cheap miniature apartments with the&lt;br /&gt;
smoker. The bees are fainting or passing out)&lt;br /&gt;
Oh, my!&lt;br /&gt;
 :&lt;br /&gt;
What's going on? Are you OK?&lt;br /&gt;
(Barry flies into one of the apartment and helps a Bee couple get off the&lt;br /&gt;
ground. They are coughing and its hard for them to stand)&lt;br /&gt;
BEE IN APARTMENT:&lt;br /&gt;
Yeah. It doesn't last too long.&lt;br /&gt;
BARRY:&lt;br /&gt;
Do you know you're&lt;br /&gt;
in a fake hive with fake walls?&lt;br /&gt;
BEE IN APPARTMENT:&lt;br /&gt;
Our queen was moved here.&lt;br /&gt;
We had no choice.&lt;br /&gt;
(The apartment room is completely empty except for a photo on the wall of&lt;br /&gt;
the &amp;quot;queen&amp;quot; who is obviously a man in women's clothes)&lt;br /&gt;
BARRY:&lt;br /&gt;
This is your queen?&lt;br /&gt;
That's a man in women's clothes!&lt;br /&gt;
 :&lt;br /&gt;
That's a drag queen!&lt;br /&gt;
 :&lt;br /&gt;
What is this?&lt;br /&gt;
(Barry flies out and he discovers that there are hundreds of these&lt;br /&gt;
structures, each housing thousands of Bees)&lt;br /&gt;
Oh, no!&lt;br /&gt;
 :&lt;br /&gt;
There's hundreds of them!&lt;br /&gt;
(Barry takes out his camera and takes pictures of these Bee work camps. The&lt;br /&gt;
beekeepers look very evil in these depictions)&lt;br /&gt;
&lt;br /&gt;
Bee honey.&lt;br /&gt;
 :&lt;br /&gt;
Our honey is being brazenly stolen&lt;br /&gt;
on a massive scale!&lt;br /&gt;
 :&lt;br /&gt;
This is worse than anything bears&lt;br /&gt;
have done! I intend to do something.&lt;br /&gt;
(Flash forward in time and Barry is showing these pictures to his parents)&lt;br /&gt;
JANET:&lt;br /&gt;
Oh, Barry, stop.&lt;br /&gt;
MARTIN:&lt;br /&gt;
Who told you humans are taking&lt;br /&gt;
our honey? That's a rumor.&lt;br /&gt;
BARRY:&lt;br /&gt;
Do these look like rumors?&lt;br /&gt;
(Holds up the pictures)&lt;br /&gt;
UNCLE CARL:&lt;br /&gt;
That's a conspiracy theory.&lt;br /&gt;
These are obviously doctored photos.&lt;br /&gt;
JANET:&lt;br /&gt;
How did you get mixed up in this?&lt;br /&gt;
ADAM:&lt;br /&gt;
He's been talking to humans.&lt;br /&gt;
JANET:&lt;br /&gt;
- What?&lt;br /&gt;
MARTIN:&lt;br /&gt;
- Talking to humans?!&lt;br /&gt;
ADAM:&lt;br /&gt;
He has a human girlfriend.&lt;br /&gt;
And they make out!&lt;br /&gt;
JANET:&lt;br /&gt;
Make out? Barry!&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
We do not.&lt;br /&gt;
ADAM:&lt;br /&gt;
- You wish you could.&lt;br /&gt;
MARTIN:&lt;br /&gt;
- Whose side are you on?&lt;br /&gt;
BARRY:&lt;br /&gt;
The bees!&lt;br /&gt;
UNCLE CARL:&lt;br /&gt;
(He has been sitting in the back of the room this entire time)&lt;br /&gt;
I dated a cricket once in San Antonio.&lt;br /&gt;
Those crazy legs kept me up all night.&lt;br /&gt;
JANET:&lt;br /&gt;
Barry, this is what you want&lt;br /&gt;
to do with your life?&lt;br /&gt;
BARRY:&lt;br /&gt;
I want to do it for all our lives.&lt;br /&gt;
Nobody works harder than bees!&lt;br /&gt;
 :&lt;br /&gt;
Dad, I remember you&lt;br /&gt;
coming home so overworked&lt;br /&gt;
 :&lt;br /&gt;
your hands were still stirring.&lt;br /&gt;
You couldn't stop.&lt;br /&gt;
JANET:&lt;br /&gt;
I remember that.&lt;br /&gt;
BARRY:&lt;br /&gt;
What right do they have to our honey?&lt;br /&gt;
 :&lt;br /&gt;
We live on two cups a year. They put it&lt;br /&gt;
in lip balm for no reason whatsoever!&lt;br /&gt;
&lt;br /&gt;
ADAM:&lt;br /&gt;
Even if it's true, what can one bee do?&lt;br /&gt;
BARRY:&lt;br /&gt;
Sting them where it really hurts.&lt;br /&gt;
MARTIN:&lt;br /&gt;
In the face! The eye!&lt;br /&gt;
 :&lt;br /&gt;
- That would hurt.&lt;br /&gt;
BARRY:&lt;br /&gt;
- No.&lt;br /&gt;
MARTIN:&lt;br /&gt;
Up the nose? That's a killer.&lt;br /&gt;
BARRY:&lt;br /&gt;
There's only one place you can sting&lt;br /&gt;
the humans, one place where it matters.&lt;br /&gt;
(Flash forward a bit in time and we are watching the Bee News)&lt;br /&gt;
BEE NEWS NARRATOR:&lt;br /&gt;
Hive at Five, the hive's only&lt;br /&gt;
full-hour action news source.&lt;br /&gt;
BEE PROTESTOR:&lt;br /&gt;
No more bee beards!&lt;br /&gt;
BEE NEWS NARRATOR:&lt;br /&gt;
With Bob Bumble at the anchor desk.&lt;br /&gt;
 :&lt;br /&gt;
Weather with Storm Stinger.&lt;br /&gt;
 :&lt;br /&gt;
Sports with Buzz Larvi.&lt;br /&gt;
 :&lt;br /&gt;
And Jeanette Chung.&lt;br /&gt;
BOB BUMBLE:&lt;br /&gt;
- Good evening. I'm Bob Bumble.&lt;br /&gt;
JEANETTE CHUNG:&lt;br /&gt;
&lt;br /&gt;
- And I'm Jeanette Chung.&lt;br /&gt;
BOB BUMBLE:&lt;br /&gt;
A tri-county bee, Barry Benson,&lt;br /&gt;
 :&lt;br /&gt;
intends to sue the human race&lt;br /&gt;
for stealing our honey,&lt;br /&gt;
 :&lt;br /&gt;
packaging it and profiting&lt;br /&gt;
from it illegally!&lt;br /&gt;
JEANETTE CHUNG:&lt;br /&gt;
Tomorrow night on Bee Larry King,&lt;br /&gt;
 :&lt;br /&gt;
we'll have three former queens here in&lt;br /&gt;
our studio, discussing their new book,&lt;br /&gt;
 :&lt;br /&gt;
Classy Ladies,&lt;br /&gt;
out this week on Hexagon.&lt;br /&gt;
(The scene changes to an interview on the news with Bee version of Larry&lt;br /&gt;
King and Barry)&lt;br /&gt;
BEE LARRY KING:&lt;br /&gt;
Tonight we're talking to Barry Benson.&lt;br /&gt;
 :&lt;br /&gt;
Did you ever think, &amp;quot;I'm a kid&lt;br /&gt;
from the hive. I can't do this&amp;quot;?&lt;br /&gt;
BARRY:&lt;br /&gt;
Bees have never been afraid&lt;br /&gt;
to change the world.&lt;br /&gt;
 :&lt;br /&gt;
What about Bee Columbus?&lt;br /&gt;
Bee Gandhi? Bejesus?&lt;br /&gt;
BEE LARRY KING:&lt;br /&gt;
Where I'm from, we'd never sue humans.&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
We were thinking&lt;br /&gt;
of stickball or candy stores.&lt;br /&gt;
BARRY:&lt;br /&gt;
How old are you?&lt;br /&gt;
BEE LARRY KING:&lt;br /&gt;
The bee community&lt;br /&gt;
is supporting you in this case,&lt;br /&gt;
 :&lt;br /&gt;
which will be the trial&lt;br /&gt;
of the bee century.&lt;br /&gt;
BARRY:&lt;br /&gt;
You know, they have a Larry King&lt;br /&gt;
in the human world too.&lt;br /&gt;
BEE LARRY KING:&lt;br /&gt;
It's a common name. Next week...&lt;br /&gt;
BARRY:&lt;br /&gt;
He looks like you and has a show&lt;br /&gt;
and suspenders and colored dots...&lt;br /&gt;
BEE LARRY KING:&lt;br /&gt;
Next week...&lt;br /&gt;
BARRY:&lt;br /&gt;
Glasses, quotes on the bottom from the&lt;br /&gt;
guest even though you just heard 'em.&lt;br /&gt;
BEE LARRY KING:&lt;br /&gt;
Bear Week next week!&lt;br /&gt;
They're scary, hairy and here, live.&lt;br /&gt;
(Bee Larry King gets annoyed and flies away offscreen)&lt;br /&gt;
BARRY:&lt;br /&gt;
Always leans forward, pointy shoulders,&lt;br /&gt;
squinty eyes, very Jewish.&lt;br /&gt;
(Flash forward in time. We see Vanessa enter and Ken enters behind her.&lt;br /&gt;
They are arguing)&lt;br /&gt;
&lt;br /&gt;
KEN:&lt;br /&gt;
In tennis, you attack&lt;br /&gt;
at the point of weakness!&lt;br /&gt;
VANESSA:&lt;br /&gt;
It was my grandmother, Ken. She's 81.&lt;br /&gt;
KEN==&lt;br /&gt;
Honey, her backhand's a joke!&lt;br /&gt;
I'm not gonna take advantage of that?&lt;br /&gt;
BARRY:&lt;br /&gt;
(To Ken)&lt;br /&gt;
Quiet, please.&lt;br /&gt;
Actual work going on here.&lt;br /&gt;
KEN:&lt;br /&gt;
(Pointing at Barry)&lt;br /&gt;
- Is that that same bee?&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Yes, it is!&lt;br /&gt;
 :&lt;br /&gt;
I'm helping him sue the human race.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Hello.&lt;br /&gt;
KEN:&lt;br /&gt;
- Hello, bee.&lt;br /&gt;
VANESSA:&lt;br /&gt;
This is Ken.&lt;br /&gt;
BARRY:&lt;br /&gt;
(Recalling the &amp;quot;Winter Boots&amp;quot; incident earlier)&lt;br /&gt;
Yeah, I remember you. Timberland, size&lt;br /&gt;
ten and a half. Vibram sole, I believe.&lt;br /&gt;
KEN:&lt;br /&gt;
(To Vanessa)&lt;br /&gt;
Why does he talk again?&lt;br /&gt;
VANESSA:&lt;br /&gt;
&lt;br /&gt;
Listen, you better go&lt;br /&gt;
'cause we're really busy working.&lt;br /&gt;
KEN:&lt;br /&gt;
But it's our yogurt night!&lt;br /&gt;
VANESSA:&lt;br /&gt;
(Holding door open for Ken)&lt;br /&gt;
Bye-bye.&lt;br /&gt;
KEN:&lt;br /&gt;
(Yelling)&lt;br /&gt;
Why is yogurt night so difficult?!&lt;br /&gt;
(Ken leaves and Vanessa walks over to Barry. His workplace is a mess)&lt;br /&gt;
VANESSA:&lt;br /&gt;
You poor thing.&lt;br /&gt;
You two have been at this for hours!&lt;br /&gt;
BARRY:&lt;br /&gt;
Yes, and Adam here&lt;br /&gt;
has been a huge help.&lt;br /&gt;
ADAM:&lt;br /&gt;
- Frosting...&lt;br /&gt;
- How many sugars?&lt;br /&gt;
 ==BARRY==&lt;br /&gt;
Just one. I try not&lt;br /&gt;
to use the competition.&lt;br /&gt;
 :&lt;br /&gt;
So why are you helping me?&lt;br /&gt;
VANESSA:&lt;br /&gt;
Bees have good qualities.&lt;br /&gt;
 :&lt;br /&gt;
And it takes my mind off the shop.&lt;br /&gt;
 :&lt;br /&gt;
Instead of flowers, people&lt;br /&gt;
are giving balloon bouquets now.&lt;br /&gt;
BARRY:&lt;br /&gt;
&lt;br /&gt;
Those are great, if you're three.&lt;br /&gt;
VANESSA:&lt;br /&gt;
And artificial flowers.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Oh, those just get me psychotic!&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Yeah, me too.&lt;br /&gt;
 :&lt;br /&gt;
BARRY:&lt;br /&gt;
Bent stingers, pointless pollination.&lt;br /&gt;
ADAM:&lt;br /&gt;
Bees must hate those fake things!&lt;br /&gt;
 :&lt;br /&gt;
Nothing worse&lt;br /&gt;
than a daffodil that's had work done.&lt;br /&gt;
 :&lt;br /&gt;
Maybe this could make up&lt;br /&gt;
for it a little bit.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- This lawsuit's a pretty big deal.&lt;br /&gt;
BARRY:&lt;br /&gt;
- I guess.&lt;br /&gt;
ADAM:&lt;br /&gt;
You sure you want to go through with it?&lt;br /&gt;
BARRY:&lt;br /&gt;
Am I sure? When I'm done with&lt;br /&gt;
the humans, they won't be able&lt;br /&gt;
 :&lt;br /&gt;
to say, &amp;quot;Honey, I'm home,&amp;quot;&lt;br /&gt;
without paying a royalty!&lt;br /&gt;
(Flash forward in time and we are watching the human news. The camera shows&lt;br /&gt;
&lt;br /&gt;
a crowd outside a courthouse)&lt;br /&gt;
NEWS REPORTER:&lt;br /&gt;
It's an incredible scene&lt;br /&gt;
here in downtown Manhattan,&lt;br /&gt;
 :&lt;br /&gt;
where the world anxiously waits,&lt;br /&gt;
because for the first time in history,&lt;br /&gt;
 :&lt;br /&gt;
we will hear for ourselves&lt;br /&gt;
if a honeybee can actually speak.&lt;br /&gt;
(We are no longer watching through a news camera)&lt;br /&gt;
ADAM:&lt;br /&gt;
What have we gotten into here, Barry?&lt;br /&gt;
BARRY:&lt;br /&gt;
It's pretty big, isn't it?&lt;br /&gt;
ADAM==&lt;br /&gt;
(Looking at the hundreds of people around the courthouse)&lt;br /&gt;
I can't believe how many humans&lt;br /&gt;
don't work during the day.&lt;br /&gt;
BARRY:&lt;br /&gt;
You think billion-dollar multinational&lt;br /&gt;
food companies have good lawyers?&lt;br /&gt;
SECURITY GUARD:&lt;br /&gt;
Everybody needs to stay&lt;br /&gt;
behind the barricade.&lt;br /&gt;
(A limousine drives up and a fat man,Layton Montgomery, a honey industry&lt;br /&gt;
owner gets out and walks past Barry)&lt;br /&gt;
ADAM:&lt;br /&gt;
- What's the matter?&lt;br /&gt;
BARRY:&lt;br /&gt;
- I don't know, I just got a chill.&lt;br /&gt;
(Fast forward in time and everyone is in the court)&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
Well, if it isn't the bee team.&lt;br /&gt;
&lt;br /&gt;
(To Honey Industry lawyers)&lt;br /&gt;
You boys work on this?&lt;br /&gt;
MAN:&lt;br /&gt;
All rise! The Honorable&lt;br /&gt;
Judge Bumbleton presiding.&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
All right. Case number 4475,&lt;br /&gt;
 :&lt;br /&gt;
Superior Court of New York,&lt;br /&gt;
Barry Bee Benson v. the Honey Industry&lt;br /&gt;
 :&lt;br /&gt;
is now in session.&lt;br /&gt;
 :&lt;br /&gt;
Mr. Montgomery, you're representing&lt;br /&gt;
the five food companies collectively?&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
A privilege.&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
Mr. Benson... you're representing&lt;br /&gt;
all the bees of the world?&lt;br /&gt;
(Everyone looks closely, they are waiting to see if a Bee can really talk)&lt;br /&gt;
(Barry makes several buzzing sounds to sound like a Bee)&lt;br /&gt;
BARRY:&lt;br /&gt;
I'm kidding. Yes, Your Honor,&lt;br /&gt;
we're ready to proceed.&lt;br /&gt;
JUDGE BUMBLBETON:&lt;br /&gt;
Mr. Montgomery,&lt;br /&gt;
your opening statement, please.&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
Ladies and gentlemen of the jury,&lt;br /&gt;
 :&lt;br /&gt;
my grandmother was a simple woman.&lt;br /&gt;
 :&lt;br /&gt;
&lt;br /&gt;
Born on a farm, she believed&lt;br /&gt;
it was man's divine right&lt;br /&gt;
 :&lt;br /&gt;
to benefit from the bounty&lt;br /&gt;
of nature God put before us.&lt;br /&gt;
 :&lt;br /&gt;
If we lived in the topsy-turvy world&lt;br /&gt;
Mr. Benson imagines,&lt;br /&gt;
 :&lt;br /&gt;
just think of what would it mean.&lt;br /&gt;
 :&lt;br /&gt;
I would have to negotiate&lt;br /&gt;
with the silkworm&lt;br /&gt;
 :&lt;br /&gt;
for the elastic in my britches!&lt;br /&gt;
 :&lt;br /&gt;
Talking bee!&lt;br /&gt;
(Montgomery walks over and looks closely at Barry)&lt;br /&gt;
 :&lt;br /&gt;
How do we know this isn't some sort of&lt;br /&gt;
 :&lt;br /&gt;
holographic motion-picture-capture&lt;br /&gt;
Hollywood wizardry?&lt;br /&gt;
 :&lt;br /&gt;
They could be using laser beams!&lt;br /&gt;
 :&lt;br /&gt;
Robotics! Ventriloquism!&lt;br /&gt;
Cloning! For all we know,&lt;br /&gt;
 :&lt;br /&gt;
he could be on steroids!&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
Mr. Benson?&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
Ladies and gentlemen,&lt;br /&gt;
there's no trickery here.&lt;br /&gt;
 :&lt;br /&gt;
I'm just an ordinary bee.&lt;br /&gt;
Honey's pretty important to me.&lt;br /&gt;
 :&lt;br /&gt;
It's important to all bees.&lt;br /&gt;
We invented it!&lt;br /&gt;
 :&lt;br /&gt;
We make it. And we protect it&lt;br /&gt;
with our lives.&lt;br /&gt;
 :&lt;br /&gt;
Unfortunately, there are&lt;br /&gt;
some people in this room&lt;br /&gt;
 :&lt;br /&gt;
who think they can take it from us&lt;br /&gt;
 :&lt;br /&gt;
'cause we're the little guys!&lt;br /&gt;
I'm hoping that, after this is all over,&lt;br /&gt;
 :&lt;br /&gt;
you'll see how, by taking our honey,&lt;br /&gt;
you not only take everything we have&lt;br /&gt;
 :&lt;br /&gt;
but everything we are!&lt;br /&gt;
JANET==&lt;br /&gt;
(To Martin)&lt;br /&gt;
I wish he'd dress like that&lt;br /&gt;
all the time. So nice!&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
Call your first witness.&lt;br /&gt;
BARRY:&lt;br /&gt;
So, Mr. Klauss Vanderhayden&lt;br /&gt;
&lt;br /&gt;
of Honey Farms, big company you have.&lt;br /&gt;
KLAUSS VANDERHAYDEN:&lt;br /&gt;
I suppose so.&lt;br /&gt;
BARRY:&lt;br /&gt;
I see you also own&lt;br /&gt;
Honeyburton and Honron!&lt;br /&gt;
KLAUSS:&lt;br /&gt;
Yes, they provide beekeepers&lt;br /&gt;
for our farms.&lt;br /&gt;
BARRY:&lt;br /&gt;
Beekeeper. I find that&lt;br /&gt;
to be a very disturbing term.&lt;br /&gt;
 :&lt;br /&gt;
I don't imagine you employ&lt;br /&gt;
any bee-free-ers, do you?&lt;br /&gt;
KLAUSS:&lt;br /&gt;
(Quietly)&lt;br /&gt;
- No.&lt;br /&gt;
BARRY:&lt;br /&gt;
- I couldn't hear you.&lt;br /&gt;
KLAUSS:&lt;br /&gt;
- No.&lt;br /&gt;
BARRY:&lt;br /&gt;
- No.&lt;br /&gt;
 :&lt;br /&gt;
Because you don't free bees.&lt;br /&gt;
You keep bees. Not only that,&lt;br /&gt;
 :&lt;br /&gt;
it seems you thought a bear would be&lt;br /&gt;
an appropriate image for a jar of honey.&lt;br /&gt;
KLAUSS:&lt;br /&gt;
They're very lovable creatures.&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
Yogi Bear, Fozzie Bear, Build-A-Bear.&lt;br /&gt;
BARRY:&lt;br /&gt;
You mean like this?&lt;br /&gt;
(The bear from Over The Hedge barges in through the back door and it is&lt;br /&gt;
roaring and standing on its hind legs. It is thrashing its claws and people&lt;br /&gt;
are screaming. It is being held back by a guard who has the bear on a&lt;br /&gt;
chain)&lt;br /&gt;
 :&lt;br /&gt;
(Pointing to the roaring bear)&lt;br /&gt;
Bears kill bees!&lt;br /&gt;
 :&lt;br /&gt;
How'd you like his head crashing&lt;br /&gt;
through your living room?!&lt;br /&gt;
 :&lt;br /&gt;
Biting into your couch!&lt;br /&gt;
Spitting out your throw pillows!&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
OK, that's enough. Take him away.&lt;br /&gt;
(The bear stops roaring and thrashing and walks out)&lt;br /&gt;
BARRY:&lt;br /&gt;
So, Mr. Sting, thank you for being here.&lt;br /&gt;
Your name intrigues me.&lt;br /&gt;
 :&lt;br /&gt;
- Where have I heard it before?&lt;br /&gt;
MR. STING:&lt;br /&gt;
- I was with a band called The Police.&lt;br /&gt;
BARRY:&lt;br /&gt;
But you've never been&lt;br /&gt;
a police officer, have you?&lt;br /&gt;
STING:&lt;br /&gt;
No, I haven't.&lt;br /&gt;
BARRY:&lt;br /&gt;
&lt;br /&gt;
No, you haven't. And so here&lt;br /&gt;
we have yet another example&lt;br /&gt;
 :&lt;br /&gt;
of bee culture casually&lt;br /&gt;
stolen by a human&lt;br /&gt;
 :&lt;br /&gt;
for nothing more than&lt;br /&gt;
a prance-about stage name.&lt;br /&gt;
STING:&lt;br /&gt;
Oh, please.&lt;br /&gt;
BARRY:&lt;br /&gt;
Have you ever been stung, Mr. Sting?&lt;br /&gt;
 :&lt;br /&gt;
Because I'm feeling&lt;br /&gt;
a little stung, Sting.&lt;br /&gt;
 :&lt;br /&gt;
Or should I say... Mr. Gordon M. Sumner!&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
That's not his real name?! You idiots!&lt;br /&gt;
BARRY:&lt;br /&gt;
Mr. Liotta, first,&lt;br /&gt;
belated congratulations on&lt;br /&gt;
 :&lt;br /&gt;
your Emmy win for a guest spot&lt;br /&gt;
on ER in 2005.&lt;br /&gt;
RAY LIOTTA:&lt;br /&gt;
Thank you. Thank you.&lt;br /&gt;
BARRY:&lt;br /&gt;
I see from your resume&lt;br /&gt;
that you're devilishly handsome&lt;br /&gt;
 :&lt;br /&gt;
with a churning inner turmoil&lt;br /&gt;
&lt;br /&gt;
that's ready to blow.&lt;br /&gt;
RAY LIOTTA:&lt;br /&gt;
I enjoy what I do. Is that a crime?&lt;br /&gt;
BARRY:&lt;br /&gt;
Not yet it isn't. But is this&lt;br /&gt;
what it's come to for you?&lt;br /&gt;
 :&lt;br /&gt;
Exploiting tiny, helpless bees&lt;br /&gt;
so you don't&lt;br /&gt;
 :&lt;br /&gt;
have to rehearse&lt;br /&gt;
your part and learn your lines, sir?&lt;br /&gt;
RAY LIOTTA:&lt;br /&gt;
Watch it, Benson!&lt;br /&gt;
I could blow right now!&lt;br /&gt;
BARRY:&lt;br /&gt;
This isn't a goodfella.&lt;br /&gt;
This is a badfella!&lt;br /&gt;
(Ray Liotta looses it and tries to grab Barry)&lt;br /&gt;
RAY LIOTTA:&lt;br /&gt;
Why doesn't someone just step on&lt;br /&gt;
this creep, and we can all go home?!&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
- Order in this court!&lt;br /&gt;
RAY LIOTTA:&lt;br /&gt;
- You're all thinking it!&lt;br /&gt;
(Judge Bumbleton starts banging her gavel)&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
Order! Order, I say!&lt;br /&gt;
RAY LIOTTA:&lt;br /&gt;
- Say it!&lt;br /&gt;
MAN:&lt;br /&gt;
&lt;br /&gt;
- Mr. Liotta, please sit down!&lt;br /&gt;
(We see a montage of magazines which feature the court case)&lt;br /&gt;
(Flash forward in time and Barry is back home with Vanessa)&lt;br /&gt;
BARRY:&lt;br /&gt;
I think it was awfully nice&lt;br /&gt;
of that bear to pitch in like that.&lt;br /&gt;
VANESSA:&lt;br /&gt;
I think the jury's on our side.&lt;br /&gt;
BARRY:&lt;br /&gt;
Are we doing everything right,you know, legally?&lt;br /&gt;
VANESSA:&lt;br /&gt;
I'm a florist.&lt;br /&gt;
BARRY:&lt;br /&gt;
Right. Well, here's to a great team.&lt;br /&gt;
VANESSA:&lt;br /&gt;
To a great team!&lt;br /&gt;
(Ken walks in from work. He sees Barry and he looks upset when he sees&lt;br /&gt;
Barry clinking his glass with Vanessa)&lt;br /&gt;
KEN:&lt;br /&gt;
Well, hello.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Oh, Ken!&lt;br /&gt;
BARRY:&lt;br /&gt;
- Hello!&lt;br /&gt;
VANESSA:&lt;br /&gt;
I didn't think you were coming.&lt;br /&gt;
 :&lt;br /&gt;
No, I was just late.&lt;br /&gt;
I tried to call, but...&lt;br /&gt;
(Ken holds up his phone and flips it open. The phone has no charge)&lt;br /&gt;
...the battery...&lt;br /&gt;
VANESSA:&lt;br /&gt;
&lt;br /&gt;
I didn't want all this to go to waste,&lt;br /&gt;
so I called Barry. Luckily, he was free.&lt;br /&gt;
KEN:&lt;br /&gt;
Oh, that was lucky.&lt;br /&gt;
(Ken sits down at the table across from Barry and Vanessa leaves the room)&lt;br /&gt;
VANESSA:&lt;br /&gt;
There's a little left.&lt;br /&gt;
I could heat it up.&lt;br /&gt;
KEN:&lt;br /&gt;
(Not taking his eyes off Barry)&lt;br /&gt;
Yeah, heat it up, sure, whatever.&lt;br /&gt;
BARRY:&lt;br /&gt;
So I hear you're quite a tennis player.&lt;br /&gt;
 :&lt;br /&gt;
I'm not much for the game myself.&lt;br /&gt;
The ball's a little grabby.&lt;br /&gt;
KEN:&lt;br /&gt;
That's where I usually sit.&lt;br /&gt;
Right...&lt;br /&gt;
(Points to where Barry is sitting)&lt;br /&gt;
there.&lt;br /&gt;
VANESSA:&lt;br /&gt;
(Calling from other room)&lt;br /&gt;
Ken, Barry was looking at your resume,&lt;br /&gt;
 :&lt;br /&gt;
and he agreed with me that eating with&lt;br /&gt;
chopsticks isn't really a special skill.&lt;br /&gt;
KEN:&lt;br /&gt;
(To Barry)&lt;br /&gt;
You think I don't see what you're doing?&lt;br /&gt;
BARRY:&lt;br /&gt;
I know how hard it is to find&lt;br /&gt;
the right job. We have that in common.&lt;br /&gt;
&lt;br /&gt;
KEN:&lt;br /&gt;
Do we?&lt;br /&gt;
BARRY:&lt;br /&gt;
Bees have 100 percent employment,&lt;br /&gt;
but we do jobs like taking the crud out.&lt;br /&gt;
KEN:&lt;br /&gt;
(Menacingly)&lt;br /&gt;
That's just what&lt;br /&gt;
I was thinking about doing.&lt;br /&gt;
(Ken reaches for a fork on the table but knocks if on the floor. He goes to&lt;br /&gt;
pick it up)&lt;br /&gt;
VANESSA:&lt;br /&gt;
Ken, I let Barry borrow your razor&lt;br /&gt;
for his fuzz. I hope that was all right.&lt;br /&gt;
(Ken quickly rises back up after hearing this but hits his head on the&lt;br /&gt;
table and yells)&lt;br /&gt;
BARRY:&lt;br /&gt;
I'm going to drain the old stinger.&lt;br /&gt;
KEN:&lt;br /&gt;
Yeah, you do that.&lt;br /&gt;
(Barry flies past Ken to get to the bathroom and Ken freaks out, splashing&lt;br /&gt;
some of the wine he was using to cool his head in his eyes. He yells in&lt;br /&gt;
anger)&lt;br /&gt;
(Barry looks at the magazines featuring his victories in court)&lt;br /&gt;
BARRY:&lt;br /&gt;
Look at that.&lt;br /&gt;
(Barry flies into the bathroom)&lt;br /&gt;
(He puts his hand on his head but this makes hurts him and makes him even&lt;br /&gt;
madder. He yells again)&lt;br /&gt;
(Barry is washing his hands in the sink but then Ken walks in)&lt;br /&gt;
KEN:&lt;br /&gt;
You know, you know I've just about had it&lt;br /&gt;
(Closes bathroom door behind him)&lt;br /&gt;
with your little mind games.&lt;br /&gt;
(Ken is menacingly rolling up a magazine)&lt;br /&gt;
BARRY:&lt;br /&gt;
&lt;br /&gt;
(Backing away)&lt;br /&gt;
- What's that?&lt;br /&gt;
KEN:&lt;br /&gt;
- Italian Vogue.&lt;br /&gt;
BARRY:&lt;br /&gt;
Mamma mia, that's a lot of pages.&lt;br /&gt;
KEN:&lt;br /&gt;
It's a lot of ads.&lt;br /&gt;
BARRY:&lt;br /&gt;
Remember what Van said, why is&lt;br /&gt;
your life more valuable than mine?&lt;br /&gt;
KEN:&lt;br /&gt;
That's funny, I just can't seem to recall that!&lt;br /&gt;
(Ken smashes everything off the sink with the magazine and Barry narrowly&lt;br /&gt;
escapes)&lt;br /&gt;
(Ken follows Barry around and tries to hit him with the magazine but he&lt;br /&gt;
keeps missing)&lt;br /&gt;
(Ken gets a spray bottle)&lt;br /&gt;
 :&lt;br /&gt;
I think something stinks in here!&lt;br /&gt;
BARRY:&lt;br /&gt;
(Enjoying the spray)&lt;br /&gt;
I love the smell of flowers.&lt;br /&gt;
(Ken holds a lighter in front of the spray bottle)&lt;br /&gt;
KEN:&lt;br /&gt;
How do you like the smell of flames?!&lt;br /&gt;
BARRY:&lt;br /&gt;
Not as much.&lt;br /&gt;
(Ken fires his make-shift flamethrower but misses Barry, burning the&lt;br /&gt;
bathroom. He torches the whole room but looses his footing and falls into&lt;br /&gt;
the bathtub. After getting hit in the head by falling objects 3 times he&lt;br /&gt;
picks up the shower head, revealing a Water bug hiding under it)&lt;br /&gt;
WATER BUG:&lt;br /&gt;
Water bug! Not taking sides!&lt;br /&gt;
&lt;br /&gt;
(Barry gets up out of a pile of bathroom supplies and he is wearing a&lt;br /&gt;
chapstick hat)&lt;br /&gt;
BARRY:&lt;br /&gt;
Ken, I'm wearing a Chapstick hat!&lt;br /&gt;
This is pathetic!&lt;br /&gt;
(Ken switches the shower head to lethal)&lt;br /&gt;
KEN:&lt;br /&gt;
I've got issues!&lt;br /&gt;
(Ken sprays Barry with the shower head and he crash lands into the toilet)&lt;br /&gt;
(Ken menacingly looks down into the toilet at Barry)&lt;br /&gt;
Well, well, well, a royal flush!&lt;br /&gt;
BARRY:&lt;br /&gt;
- You're bluffing.&lt;br /&gt;
KEN:&lt;br /&gt;
- Am I?&lt;br /&gt;
(flushes toilet)&lt;br /&gt;
(Barry grabs a chapstick from the toilet seat and uses it to surf in the&lt;br /&gt;
flushing toilet)&lt;br /&gt;
BARRY:&lt;br /&gt;
Surf's up, dude!&lt;br /&gt;
(Barry flies out of the toilet on the chapstick and sprays Ken's face with&lt;br /&gt;
the toilet water)&lt;br /&gt;
 :&lt;br /&gt;
EW,Poo water!&lt;br /&gt;
BARRY:&lt;br /&gt;
That bowl is gnarly.&lt;br /&gt;
KEN:&lt;br /&gt;
(Aiming a toilet cleaner at Barry)&lt;br /&gt;
Except for those dirty yellow rings!&lt;br /&gt;
(Barry cowers and covers his head and Vanessa runs in and takes the toilet&lt;br /&gt;
cleaner from Ken just before he hits Barry)&lt;br /&gt;
VANESSA:&lt;br /&gt;
Kenneth! What are you doing?!&lt;br /&gt;
KEN==&lt;br /&gt;
(Leaning towards Barry)&lt;br /&gt;
&lt;br /&gt;
You know, I don't even like honey!&lt;br /&gt;
I don't eat it!&lt;br /&gt;
VANESSA:&lt;br /&gt;
We need to talk!&lt;br /&gt;
(Vanessa pulls Ken out of the bathroom)&lt;br /&gt;
 :&lt;br /&gt;
He's just a little bee!&lt;br /&gt;
 :&lt;br /&gt;
And he happens to be&lt;br /&gt;
the nicest bee I've met in a long time!&lt;br /&gt;
KEN:&lt;br /&gt;
Long time? What are you talking about?!&lt;br /&gt;
Are there other bugs in your life?&lt;br /&gt;
VANESSA:&lt;br /&gt;
No, but there are other things bugging&lt;br /&gt;
me in life. And you're one of them!&lt;br /&gt;
KEN:&lt;br /&gt;
Fine! Talking bees, no yogurt night...&lt;br /&gt;
 :&lt;br /&gt;
My nerves are fried from riding&lt;br /&gt;
on this emotional roller coaster!&lt;br /&gt;
VANESSA:&lt;br /&gt;
Goodbye, Ken.&lt;br /&gt;
(Ken huffs and walks out and slams the door. But suddenly he walks back in&lt;br /&gt;
and stares at Barry)&lt;br /&gt;
 :&lt;br /&gt;
And for your information,&lt;br /&gt;
I prefer sugar-free, artificial&lt;br /&gt;
sweeteners MADE BY MAN!&lt;br /&gt;
(Ken leaves again and Vanessa leans in towards Barry)&lt;br /&gt;
VANESSA:&lt;br /&gt;
I'm sorry about all that.&lt;br /&gt;
(Ken walks back in again)&lt;br /&gt;
&lt;br /&gt;
KEN:&lt;br /&gt;
I know it's got&lt;br /&gt;
an aftertaste! I LIKE IT!&lt;br /&gt;
(Ken leaves for the last time)&lt;br /&gt;
VANESSA:&lt;br /&gt;
I always felt there was some kind&lt;br /&gt;
of barrier between Ken and me.&lt;br /&gt;
 :&lt;br /&gt;
I couldn't overcome it.&lt;br /&gt;
Oh, well.&lt;br /&gt;
 :&lt;br /&gt;
Are you OK for the trial?&lt;br /&gt;
BARRY:&lt;br /&gt;
I believe Mr. Montgomery&lt;br /&gt;
is about out of ideas.&lt;br /&gt;
(Flash forward in time and Barry, Adam, and Vanessa are back in court)&lt;br /&gt;
MONTGOMERY--&lt;br /&gt;
We would like to call&lt;br /&gt;
Mr. Barry Benson Bee to the stand.&lt;br /&gt;
ADAM:&lt;br /&gt;
Good idea! You can really see why he's&lt;br /&gt;
considered one of the best lawyers...&lt;br /&gt;
(Barry stares at Adam)&lt;br /&gt;
...Yeah.&lt;br /&gt;
LAWYER:&lt;br /&gt;
Layton, you've&lt;br /&gt;
gotta weave some magic&lt;br /&gt;
with this jury,&lt;br /&gt;
or it's gonna be all over.&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
Don't worry. The only thing I have&lt;br /&gt;
to do to turn this jury around&lt;br /&gt;
 :&lt;br /&gt;
is to remind them&lt;br /&gt;
of what they don't like about bees.&lt;br /&gt;
(To lawyer)&lt;br /&gt;
&lt;br /&gt;
- You got the tweezers?&lt;br /&gt;
LAWYER:&lt;br /&gt;
- Are you allergic?&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
Only to losing, son. Only to losing.&lt;br /&gt;
 :&lt;br /&gt;
Mr. Benson Bee, I'll ask you&lt;br /&gt;
what I think we'd all like to know.&lt;br /&gt;
 :&lt;br /&gt;
What exactly is your relationship&lt;br /&gt;
(Points to Vanessa)&lt;br /&gt;
 :&lt;br /&gt;
to that woman?&lt;br /&gt;
BARRY:&lt;br /&gt;
We're friends.&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
- Good friends?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Yes.&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
How good? Do you live together?&lt;br /&gt;
ADAM:&lt;br /&gt;
Wait a minute...&lt;br /&gt;
 :&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
Are you her little...&lt;br /&gt;
 :&lt;br /&gt;
...bedbug?&lt;br /&gt;
(Adam's stinger starts vibrating. He is agitated)&lt;br /&gt;
I've seen a bee documentary or two.&lt;br /&gt;
From what I understand,&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
doesn't your queen give birth&lt;br /&gt;
to all the bee children?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Yeah, but...&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
(Pointing at Janet and Martin)&lt;br /&gt;
- So those aren't your real parents!&lt;br /&gt;
JANET:&lt;br /&gt;
- Oh, Barry...&lt;br /&gt;
BARRY:&lt;br /&gt;
- Yes, they are!&lt;br /&gt;
ADAM:&lt;br /&gt;
Hold me back!&lt;br /&gt;
(Vanessa tries to hold Adam back. He wants to sting Montgomery)&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
You're an illegitimate bee,&lt;br /&gt;
aren't you, Benson?&lt;br /&gt;
ADAM:&lt;br /&gt;
He's denouncing bees!&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
Don't y'all date your cousins?&lt;br /&gt;
(Montgomery leans over on the jury stand and stares at Adam)&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Objection!&lt;br /&gt;
(Vanessa raises her hand to object but Adam gets free. He flies straight at&lt;br /&gt;
Montgomery)&lt;br /&gt;
=ADAM:&lt;br /&gt;
- I'm going to pincushion this guy!&lt;br /&gt;
BARRY:&lt;br /&gt;
Adam, don't! It's what he wants!&lt;br /&gt;
(Adam stings Montgomery in the butt and he starts thrashing around)&lt;br /&gt;
&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
Oh, I'm hit!!&lt;br /&gt;
 :&lt;br /&gt;
Oh, lordy, I am hit!&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
(Banging gavel)&lt;br /&gt;
Order! Order!&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
(Overreacting)&lt;br /&gt;
The venom! The venom&lt;br /&gt;
is coursing through my veins!&lt;br /&gt;
 :&lt;br /&gt;
I have been felled&lt;br /&gt;
by a winged beast of destruction!&lt;br /&gt;
 :&lt;br /&gt;
You see? You can't treat them&lt;br /&gt;
like equals! They're striped savages!&lt;br /&gt;
 :&lt;br /&gt;
Stinging's the only thing&lt;br /&gt;
they know! It's their way!&lt;br /&gt;
BARRY:&lt;br /&gt;
- Adam, stay with me.&lt;br /&gt;
ADAM:&lt;br /&gt;
- I can't feel my legs.&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
(Overreacting and throwing his body around the room)&lt;br /&gt;
What angel of mercy&lt;br /&gt;
will come forward to suck the poison&lt;br /&gt;
 :&lt;br /&gt;
from my heaving buttocks?&lt;br /&gt;
JUDGE BUMLBETON:&lt;br /&gt;
I will have order in this court. Order!&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
Order, please!&lt;br /&gt;
(Flash forward in time and we see a human news reporter)&lt;br /&gt;
NEWS REPORTER:&lt;br /&gt;
The case of the honeybees&lt;br /&gt;
versus the human race&lt;br /&gt;
 :&lt;br /&gt;
took a pointed turn against the bees&lt;br /&gt;
 :&lt;br /&gt;
yesterday when one of their legal&lt;br /&gt;
team stung Layton T. Montgomery.&lt;br /&gt;
(Adam is laying in a hospital bed and Barry flies in to see him)&lt;br /&gt;
BARRY:&lt;br /&gt;
- Hey, buddy.&lt;br /&gt;
ADAM:&lt;br /&gt;
- Hey.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Is there much pain?&lt;br /&gt;
ADAM:&lt;br /&gt;
- Yeah.&lt;br /&gt;
 :&lt;br /&gt;
I...&lt;br /&gt;
 :&lt;br /&gt;
I blew the whole case, didn't I?&lt;br /&gt;
BARRY:&lt;br /&gt;
It doesn't matter. What matters is&lt;br /&gt;
you're alive. You could have died.&lt;br /&gt;
ADAM:&lt;br /&gt;
I'd be better off dead. Look at me.&lt;br /&gt;
(A small plastic sword is replaced as Adam's stinger)&lt;br /&gt;
They got it from the cafeteria&lt;br /&gt;
downstairs, in a tuna sandwich.&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
Look, there's&lt;br /&gt;
a little celery still on it.&lt;br /&gt;
(Flicks off the celery and sighs)&lt;br /&gt;
BARRY:&lt;br /&gt;
What was it like to sting someone?&lt;br /&gt;
ADAM:&lt;br /&gt;
I can't explain it. It was all...&lt;br /&gt;
 :&lt;br /&gt;
All adrenaline and then...&lt;br /&gt;
and then ecstasy!&lt;br /&gt;
BARRY:&lt;br /&gt;
...All right.&lt;br /&gt;
ADAM:&lt;br /&gt;
You think it was all a trap?&lt;br /&gt;
BARRY:&lt;br /&gt;
Of course. I'm sorry.&lt;br /&gt;
I flew us right into this.&lt;br /&gt;
 :&lt;br /&gt;
What were we thinking? Look at us. We're&lt;br /&gt;
just a couple of bugs in this world.&lt;br /&gt;
ADAM:&lt;br /&gt;
What will the humans do to us&lt;br /&gt;
if they win?&lt;br /&gt;
BARRY:&lt;br /&gt;
I don't know.&lt;br /&gt;
ADAM:&lt;br /&gt;
I hear they put the roaches in motels.&lt;br /&gt;
That doesn't sound so bad.&lt;br /&gt;
BARRY:&lt;br /&gt;
Adam, they check in,&lt;br /&gt;
but they don't check out!&lt;br /&gt;
&lt;br /&gt;
ADAM:&lt;br /&gt;
Oh, my.&lt;br /&gt;
(Coughs)&lt;br /&gt;
Could you get a nurse&lt;br /&gt;
to close that window?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Why?&lt;br /&gt;
ADAM:&lt;br /&gt;
- The smoke.&lt;br /&gt;
(We can see that two humans are smoking cigarettes outside)&lt;br /&gt;
 :&lt;br /&gt;
Bees don't smoke.&lt;br /&gt;
BARRY:&lt;br /&gt;
Right. Bees don't smoke.&lt;br /&gt;
 :&lt;br /&gt;
Bees don't smoke!&lt;br /&gt;
But some bees are smoking.&lt;br /&gt;
 :&lt;br /&gt;
That's it! That's our case!&lt;br /&gt;
ADAM:&lt;br /&gt;
It is? It's not over?&lt;br /&gt;
BARRY:&lt;br /&gt;
Get dressed. I've gotta go somewhere.&lt;br /&gt;
 :&lt;br /&gt;
Get back to the court and stall.&lt;br /&gt;
Stall any way you can.&lt;br /&gt;
(Flash forward in time and Adam is making a paper boat in the courtroom)&lt;br /&gt;
ADAM:&lt;br /&gt;
And assuming you've done step 29 correctly, you're ready for the tub!&lt;br /&gt;
(We see that the jury have each made their own paper boats after being&lt;br /&gt;
taught how by Adam. They all look confused)&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
&lt;br /&gt;
Mr. Flayman.&lt;br /&gt;
ADAM:&lt;br /&gt;
Yes? Yes, Your Honor!&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
Where is the rest of your team?&lt;br /&gt;
ADAM:&lt;br /&gt;
(Continues stalling)&lt;br /&gt;
Well, Your Honor, it's interesting.&lt;br /&gt;
 :&lt;br /&gt;
Bees are trained to fly haphazardly,&lt;br /&gt;
 :&lt;br /&gt;
and as a result,&lt;br /&gt;
we don't make very good time.&lt;br /&gt;
 :&lt;br /&gt;
I actually heard a funny story about...&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
Your Honor,&lt;br /&gt;
haven't these ridiculous bugs&lt;br /&gt;
 :&lt;br /&gt;
taken up enough&lt;br /&gt;
of this court's valuable time?&lt;br /&gt;
 :&lt;br /&gt;
How much longer will we allow&lt;br /&gt;
these absurd shenanigans to go on?&lt;br /&gt;
 :&lt;br /&gt;
They have presented no compelling&lt;br /&gt;
evidence to support their charges&lt;br /&gt;
 :&lt;br /&gt;
against my clients,&lt;br /&gt;
who run legitimate businesses.&lt;br /&gt;
 :&lt;br /&gt;
I move for a complete dismissal&lt;br /&gt;
&lt;br /&gt;
of this entire case!&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
Mr. Flayman, I'm afraid I'm going&lt;br /&gt;
 :&lt;br /&gt;
to have to consider&lt;br /&gt;
Mr. Montgomery's motion.&lt;br /&gt;
ADAM:&lt;br /&gt;
But you can't! We have a terrific case.&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
Where is your proof?&lt;br /&gt;
Where is the evidence?&lt;br /&gt;
 :&lt;br /&gt;
Show me the smoking gun!&lt;br /&gt;
BARRY:&lt;br /&gt;
(Barry flies in through the door)&lt;br /&gt;
Hold it, Your Honor!&lt;br /&gt;
You want a smoking gun?&lt;br /&gt;
 :&lt;br /&gt;
Here is your smoking gun.&lt;br /&gt;
(Vanessa walks in holding a bee smoker. She sets it down on the Judge's&lt;br /&gt;
podium)&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
What is that?&lt;br /&gt;
BARRY:&lt;br /&gt;
It's a bee smoker!&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
(Picks up smoker)&lt;br /&gt;
What, this?&lt;br /&gt;
This harmless little contraption?&lt;br /&gt;
 :&lt;br /&gt;
This couldn't hurt a fly,&lt;br /&gt;
let alone a bee.&lt;br /&gt;
(Montgomery accidentally fires it at the bees in the crowd and they faint&lt;br /&gt;
&lt;br /&gt;
and cough)&lt;br /&gt;
(Dozens of reporters start taking pictures of the suffering bees)&lt;br /&gt;
BARRY:&lt;br /&gt;
Look at what has happened&lt;br /&gt;
 :&lt;br /&gt;
to bees who have never been asked,&lt;br /&gt;
&amp;quot;Smoking or non?&amp;quot;&lt;br /&gt;
 :&lt;br /&gt;
Is this what nature intended for us?&lt;br /&gt;
 :&lt;br /&gt;
To be forcibly addicted&lt;br /&gt;
to smoke machines&lt;br /&gt;
 :&lt;br /&gt;
and man-made wooden slat work camps?&lt;br /&gt;
 :&lt;br /&gt;
Living out our lives as honey slaves&lt;br /&gt;
to the white man?&lt;br /&gt;
(Barry points to the honey industry owners. One of them is an African&lt;br /&gt;
American so he awkwardly separates himself from the others)&lt;br /&gt;
LAWYER:&lt;br /&gt;
- What are we gonna do?&lt;br /&gt;
- He's playing the species card.&lt;br /&gt;
BARRY:&lt;br /&gt;
Ladies and gentlemen, please,&lt;br /&gt;
free these bees!&lt;br /&gt;
ADAM AND VANESSA:&lt;br /&gt;
Free the bees! Free the bees!&lt;br /&gt;
BEES IN CROWD:&lt;br /&gt;
Free the bees!&lt;br /&gt;
HUMAN JURY:&lt;br /&gt;
Free the bees! Free the bees!&lt;br /&gt;
JUDGE BUMBLETON:&lt;br /&gt;
The court finds in favor of the bees!&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
Vanessa, we won!&lt;br /&gt;
VANESSA:&lt;br /&gt;
I knew you could do it! High-five!&lt;br /&gt;
(Vanessa hits Barry hard because her hand is too big)&lt;br /&gt;
 :&lt;br /&gt;
Sorry.&lt;br /&gt;
BARRY:&lt;br /&gt;
(Overjoyed)&lt;br /&gt;
I'm OK! You know what this means?&lt;br /&gt;
 :&lt;br /&gt;
All the honey&lt;br /&gt;
will finally belong to the bees.&lt;br /&gt;
 :&lt;br /&gt;
Now we won't have&lt;br /&gt;
to work so hard all the time.&lt;br /&gt;
MONTGOMERY:&lt;br /&gt;
This is an unholy perversion&lt;br /&gt;
of the balance of nature, Benson.&lt;br /&gt;
 :&lt;br /&gt;
You'll regret this.&lt;br /&gt;
(Montgomery leaves and Barry goes outside the courtroom. Several reporters&lt;br /&gt;
start asking Barry questions)&lt;br /&gt;
REPORTER 1#:&lt;br /&gt;
Barry, how much honey is out there?&lt;br /&gt;
BARRY:&lt;br /&gt;
All right. One at a time.&lt;br /&gt;
REPORTER 2#:&lt;br /&gt;
Barry, who are you wearing?&lt;br /&gt;
BARRY:&lt;br /&gt;
My sweater is Ralph Lauren,&lt;br /&gt;
and I have no pants.&lt;br /&gt;
&lt;br /&gt;
(Barry flies outside with the paparazzi and Adam and Vanessa stay back)&lt;br /&gt;
ADAM:&lt;br /&gt;
(To Vanessa)&lt;br /&gt;
- What if Montgomery's right?&lt;br /&gt;
Vanessa:&lt;br /&gt;
- What do you mean?&lt;br /&gt;
ADAM:&lt;br /&gt;
We've been living the bee way&lt;br /&gt;
a long time, 27 million years.&lt;br /&gt;
(Flash forward in time and Barry is talking to a man)&lt;br /&gt;
BUSINESS MAN:&lt;br /&gt;
Congratulations on your victory.&lt;br /&gt;
What will you demand as a settlement?&lt;br /&gt;
BARRY:&lt;br /&gt;
First, we'll demand a complete shutdown&lt;br /&gt;
of all bee work camps.&lt;br /&gt;
(As Barry is talking we see a montage of men putting &amp;quot;closed&amp;quot; tape over the&lt;br /&gt;
work camps and freeing the bees in the crappy apartments)&lt;br /&gt;
Then we want back the honey&lt;br /&gt;
that was ours to begin with,&lt;br /&gt;
 :&lt;br /&gt;
every last drop.&lt;br /&gt;
(Men in suits are pushing all the honey of the aisle and into carts)&lt;br /&gt;
We demand an end to the glorification&lt;br /&gt;
of the bear as anything more&lt;br /&gt;
(We see a statue of a bear-shaped honey container being pulled down by&lt;br /&gt;
bees)&lt;br /&gt;
than a filthy, smelly,&lt;br /&gt;
bad-breath stink machine.&lt;br /&gt;
 :&lt;br /&gt;
We're all aware&lt;br /&gt;
of what they do in the woods.&lt;br /&gt;
(We see Winnie the Pooh sharing his honey with Piglet in the cross-hairs of&lt;br /&gt;
a high-tech sniper rifle)&lt;br /&gt;
BARRY:&lt;br /&gt;
(Looking through binoculars)&lt;br /&gt;
&lt;br /&gt;
Wait for my signal.&lt;br /&gt;
 :&lt;br /&gt;
Take him out.&lt;br /&gt;
(Winnie gets hit by a tranquilizer dart and dramatically falls off the log&lt;br /&gt;
he was standing on, his tongue hanging out. Piglet looks at Pooh in fear&lt;br /&gt;
and the Sniper takes the honey.)&lt;br /&gt;
SNIPER:&lt;br /&gt;
He'll have nausea&lt;br /&gt;
for a few hours, then he'll be fine.&lt;br /&gt;
(Flash forward in time)&lt;br /&gt;
BARRY:&lt;br /&gt;
And we will no longer tolerate&lt;br /&gt;
bee-negative nicknames...&lt;br /&gt;
(Mr. Sting is sitting at home until he is taken out of his house by the men&lt;br /&gt;
in suits)&lt;br /&gt;
STING:&lt;br /&gt;
But it's just a prance-about stage name!&lt;br /&gt;
BARRY:&lt;br /&gt;
...unnecessary inclusion of honey&lt;br /&gt;
in bogus health products&lt;br /&gt;
 :&lt;br /&gt;
and la-dee-da human&lt;br /&gt;
tea-time snack garnishments.&lt;br /&gt;
(An old lady is mixing honey into her tea but suddenly men in suits smash&lt;br /&gt;
her face down on the table and take the honey)&lt;br /&gt;
OLD LADY:&lt;br /&gt;
Can't breathe.&lt;br /&gt;
(A honey truck pulls up to Barry's hive)&lt;br /&gt;
WORKER:&lt;br /&gt;
Bring it in, boys!&lt;br /&gt;
 :&lt;br /&gt;
Hold it right there! Good.&lt;br /&gt;
 :&lt;br /&gt;
Tap it.&lt;br /&gt;
&lt;br /&gt;
(Tons of honey is being pumped into the hive's storage)&lt;br /&gt;
BEE WORKER 1#:&lt;br /&gt;
(Honey overflows from the cup)&lt;br /&gt;
Mr. Buzzwell, we just passed three cups,&lt;br /&gt;
and there's gallons more coming!&lt;br /&gt;
 :&lt;br /&gt;
- I think we need to shut down!&lt;br /&gt;
=BEE WORKER #2=&lt;br /&gt;
- Shut down? We've never shut down.&lt;br /&gt;
 :&lt;br /&gt;
Shut down honey production!&lt;br /&gt;
DEAN BUZZWELL:&lt;br /&gt;
Stop making honey!&lt;br /&gt;
(The bees all leave their stations. Two bees run into a room and they put&lt;br /&gt;
the keys into a machine)&lt;br /&gt;
Turn your key, sir!&lt;br /&gt;
(Two worker bees dramatically turn their keys, which opens the button which&lt;br /&gt;
they press, shutting down the honey-making machines. This is the first time&lt;br /&gt;
this has ever happened)&lt;br /&gt;
BEE:&lt;br /&gt;
...What do we do now?&lt;br /&gt;
(Flash forward in time and a Bee is about to jump into a pool full of&lt;br /&gt;
honey)&lt;br /&gt;
Cannonball!&lt;br /&gt;
(The bee gets stuck in the honey and we get a short montage of Bees leaving&lt;br /&gt;
work)&lt;br /&gt;
(We see the Pollen Jocks flying but one of them gets a call on his antenna)&lt;br /&gt;
LOU LU DUVA:&lt;br /&gt;
(Through &amp;quot;phone&amp;quot;)&lt;br /&gt;
We're shutting honey production!&lt;br /&gt;
 :&lt;br /&gt;
Mission abort.&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
Aborting pollination and nectar detail.&lt;br /&gt;
Returning to base.&lt;br /&gt;
(The Pollen Jocks fly back to the hive)&lt;br /&gt;
&lt;br /&gt;
(We get a time lapse of Central Park slowly wilting away as the bees all&lt;br /&gt;
relax)&lt;br /&gt;
BARRY:&lt;br /&gt;
Adam, you wouldn't believe&lt;br /&gt;
how much honey was out there.&lt;br /&gt;
ADAM:&lt;br /&gt;
Oh, yeah?&lt;br /&gt;
BARRY:&lt;br /&gt;
What's going on? Where is everybody?&lt;br /&gt;
(The entire street is deserted)&lt;br /&gt;
 :&lt;br /&gt;
- Are they out celebrating?&lt;br /&gt;
ADAM:&lt;br /&gt;
- They're home.&lt;br /&gt;
 :&lt;br /&gt;
They don't know what to do.&lt;br /&gt;
Laying out, sleeping in.&lt;br /&gt;
 :&lt;br /&gt;
I heard your Uncle Carl was on his way&lt;br /&gt;
to San Antonio with a cricket.&lt;br /&gt;
BARRY:&lt;br /&gt;
At least we got our honey back.&lt;br /&gt;
ADAM:&lt;br /&gt;
Sometimes I think, so what if humans&lt;br /&gt;
liked our honey? Who wouldn't?&lt;br /&gt;
 :&lt;br /&gt;
It's the greatest thing in the world!&lt;br /&gt;
I was excited to be part of making it.&lt;br /&gt;
 :&lt;br /&gt;
This was my new desk. This was my&lt;br /&gt;
new job. I wanted to do it really well.&lt;br /&gt;
 :&lt;br /&gt;
&lt;br /&gt;
And now...&lt;br /&gt;
 :&lt;br /&gt;
Now I can't.&lt;br /&gt;
(Flash forward in time and Barry is talking to Vanessa)&lt;br /&gt;
BARRY:&lt;br /&gt;
I don't understand&lt;br /&gt;
why they're not happy.&lt;br /&gt;
 :&lt;br /&gt;
I thought their lives would be better!&lt;br /&gt;
 :&lt;br /&gt;
They're doing nothing. It's amazing.&lt;br /&gt;
Honey really changes people.&lt;br /&gt;
VANESSA:&lt;br /&gt;
You don't have any idea&lt;br /&gt;
what's going on, do you?&lt;br /&gt;
BARRY:&lt;br /&gt;
- What did you want to show me?&lt;br /&gt;
(Vanessa takes Barry to the rooftop where they first had coffee and points&lt;br /&gt;
to her store)&lt;br /&gt;
VANESSA:&lt;br /&gt;
- This.&lt;br /&gt;
(Points at her flowers. They are all grey and wilting)&lt;br /&gt;
BARRY:&lt;br /&gt;
What happened here?&lt;br /&gt;
VANESSA:&lt;br /&gt;
That is not the half of it.&lt;br /&gt;
(Small flash forward in time and Vanessa and Barry are on the roof of her&lt;br /&gt;
store and she points to Central Park)&lt;br /&gt;
(We see that Central Park is no longer green and colorful, rather it is&lt;br /&gt;
grey, brown, and dead-like. It is very depressing to look at)&lt;br /&gt;
BARRY:&lt;br /&gt;
Oh, no. Oh, my.&lt;br /&gt;
 :&lt;br /&gt;
&lt;br /&gt;
They're all wilting.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Doesn't look very good, does it?&lt;br /&gt;
BARRY:&lt;br /&gt;
No.&lt;br /&gt;
VANESSA:&lt;br /&gt;
And whose fault do you think that is?&lt;br /&gt;
BARRY:&lt;br /&gt;
You know, I'm gonna guess bees.&lt;br /&gt;
VANESSA==&lt;br /&gt;
(Staring at Barry)&lt;br /&gt;
Bees?&lt;br /&gt;
BARRY:&lt;br /&gt;
Specifically, me.&lt;br /&gt;
 :&lt;br /&gt;
I didn't think bees not needing to make&lt;br /&gt;
honey would affect all these things.&lt;br /&gt;
VANESSA:&lt;br /&gt;
It's not just flowers.&lt;br /&gt;
Fruits, vegetables, they all need bees.&lt;br /&gt;
BARRY:&lt;br /&gt;
That's our whole SAT test right there.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Take away produce, that affects&lt;br /&gt;
the entire animal kingdom.&lt;br /&gt;
 :&lt;br /&gt;
And then, of course...&lt;br /&gt;
BARRY:&lt;br /&gt;
The human species?&lt;br /&gt;
 :&lt;br /&gt;
So if there's no more pollination,&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
it could all just go south here,&lt;br /&gt;
couldn't it?&lt;br /&gt;
VANESSA:&lt;br /&gt;
I know this is also partly my fault.&lt;br /&gt;
BARRY:&lt;br /&gt;
How about a suicide pact?&lt;br /&gt;
VANESSA:&lt;br /&gt;
How do we do it?&lt;br /&gt;
BARRY:&lt;br /&gt;
- I'll sting you, you step on me.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- That just kills you twice.&lt;br /&gt;
BARRY:&lt;br /&gt;
Right, right.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Listen, Barry...&lt;br /&gt;
sorry, but I gotta get going.&lt;br /&gt;
(Vanessa leaves)&lt;br /&gt;
BARRY:&lt;br /&gt;
(To himself)&lt;br /&gt;
I had to open my mouth and talk.&lt;br /&gt;
 :&lt;br /&gt;
Vanessa?&lt;br /&gt;
 :&lt;br /&gt;
Vanessa? Why are you leaving?&lt;br /&gt;
Where are you going?&lt;br /&gt;
(Vanessa is getting into a taxi)&lt;br /&gt;
VANESSA:&lt;br /&gt;
To the final Tournament of Roses parade&lt;br /&gt;
in Pasadena.&lt;br /&gt;
 :&lt;br /&gt;
&lt;br /&gt;
They've moved it to this weekend&lt;br /&gt;
because all the flowers are dying.&lt;br /&gt;
 :&lt;br /&gt;
It's the last chance&lt;br /&gt;
I'll ever have to see it.&lt;br /&gt;
BARRY:&lt;br /&gt;
Vanessa, I just wanna say I'm sorry.&lt;br /&gt;
I never meant it to turn out like this.&lt;br /&gt;
VANESSA:&lt;br /&gt;
I know. Me neither.&lt;br /&gt;
(The taxi starts to drive away)&lt;br /&gt;
BARRY:&lt;br /&gt;
Tournament of Roses.&lt;br /&gt;
Roses can't do sports.&lt;br /&gt;
 :&lt;br /&gt;
Wait a minute. Roses. Roses?&lt;br /&gt;
 :&lt;br /&gt;
Roses!&lt;br /&gt;
 :&lt;br /&gt;
Vanessa!&lt;br /&gt;
(Barry flies after the Taxi)&lt;br /&gt;
VANESSA:&lt;br /&gt;
Roses?!&lt;br /&gt;
 :&lt;br /&gt;
Barry?&lt;br /&gt;
(Barry is flying outside the window of the taxi)&lt;br /&gt;
BARRY:&lt;br /&gt;
- Roses are flowers!&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Yes, they are.&lt;br /&gt;
BARRY:&lt;br /&gt;
Flowers, bees, pollen!&lt;br /&gt;
&lt;br /&gt;
VANESSA:&lt;br /&gt;
I know.&lt;br /&gt;
That's why this is the last parade.&lt;br /&gt;
BARRY:&lt;br /&gt;
Maybe not.&lt;br /&gt;
Could you ask him to slow down?&lt;br /&gt;
VANESSA:&lt;br /&gt;
Could you slow down?&lt;br /&gt;
(The taxi driver screeches to a stop and Barry keeps flying forward)&lt;br /&gt;
 :&lt;br /&gt;
Barry!&lt;br /&gt;
(Barry flies back to the window)&lt;br /&gt;
BARRY:&lt;br /&gt;
OK, I made a huge mistake.&lt;br /&gt;
This is a total disaster, all my fault.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Yes, it kind of is.&lt;br /&gt;
BARRY:&lt;br /&gt;
I've ruined the planet.&lt;br /&gt;
I wanted to help you&lt;br /&gt;
 :&lt;br /&gt;
with the flower shop.&lt;br /&gt;
I've made it worse.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Actually, it's completely closed down.&lt;br /&gt;
BARRY:&lt;br /&gt;
I thought maybe you were remodeling.&lt;br /&gt;
 :&lt;br /&gt;
But I have another idea, and it's&lt;br /&gt;
greater than my previous ideas combined.&lt;br /&gt;
VANESSA:&lt;br /&gt;
I don't want to hear it!&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
All right, they have the roses,&lt;br /&gt;
the roses have the pollen.&lt;br /&gt;
 :&lt;br /&gt;
I know every bee, plant&lt;br /&gt;
and flower bud in this park.&lt;br /&gt;
 :&lt;br /&gt;
All we gotta do is get what they've got&lt;br /&gt;
back here with what we've got.&lt;br /&gt;
 :&lt;br /&gt;
- Bees.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Park.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Pollen!&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Flowers.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Re-pollination!&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Across the nation!&lt;br /&gt;
 :&lt;br /&gt;
Tournament of Roses,&lt;br /&gt;
Pasadena, California.&lt;br /&gt;
 :&lt;br /&gt;
They've got nothing&lt;br /&gt;
but flowers, floats and cotton candy.&lt;br /&gt;
 :&lt;br /&gt;
Security will be tight.&lt;br /&gt;
BARRY:&lt;br /&gt;
I have an idea.&lt;br /&gt;
&lt;br /&gt;
(Flash forward in time. Vanessa is about to board a plane which has all the&lt;br /&gt;
Roses on board.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Vanessa Bloome, FTD.&lt;br /&gt;
(Holds out badge)&lt;br /&gt;
 :&lt;br /&gt;
Official floral business. It's real.&lt;br /&gt;
SECURITY GUARD:&lt;br /&gt;
Sorry, ma'am. Nice brooch.&lt;br /&gt;
=VANESSA==&lt;br /&gt;
Thank you. It was a gift.&lt;br /&gt;
(Barry is revealed to be hiding inside the brooch)&lt;br /&gt;
(Flash back in time and Barry and Vanessa are discussing their plan)&lt;br /&gt;
BARRY:&lt;br /&gt;
Once inside,&lt;br /&gt;
we just pick the right float.&lt;br /&gt;
VANESSA:&lt;br /&gt;
How about The Princess and the Pea?&lt;br /&gt;
 :&lt;br /&gt;
I could be the princess,&lt;br /&gt;
and you could be the pea!&lt;br /&gt;
BARRY:&lt;br /&gt;
Yes, I got it.&lt;br /&gt;
 :&lt;br /&gt;
- Where should I sit?&lt;br /&gt;
GUARD:&lt;br /&gt;
- What are you?&lt;br /&gt;
BARRY:&lt;br /&gt;
- I believe I'm the pea.&lt;br /&gt;
GUARD:&lt;br /&gt;
- The pea?&lt;br /&gt;
VANESSA:&lt;br /&gt;
&lt;br /&gt;
It goes under the mattresses.&lt;br /&gt;
GUARD:&lt;br /&gt;
- Not in this fairy tale, sweetheart.&lt;br /&gt;
- I'm getting the marshal.&lt;br /&gt;
VANESSA:&lt;br /&gt;
You do that!&lt;br /&gt;
This whole parade is a fiasco!&lt;br /&gt;
 :&lt;br /&gt;
Let's see what this baby'll do.&lt;br /&gt;
(Vanessa drives the float through traffic)&lt;br /&gt;
GUARD:&lt;br /&gt;
Hey, what are you doing?!&lt;br /&gt;
BARRY==&lt;br /&gt;
Then all we do&lt;br /&gt;
is blend in with traffic...&lt;br /&gt;
 :&lt;br /&gt;
...without arousing suspicion.&lt;br /&gt;
 :&lt;br /&gt;
Once at the airport,&lt;br /&gt;
there's no stopping us.&lt;br /&gt;
(Flash forward in time and Barry and Vanessa are about to get on a plane)&lt;br /&gt;
SECURITY GUARD:&lt;br /&gt;
Stop! Security.&lt;br /&gt;
 :&lt;br /&gt;
- You and your insect pack your float?&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Yes.&lt;br /&gt;
SECURITY GUARD:&lt;br /&gt;
Has it been&lt;br /&gt;
in your possession the entire time?&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Yes.&lt;br /&gt;
&lt;br /&gt;
SECURITY GUARD:&lt;br /&gt;
Would you remove your shoes?&lt;br /&gt;
(To Barry)&lt;br /&gt;
- Remove your stinger.&lt;br /&gt;
BARRY:&lt;br /&gt;
- It's part of me.&lt;br /&gt;
SECURITY GUARD:&lt;br /&gt;
I know. Just having some fun.&lt;br /&gt;
Enjoy your flight.&lt;br /&gt;
(Barry plotting with Vanessa)&lt;br /&gt;
BARRY:&lt;br /&gt;
Then if we're lucky, we'll have&lt;br /&gt;
just enough pollen to do the job.&lt;br /&gt;
(Flash forward in time and Barry and Vanessa are flying on the plane)&lt;br /&gt;
Can you believe how lucky we are? We&lt;br /&gt;
have just enough pollen to do the job!&lt;br /&gt;
VANESSA:&lt;br /&gt;
I think this is gonna work.&lt;br /&gt;
BARRY:&lt;br /&gt;
It's got to work.&lt;br /&gt;
CAPTAIN SCOTT:&lt;br /&gt;
(On intercom)&lt;br /&gt;
Attention, passengers,&lt;br /&gt;
this is Captain Scott.&lt;br /&gt;
 :&lt;br /&gt;
We have a bit of bad weather&lt;br /&gt;
in New York.&lt;br /&gt;
 :&lt;br /&gt;
It looks like we'll experience&lt;br /&gt;
a couple hours delay.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Barry, these are cut flowers&lt;br /&gt;
with no water. They'll never make it.&lt;br /&gt;
BARRY:&lt;br /&gt;
&lt;br /&gt;
I gotta get up there&lt;br /&gt;
and talk to them.&lt;br /&gt;
VANESSA==&lt;br /&gt;
Be careful.&lt;br /&gt;
(Barry flies right outside the cockpit door)&lt;br /&gt;
BARRY:&lt;br /&gt;
Can I get help&lt;br /&gt;
with the Sky Mall magazine?&lt;br /&gt;
I'd like to order the talking&lt;br /&gt;
inflatable nose and ear hair trimmer.&lt;br /&gt;
(The flight attendant opens the door and walks out and Barry flies into the&lt;br /&gt;
cockpit unseen)&lt;br /&gt;
BARRY:&lt;br /&gt;
Captain, I'm in a real situation.&lt;br /&gt;
CAPTAIN SCOTT:&lt;br /&gt;
- What'd you say, Hal?&lt;br /&gt;
CO-PILOT HAL:&lt;br /&gt;
- Nothing.&lt;br /&gt;
(Scott notices Barry and freaks out)&lt;br /&gt;
CAPTAIN SCOTT:&lt;br /&gt;
Bee!&lt;br /&gt;
BARRY:&lt;br /&gt;
No,no,no, Don't freak out! My entire species...&lt;br /&gt;
(Captain Scott gets out of his seat and tries to suck Barry into a handheld&lt;br /&gt;
vacuum)&lt;br /&gt;
HAL:&lt;br /&gt;
(To Scott)&lt;br /&gt;
What are you doing?&lt;br /&gt;
(Barry lands on Hals hair but Scott sees him. He tries to suck up Barry but&lt;br /&gt;
instead he sucks up Hals toupee)&lt;br /&gt;
CAPTAIN SCOTT:&lt;br /&gt;
Uh-oh.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Wait a minute! I'm an attorney!&lt;br /&gt;
&lt;br /&gt;
HAL:&lt;br /&gt;
(Hal doesn't know Barry is on his head)&lt;br /&gt;
- Who's an attorney?&lt;br /&gt;
CAPTAIN SCOTT:&lt;br /&gt;
Don't move.&lt;br /&gt;
(Scott hits Hal in the face with the vacuum in an attempt to hit Barry. Hal&lt;br /&gt;
is knocked out and he falls on the life raft button which launches an&lt;br /&gt;
infalatable boat into Scott, who gets knocked out and falls to the floor.&lt;br /&gt;
They are both uncounscious.)&lt;br /&gt;
BARRY:&lt;br /&gt;
(To himself)&lt;br /&gt;
Oh, Barry.&lt;br /&gt;
BARRY:&lt;br /&gt;
(On intercom, with a Southern accent)&lt;br /&gt;
Good afternoon, passengers.&lt;br /&gt;
This is your captain.&lt;br /&gt;
 :&lt;br /&gt;
Would a Miss Vanessa Bloome in 24B&lt;br /&gt;
please report to the cockpit?&lt;br /&gt;
(Vanessa looks confused)&lt;br /&gt;
(Normal accent)&lt;br /&gt;
...And please hurry!&lt;br /&gt;
(Vanessa opens the door and sees the life raft and the uncounscious pilots)&lt;br /&gt;
VANESSA:&lt;br /&gt;
What happened here?&lt;br /&gt;
BARRY:&lt;br /&gt;
I tried to talk to them, but&lt;br /&gt;
then there was a DustBuster,&lt;br /&gt;
a toupee, a life raft exploded.&lt;br /&gt;
 :&lt;br /&gt;
Now one's bald, one's in a boat,&lt;br /&gt;
and they're both unconscious!&lt;br /&gt;
VANESSA:&lt;br /&gt;
...Is that another bee joke?&lt;br /&gt;
BARRY:&lt;br /&gt;
&lt;br /&gt;
- No!&lt;br /&gt;
 :&lt;br /&gt;
No one's flying the plane!&lt;br /&gt;
BUD DITCHWATER:&lt;br /&gt;
(Through radio on plane)&lt;br /&gt;
This is JFK control tower, Flight 356.&lt;br /&gt;
What's your status?&lt;br /&gt;
VANESSA:&lt;br /&gt;
This is Vanessa Bloome.&lt;br /&gt;
I'm a florist from New York.&lt;br /&gt;
BUD:&lt;br /&gt;
Where's the pilot?&lt;br /&gt;
VANESSA:&lt;br /&gt;
He's unconscious,&lt;br /&gt;
and so is the copilot.&lt;br /&gt;
BUD:&lt;br /&gt;
Not good. Does anyone onboard&lt;br /&gt;
have flight experience?&lt;br /&gt;
BARRY:&lt;br /&gt;
As a matter of fact, there is.&lt;br /&gt;
BUD:&lt;br /&gt;
- Who's that?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Barry Benson.&lt;br /&gt;
BUD:&lt;br /&gt;
From the honey trial?! Oh, great.&lt;br /&gt;
BARRY:&lt;br /&gt;
Vanessa, this is nothing more&lt;br /&gt;
than a big metal bee.&lt;br /&gt;
 :&lt;br /&gt;
It's got giant wings, huge engines.&lt;br /&gt;
&lt;br /&gt;
VANESSA:&lt;br /&gt;
I can't fly a plane.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Why not? Isn't John Travolta a pilot?&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Yes.&lt;br /&gt;
BARRY:&lt;br /&gt;
How hard could it be?&lt;br /&gt;
(Vanessa sits down and flies for a little bit but we see lightning clouds&lt;br /&gt;
outside the window)&lt;br /&gt;
VANESSA:&lt;br /&gt;
Wait, Barry!&lt;br /&gt;
We're headed into some lightning.&lt;br /&gt;
(An ominous lightning storm looms in front of the plane)&lt;br /&gt;
(We are now watching the Bee News)&lt;br /&gt;
BOB BUMBLE:&lt;br /&gt;
This is Bob Bumble. We have some&lt;br /&gt;
late-breaking news from JFK Airport,&lt;br /&gt;
 :&lt;br /&gt;
where a suspenseful scene&lt;br /&gt;
is developing.&lt;br /&gt;
 :&lt;br /&gt;
Barry Benson,&lt;br /&gt;
fresh from his legal victory...&lt;br /&gt;
ADAM:&lt;br /&gt;
That's Barry!&lt;br /&gt;
BOB BUMBLE:&lt;br /&gt;
...is attempting to land a plane,&lt;br /&gt;
loaded with people, flowers&lt;br /&gt;
 :&lt;br /&gt;
and an incapacitated flight crew.&lt;br /&gt;
JANET, MARTIN, UNCLE CAR AND ADAM:&lt;br /&gt;
Flowers?!&lt;br /&gt;
(The scene switches to the human news)&lt;br /&gt;
&lt;br /&gt;
REPORTER:&lt;br /&gt;
(Talking with Bob Bumble)&lt;br /&gt;
We have a storm in the area&lt;br /&gt;
and two individuals at the controls&lt;br /&gt;
 :&lt;br /&gt;
with absolutely no flight experience.&lt;br /&gt;
BOB BUMBLE:&lt;br /&gt;
Just a minute.&lt;br /&gt;
There's a bee on that plane.&lt;br /&gt;
BUD:&lt;br /&gt;
I'm quite familiar with Mr. Benson&lt;br /&gt;
and his no-account compadres.&lt;br /&gt;
 :&lt;br /&gt;
They've done enough damage.&lt;br /&gt;
REPORTER:&lt;br /&gt;
But isn't he your only hope?&lt;br /&gt;
BUD:&lt;br /&gt;
Technically, a bee&lt;br /&gt;
shouldn't be able to fly at all.&lt;br /&gt;
 :&lt;br /&gt;
Their wings are too small...&lt;br /&gt;
BARRY:&lt;br /&gt;
(Through radio)&lt;br /&gt;
Haven't we heard this a million times?&lt;br /&gt;
 :&lt;br /&gt;
&amp;quot;The surface area of the wings&lt;br /&gt;
and body mass make no sense.&amp;quot;...&lt;br /&gt;
BOB BUMBLE:&lt;br /&gt;
- Get this on the air!&lt;br /&gt;
BEE:&lt;br /&gt;
- Got it.&lt;br /&gt;
&lt;br /&gt;
BEE NEWS CREW:&lt;br /&gt;
- Stand by.&lt;br /&gt;
BEE NEWS CREW:&lt;br /&gt;
- We're going live!&lt;br /&gt;
BARRY:&lt;br /&gt;
(Through radio on TV)&lt;br /&gt;
...The way we work may be a mystery to you.&lt;br /&gt;
 :&lt;br /&gt;
Making honey takes a lot of bees&lt;br /&gt;
doing a lot of small jobs.&lt;br /&gt;
 :&lt;br /&gt;
But let me tell you about a small job.&lt;br /&gt;
 :&lt;br /&gt;
If you do it well,&lt;br /&gt;
it makes a big difference.&lt;br /&gt;
 :&lt;br /&gt;
More than we realized.&lt;br /&gt;
To us, to everyone.&lt;br /&gt;
 :&lt;br /&gt;
That's why I want to get bees&lt;br /&gt;
back to working together.&lt;br /&gt;
 :&lt;br /&gt;
That's the bee way!&lt;br /&gt;
We're not made of Jell-O.&lt;br /&gt;
 :&lt;br /&gt;
We get behind a fellow.&lt;br /&gt;
 :&lt;br /&gt;
- Black and yellow!&lt;br /&gt;
BEES:&lt;br /&gt;
- Hello!&lt;br /&gt;
(The scene switches and Barry is teaching Vanessa how to fly)&lt;br /&gt;
BARRY:&lt;br /&gt;
&lt;br /&gt;
Left, right, down, hover.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Hover?&lt;br /&gt;
BARRY:&lt;br /&gt;
- Forget hover.&lt;br /&gt;
VANESSA:&lt;br /&gt;
This isn't so hard.&lt;br /&gt;
(Pretending to honk the horn)&lt;br /&gt;
Beep-beep! Beep-beep!&lt;br /&gt;
(A Lightning bolt hits the plane and autopilot turns off)&lt;br /&gt;
Barry, what happened?!&lt;br /&gt;
BARRY:&lt;br /&gt;
Wait, I think we were&lt;br /&gt;
on autopilot the whole time.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- That may have been helping me.&lt;br /&gt;
BARRY:&lt;br /&gt;
- And now we're not!&lt;br /&gt;
VANESSA:&lt;br /&gt;
So it turns out I cannot fly a plane.&lt;br /&gt;
(The plane plummets but we see Lou Lu Duva and the Pollen Jocks, along with&lt;br /&gt;
multiple other bees flying towards the plane)&lt;br /&gt;
Lou Lu DUva:&lt;br /&gt;
All of you, let's get&lt;br /&gt;
behind this fellow! Move it out!&lt;br /&gt;
 :&lt;br /&gt;
Move out!&lt;br /&gt;
(The scene switches back to Vanessa and Barry in the plane)&lt;br /&gt;
BARRY:&lt;br /&gt;
Our only chance is if I do what I'd do,&lt;br /&gt;
you copy me with the wings of the plane!&lt;br /&gt;
(Barry sticks out his arms like an airplane and flys in front of Vanessa's&lt;br /&gt;
face)&lt;br /&gt;
&lt;br /&gt;
VANESSA:&lt;br /&gt;
Don't have to yell.&lt;br /&gt;
BARRY:&lt;br /&gt;
I'm not yelling!&lt;br /&gt;
We're in a lot of trouble.&lt;br /&gt;
VANESSA:&lt;br /&gt;
It's very hard to concentrate&lt;br /&gt;
with that panicky tone in your voice!&lt;br /&gt;
BARRY:&lt;br /&gt;
It's not a tone. I'm panicking!&lt;br /&gt;
VANESSA:&lt;br /&gt;
I can't do this!&lt;br /&gt;
(Barry slaps Vanessa)&lt;br /&gt;
BARRY:&lt;br /&gt;
Vanessa, pull yourself together.&lt;br /&gt;
You have to snap out of it!&lt;br /&gt;
VANESSA:&lt;br /&gt;
(Slaps Barry)&lt;br /&gt;
You snap out of it.&lt;br /&gt;
BARRY:&lt;br /&gt;
(Slaps Vanessa)&lt;br /&gt;
 :&lt;br /&gt;
You snap out of it.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- You snap out of it!&lt;br /&gt;
BARRY:&lt;br /&gt;
- You snap out of it!&lt;br /&gt;
(We see that all the Pollen Jocks are flying under the plane)&lt;br /&gt;
VANESSA:&lt;br /&gt;
- You snap out of it!&lt;br /&gt;
BARRY:&lt;br /&gt;
- You snap out of it!&lt;br /&gt;
&lt;br /&gt;
VANESSA:&lt;br /&gt;
- You snap out of it!&lt;br /&gt;
BARRY:&lt;br /&gt;
- You snap out of it!&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Hold it!&lt;br /&gt;
BARRY:&lt;br /&gt;
- Why? Come on, it's my turn.&lt;br /&gt;
VANESSA:&lt;br /&gt;
How is the plane flying?&lt;br /&gt;
(The plane is now safely flying)&lt;br /&gt;
VANESSA:&lt;br /&gt;
I don't know.&lt;br /&gt;
(Barry's antennae rings like a phone. Barry picks up)&lt;br /&gt;
BARRY:&lt;br /&gt;
Hello?&lt;br /&gt;
LOU LU DUVA:&lt;br /&gt;
(Through &amp;quot;phone&amp;quot;)&lt;br /&gt;
Benson, got any flowers&lt;br /&gt;
for a happy occasion in there?&lt;br /&gt;
(All of the Pollen Jocks are carrying the plane)&lt;br /&gt;
BARRY:&lt;br /&gt;
The Pollen Jocks!&lt;br /&gt;
 :&lt;br /&gt;
They do get behind a fellow.&lt;br /&gt;
LOU LU DUVA:&lt;br /&gt;
- Black and yellow.&lt;br /&gt;
POLLEN JOCKS:&lt;br /&gt;
- Hello.&lt;br /&gt;
LOU LU DUVA:&lt;br /&gt;
All right, let's drop this tin can&lt;br /&gt;
&lt;br /&gt;
on the blacktop.&lt;br /&gt;
BARRY:&lt;br /&gt;
Where? I can't see anything. Can you?&lt;br /&gt;
VANESSA:&lt;br /&gt;
No, nothing. It's all cloudy.&lt;br /&gt;
 :&lt;br /&gt;
Come on. You got to think bee, Barry.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Thinking bee.&lt;br /&gt;
- Thinking bee.&lt;br /&gt;
(On the runway there are millions of bees laying on their backs)&lt;br /&gt;
BEES:&lt;br /&gt;
Thinking bee!&lt;br /&gt;
Thinking bee! Thinking bee!&lt;br /&gt;
BARRY:&lt;br /&gt;
Wait a minute.&lt;br /&gt;
I think I'm feeling something.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- What?&lt;br /&gt;
BARRY:&lt;br /&gt;
- I don't know. It's strong, pulling me.&lt;br /&gt;
 :&lt;br /&gt;
Like a 27-million-year-old instinct.&lt;br /&gt;
 :&lt;br /&gt;
Bring the nose down.&lt;br /&gt;
BEES:&lt;br /&gt;
Thinking bee!&lt;br /&gt;
Thinking bee! Thinking bee!&lt;br /&gt;
CONTROL TOWER OPERATOR:&lt;br /&gt;
- What in the world is on the tarmac?&lt;br /&gt;
BUD:&lt;br /&gt;
- Get some lights on that!&lt;br /&gt;
&lt;br /&gt;
(It is revealed that all the bees are organized into a giant pulsating&lt;br /&gt;
flower formation)&lt;br /&gt;
BEES:&lt;br /&gt;
Thinking bee!&lt;br /&gt;
Thinking bee! Thinking bee!&lt;br /&gt;
BARRY:&lt;br /&gt;
- Vanessa, aim for the flower.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- OK.&lt;br /&gt;
BARRY:&lt;br /&gt;
Out the engines. We're going in&lt;br /&gt;
on bee power. Ready, boys?&lt;br /&gt;
LOU LU DUVA:&lt;br /&gt;
Affirmative!&lt;br /&gt;
BARRY:&lt;br /&gt;
Good. Good. Easy, now. That's it.&lt;br /&gt;
 :&lt;br /&gt;
Land on that flower!&lt;br /&gt;
 :&lt;br /&gt;
Ready? Full reverse!&lt;br /&gt;
 :&lt;br /&gt;
Spin it around!&lt;br /&gt;
(The plane's nose is pointed at a flower painted on a nearby plane)&lt;br /&gt;
- Not that flower! The other one!&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Which one?&lt;br /&gt;
BARRY:&lt;br /&gt;
- That flower.&lt;br /&gt;
(The plane is now pointed at a fat guy in a flowered shirt. He freaks out&lt;br /&gt;
and tries to take a picture of the plane)&lt;br /&gt;
VANESSA:&lt;br /&gt;
- I'm aiming at the flower!&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
That's a fat guy in a flowered shirt.&lt;br /&gt;
I mean the giant pulsating flower&lt;br /&gt;
made of millions of bees!&lt;br /&gt;
(The plane hovers over the bee-flower)&lt;br /&gt;
 :&lt;br /&gt;
Pull forward. Nose down. Tail up.&lt;br /&gt;
 :&lt;br /&gt;
Rotate around it.&lt;br /&gt;
VANESSA:&lt;br /&gt;
- This is insane, Barry!&lt;br /&gt;
BARRY:&lt;br /&gt;
- This's the only way I know how to fly.&lt;br /&gt;
BUD:&lt;br /&gt;
Am I koo-koo-kachoo, or is this plane&lt;br /&gt;
flying in an insect-like pattern?&lt;br /&gt;
(The plane is unrealistically hovering and spinning over the bee-flower)&lt;br /&gt;
BARRY:&lt;br /&gt;
Get your nose in there. Don't be afraid.&lt;br /&gt;
Smell it. Full reverse!&lt;br /&gt;
 :&lt;br /&gt;
Just drop it. Be a part of it.&lt;br /&gt;
 :&lt;br /&gt;
Aim for the center!&lt;br /&gt;
 :&lt;br /&gt;
Now drop it in! Drop it in, woman!&lt;br /&gt;
 :&lt;br /&gt;
Come on, already.&lt;br /&gt;
(The bees scatter and the plane safely lands)&lt;br /&gt;
VANESSA:&lt;br /&gt;
Barry, we did it!&lt;br /&gt;
You taught me how to fly!&lt;br /&gt;
&lt;br /&gt;
BARRY:&lt;br /&gt;
- Yes!&lt;br /&gt;
(Vanessa is about to high-five Barry)&lt;br /&gt;
No high-five!&lt;br /&gt;
VANESSA:&lt;br /&gt;
- Right.&lt;br /&gt;
ADAM:&lt;br /&gt;
Barry, it worked!&lt;br /&gt;
Did you see the giant flower?&lt;br /&gt;
BARRY:&lt;br /&gt;
What giant flower? Where? Of course&lt;br /&gt;
I saw the flower! That was genius!&lt;br /&gt;
ADAM:&lt;br /&gt;
- Thank you.&lt;br /&gt;
BARRY:&lt;br /&gt;
- But we're not done yet.&lt;br /&gt;
 :&lt;br /&gt;
Listen, everyone!&lt;br /&gt;
 :&lt;br /&gt;
This runway is covered&lt;br /&gt;
with the last pollen&lt;br /&gt;
 :&lt;br /&gt;
from the last flowers&lt;br /&gt;
available anywhere on Earth.&lt;br /&gt;
 :&lt;br /&gt;
That means this is our last chance.&lt;br /&gt;
 :&lt;br /&gt;
We're the only ones who make honey,&lt;br /&gt;
pollinate flowers and dress like this.&lt;br /&gt;
 :&lt;br /&gt;
If we're gonna survive as a species,&lt;br /&gt;
this is our moment! What do you say?&lt;br /&gt;
&lt;br /&gt;
 :&lt;br /&gt;
Are we going to be bees, or just&lt;br /&gt;
Museum of Natural History keychains?&lt;br /&gt;
BEES:&lt;br /&gt;
We're bees!&lt;br /&gt;
BEE WHO LIKES KEYCHAINS:&lt;br /&gt;
Keychain!&lt;br /&gt;
BARRY:&lt;br /&gt;
Then follow me! Except Keychain.&lt;br /&gt;
POLLEN JOCK #1:&lt;br /&gt;
Hold on, Barry. Here.&lt;br /&gt;
 :&lt;br /&gt;
You've earned this.&lt;br /&gt;
BARRY:&lt;br /&gt;
Yeah!&lt;br /&gt;
 :&lt;br /&gt;
I'm a Pollen Jock! And it's a perfect&lt;br /&gt;
fit. All I gotta do are the sleeves.&lt;br /&gt;
(The Pollen Jocks throw Barry a nectar-collecting gun. Barry catches it)&lt;br /&gt;
Oh, yeah.&lt;br /&gt;
JANET:&lt;br /&gt;
That's our Barry.&lt;br /&gt;
(Barry and the Pollen Jocks get pollen from the flowers on the plane)&lt;br /&gt;
(Flash forward in time and the Pollen Jocks are flying over NYC)&lt;br /&gt;
 :&lt;br /&gt;
(Barry pollinates the flowers in Vanessa's shop and then heads to Central&lt;br /&gt;
Park)&lt;br /&gt;
BOY IN PARK:&lt;br /&gt;
Mom! The bees are back!&lt;br /&gt;
ADAM:&lt;br /&gt;
(Putting on his Krelman hat)&lt;br /&gt;
If anybody needs&lt;br /&gt;
&lt;br /&gt;
to make a call, now's the time.&lt;br /&gt;
 :&lt;br /&gt;
I got a feeling we'll be&lt;br /&gt;
working late tonight!&lt;br /&gt;
(The bee honey factories are back up and running)&lt;br /&gt;
(Meanwhile at Vanessa's shop)&lt;br /&gt;
VANESSA:&lt;br /&gt;
(To customer)&lt;br /&gt;
Here's your change. Have a great&lt;br /&gt;
afternoon! Can I help who's next?&lt;br /&gt;
 :&lt;br /&gt;
Would you like some honey with that?&lt;br /&gt;
It is bee-approved. Don't forget these.&lt;br /&gt;
(There is a room in the shop where Barry does legal work for other animals.&lt;br /&gt;
He is currently talking with a Cow)&lt;br /&gt;
COW:&lt;br /&gt;
Milk, cream, cheese, it's all me.&lt;br /&gt;
And I don't see a nickel!&lt;br /&gt;
 :&lt;br /&gt;
Sometimes I just feel&lt;br /&gt;
like a piece of meat!&lt;br /&gt;
BARRY:&lt;br /&gt;
I had no idea.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Barry, I'm sorry.&lt;br /&gt;
Have you got a moment?&lt;br /&gt;
BARRY:&lt;br /&gt;
Would you excuse me?&lt;br /&gt;
My mosquito associate will help you.&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
Sorry I'm late.&lt;br /&gt;
COW:&lt;br /&gt;
He's a lawyer too?&lt;br /&gt;
&lt;br /&gt;
MOOSEBLOOD:&lt;br /&gt;
Ma'am, I was already a blood-sucking parasite.&lt;br /&gt;
All I needed was a briefcase.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Have a great afternoon!&lt;br /&gt;
 :&lt;br /&gt;
Barry, I just got this huge tulip order,&lt;br /&gt;
and I can't get them anywhere.&lt;br /&gt;
BARRY:&lt;br /&gt;
No problem, Vannie.&lt;br /&gt;
Just leave it to me.&lt;br /&gt;
VANESSA:&lt;br /&gt;
You're a lifesaver, Barry.&lt;br /&gt;
Can I help who's next?&lt;br /&gt;
BARRY:&lt;br /&gt;
All right, scramble, jocks!&lt;br /&gt;
It's time to fly.&lt;br /&gt;
VANESSA:&lt;br /&gt;
Thank you, Barry!&lt;br /&gt;
(Ken walks by on the sidewalk and sees the &amp;quot;bee-approved honey&amp;quot; in&lt;br /&gt;
Vanessa's shop)&lt;br /&gt;
KEN:&lt;br /&gt;
That bee is living my life!!&lt;br /&gt;
ANDY:&lt;br /&gt;
Let it go, Kenny.&lt;br /&gt;
KEN:&lt;br /&gt;
- When will this nightmare end?!&lt;br /&gt;
ANDY:&lt;br /&gt;
- Let it all go.&lt;br /&gt;
BARRY:&lt;br /&gt;
- Beautiful day to fly.&lt;br /&gt;
POLLEN JOCK:&lt;br /&gt;
&lt;br /&gt;
- Sure is.&lt;br /&gt;
BARRY:&lt;br /&gt;
Between you and me,&lt;br /&gt;
I was dying to get out of that office.&lt;br /&gt;
(Barry recreates the scene near the beginning of the movie where he flies&lt;br /&gt;
through the box kite. The movie fades to black and the credits being)&lt;br /&gt;
[--after credits; No scene can be seen but the characters can be heard&lt;br /&gt;
talking over the credits--]&lt;br /&gt;
You have got&lt;br /&gt;
to start thinking bee, my friend!&lt;br /&gt;
 :&lt;br /&gt;
- Thinking bee!&lt;br /&gt;
- Me?&lt;br /&gt;
BARRY:&lt;br /&gt;
(Talking over singer)&lt;br /&gt;
Hold it. Let's just stop&lt;br /&gt;
for a second. Hold it.&lt;br /&gt;
 :&lt;br /&gt;
I'm sorry. I'm sorry, everyone.&lt;br /&gt;
Can we stop here?&lt;br /&gt;
SINGER:&lt;br /&gt;
Oh, BarryBARRY:&lt;br /&gt;
I'm not making a major life decision&lt;br /&gt;
during a production number!&lt;br /&gt;
SINGER:&lt;br /&gt;
All right. Take ten, everybody.&lt;br /&gt;
Wrap it up, guys.&lt;br /&gt;
BARRY:&lt;br /&gt;
I had virtually no rehearsal for that.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024&amp;diff=157316</id>
		<title>CSC/ECE 517 Fall 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024&amp;diff=157316"/>
		<updated>2024-10-28T23:00:16Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Add 2480 - Implement testing for new Bookmarks Controller&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2024 - E2454. Refactor student_task.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2456. Refactor teams_user.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2459. View for results of bidding]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2461. UI for Courses]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2465. UI for Institutions and Notification]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2466. UI for Impersonate User]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2467. UI for View Submissions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2469. Reimplement grades/view_team]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2482. Reimplement heatgrid for reviews]]&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=Broken_Links&amp;diff=157309</id>
		<title>Broken Links</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Broken_Links&amp;diff=157309"/>
		<updated>2024-10-28T22:25:13Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Updated the list with all other links on Expertiza_documentation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The goal of this page is to note broken links so they can be fixed. If adding an entry to the table, add the wiki page and header the link can be found in, the broken link and the link text, and note what is broken with the link (404, now redirects to a different site, etc.)&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto&amp;quot;&lt;br /&gt;
|+ Broken Links&lt;br /&gt;
|-&lt;br /&gt;
! Wiki Page !! Broken Link !! Notes&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] ||[[https://research.csc.ncsu.edu/efg/expertiza/presentations/ELI_11_wiki_textbook.ppt presentation]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/Purdue_TLT_2009.ppt plenary talk]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/Expertiza-short.htm rationale]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/Expertiza%20in%20Action.ppt virtual demo]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Papers]] || [[https://innovateonline.info/index.php?view=article&amp;amp;id=365 prose rendition]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Papers]] || [[http://innovateonline.info/ Innovate]] || redirects to [[https://onlinegraduateprograms.net/ onlinegraduateprograms.net]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Papers]] || [[https://research.csc.ncsu.edu/efg/expertiza/papers/ here]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Video presentations]] || [[http://connectpro86502729.na6.acrobat.com/p99048610/ overview]] || times out&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Video presentations]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/TLT_Live.ppt (slides)]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Video presentations]] || [[https://sas.elluminate.com/site/external/recording/playback/link/dropin.jnlp?sid=2008350&amp;amp;suid=D.2D2E269EE524FD263F89DA6872A41E Student-authored wiki textbooks: Composition and review]] || site can't be reached&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Video presentations]] || [[http://educause.mediasite.com/mediasite/SilverlightPlayer/Default.aspx?peid=cdeebca6d1a34610923bcabd4c2d2fd91d session from EDUCAUSE ELI 2011]] || Site loads, but displays &amp;quot;No compatible source was found for this media.&amp;quot;. Site might be using Silverlight to stream, which is EOL.&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Video presentations]] || [[http://breeze.uliveandlearn.com/p10263667/ Webcast]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Video presentations]] || [[http://www.youtube.com/watch?v=hVpS7qvC5Zs interview]] || Video unavailable (posting account has been terminated)&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Video presentations]] || [[http://breeze.uliveandlearn.com/p84785847/ Ideagora]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Video presentations]] || [[https://sas.elluminate.com/site/external/jwsdetect/playback.jnlp?psid=2009-03-17.1032.M.F13AAE88367AEE982449E713075D42.vcr Forming and managing student teams and peer feedback in Expertiza]] || site can't be reached&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Documentation]] || [[https://research.csc.ncsu.edu/efg/expertiza/reports/Instructor_documentation.doc instructor manual]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Documentation]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/videos/instructor.swf instructor video]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Documentation]] || [[http://rajanalwan.com/ui_guidelines/ design document]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Documentation]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/student_documentation.ppt Powerpoint]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Documentation]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/student_documentation.pdf PDF]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Documentation]] || [[http://research.csc.ncsu.edu/efg/expertiza/presentations/videos/student.swf video]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Documentation]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/student_wiki_documentation.ppt Powerpoint]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Documentation]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/student_wiki_documentation.pdf PDF]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Documentation]] || [[https://courses.ncsu.edu/csc517/common/homework/topic-signup-team-formation.ppt Powerpoint]] || site can't be reached&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Documentation]] || [[https://courses.ncsu.edu/csc517/common/homework/topic-signup-team-formation.pdf PDF]] || site can't be reached&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Developers section]] || [[https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEUmNKVncxRUhUVVE/view?usp=sharing Download the VirtualBox Ubuntu image here]] || Sorry, the file you have requested does not exist&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Links]] || [[https://research.csc.ncsu.edu/efg/expertiza/papers Papers on Expertiza]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Links]] || [[http://research.csc.ncsu.edu/efg/expertiza/presentations/Expertiza-short.htm PowerPoint Presentation - The Expertiza platform]] || 404&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=Broken_Links&amp;diff=157233</id>
		<title>Broken Links</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Broken_Links&amp;diff=157233"/>
		<updated>2024-10-26T17:06:30Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: added a few more links under video presentations&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The goal of this page is to note broken links so they can be fixed. If adding an entry to the table, add the wiki page and header the link can be found in, the broken link and the link text, and note what is broken with the link (404, now redirects to a different site, etc.)&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto&amp;quot;&lt;br /&gt;
|+ Broken Links&lt;br /&gt;
|-&lt;br /&gt;
! Wiki Page !! Broken Link !! Notes&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] ||[[https://research.csc.ncsu.edu/efg/expertiza/presentations/ELI_11_wiki_textbook.ppt presentation]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/Purdue_TLT_2009.ppt plenary talk]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/Expertiza-short.htm rationale]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/Expertiza%20in%20Action.ppt virtual demo]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Papers]] || [[https://innovateonline.info/index.php?view=article&amp;amp;id=365 prose rendition]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Papers]] || [[http://innovateonline.info/ Innovate]] || redirects to [[https://onlinegraduateprograms.net/ onlinegraduateprograms.net]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Papers]] || [[https://research.csc.ncsu.edu/efg/expertiza/papers/ here]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Video presentations]] || [[http://connectpro86502729.na6.acrobat.com/p99048610/ overview]] || times out&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Video presentations]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/TLT_Live.ppt (slides)]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Video presentations]] || [[https://sas.elluminate.com/site/external/recording/playback/link/dropin.jnlp?sid=2008350&amp;amp;suid=D.2D2E269EE524FD263F89DA6872A41E Student-authored wiki textbooks: Composition and review]] || site can't be reached&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=Expertiza_documentation&amp;diff=157232</id>
		<title>Expertiza documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Expertiza_documentation&amp;diff=157232"/>
		<updated>2024-10-26T16:56:27Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Added a link to the &amp;quot;Broken Links&amp;quot; page under Misc&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:715px-EXPERTIZA.png|715px]]&lt;br /&gt;
&lt;br /&gt;
= Welcome to the Expertiza project! =&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Short Powerpoint introductions ==&lt;br /&gt;
*My [http://research.csc.ncsu.edu/efg/expertiza/presentations/ELI_11_wiki_textbook.ppt presentation] on using Expertiza to support wiki-textbook creation, at the 2011 EDUCAUSE Learning Initiative conference, February 15, 2011&lt;br /&gt;
*My [http://research.csc.ncsu.edu/efg/expertiza/presentations/Purdue_TLT_2009.ppt plenary talk] at the Purdue TLT Conference on April 22, 2009&lt;br /&gt;
*We invite you to view the original [http://research.csc.ncsu.edu/efg/expertiza/presentations/Expertiza-short.htm rationale] for the system.&lt;br /&gt;
*You can walk through a [http://research.csc.ncsu.edu/efg/expertiza/presentations/Expertiza%20in%20Action.ppt virtual demo] of the system.&lt;br /&gt;
&lt;br /&gt;
== Papers ==&lt;br /&gt;
*A [http://innovateonline.info/index.php?view=article&amp;amp;id=365 prose rendition] of the rationale was published in [http://innovateonline.info/ Innovate] in 2007. (To view it, you need to register, and you will receive e-mail each time a new issue of this very interesting and useful journal is published.)&lt;br /&gt;
*Other papers on Expertiza can be found [http://research.csc.ncsu.edu/efg/expertiza/papers/ here].&lt;br /&gt;
&lt;br /&gt;
== Video presentations ==&lt;br /&gt;
&lt;br /&gt;
*An [http://connectpro86502729.na6.acrobat.com/p99048610/ overview] of Expertiza (&amp;quot;Software support for teamwork and authentic assessment [http://research.csc.ncsu.edu/efg/expertiza/presentations/TLT_Live.ppt  (slides)]&amp;quot;) from the TLT Group's Friday Live, September 24, 2010&lt;br /&gt;
*[https://sas.elluminate.com/site/external/recording/playback/link/dropin.jnlp?sid=2008350&amp;amp;suid=D.2D2E269EE524FD263F89DA6872A41E Student-authored wiki textbooks: Composition and review] from the 2011 Global Education Consortium, November 18, 2011&lt;br /&gt;
*This [http://educause.mediasite.com/mediasite/SilverlightPlayer/Default.aspx?peid=cdeebca6d1a34610923bcabd4c2d2fd91d session from EDUCAUSE ELI 2011] describes how Expertiza can be used to review wiki-textbook contributions.  It is an earlier version of the presentation above that includes a live demo. &lt;br /&gt;
*This Innovate [http://breeze.uliveandlearn.com/p10263667/ Webcast] from July 2007 includes the rationale and a demo of the system.&lt;br /&gt;
*A six-minute [http://www.youtube.com/watch?v=hVpS7qvC5Zs interview] from the 2009 Lilly Conference on College Teaching describes the goals and realization of the project.  (&amp;lt;i&amp;gt;Note:&amp;lt;/i&amp;gt; Background noise may be distracting.)&lt;br /&gt;
*This Innovate [http://breeze.uliveandlearn.com/p84785847/ Ideagora] discussion from January 2009 describes the social-networking features planned for Expertiza.&lt;br /&gt;
*[https://sas.elluminate.com/site/external/jwsdetect/playback.jnlp?psid=2009-03-17.1032.M.F13AAE88367AEE982449E713075D42.vcr Forming and managing student teams and peer feedback in Expertiza], a presentation at the UNC TLT conference in March 2009.&lt;br /&gt;
&lt;br /&gt;
== Documentation ==&lt;br /&gt;
&lt;br /&gt;
*An [http://research.csc.ncsu.edu/efg/expertiza/reports/Instructor_documentation.doc instructor manual], explaining how to create an deploy an assignment in Expertiza.&lt;br /&gt;
*An [http://research.csc.ncsu.edu/efg/expertiza/presentations/videos/instructor.swf instructor video], slightly dated, showing how to create and deploy an assignment&lt;br /&gt;
*A [http://rajanalwan.com/ui_guidelines/ design document] for the application.&lt;br /&gt;
* A guide for [[Creating_Custom_Rubric]]&lt;br /&gt;
*For students, a [http://research.csc.ncsu.edu/efg/expertiza/presentations/student_documentation.ppt Powerpoint] or [http://research.csc.ncsu.edu/efg/expertiza/presentations/student_documentation.pdf PDF] presentation explaining how to submit and review an assignment with Expertiza.&lt;br /&gt;
*For students, a [http://research.csc.ncsu.edu/efg/expertiza/presentations/videos/student.swf video] showing how to use the system to submit and review an assignment.&lt;br /&gt;
*For students, a [http://research.csc.ncsu.edu/efg/expertiza/presentations/student_wiki_documentation.ppt Powerpoint] or [http://research.csc.ncsu.edu/efg/expertiza/presentations/student_wiki_documentation.pdf PDF] presentation explaining how to submit and review wiki pages with Expertiza.&lt;br /&gt;
*For students, a [http://courses.ncsu.edu/csc517/common/homework/topic-signup-team-formation.ppt Powerpoint] or [http://courses.ncsu.edu/csc517/common/homework/topic-signup-team-formation.pdf PDF] presentation explaining how to form teams and sign up for topics.&lt;br /&gt;
&lt;br /&gt;
== Developers section ==&lt;br /&gt;
''Expertiza now has a Java dependency, so the machine you are using to develop Expertiza on should have the JVM installed.''&lt;br /&gt;
=== Development Environment Setup Guides ===&lt;br /&gt;
* [[Creating a Linux Development Environment for Expertiza - Installation Guide]]&lt;br /&gt;
**[http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:Linux:Debian Development setup for Ubuntu/Debian]&lt;br /&gt;
* [[Development:Setup:OSX]]&lt;br /&gt;
*[http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:Linux:RHEL  Development setup for Linux RHEL ]&lt;br /&gt;
*[[Developing Expertiza on the VCL]]&lt;br /&gt;
*Developing Expertiza on Virtual Box&lt;br /&gt;
** [https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEUmNKVncxRUhUVVE/view?usp=sharing Download the VirtualBox Ubuntu image here]&lt;br /&gt;
** [https://drive.google.com/open?id=1YlqiSsbZl8TfPuQmIFG7TYo2npWzqqu4 or try the Lubuntu image here if the Ubuntu image is too heavy for your PC/Laptop ]&lt;br /&gt;
*Docker image (Only if you are familiar with docker. You will need it if you choose Expertiza to do OSS project.)&lt;br /&gt;
** Please follow the instruction in https://hub.docker.com/r/winbobob/expertiza-fall2016/&lt;br /&gt;
&lt;br /&gt;
=== Database Guides ===&lt;br /&gt;
*[[Deploying and importing production data with capistrano]]&lt;br /&gt;
*[[Documentation on Database Tables]]&lt;br /&gt;
*[[Documentation for Database Anonymization]]&lt;br /&gt;
&lt;br /&gt;
=== Security Guidelines ===&lt;br /&gt;
*[[Security guidelines for Expertiza]]&lt;br /&gt;
=== Git ===&lt;br /&gt;
*[[Version Control with the Git repository]]&lt;br /&gt;
*[http://wiki.expertiza.ncsu.edu/index.php/How_to_Begin_a_Project_from_the_Current_Expertiza_Repository How to Begin a Project from the Current Expertiza Repository]&lt;br /&gt;
&lt;br /&gt;
=== Ruby and Rails ===&lt;br /&gt;
*[[Restart Instructions for Expertiza]]&lt;br /&gt;
*[[Deploying Expertiza to Production]]&lt;br /&gt;
*[[Gem dependencies]]&lt;br /&gt;
*[[http://wiki.expertiza.ncsu.edu/index.php?title=Using_Cucumber_with_Expertiza Using Cucumber with Expertiza]]&lt;br /&gt;
&lt;br /&gt;
=== Misc ===&lt;br /&gt;
*[[Setting up and using TA functionality]]&lt;br /&gt;
*[[Restart instructions for Wiki]]&lt;br /&gt;
*[[Scoring &amp;amp; Grading Methods (Fall '21)]]&lt;br /&gt;
*[[Broken Links]]&lt;br /&gt;
&lt;br /&gt;
=== Final Projects on Expertiza for Fall 2015 ===&lt;br /&gt;
[https://docs.google.com/document/d/1t0keeNQ2kP0NmcgIrtQXGi5K_GhQYcKzEVWJPPRBOHE/edit?pli=1 The Expertiza Final Project Submission] &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
[http://expertiza.ncsu.edu The Expertiza application] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://research.csc.ncsu.edu/efg/expertiza/papers Papers on Expertiza] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://research.csc.ncsu.edu/efg/expertiza/presentations/Expertiza-short.htm PowerPoint Presentation - The Expertiza platform]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.csc.ncsu.edu/news/463 Expertiza Platform Takes Honorable Mention in Gertrude Cox Awards]&lt;br /&gt;
&lt;br /&gt;
== Acknowledgments ==&lt;br /&gt;
&lt;br /&gt;
This material is based upon work supported by the National Science Foundation under Grant No. 0536558.  Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=Broken_Links&amp;diff=157231</id>
		<title>Broken Links</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Broken_Links&amp;diff=157231"/>
		<updated>2024-10-26T16:55:06Z</updated>

		<summary type="html">&lt;p&gt;Wagrocho: Created initial wiki to keep&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The goal of this page is to note broken links so they can be fixed. If adding an entry to the table, add the wiki page and header the link can be found in, the broken link and the link text, and note what is broken with the link (404, now redirects to a different site, etc.)&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto&amp;quot;&lt;br /&gt;
|+ Broken Links&lt;br /&gt;
|-&lt;br /&gt;
! Wiki Page !! Broken Link !! Notes&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] ||[[https://research.csc.ncsu.edu/efg/expertiza/presentations/ELI_11_wiki_textbook.ppt presentation]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/Purdue_TLT_2009.ppt plenary talk]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/Expertiza-short.htm rationale]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Short Powerpoint introductions]] || [[https://research.csc.ncsu.edu/efg/expertiza/presentations/Expertiza%20in%20Action.ppt virtual demo]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Papers]] || [[https://innovateonline.info/index.php?view=article&amp;amp;id=365 prose rendition]] || 404&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Papers]] || [[http://innovateonline.info/ Innovate]] || Redirects to [[https://onlinegraduateprograms.net/ onlinegraduateprograms.net]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Expertiza_documentation#Papers]] || [[https://research.csc.ncsu.edu/efg/expertiza/papers/ here]] || 404&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Wagrocho</name></author>
	</entry>
</feed>