<?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=Xma21</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=Xma21"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Xma21"/>
	<updated>2026-07-15T18:42:29Z</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_2007/wiki2_4_2q&amp;diff=117529</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 4 2q</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117529"/>
		<updated>2018-08-24T14:34:18Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Writing effective Use Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''A Guide to Use Cases on the WEB'''&lt;br /&gt;
&lt;br /&gt;
''Topic :Use cases. There are even more pages on the Web on use cases than on MVC. If someone wants to learn about them, what should (s)he do? Look at the first few hits in Google? I expect we can do better than that. Write a review of the use-case sites on the Web. Which are best for learning about the concept? Which have the most instructive examples? Which teach advanced concepts that are not apparent in perusing most use-case sites? Read at least several dozen pages before deciding how to organize your overview.'' &lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This page tries to review the use-case sites on the Web which can be useful to best understand the concept. Also a few instructive examples are covered paying attention to the basic use case as well as advanced concepts that are not apparent in perusing most use-case sites.&lt;br /&gt;
 &lt;br /&gt;
=What is a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;'''''Use case''' is a methodology used in software and systems engineering to understand and identify the functional requirements of a system. Use cases describe the interaction between a primary actor, the initiator of the interaction and the system itself, represented as a sequence of simple steps.''&amp;quot;[1][2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An actor who can more generally be described as the user of the system, is the external entity and can be a person or another system itself. A use case can be best described as what happens when the actor is using the system to achieve some goal. This goal is nothing but the end result which follows the sequence of events as described in the use cases. &lt;br /&gt;
&lt;br /&gt;
Every use case gives a complete list of events which occur from the time the actor starts interacting with the system till the time the final goal is achieved. A use case also records all the possible scenarios that may occur while trying to reach the desired goal. We can think of it as existence of a main course of events that will occur in normal circumstances, to which the exceptional cases are added. Anything that is not relevant to the actor/user is not a part of the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are a few links to external websites which further illustrate this concept.&lt;br /&gt;
&lt;br /&gt;
* [https://www.ibm.com/developerworks/library/ws-using-oo/ OO design process: Use cases, an introduction]&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
&lt;br /&gt;
==UML Diagrams and Use cases==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''The Use case diagram is used to identify the primary elements and processes that form the system. The primary elements are termed as 'actors' and the processes are called &amp;quot;use cases.&amp;quot; The Use case diagram shows which actors interact with each use case.&amp;quot;''[3]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
They are useful in providing a pictorial view of the interactions between the users (actors) and sets of events (use cases) associated with the system.They also evolve as the projects or system change with time. The standard elements of a use case diagram makes comprehension easy for anyone trying to understand the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to draw typical use case diagrams.&lt;br /&gt;
&lt;br /&gt;
* [https://www.smartdraw.com/uml-diagram/ An introduction to UML diagrams &amp;amp; Tutorial] &lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
&lt;br /&gt;
=Examples using Use Cases=&lt;br /&gt;
In this section, a few instructive examples have been outlined along with their references which illustrate different ways in which use cases can be written. The first example is a basic use-case template.&lt;br /&gt;
&lt;br /&gt;
===Basic use case template===&lt;br /&gt;
Described below are some the characteristics of a typical use case.&lt;br /&gt;
  '''CHARACTERISTIC INFORMATION'''&lt;br /&gt;
  * ''Goal in Context'':   Buyer issues request directly to our company, expects goods shipped and to be billed.&lt;br /&gt;
  * ''Scope'':  Company&lt;br /&gt;
  * ''Preconditions'':  We know Buyer, their address, etc.&lt;br /&gt;
  * ''Success End Condition'':  Buyer has goods, we have money for the goods.&lt;br /&gt;
  * ''Failed End Condition'':  We have not sent the goods, Buyer has not spent the money.&lt;br /&gt;
  * ''Primary Actor'':  Buyer, any agent (or computer) acting for the customer&lt;br /&gt;
  * ''Trigger'':  purchase request comes in.&lt;br /&gt;
  &lt;br /&gt;
  '''MAIN SUCCESS SCENARIO'''&lt;br /&gt;
  1. Buyer calls in with a purchase request.&lt;br /&gt;
  2. Company captures buyer’s name, address, requested goods, etc.&lt;br /&gt;
  3. Company gives buyer information on goods, prices, delivery dates, etc.&lt;br /&gt;
  4. Buyer signs for order.&lt;br /&gt;
  5. Company creates order, ships order to buyer.&lt;br /&gt;
  6. Company ships invoice to buyer.&lt;br /&gt;
  7. Buyers pays invoice.&lt;br /&gt;
  &lt;br /&gt;
  '''EXTENSIONS'''&lt;br /&gt;
  3a. Company is out of one of the ordered items: &lt;br /&gt;
      3a1. Renegotiate order.&lt;br /&gt;
  4a. Buyer pays directly with credit card:&lt;br /&gt;
      4a1. Take payment by credit card (use case 44)&lt;br /&gt;
  7a. Buyer returns goods:&lt;br /&gt;
      7a. Handle returned goods (use case 105)&lt;br /&gt;
The basic steps that can be followed so as to ensure writing an effective use case has been described well in [http://www.gatherspace.com/static/use_case_example.html Writing Effective Use Cases].[5]&lt;br /&gt;
&lt;br /&gt;
===Restaurant===&lt;br /&gt;
This example provides one use case but distinctly provides a step by step analysis of the events that constitute a Use Case. It mentions the actors, pre-conditions, Exceptions and Alternative scenarios.&lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/restaurant-uml-use-case-diagram-example.html Restaurant]&lt;br /&gt;
&lt;br /&gt;
===Purchase order===&lt;br /&gt;
This example provides a typical use case specification by listing the Activity, Result, Constraints and Extensions involved with a purchase order from a Finance web page.&lt;br /&gt;
&lt;br /&gt;
* [https://creately.com/diagram/example/ifq4uulr/Purchase%20Order Purchase order System]&lt;br /&gt;
&lt;br /&gt;
===ATM system===&lt;br /&gt;
This example is a little more involved in that it provides a number of use cases associated with using an ATM system including cash withdrawal,&lt;br /&gt;
transfers, deposits, balance inquiry, etc.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.fsu.edu/~baker/swe1/restricted/templates/rr631gv1_stuwrk_withdraw_cash_use-case_spec.pdf ATM System]&lt;br /&gt;
&lt;br /&gt;
===A shopping website order Process===&lt;br /&gt;
This is a very good example that describes the scenarios and extensions involved in writing a use case for a online shopping order. It also describes the UML diagram.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/examples/online-shopping-use-case-diagram-example.html?context=uc-examples Shopping website order]&lt;br /&gt;
&lt;br /&gt;
===Self Service Machine===&lt;br /&gt;
This example provides the typical Use Cases in a self service machine. Some of the aspects of using a self service machine are: buying a product, re-stocking the machine, collecting the money etc. The following link expands on how to do this and also provides the UML diagrams which depict the interaction between the users and system through the use case&lt;br /&gt;
  &lt;br /&gt;
* [http://www.cloudbus.org/~raj/254/Lectures/RajUML2.pdf Self-Service Machine (page-3)]&lt;br /&gt;
&lt;br /&gt;
=How to Write a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Writing Effective Use Cases==&lt;br /&gt;
&lt;br /&gt;
One of the most difficult problem in software development is capturing precisely what you want to build. Inaccurate requirement will end-up with significant delay, rework or even abandonment of the project. Effective applying use case technique helps your team capturing requirements in user point of view which can be easily understood by both the end-user and your team. Use case driven development support subsequent development activities such as analysis and design and testing.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to write effective use cases.&lt;br /&gt;
* [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing Effective Use Cases]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
* [1] Ivar Jacobson (1992). Object-Oriented Software Engineering. Addison Wesley Professional. ISBN 0-201-54435.&lt;br /&gt;
* [2] [http://en.wikipedia.org/wiki/Use_case Wikipidea Page] Basic definition of Use Case&lt;br /&gt;
* [3] [http://www.developer.com/design/article.php/2109801 Use Case Diagrams]&lt;br /&gt;
* [4] [http://alistair.cockburn.us/images/Uctempla.doc Basic Use Case Template]&lt;br /&gt;
* [5] [http://www.gatherspace.com/static/use_case_example.html#1 Writing Effective Use Cases]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
* [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing effective Use Cases]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117528</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 4 2q</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117528"/>
		<updated>2018-08-24T14:33:55Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''A Guide to Use Cases on the WEB'''&lt;br /&gt;
&lt;br /&gt;
''Topic :Use cases. There are even more pages on the Web on use cases than on MVC. If someone wants to learn about them, what should (s)he do? Look at the first few hits in Google? I expect we can do better than that. Write a review of the use-case sites on the Web. Which are best for learning about the concept? Which have the most instructive examples? Which teach advanced concepts that are not apparent in perusing most use-case sites? Read at least several dozen pages before deciding how to organize your overview.'' &lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This page tries to review the use-case sites on the Web which can be useful to best understand the concept. Also a few instructive examples are covered paying attention to the basic use case as well as advanced concepts that are not apparent in perusing most use-case sites.&lt;br /&gt;
 &lt;br /&gt;
=What is a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;'''''Use case''' is a methodology used in software and systems engineering to understand and identify the functional requirements of a system. Use cases describe the interaction between a primary actor, the initiator of the interaction and the system itself, represented as a sequence of simple steps.''&amp;quot;[1][2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An actor who can more generally be described as the user of the system, is the external entity and can be a person or another system itself. A use case can be best described as what happens when the actor is using the system to achieve some goal. This goal is nothing but the end result which follows the sequence of events as described in the use cases. &lt;br /&gt;
&lt;br /&gt;
Every use case gives a complete list of events which occur from the time the actor starts interacting with the system till the time the final goal is achieved. A use case also records all the possible scenarios that may occur while trying to reach the desired goal. We can think of it as existence of a main course of events that will occur in normal circumstances, to which the exceptional cases are added. Anything that is not relevant to the actor/user is not a part of the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are a few links to external websites which further illustrate this concept.&lt;br /&gt;
&lt;br /&gt;
* [https://www.ibm.com/developerworks/library/ws-using-oo/ OO design process: Use cases, an introduction]&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
&lt;br /&gt;
==UML Diagrams and Use cases==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''The Use case diagram is used to identify the primary elements and processes that form the system. The primary elements are termed as 'actors' and the processes are called &amp;quot;use cases.&amp;quot; The Use case diagram shows which actors interact with each use case.&amp;quot;''[3]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
They are useful in providing a pictorial view of the interactions between the users (actors) and sets of events (use cases) associated with the system.They also evolve as the projects or system change with time. The standard elements of a use case diagram makes comprehension easy for anyone trying to understand the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to draw typical use case diagrams.&lt;br /&gt;
&lt;br /&gt;
* [https://www.smartdraw.com/uml-diagram/ An introduction to UML diagrams &amp;amp; Tutorial] &lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
&lt;br /&gt;
=Examples using Use Cases=&lt;br /&gt;
In this section, a few instructive examples have been outlined along with their references which illustrate different ways in which use cases can be written. The first example is a basic use-case template.&lt;br /&gt;
&lt;br /&gt;
===Basic use case template===&lt;br /&gt;
Described below are some the characteristics of a typical use case.&lt;br /&gt;
  '''CHARACTERISTIC INFORMATION'''&lt;br /&gt;
  * ''Goal in Context'':   Buyer issues request directly to our company, expects goods shipped and to be billed.&lt;br /&gt;
  * ''Scope'':  Company&lt;br /&gt;
  * ''Preconditions'':  We know Buyer, their address, etc.&lt;br /&gt;
  * ''Success End Condition'':  Buyer has goods, we have money for the goods.&lt;br /&gt;
  * ''Failed End Condition'':  We have not sent the goods, Buyer has not spent the money.&lt;br /&gt;
  * ''Primary Actor'':  Buyer, any agent (or computer) acting for the customer&lt;br /&gt;
  * ''Trigger'':  purchase request comes in.&lt;br /&gt;
  &lt;br /&gt;
  '''MAIN SUCCESS SCENARIO'''&lt;br /&gt;
  1. Buyer calls in with a purchase request.&lt;br /&gt;
  2. Company captures buyer’s name, address, requested goods, etc.&lt;br /&gt;
  3. Company gives buyer information on goods, prices, delivery dates, etc.&lt;br /&gt;
  4. Buyer signs for order.&lt;br /&gt;
  5. Company creates order, ships order to buyer.&lt;br /&gt;
  6. Company ships invoice to buyer.&lt;br /&gt;
  7. Buyers pays invoice.&lt;br /&gt;
  &lt;br /&gt;
  '''EXTENSIONS'''&lt;br /&gt;
  3a. Company is out of one of the ordered items: &lt;br /&gt;
      3a1. Renegotiate order.&lt;br /&gt;
  4a. Buyer pays directly with credit card:&lt;br /&gt;
      4a1. Take payment by credit card (use case 44)&lt;br /&gt;
  7a. Buyer returns goods:&lt;br /&gt;
      7a. Handle returned goods (use case 105)&lt;br /&gt;
The basic steps that can be followed so as to ensure writing an effective use case has been described well in [http://www.gatherspace.com/static/use_case_example.html Writing Effective Use Cases].[5]&lt;br /&gt;
&lt;br /&gt;
===Restaurant===&lt;br /&gt;
This example provides one use case but distinctly provides a step by step analysis of the events that constitute a Use Case. It mentions the actors, pre-conditions, Exceptions and Alternative scenarios.&lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/restaurant-uml-use-case-diagram-example.html Restaurant]&lt;br /&gt;
&lt;br /&gt;
===Purchase order===&lt;br /&gt;
This example provides a typical use case specification by listing the Activity, Result, Constraints and Extensions involved with a purchase order from a Finance web page.&lt;br /&gt;
&lt;br /&gt;
* [https://creately.com/diagram/example/ifq4uulr/Purchase%20Order Purchase order System]&lt;br /&gt;
&lt;br /&gt;
===ATM system===&lt;br /&gt;
This example is a little more involved in that it provides a number of use cases associated with using an ATM system including cash withdrawal,&lt;br /&gt;
transfers, deposits, balance inquiry, etc.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.fsu.edu/~baker/swe1/restricted/templates/rr631gv1_stuwrk_withdraw_cash_use-case_spec.pdf ATM System]&lt;br /&gt;
&lt;br /&gt;
===A shopping website order Process===&lt;br /&gt;
This is a very good example that describes the scenarios and extensions involved in writing a use case for a online shopping order. It also describes the UML diagram.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/examples/online-shopping-use-case-diagram-example.html?context=uc-examples Shopping website order]&lt;br /&gt;
&lt;br /&gt;
===Self Service Machine===&lt;br /&gt;
This example provides the typical Use Cases in a self service machine. Some of the aspects of using a self service machine are: buying a product, re-stocking the machine, collecting the money etc. The following link expands on how to do this and also provides the UML diagrams which depict the interaction between the users and system through the use case&lt;br /&gt;
  &lt;br /&gt;
* [http://www.cloudbus.org/~raj/254/Lectures/RajUML2.pdf Self-Service Machine (page-3)]&lt;br /&gt;
&lt;br /&gt;
=How to Write a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Writing effective Use Cases==&lt;br /&gt;
&lt;br /&gt;
One of the most difficult problem in software development is capturing precisely what you want to build. Inaccurate requirement will end-up with significant delay, rework or even abandonment of the project. Effective applying use case technique helps your team capturing requirements in user point of view which can be easily understood by both the end-user and your team. Use case driven development support subsequent development activities such as analysis and design and testing.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to write effective use cases.&lt;br /&gt;
* [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing effective Use Cases]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
* [1] Ivar Jacobson (1992). Object-Oriented Software Engineering. Addison Wesley Professional. ISBN 0-201-54435.&lt;br /&gt;
* [2] [http://en.wikipedia.org/wiki/Use_case Wikipidea Page] Basic definition of Use Case&lt;br /&gt;
* [3] [http://www.developer.com/design/article.php/2109801 Use Case Diagrams]&lt;br /&gt;
* [4] [http://alistair.cockburn.us/images/Uctempla.doc Basic Use Case Template]&lt;br /&gt;
* [5] [http://www.gatherspace.com/static/use_case_example.html#1 Writing Effective Use Cases]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
* [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing effective Use Cases]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117527</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 4 2q</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117527"/>
		<updated>2018-08-24T14:32:50Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''A Guide to Use Cases on the WEB'''&lt;br /&gt;
&lt;br /&gt;
''Topic :Use cases. There are even more pages on the Web on use cases than on MVC. If someone wants to learn about them, what should (s)he do? Look at the first few hits in Google? I expect we can do better than that. Write a review of the use-case sites on the Web. Which are best for learning about the concept? Which have the most instructive examples? Which teach advanced concepts that are not apparent in perusing most use-case sites? Read at least several dozen pages before deciding how to organize your overview.'' &lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This page tries to review the use-case sites on the Web which can be useful to best understand the concept. Also a few instructive examples are covered paying attention to the basic use case as well as advanced concepts that are not apparent in perusing most use-case sites.&lt;br /&gt;
 &lt;br /&gt;
=What is a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;'''''Use case''' is a methodology used in software and systems engineering to understand and identify the functional requirements of a system. Use cases describe the interaction between a primary actor, the initiator of the interaction and the system itself, represented as a sequence of simple steps.''&amp;quot;[1][2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An actor who can more generally be described as the user of the system, is the external entity and can be a person or another system itself. A use case can be best described as what happens when the actor is using the system to achieve some goal. This goal is nothing but the end result which follows the sequence of events as described in the use cases. &lt;br /&gt;
&lt;br /&gt;
Every use case gives a complete list of events which occur from the time the actor starts interacting with the system till the time the final goal is achieved. A use case also records all the possible scenarios that may occur while trying to reach the desired goal. We can think of it as existence of a main course of events that will occur in normal circumstances, to which the exceptional cases are added. Anything that is not relevant to the actor/user is not a part of the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are a few links to external websites which further illustrate this concept.&lt;br /&gt;
&lt;br /&gt;
* [https://www.ibm.com/developerworks/library/ws-using-oo/ OO design process: Use cases, an introduction]&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
&lt;br /&gt;
==UML Diagrams and Use cases==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''The Use case diagram is used to identify the primary elements and processes that form the system. The primary elements are termed as 'actors' and the processes are called &amp;quot;use cases.&amp;quot; The Use case diagram shows which actors interact with each use case.&amp;quot;''[3]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
They are useful in providing a pictorial view of the interactions between the users (actors) and sets of events (use cases) associated with the system.They also evolve as the projects or system change with time. The standard elements of a use case diagram makes comprehension easy for anyone trying to understand the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to draw typical use case diagrams.&lt;br /&gt;
&lt;br /&gt;
* [https://www.smartdraw.com/uml-diagram/ An introduction to UML diagrams &amp;amp; Tutorial] &lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
&lt;br /&gt;
=Examples using Use Cases=&lt;br /&gt;
In this section, a few instructive examples have been outlined along with their references which illustrate different ways in which use cases can be written. The first example is a basic use-case template.&lt;br /&gt;
&lt;br /&gt;
===Basic use case template===&lt;br /&gt;
Described below are some the characteristics of a typical use case.&lt;br /&gt;
  '''CHARACTERISTIC INFORMATION'''&lt;br /&gt;
  * ''Goal in Context'':   Buyer issues request directly to our company, expects goods shipped and to be billed.&lt;br /&gt;
  * ''Scope'':  Company&lt;br /&gt;
  * ''Preconditions'':  We know Buyer, their address, etc.&lt;br /&gt;
  * ''Success End Condition'':  Buyer has goods, we have money for the goods.&lt;br /&gt;
  * ''Failed End Condition'':  We have not sent the goods, Buyer has not spent the money.&lt;br /&gt;
  * ''Primary Actor'':  Buyer, any agent (or computer) acting for the customer&lt;br /&gt;
  * ''Trigger'':  purchase request comes in.&lt;br /&gt;
  &lt;br /&gt;
  '''MAIN SUCCESS SCENARIO'''&lt;br /&gt;
  1. Buyer calls in with a purchase request.&lt;br /&gt;
  2. Company captures buyer’s name, address, requested goods, etc.&lt;br /&gt;
  3. Company gives buyer information on goods, prices, delivery dates, etc.&lt;br /&gt;
  4. Buyer signs for order.&lt;br /&gt;
  5. Company creates order, ships order to buyer.&lt;br /&gt;
  6. Company ships invoice to buyer.&lt;br /&gt;
  7. Buyers pays invoice.&lt;br /&gt;
  &lt;br /&gt;
  '''EXTENSIONS'''&lt;br /&gt;
  3a. Company is out of one of the ordered items: &lt;br /&gt;
      3a1. Renegotiate order.&lt;br /&gt;
  4a. Buyer pays directly with credit card:&lt;br /&gt;
      4a1. Take payment by credit card (use case 44)&lt;br /&gt;
  7a. Buyer returns goods:&lt;br /&gt;
      7a. Handle returned goods (use case 105)&lt;br /&gt;
The basic steps that can be followed so as to ensure writing an effective use case has been described well in [http://www.gatherspace.com/static/use_case_example.html Writing Effective Use Cases].[5]&lt;br /&gt;
&lt;br /&gt;
===Restaurant===&lt;br /&gt;
This example provides one use case but distinctly provides a step by step analysis of the events that constitute a Use Case. It mentions the actors, pre-conditions, Exceptions and Alternative scenarios.&lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/restaurant-uml-use-case-diagram-example.html Restaurant]&lt;br /&gt;
&lt;br /&gt;
===Purchase order===&lt;br /&gt;
This example provides a typical use case specification by listing the Activity, Result, Constraints and Extensions involved with a purchase order from a Finance web page.&lt;br /&gt;
&lt;br /&gt;
* [https://creately.com/diagram/example/ifq4uulr/Purchase%20Order Purchase order System]&lt;br /&gt;
&lt;br /&gt;
===ATM system===&lt;br /&gt;
This example is a little more involved in that it provides a number of use cases associated with using an ATM system including cash withdrawal,&lt;br /&gt;
transfers, deposits, balance inquiry, etc.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.fsu.edu/~baker/swe1/restricted/templates/rr631gv1_stuwrk_withdraw_cash_use-case_spec.pdf ATM System]&lt;br /&gt;
&lt;br /&gt;
===A shopping website order Process===&lt;br /&gt;
This is a very good example that describes the scenarios and extensions involved in writing a use case for a online shopping order. It also describes the UML diagram.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/examples/online-shopping-use-case-diagram-example.html?context=uc-examples Shopping website order]&lt;br /&gt;
&lt;br /&gt;
===Self Service Machine===&lt;br /&gt;
This example provides the typical Use Cases in a self service machine. Some of the aspects of using a self service machine are: buying a product, re-stocking the machine, collecting the money etc. The following link expands on how to do this and also provides the UML diagrams which depict the interaction between the users and system through the use case&lt;br /&gt;
  &lt;br /&gt;
* [http://www.cloudbus.org/~raj/254/Lectures/RajUML2.pdf Self-Service Machine (page-3)]&lt;br /&gt;
&lt;br /&gt;
=How to Write a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Writing effective Use Cases==&lt;br /&gt;
&lt;br /&gt;
One of the most difficult problem in software development is capturing precisely what you want to build. Inaccurate requirement will end-up with significant delay, rework or even abandonment of the project. Effective applying use case technique helps your team capturing requirements in user point of view which can be easily understood by both the end-user and your team. Use case driven development support subsequent development activities such as analysis and design and testing.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to write effective use cases.&lt;br /&gt;
* [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing effective Use Cases]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
* [1] Ivar Jacobson (1992). Object-Oriented Software Engineering. Addison Wesley Professional. ISBN 0-201-54435.&lt;br /&gt;
* [2] [http://en.wikipedia.org/wiki/Use_case Wikipidea Page] Basic definition of Use Case&lt;br /&gt;
* [3] [http://www.developer.com/design/article.php/2109801 Use Case Diagrams]&lt;br /&gt;
* [4] [http://alistair.cockburn.us/images/Uctempla.doc Basic Use Case Template]&lt;br /&gt;
* [5] [http://www.gatherspace.com/static/use_case_example.html#1 Writing Effective Use Cases]&lt;br /&gt;
* [6] [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing effective Use Cases]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
* [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing effective Use Cases]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117526</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 4 2q</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117526"/>
		<updated>2018-08-24T14:32:13Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* External Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''A Guide to Use Cases on the WEB'''&lt;br /&gt;
&lt;br /&gt;
''Topic :Use cases. There are even more pages on the Web on use cases than on MVC. If someone wants to learn about them, what should (s)he do? Look at the first few hits in Google? I expect we can do better than that. Write a review of the use-case sites on the Web. Which are best for learning about the concept? Which have the most instructive examples? Which teach advanced concepts that are not apparent in perusing most use-case sites? Read at least several dozen pages before deciding how to organize your overview.'' &lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This page tries to review the use-case sites on the Web which can be useful to best understand the concept. Also a few instructive examples are covered paying attention to the basic use case as well as advanced concepts that are not apparent in perusing most use-case sites.&lt;br /&gt;
 &lt;br /&gt;
=What is a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;'''''Use case''' is a methodology used in software and systems engineering to understand and identify the functional requirements of a system. Use cases describe the interaction between a primary actor, the initiator of the interaction and the system itself, represented as a sequence of simple steps.''&amp;quot;[1][2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An actor who can more generally be described as the user of the system, is the external entity and can be a person or another system itself. A use case can be best described as what happens when the actor is using the system to achieve some goal. This goal is nothing but the end result which follows the sequence of events as described in the use cases. &lt;br /&gt;
&lt;br /&gt;
Every use case gives a complete list of events which occur from the time the actor starts interacting with the system till the time the final goal is achieved. A use case also records all the possible scenarios that may occur while trying to reach the desired goal. We can think of it as existence of a main course of events that will occur in normal circumstances, to which the exceptional cases are added. Anything that is not relevant to the actor/user is not a part of the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are a few links to external websites which further illustrate this concept.&lt;br /&gt;
&lt;br /&gt;
* [https://www.ibm.com/developerworks/library/ws-using-oo/ OO design process: Use cases, an introduction]&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
&lt;br /&gt;
==UML Diagrams and Use cases==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''The Use case diagram is used to identify the primary elements and processes that form the system. The primary elements are termed as 'actors' and the processes are called &amp;quot;use cases.&amp;quot; The Use case diagram shows which actors interact with each use case.&amp;quot;''[3]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
They are useful in providing a pictorial view of the interactions between the users (actors) and sets of events (use cases) associated with the system.They also evolve as the projects or system change with time. The standard elements of a use case diagram makes comprehension easy for anyone trying to understand the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to draw typical use case diagrams.&lt;br /&gt;
&lt;br /&gt;
* [https://www.smartdraw.com/uml-diagram/ An introduction to UML diagrams &amp;amp; Tutorial] &lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
&lt;br /&gt;
=Examples using Use Cases=&lt;br /&gt;
In this section, a few instructive examples have been outlined along with their references which illustrate different ways in which use cases can be written. The first example is a basic use-case template.&lt;br /&gt;
&lt;br /&gt;
===Basic use case template===&lt;br /&gt;
Described below are some the characteristics of a typical use case.&lt;br /&gt;
  '''CHARACTERISTIC INFORMATION'''&lt;br /&gt;
  * ''Goal in Context'':   Buyer issues request directly to our company, expects goods shipped and to be billed.&lt;br /&gt;
  * ''Scope'':  Company&lt;br /&gt;
  * ''Preconditions'':  We know Buyer, their address, etc.&lt;br /&gt;
  * ''Success End Condition'':  Buyer has goods, we have money for the goods.&lt;br /&gt;
  * ''Failed End Condition'':  We have not sent the goods, Buyer has not spent the money.&lt;br /&gt;
  * ''Primary Actor'':  Buyer, any agent (or computer) acting for the customer&lt;br /&gt;
  * ''Trigger'':  purchase request comes in.&lt;br /&gt;
  &lt;br /&gt;
  '''MAIN SUCCESS SCENARIO'''&lt;br /&gt;
  1. Buyer calls in with a purchase request.&lt;br /&gt;
  2. Company captures buyer’s name, address, requested goods, etc.&lt;br /&gt;
  3. Company gives buyer information on goods, prices, delivery dates, etc.&lt;br /&gt;
  4. Buyer signs for order.&lt;br /&gt;
  5. Company creates order, ships order to buyer.&lt;br /&gt;
  6. Company ships invoice to buyer.&lt;br /&gt;
  7. Buyers pays invoice.&lt;br /&gt;
  &lt;br /&gt;
  '''EXTENSIONS'''&lt;br /&gt;
  3a. Company is out of one of the ordered items: &lt;br /&gt;
      3a1. Renegotiate order.&lt;br /&gt;
  4a. Buyer pays directly with credit card:&lt;br /&gt;
      4a1. Take payment by credit card (use case 44)&lt;br /&gt;
  7a. Buyer returns goods:&lt;br /&gt;
      7a. Handle returned goods (use case 105)&lt;br /&gt;
The basic steps that can be followed so as to ensure writing an effective use case has been described well in [http://www.gatherspace.com/static/use_case_example.html Writing Effective Use Cases].[5]&lt;br /&gt;
&lt;br /&gt;
===Restaurant===&lt;br /&gt;
This example provides one use case but distinctly provides a step by step analysis of the events that constitute a Use Case. It mentions the actors, pre-conditions, Exceptions and Alternative scenarios.&lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/restaurant-uml-use-case-diagram-example.html Restaurant]&lt;br /&gt;
&lt;br /&gt;
===Purchase order===&lt;br /&gt;
This example provides a typical use case specification by listing the Activity, Result, Constraints and Extensions involved with a purchase order from a Finance web page.&lt;br /&gt;
&lt;br /&gt;
* [https://creately.com/diagram/example/ifq4uulr/Purchase%20Order Purchase order System]&lt;br /&gt;
&lt;br /&gt;
===ATM system===&lt;br /&gt;
This example is a little more involved in that it provides a number of use cases associated with using an ATM system including cash withdrawal,&lt;br /&gt;
transfers, deposits, balance inquiry, etc.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.fsu.edu/~baker/swe1/restricted/templates/rr631gv1_stuwrk_withdraw_cash_use-case_spec.pdf ATM System]&lt;br /&gt;
&lt;br /&gt;
===A shopping website order Process===&lt;br /&gt;
This is a very good example that describes the scenarios and extensions involved in writing a use case for a online shopping order. It also describes the UML diagram.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/examples/online-shopping-use-case-diagram-example.html?context=uc-examples Shopping website order]&lt;br /&gt;
&lt;br /&gt;
===Self Service Machine===&lt;br /&gt;
This example provides the typical Use Cases in a self service machine. Some of the aspects of using a self service machine are: buying a product, re-stocking the machine, collecting the money etc. The following link expands on how to do this and also provides the UML diagrams which depict the interaction between the users and system through the use case&lt;br /&gt;
  &lt;br /&gt;
* [http://www.cloudbus.org/~raj/254/Lectures/RajUML2.pdf Self-Service Machine (page-3)]&lt;br /&gt;
&lt;br /&gt;
=How to Write a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Writing effective Use Cases==&lt;br /&gt;
&lt;br /&gt;
One of the most difficult problem in software development is capturing precisely what you want to build. Inaccurate requirement will end-up with significant delay, rework or even abandonment of the project. Effective applying use case technique helps your team capturing requirements in user point of view which can be easily understood by both the end-user and your team. Use case driven development support subsequent development activities such as analysis and design and testing.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to write effective use cases.&lt;br /&gt;
* [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing effective Use Cases]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
* [1] Ivar Jacobson (1992). Object-Oriented Software Engineering. Addison Wesley Professional. ISBN 0-201-54435.&lt;br /&gt;
* [2] [http://en.wikipedia.org/wiki/Use_case Wikipidea Page] Basic definition of Use Case&lt;br /&gt;
* [3] [http://www.developer.com/design/article.php/2109801 Use Case Diagrams]&lt;br /&gt;
* [4] [http://alistair.cockburn.us/images/Uctempla.doc Basic Use Case Template]&lt;br /&gt;
* [5] [http://www.gatherspace.com/static/use_case_example.html#1 Writing Effective Use Cases]&lt;br /&gt;
* [6] [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
* [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing effective Use Cases]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117525</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 4 2q</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117525"/>
		<updated>2018-08-24T14:31:11Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Writing effective Use Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''A Guide to Use Cases on the WEB'''&lt;br /&gt;
&lt;br /&gt;
''Topic :Use cases. There are even more pages on the Web on use cases than on MVC. If someone wants to learn about them, what should (s)he do? Look at the first few hits in Google? I expect we can do better than that. Write a review of the use-case sites on the Web. Which are best for learning about the concept? Which have the most instructive examples? Which teach advanced concepts that are not apparent in perusing most use-case sites? Read at least several dozen pages before deciding how to organize your overview.'' &lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This page tries to review the use-case sites on the Web which can be useful to best understand the concept. Also a few instructive examples are covered paying attention to the basic use case as well as advanced concepts that are not apparent in perusing most use-case sites.&lt;br /&gt;
 &lt;br /&gt;
=What is a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;'''''Use case''' is a methodology used in software and systems engineering to understand and identify the functional requirements of a system. Use cases describe the interaction between a primary actor, the initiator of the interaction and the system itself, represented as a sequence of simple steps.''&amp;quot;[1][2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An actor who can more generally be described as the user of the system, is the external entity and can be a person or another system itself. A use case can be best described as what happens when the actor is using the system to achieve some goal. This goal is nothing but the end result which follows the sequence of events as described in the use cases. &lt;br /&gt;
&lt;br /&gt;
Every use case gives a complete list of events which occur from the time the actor starts interacting with the system till the time the final goal is achieved. A use case also records all the possible scenarios that may occur while trying to reach the desired goal. We can think of it as existence of a main course of events that will occur in normal circumstances, to which the exceptional cases are added. Anything that is not relevant to the actor/user is not a part of the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are a few links to external websites which further illustrate this concept.&lt;br /&gt;
&lt;br /&gt;
* [https://www.ibm.com/developerworks/library/ws-using-oo/ OO design process: Use cases, an introduction]&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
&lt;br /&gt;
==UML Diagrams and Use cases==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''The Use case diagram is used to identify the primary elements and processes that form the system. The primary elements are termed as 'actors' and the processes are called &amp;quot;use cases.&amp;quot; The Use case diagram shows which actors interact with each use case.&amp;quot;''[3]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
They are useful in providing a pictorial view of the interactions between the users (actors) and sets of events (use cases) associated with the system.They also evolve as the projects or system change with time. The standard elements of a use case diagram makes comprehension easy for anyone trying to understand the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to draw typical use case diagrams.&lt;br /&gt;
&lt;br /&gt;
* [https://www.smartdraw.com/uml-diagram/ An introduction to UML diagrams &amp;amp; Tutorial] &lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
&lt;br /&gt;
=Examples using Use Cases=&lt;br /&gt;
In this section, a few instructive examples have been outlined along with their references which illustrate different ways in which use cases can be written. The first example is a basic use-case template.&lt;br /&gt;
&lt;br /&gt;
===Basic use case template===&lt;br /&gt;
Described below are some the characteristics of a typical use case.&lt;br /&gt;
  '''CHARACTERISTIC INFORMATION'''&lt;br /&gt;
  * ''Goal in Context'':   Buyer issues request directly to our company, expects goods shipped and to be billed.&lt;br /&gt;
  * ''Scope'':  Company&lt;br /&gt;
  * ''Preconditions'':  We know Buyer, their address, etc.&lt;br /&gt;
  * ''Success End Condition'':  Buyer has goods, we have money for the goods.&lt;br /&gt;
  * ''Failed End Condition'':  We have not sent the goods, Buyer has not spent the money.&lt;br /&gt;
  * ''Primary Actor'':  Buyer, any agent (or computer) acting for the customer&lt;br /&gt;
  * ''Trigger'':  purchase request comes in.&lt;br /&gt;
  &lt;br /&gt;
  '''MAIN SUCCESS SCENARIO'''&lt;br /&gt;
  1. Buyer calls in with a purchase request.&lt;br /&gt;
  2. Company captures buyer’s name, address, requested goods, etc.&lt;br /&gt;
  3. Company gives buyer information on goods, prices, delivery dates, etc.&lt;br /&gt;
  4. Buyer signs for order.&lt;br /&gt;
  5. Company creates order, ships order to buyer.&lt;br /&gt;
  6. Company ships invoice to buyer.&lt;br /&gt;
  7. Buyers pays invoice.&lt;br /&gt;
  &lt;br /&gt;
  '''EXTENSIONS'''&lt;br /&gt;
  3a. Company is out of one of the ordered items: &lt;br /&gt;
      3a1. Renegotiate order.&lt;br /&gt;
  4a. Buyer pays directly with credit card:&lt;br /&gt;
      4a1. Take payment by credit card (use case 44)&lt;br /&gt;
  7a. Buyer returns goods:&lt;br /&gt;
      7a. Handle returned goods (use case 105)&lt;br /&gt;
The basic steps that can be followed so as to ensure writing an effective use case has been described well in [http://www.gatherspace.com/static/use_case_example.html Writing Effective Use Cases].[5]&lt;br /&gt;
&lt;br /&gt;
===Restaurant===&lt;br /&gt;
This example provides one use case but distinctly provides a step by step analysis of the events that constitute a Use Case. It mentions the actors, pre-conditions, Exceptions and Alternative scenarios.&lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/restaurant-uml-use-case-diagram-example.html Restaurant]&lt;br /&gt;
&lt;br /&gt;
===Purchase order===&lt;br /&gt;
This example provides a typical use case specification by listing the Activity, Result, Constraints and Extensions involved with a purchase order from a Finance web page.&lt;br /&gt;
&lt;br /&gt;
* [https://creately.com/diagram/example/ifq4uulr/Purchase%20Order Purchase order System]&lt;br /&gt;
&lt;br /&gt;
===ATM system===&lt;br /&gt;
This example is a little more involved in that it provides a number of use cases associated with using an ATM system including cash withdrawal,&lt;br /&gt;
transfers, deposits, balance inquiry, etc.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.fsu.edu/~baker/swe1/restricted/templates/rr631gv1_stuwrk_withdraw_cash_use-case_spec.pdf ATM System]&lt;br /&gt;
&lt;br /&gt;
===A shopping website order Process===&lt;br /&gt;
This is a very good example that describes the scenarios and extensions involved in writing a use case for a online shopping order. It also describes the UML diagram.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/examples/online-shopping-use-case-diagram-example.html?context=uc-examples Shopping website order]&lt;br /&gt;
&lt;br /&gt;
===Self Service Machine===&lt;br /&gt;
This example provides the typical Use Cases in a self service machine. Some of the aspects of using a self service machine are: buying a product, re-stocking the machine, collecting the money etc. The following link expands on how to do this and also provides the UML diagrams which depict the interaction between the users and system through the use case&lt;br /&gt;
  &lt;br /&gt;
* [http://www.cloudbus.org/~raj/254/Lectures/RajUML2.pdf Self-Service Machine (page-3)]&lt;br /&gt;
&lt;br /&gt;
=How to Write a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Writing effective Use Cases==&lt;br /&gt;
&lt;br /&gt;
One of the most difficult problem in software development is capturing precisely what you want to build. Inaccurate requirement will end-up with significant delay, rework or even abandonment of the project. Effective applying use case technique helps your team capturing requirements in user point of view which can be easily understood by both the end-user and your team. Use case driven development support subsequent development activities such as analysis and design and testing.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to write effective use cases.&lt;br /&gt;
* [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing effective Use Cases]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
* [1] Ivar Jacobson (1992). Object-Oriented Software Engineering. Addison Wesley Professional. ISBN 0-201-54435.&lt;br /&gt;
* [2] [http://en.wikipedia.org/wiki/Use_case Wikipidea Page] Basic definition of Use Case&lt;br /&gt;
* [3] [http://www.developer.com/design/article.php/2109801 Use Case Diagrams]&lt;br /&gt;
* [4] [http://alistair.cockburn.us/images/Uctempla.doc Basic Use Case Template]&lt;br /&gt;
* [5] [http://www.gatherspace.com/static/use_case_example.html#1 Writing Effective Use Cases]&lt;br /&gt;
* [6] [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
* [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117524</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 4 2q</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117524"/>
		<updated>2018-08-24T14:29:49Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* How to Write a Use Case */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''A Guide to Use Cases on the WEB'''&lt;br /&gt;
&lt;br /&gt;
''Topic :Use cases. There are even more pages on the Web on use cases than on MVC. If someone wants to learn about them, what should (s)he do? Look at the first few hits in Google? I expect we can do better than that. Write a review of the use-case sites on the Web. Which are best for learning about the concept? Which have the most instructive examples? Which teach advanced concepts that are not apparent in perusing most use-case sites? Read at least several dozen pages before deciding how to organize your overview.'' &lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This page tries to review the use-case sites on the Web which can be useful to best understand the concept. Also a few instructive examples are covered paying attention to the basic use case as well as advanced concepts that are not apparent in perusing most use-case sites.&lt;br /&gt;
 &lt;br /&gt;
=What is a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;'''''Use case''' is a methodology used in software and systems engineering to understand and identify the functional requirements of a system. Use cases describe the interaction between a primary actor, the initiator of the interaction and the system itself, represented as a sequence of simple steps.''&amp;quot;[1][2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An actor who can more generally be described as the user of the system, is the external entity and can be a person or another system itself. A use case can be best described as what happens when the actor is using the system to achieve some goal. This goal is nothing but the end result which follows the sequence of events as described in the use cases. &lt;br /&gt;
&lt;br /&gt;
Every use case gives a complete list of events which occur from the time the actor starts interacting with the system till the time the final goal is achieved. A use case also records all the possible scenarios that may occur while trying to reach the desired goal. We can think of it as existence of a main course of events that will occur in normal circumstances, to which the exceptional cases are added. Anything that is not relevant to the actor/user is not a part of the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are a few links to external websites which further illustrate this concept.&lt;br /&gt;
&lt;br /&gt;
* [https://www.ibm.com/developerworks/library/ws-using-oo/ OO design process: Use cases, an introduction]&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
&lt;br /&gt;
==UML Diagrams and Use cases==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''The Use case diagram is used to identify the primary elements and processes that form the system. The primary elements are termed as 'actors' and the processes are called &amp;quot;use cases.&amp;quot; The Use case diagram shows which actors interact with each use case.&amp;quot;''[3]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
They are useful in providing a pictorial view of the interactions between the users (actors) and sets of events (use cases) associated with the system.They also evolve as the projects or system change with time. The standard elements of a use case diagram makes comprehension easy for anyone trying to understand the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to draw typical use case diagrams.&lt;br /&gt;
&lt;br /&gt;
* [https://www.smartdraw.com/uml-diagram/ An introduction to UML diagrams &amp;amp; Tutorial] &lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
&lt;br /&gt;
=Examples using Use Cases=&lt;br /&gt;
In this section, a few instructive examples have been outlined along with their references which illustrate different ways in which use cases can be written. The first example is a basic use-case template.&lt;br /&gt;
&lt;br /&gt;
===Basic use case template===&lt;br /&gt;
Described below are some the characteristics of a typical use case.&lt;br /&gt;
  '''CHARACTERISTIC INFORMATION'''&lt;br /&gt;
  * ''Goal in Context'':   Buyer issues request directly to our company, expects goods shipped and to be billed.&lt;br /&gt;
  * ''Scope'':  Company&lt;br /&gt;
  * ''Preconditions'':  We know Buyer, their address, etc.&lt;br /&gt;
  * ''Success End Condition'':  Buyer has goods, we have money for the goods.&lt;br /&gt;
  * ''Failed End Condition'':  We have not sent the goods, Buyer has not spent the money.&lt;br /&gt;
  * ''Primary Actor'':  Buyer, any agent (or computer) acting for the customer&lt;br /&gt;
  * ''Trigger'':  purchase request comes in.&lt;br /&gt;
  &lt;br /&gt;
  '''MAIN SUCCESS SCENARIO'''&lt;br /&gt;
  1. Buyer calls in with a purchase request.&lt;br /&gt;
  2. Company captures buyer’s name, address, requested goods, etc.&lt;br /&gt;
  3. Company gives buyer information on goods, prices, delivery dates, etc.&lt;br /&gt;
  4. Buyer signs for order.&lt;br /&gt;
  5. Company creates order, ships order to buyer.&lt;br /&gt;
  6. Company ships invoice to buyer.&lt;br /&gt;
  7. Buyers pays invoice.&lt;br /&gt;
  &lt;br /&gt;
  '''EXTENSIONS'''&lt;br /&gt;
  3a. Company is out of one of the ordered items: &lt;br /&gt;
      3a1. Renegotiate order.&lt;br /&gt;
  4a. Buyer pays directly with credit card:&lt;br /&gt;
      4a1. Take payment by credit card (use case 44)&lt;br /&gt;
  7a. Buyer returns goods:&lt;br /&gt;
      7a. Handle returned goods (use case 105)&lt;br /&gt;
The basic steps that can be followed so as to ensure writing an effective use case has been described well in [http://www.gatherspace.com/static/use_case_example.html Writing Effective Use Cases].[5]&lt;br /&gt;
&lt;br /&gt;
===Restaurant===&lt;br /&gt;
This example provides one use case but distinctly provides a step by step analysis of the events that constitute a Use Case. It mentions the actors, pre-conditions, Exceptions and Alternative scenarios.&lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/restaurant-uml-use-case-diagram-example.html Restaurant]&lt;br /&gt;
&lt;br /&gt;
===Purchase order===&lt;br /&gt;
This example provides a typical use case specification by listing the Activity, Result, Constraints and Extensions involved with a purchase order from a Finance web page.&lt;br /&gt;
&lt;br /&gt;
* [https://creately.com/diagram/example/ifq4uulr/Purchase%20Order Purchase order System]&lt;br /&gt;
&lt;br /&gt;
===ATM system===&lt;br /&gt;
This example is a little more involved in that it provides a number of use cases associated with using an ATM system including cash withdrawal,&lt;br /&gt;
transfers, deposits, balance inquiry, etc.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.fsu.edu/~baker/swe1/restricted/templates/rr631gv1_stuwrk_withdraw_cash_use-case_spec.pdf ATM System]&lt;br /&gt;
&lt;br /&gt;
===A shopping website order Process===&lt;br /&gt;
This is a very good example that describes the scenarios and extensions involved in writing a use case for a online shopping order. It also describes the UML diagram.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/examples/online-shopping-use-case-diagram-example.html?context=uc-examples Shopping website order]&lt;br /&gt;
&lt;br /&gt;
===Self Service Machine===&lt;br /&gt;
This example provides the typical Use Cases in a self service machine. Some of the aspects of using a self service machine are: buying a product, re-stocking the machine, collecting the money etc. The following link expands on how to do this and also provides the UML diagrams which depict the interaction between the users and system through the use case&lt;br /&gt;
  &lt;br /&gt;
* [http://www.cloudbus.org/~raj/254/Lectures/RajUML2.pdf Self-Service Machine (page-3)]&lt;br /&gt;
&lt;br /&gt;
=How to Write a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Writing effective Use Cases==&lt;br /&gt;
&lt;br /&gt;
One of the most difficult problem in software development is capturing precisely what you want to build. Inaccurate requirement will end-up with significant delay, rework or even abandonment of the project. Effective applying use case technique helps your team capturing requirements in user point of view which can be easily understood by both the end-user and your team. Use case driven development support subsequent development activities such as analysis and design and testing.&lt;br /&gt;
&lt;br /&gt;
* [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing effective Use Cases]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
* [1] Ivar Jacobson (1992). Object-Oriented Software Engineering. Addison Wesley Professional. ISBN 0-201-54435.&lt;br /&gt;
* [2] [http://en.wikipedia.org/wiki/Use_case Wikipidea Page] Basic definition of Use Case&lt;br /&gt;
* [3] [http://www.developer.com/design/article.php/2109801 Use Case Diagrams]&lt;br /&gt;
* [4] [http://alistair.cockburn.us/images/Uctempla.doc Basic Use Case Template]&lt;br /&gt;
* [5] [http://www.gatherspace.com/static/use_case_example.html#1 Writing Effective Use Cases]&lt;br /&gt;
* [6] [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
* [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117523</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 4 2q</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117523"/>
		<updated>2018-08-24T14:27:35Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Writing effective Use Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''A Guide to Use Cases on the WEB'''&lt;br /&gt;
&lt;br /&gt;
''Topic :Use cases. There are even more pages on the Web on use cases than on MVC. If someone wants to learn about them, what should (s)he do? Look at the first few hits in Google? I expect we can do better than that. Write a review of the use-case sites on the Web. Which are best for learning about the concept? Which have the most instructive examples? Which teach advanced concepts that are not apparent in perusing most use-case sites? Read at least several dozen pages before deciding how to organize your overview.'' &lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This page tries to review the use-case sites on the Web which can be useful to best understand the concept. Also a few instructive examples are covered paying attention to the basic use case as well as advanced concepts that are not apparent in perusing most use-case sites.&lt;br /&gt;
 &lt;br /&gt;
=What is a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;'''''Use case''' is a methodology used in software and systems engineering to understand and identify the functional requirements of a system. Use cases describe the interaction between a primary actor, the initiator of the interaction and the system itself, represented as a sequence of simple steps.''&amp;quot;[1][2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An actor who can more generally be described as the user of the system, is the external entity and can be a person or another system itself. A use case can be best described as what happens when the actor is using the system to achieve some goal. This goal is nothing but the end result which follows the sequence of events as described in the use cases. &lt;br /&gt;
&lt;br /&gt;
Every use case gives a complete list of events which occur from the time the actor starts interacting with the system till the time the final goal is achieved. A use case also records all the possible scenarios that may occur while trying to reach the desired goal. We can think of it as existence of a main course of events that will occur in normal circumstances, to which the exceptional cases are added. Anything that is not relevant to the actor/user is not a part of the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are a few links to external websites which further illustrate this concept.&lt;br /&gt;
&lt;br /&gt;
* [https://www.ibm.com/developerworks/library/ws-using-oo/ OO design process: Use cases, an introduction]&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
&lt;br /&gt;
==UML Diagrams and Use cases==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''The Use case diagram is used to identify the primary elements and processes that form the system. The primary elements are termed as 'actors' and the processes are called &amp;quot;use cases.&amp;quot; The Use case diagram shows which actors interact with each use case.&amp;quot;''[3]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
They are useful in providing a pictorial view of the interactions between the users (actors) and sets of events (use cases) associated with the system.They also evolve as the projects or system change with time. The standard elements of a use case diagram makes comprehension easy for anyone trying to understand the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to draw typical use case diagrams.&lt;br /&gt;
&lt;br /&gt;
* [https://www.smartdraw.com/uml-diagram/ An introduction to UML diagrams &amp;amp; Tutorial] &lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
&lt;br /&gt;
=Examples using Use Cases=&lt;br /&gt;
In this section, a few instructive examples have been outlined along with their references which illustrate different ways in which use cases can be written. The first example is a basic use-case template.&lt;br /&gt;
&lt;br /&gt;
===Basic use case template===&lt;br /&gt;
Described below are some the characteristics of a typical use case.&lt;br /&gt;
  '''CHARACTERISTIC INFORMATION'''&lt;br /&gt;
  * ''Goal in Context'':   Buyer issues request directly to our company, expects goods shipped and to be billed.&lt;br /&gt;
  * ''Scope'':  Company&lt;br /&gt;
  * ''Preconditions'':  We know Buyer, their address, etc.&lt;br /&gt;
  * ''Success End Condition'':  Buyer has goods, we have money for the goods.&lt;br /&gt;
  * ''Failed End Condition'':  We have not sent the goods, Buyer has not spent the money.&lt;br /&gt;
  * ''Primary Actor'':  Buyer, any agent (or computer) acting for the customer&lt;br /&gt;
  * ''Trigger'':  purchase request comes in.&lt;br /&gt;
  &lt;br /&gt;
  '''MAIN SUCCESS SCENARIO'''&lt;br /&gt;
  1. Buyer calls in with a purchase request.&lt;br /&gt;
  2. Company captures buyer’s name, address, requested goods, etc.&lt;br /&gt;
  3. Company gives buyer information on goods, prices, delivery dates, etc.&lt;br /&gt;
  4. Buyer signs for order.&lt;br /&gt;
  5. Company creates order, ships order to buyer.&lt;br /&gt;
  6. Company ships invoice to buyer.&lt;br /&gt;
  7. Buyers pays invoice.&lt;br /&gt;
  &lt;br /&gt;
  '''EXTENSIONS'''&lt;br /&gt;
  3a. Company is out of one of the ordered items: &lt;br /&gt;
      3a1. Renegotiate order.&lt;br /&gt;
  4a. Buyer pays directly with credit card:&lt;br /&gt;
      4a1. Take payment by credit card (use case 44)&lt;br /&gt;
  7a. Buyer returns goods:&lt;br /&gt;
      7a. Handle returned goods (use case 105)&lt;br /&gt;
The basic steps that can be followed so as to ensure writing an effective use case has been described well in [http://www.gatherspace.com/static/use_case_example.html Writing Effective Use Cases].[5]&lt;br /&gt;
&lt;br /&gt;
===Restaurant===&lt;br /&gt;
This example provides one use case but distinctly provides a step by step analysis of the events that constitute a Use Case. It mentions the actors, pre-conditions, Exceptions and Alternative scenarios.&lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/restaurant-uml-use-case-diagram-example.html Restaurant]&lt;br /&gt;
&lt;br /&gt;
===Purchase order===&lt;br /&gt;
This example provides a typical use case specification by listing the Activity, Result, Constraints and Extensions involved with a purchase order from a Finance web page.&lt;br /&gt;
&lt;br /&gt;
* [https://creately.com/diagram/example/ifq4uulr/Purchase%20Order Purchase order System]&lt;br /&gt;
&lt;br /&gt;
===ATM system===&lt;br /&gt;
This example is a little more involved in that it provides a number of use cases associated with using an ATM system including cash withdrawal,&lt;br /&gt;
transfers, deposits, balance inquiry, etc.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.fsu.edu/~baker/swe1/restricted/templates/rr631gv1_stuwrk_withdraw_cash_use-case_spec.pdf ATM System]&lt;br /&gt;
&lt;br /&gt;
===A shopping website order Process===&lt;br /&gt;
This is a very good example that describes the scenarios and extensions involved in writing a use case for a online shopping order. It also describes the UML diagram.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/examples/online-shopping-use-case-diagram-example.html?context=uc-examples Shopping website order]&lt;br /&gt;
&lt;br /&gt;
===Self Service Machine===&lt;br /&gt;
This example provides the typical Use Cases in a self service machine. Some of the aspects of using a self service machine are: buying a product, re-stocking the machine, collecting the money etc. The following link expands on how to do this and also provides the UML diagrams which depict the interaction between the users and system through the use case&lt;br /&gt;
  &lt;br /&gt;
* [http://www.cloudbus.org/~raj/254/Lectures/RajUML2.pdf Self-Service Machine (page-3)]&lt;br /&gt;
&lt;br /&gt;
=How to Write a Use Case=&lt;br /&gt;
&lt;br /&gt;
==Writing effective Use Cases==&lt;br /&gt;
&lt;br /&gt;
Most of the time it is found that common behavior is replicated in Use Cases. This can be handled by writing Use Cases with basic behavior which can be 'plugged-in' to write use cases which cover more behavior. This makes them reusable from one project to another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''A pluggable use case is written in a generic form such that it may be exercised wherever needed. As the name implies a pluggable use case can be ‘plugged’ into any other use case even another pluggable use case. It contains a cohesive set of functionality that encapsulates the common behavior of a subgoal, where this subgoal exists in multiple transactions. Because a pluggable use case only constitutes a subgoal of another use case its context must be inferred from the invoking use case.&amp;quot;'' [6]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following link gives a detailed description of this concept&lt;br /&gt;
&lt;br /&gt;
* [https://www.visual-paradigm.com/tutorials/writingeffectiveusecase.jsp Writing effective Use Cases]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
* [1] Ivar Jacobson (1992). Object-Oriented Software Engineering. Addison Wesley Professional. ISBN 0-201-54435.&lt;br /&gt;
* [2] [http://en.wikipedia.org/wiki/Use_case Wikipidea Page] Basic definition of Use Case&lt;br /&gt;
* [3] [http://www.developer.com/design/article.php/2109801 Use Case Diagrams]&lt;br /&gt;
* [4] [http://alistair.cockburn.us/images/Uctempla.doc Basic Use Case Template]&lt;br /&gt;
* [5] [http://www.gatherspace.com/static/use_case_example.html#1 Writing Effective Use Cases]&lt;br /&gt;
* [6] [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
* [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117522</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 4 2q</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117522"/>
		<updated>2018-08-24T14:22:18Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Advanced Concepts on Use Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''A Guide to Use Cases on the WEB'''&lt;br /&gt;
&lt;br /&gt;
''Topic :Use cases. There are even more pages on the Web on use cases than on MVC. If someone wants to learn about them, what should (s)he do? Look at the first few hits in Google? I expect we can do better than that. Write a review of the use-case sites on the Web. Which are best for learning about the concept? Which have the most instructive examples? Which teach advanced concepts that are not apparent in perusing most use-case sites? Read at least several dozen pages before deciding how to organize your overview.'' &lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This page tries to review the use-case sites on the Web which can be useful to best understand the concept. Also a few instructive examples are covered paying attention to the basic use case as well as advanced concepts that are not apparent in perusing most use-case sites.&lt;br /&gt;
 &lt;br /&gt;
=What is a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;'''''Use case''' is a methodology used in software and systems engineering to understand and identify the functional requirements of a system. Use cases describe the interaction between a primary actor, the initiator of the interaction and the system itself, represented as a sequence of simple steps.''&amp;quot;[1][2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An actor who can more generally be described as the user of the system, is the external entity and can be a person or another system itself. A use case can be best described as what happens when the actor is using the system to achieve some goal. This goal is nothing but the end result which follows the sequence of events as described in the use cases. &lt;br /&gt;
&lt;br /&gt;
Every use case gives a complete list of events which occur from the time the actor starts interacting with the system till the time the final goal is achieved. A use case also records all the possible scenarios that may occur while trying to reach the desired goal. We can think of it as existence of a main course of events that will occur in normal circumstances, to which the exceptional cases are added. Anything that is not relevant to the actor/user is not a part of the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are a few links to external websites which further illustrate this concept.&lt;br /&gt;
&lt;br /&gt;
* [https://www.ibm.com/developerworks/library/ws-using-oo/ OO design process: Use cases, an introduction]&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
&lt;br /&gt;
==UML Diagrams and Use cases==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''The Use case diagram is used to identify the primary elements and processes that form the system. The primary elements are termed as 'actors' and the processes are called &amp;quot;use cases.&amp;quot; The Use case diagram shows which actors interact with each use case.&amp;quot;''[3]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
They are useful in providing a pictorial view of the interactions between the users (actors) and sets of events (use cases) associated with the system.They also evolve as the projects or system change with time. The standard elements of a use case diagram makes comprehension easy for anyone trying to understand the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to draw typical use case diagrams.&lt;br /&gt;
&lt;br /&gt;
* [https://www.smartdraw.com/uml-diagram/ An introduction to UML diagrams &amp;amp; Tutorial] &lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
&lt;br /&gt;
=Examples using Use Cases=&lt;br /&gt;
In this section, a few instructive examples have been outlined along with their references which illustrate different ways in which use cases can be written. The first example is a basic use-case template.&lt;br /&gt;
&lt;br /&gt;
===Basic use case template===&lt;br /&gt;
Described below are some the characteristics of a typical use case.&lt;br /&gt;
  '''CHARACTERISTIC INFORMATION'''&lt;br /&gt;
  * ''Goal in Context'':   Buyer issues request directly to our company, expects goods shipped and to be billed.&lt;br /&gt;
  * ''Scope'':  Company&lt;br /&gt;
  * ''Preconditions'':  We know Buyer, their address, etc.&lt;br /&gt;
  * ''Success End Condition'':  Buyer has goods, we have money for the goods.&lt;br /&gt;
  * ''Failed End Condition'':  We have not sent the goods, Buyer has not spent the money.&lt;br /&gt;
  * ''Primary Actor'':  Buyer, any agent (or computer) acting for the customer&lt;br /&gt;
  * ''Trigger'':  purchase request comes in.&lt;br /&gt;
  &lt;br /&gt;
  '''MAIN SUCCESS SCENARIO'''&lt;br /&gt;
  1. Buyer calls in with a purchase request.&lt;br /&gt;
  2. Company captures buyer’s name, address, requested goods, etc.&lt;br /&gt;
  3. Company gives buyer information on goods, prices, delivery dates, etc.&lt;br /&gt;
  4. Buyer signs for order.&lt;br /&gt;
  5. Company creates order, ships order to buyer.&lt;br /&gt;
  6. Company ships invoice to buyer.&lt;br /&gt;
  7. Buyers pays invoice.&lt;br /&gt;
  &lt;br /&gt;
  '''EXTENSIONS'''&lt;br /&gt;
  3a. Company is out of one of the ordered items: &lt;br /&gt;
      3a1. Renegotiate order.&lt;br /&gt;
  4a. Buyer pays directly with credit card:&lt;br /&gt;
      4a1. Take payment by credit card (use case 44)&lt;br /&gt;
  7a. Buyer returns goods:&lt;br /&gt;
      7a. Handle returned goods (use case 105)&lt;br /&gt;
The basic steps that can be followed so as to ensure writing an effective use case has been described well in [http://www.gatherspace.com/static/use_case_example.html Writing Effective Use Cases].[5]&lt;br /&gt;
&lt;br /&gt;
===Restaurant===&lt;br /&gt;
This example provides one use case but distinctly provides a step by step analysis of the events that constitute a Use Case. It mentions the actors, pre-conditions, Exceptions and Alternative scenarios.&lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/restaurant-uml-use-case-diagram-example.html Restaurant]&lt;br /&gt;
&lt;br /&gt;
===Purchase order===&lt;br /&gt;
This example provides a typical use case specification by listing the Activity, Result, Constraints and Extensions involved with a purchase order from a Finance web page.&lt;br /&gt;
&lt;br /&gt;
* [https://creately.com/diagram/example/ifq4uulr/Purchase%20Order Purchase order System]&lt;br /&gt;
&lt;br /&gt;
===ATM system===&lt;br /&gt;
This example is a little more involved in that it provides a number of use cases associated with using an ATM system including cash withdrawal,&lt;br /&gt;
transfers, deposits, balance inquiry, etc.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.fsu.edu/~baker/swe1/restricted/templates/rr631gv1_stuwrk_withdraw_cash_use-case_spec.pdf ATM System]&lt;br /&gt;
&lt;br /&gt;
===A shopping website order Process===&lt;br /&gt;
This is a very good example that describes the scenarios and extensions involved in writing a use case for a online shopping order. It also describes the UML diagram.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/examples/online-shopping-use-case-diagram-example.html?context=uc-examples Shopping website order]&lt;br /&gt;
&lt;br /&gt;
===Self Service Machine===&lt;br /&gt;
This example provides the typical Use Cases in a self service machine. Some of the aspects of using a self service machine are: buying a product, re-stocking the machine, collecting the money etc. The following link expands on how to do this and also provides the UML diagrams which depict the interaction between the users and system through the use case&lt;br /&gt;
  &lt;br /&gt;
* [http://www.cloudbus.org/~raj/254/Lectures/RajUML2.pdf Self-Service Machine (page-3)]&lt;br /&gt;
&lt;br /&gt;
=Writing effective Use Cases=&lt;br /&gt;
&lt;br /&gt;
==Pluggable Use Cases==&lt;br /&gt;
&lt;br /&gt;
Most of the time it is found that common behavior is replicated in Use Cases. This can be handled by writing Use Cases with basic behavior which can be 'plugged-in' to write use cases which cover more behavior. This makes them reusable from one project to another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''A pluggable use case is written in a generic form such that it may be exercised wherever needed. As the name implies a pluggable use case can be ‘plugged’ into any other use case even another pluggable use case. It contains a cohesive set of functionality that encapsulates the common behavior of a subgoal, where this subgoal exists in multiple transactions. Because a pluggable use case only constitutes a subgoal of another use case its context must be inferred from the invoking use case.&amp;quot;'' [6]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following link gives a detailed description of this concept&lt;br /&gt;
&lt;br /&gt;
* [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
* [1] Ivar Jacobson (1992). Object-Oriented Software Engineering. Addison Wesley Professional. ISBN 0-201-54435.&lt;br /&gt;
* [2] [http://en.wikipedia.org/wiki/Use_case Wikipidea Page] Basic definition of Use Case&lt;br /&gt;
* [3] [http://www.developer.com/design/article.php/2109801 Use Case Diagrams]&lt;br /&gt;
* [4] [http://alistair.cockburn.us/images/Uctempla.doc Basic Use Case Template]&lt;br /&gt;
* [5] [http://www.gatherspace.com/static/use_case_example.html#1 Writing Effective Use Cases]&lt;br /&gt;
* [6] [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
* [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117521</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 4 2q</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117521"/>
		<updated>2018-08-24T13:34:11Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* External Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''A Guide to Use Cases on the WEB'''&lt;br /&gt;
&lt;br /&gt;
''Topic :Use cases. There are even more pages on the Web on use cases than on MVC. If someone wants to learn about them, what should (s)he do? Look at the first few hits in Google? I expect we can do better than that. Write a review of the use-case sites on the Web. Which are best for learning about the concept? Which have the most instructive examples? Which teach advanced concepts that are not apparent in perusing most use-case sites? Read at least several dozen pages before deciding how to organize your overview.'' &lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This page tries to review the use-case sites on the Web which can be useful to best understand the concept. Also a few instructive examples are covered paying attention to the basic use case as well as advanced concepts that are not apparent in perusing most use-case sites.&lt;br /&gt;
 &lt;br /&gt;
=What is a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;'''''Use case''' is a methodology used in software and systems engineering to understand and identify the functional requirements of a system. Use cases describe the interaction between a primary actor, the initiator of the interaction and the system itself, represented as a sequence of simple steps.''&amp;quot;[1][2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An actor who can more generally be described as the user of the system, is the external entity and can be a person or another system itself. A use case can be best described as what happens when the actor is using the system to achieve some goal. This goal is nothing but the end result which follows the sequence of events as described in the use cases. &lt;br /&gt;
&lt;br /&gt;
Every use case gives a complete list of events which occur from the time the actor starts interacting with the system till the time the final goal is achieved. A use case also records all the possible scenarios that may occur while trying to reach the desired goal. We can think of it as existence of a main course of events that will occur in normal circumstances, to which the exceptional cases are added. Anything that is not relevant to the actor/user is not a part of the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are a few links to external websites which further illustrate this concept.&lt;br /&gt;
&lt;br /&gt;
* [https://www.ibm.com/developerworks/library/ws-using-oo/ OO design process: Use cases, an introduction]&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
&lt;br /&gt;
==UML Diagrams and Use cases==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''The Use case diagram is used to identify the primary elements and processes that form the system. The primary elements are termed as 'actors' and the processes are called &amp;quot;use cases.&amp;quot; The Use case diagram shows which actors interact with each use case.&amp;quot;''[3]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
They are useful in providing a pictorial view of the interactions between the users (actors) and sets of events (use cases) associated with the system.They also evolve as the projects or system change with time. The standard elements of a use case diagram makes comprehension easy for anyone trying to understand the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to draw typical use case diagrams.&lt;br /&gt;
&lt;br /&gt;
* [https://www.smartdraw.com/uml-diagram/ An introduction to UML diagrams &amp;amp; Tutorial] &lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
&lt;br /&gt;
=Examples using Use Cases=&lt;br /&gt;
In this section, a few instructive examples have been outlined along with their references which illustrate different ways in which use cases can be written. The first example is a basic use-case template.&lt;br /&gt;
&lt;br /&gt;
===Basic use case template===&lt;br /&gt;
Described below are some the characteristics of a typical use case.&lt;br /&gt;
  '''CHARACTERISTIC INFORMATION'''&lt;br /&gt;
  * ''Goal in Context'':   Buyer issues request directly to our company, expects goods shipped and to be billed.&lt;br /&gt;
  * ''Scope'':  Company&lt;br /&gt;
  * ''Preconditions'':  We know Buyer, their address, etc.&lt;br /&gt;
  * ''Success End Condition'':  Buyer has goods, we have money for the goods.&lt;br /&gt;
  * ''Failed End Condition'':  We have not sent the goods, Buyer has not spent the money.&lt;br /&gt;
  * ''Primary Actor'':  Buyer, any agent (or computer) acting for the customer&lt;br /&gt;
  * ''Trigger'':  purchase request comes in.&lt;br /&gt;
  &lt;br /&gt;
  '''MAIN SUCCESS SCENARIO'''&lt;br /&gt;
  1. Buyer calls in with a purchase request.&lt;br /&gt;
  2. Company captures buyer’s name, address, requested goods, etc.&lt;br /&gt;
  3. Company gives buyer information on goods, prices, delivery dates, etc.&lt;br /&gt;
  4. Buyer signs for order.&lt;br /&gt;
  5. Company creates order, ships order to buyer.&lt;br /&gt;
  6. Company ships invoice to buyer.&lt;br /&gt;
  7. Buyers pays invoice.&lt;br /&gt;
  &lt;br /&gt;
  '''EXTENSIONS'''&lt;br /&gt;
  3a. Company is out of one of the ordered items: &lt;br /&gt;
      3a1. Renegotiate order.&lt;br /&gt;
  4a. Buyer pays directly with credit card:&lt;br /&gt;
      4a1. Take payment by credit card (use case 44)&lt;br /&gt;
  7a. Buyer returns goods:&lt;br /&gt;
      7a. Handle returned goods (use case 105)&lt;br /&gt;
The basic steps that can be followed so as to ensure writing an effective use case has been described well in [http://www.gatherspace.com/static/use_case_example.html Writing Effective Use Cases].[5]&lt;br /&gt;
&lt;br /&gt;
===Restaurant===&lt;br /&gt;
This example provides one use case but distinctly provides a step by step analysis of the events that constitute a Use Case. It mentions the actors, pre-conditions, Exceptions and Alternative scenarios.&lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/restaurant-uml-use-case-diagram-example.html Restaurant]&lt;br /&gt;
&lt;br /&gt;
===Purchase order===&lt;br /&gt;
This example provides a typical use case specification by listing the Activity, Result, Constraints and Extensions involved with a purchase order from a Finance web page.&lt;br /&gt;
&lt;br /&gt;
* [https://creately.com/diagram/example/ifq4uulr/Purchase%20Order Purchase order System]&lt;br /&gt;
&lt;br /&gt;
===ATM system===&lt;br /&gt;
This example is a little more involved in that it provides a number of use cases associated with using an ATM system including cash withdrawal,&lt;br /&gt;
transfers, deposits, balance inquiry, etc.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.fsu.edu/~baker/swe1/restricted/templates/rr631gv1_stuwrk_withdraw_cash_use-case_spec.pdf ATM System]&lt;br /&gt;
&lt;br /&gt;
===A shopping website order Process===&lt;br /&gt;
This is a very good example that describes the scenarios and extensions involved in writing a use case for a online shopping order. It also describes the UML diagram.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/examples/online-shopping-use-case-diagram-example.html?context=uc-examples Shopping website order]&lt;br /&gt;
&lt;br /&gt;
===Self Service Machine===&lt;br /&gt;
This example provides the typical Use Cases in a self service machine. Some of the aspects of using a self service machine are: buying a product, re-stocking the machine, collecting the money etc. The following link expands on how to do this and also provides the UML diagrams which depict the interaction between the users and system through the use case&lt;br /&gt;
  &lt;br /&gt;
* [http://www.cloudbus.org/~raj/254/Lectures/RajUML2.pdf Self-Service Machine (page-3)]&lt;br /&gt;
&lt;br /&gt;
=Advanced Concepts on Use Cases=&lt;br /&gt;
&lt;br /&gt;
==Pluggable Use Cases==&lt;br /&gt;
&lt;br /&gt;
Most of the time it is found that common behavior is replicated in Use Cases. This can be handled by writing Use Cases with basic behavior which can be 'plugged-in' to write use cases which cover more behavior. This makes them reusable from one project to another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''A pluggable use case is written in a generic form such that it may be exercised wherever needed. As the name implies a pluggable use case can be ‘plugged’ into any other use case even another pluggable use case. It contains a cohesive set of functionality that encapsulates the common behavior of a subgoal, where this subgoal exists in multiple transactions. Because a pluggable use case only constitutes a subgoal of another use case its context must be inferred from the invoking use case.&amp;quot;'' [6]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following link gives a detailed description of this concept&lt;br /&gt;
&lt;br /&gt;
* [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
* [1] Ivar Jacobson (1992). Object-Oriented Software Engineering. Addison Wesley Professional. ISBN 0-201-54435.&lt;br /&gt;
* [2] [http://en.wikipedia.org/wiki/Use_case Wikipidea Page] Basic definition of Use Case&lt;br /&gt;
* [3] [http://www.developer.com/design/article.php/2109801 Use Case Diagrams]&lt;br /&gt;
* [4] [http://alistair.cockburn.us/images/Uctempla.doc Basic Use Case Template]&lt;br /&gt;
* [5] [http://www.gatherspace.com/static/use_case_example.html#1 Writing Effective Use Cases]&lt;br /&gt;
* [6] [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
* [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117520</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 4 2q</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_4_2q&amp;diff=117520"/>
		<updated>2018-08-24T13:24:29Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''A Guide to Use Cases on the WEB'''&lt;br /&gt;
&lt;br /&gt;
''Topic :Use cases. There are even more pages on the Web on use cases than on MVC. If someone wants to learn about them, what should (s)he do? Look at the first few hits in Google? I expect we can do better than that. Write a review of the use-case sites on the Web. Which are best for learning about the concept? Which have the most instructive examples? Which teach advanced concepts that are not apparent in perusing most use-case sites? Read at least several dozen pages before deciding how to organize your overview.'' &lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
This page tries to review the use-case sites on the Web which can be useful to best understand the concept. Also a few instructive examples are covered paying attention to the basic use case as well as advanced concepts that are not apparent in perusing most use-case sites.&lt;br /&gt;
 &lt;br /&gt;
=What is a Use Case?=&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;'''''Use case''' is a methodology used in software and systems engineering to understand and identify the functional requirements of a system. Use cases describe the interaction between a primary actor, the initiator of the interaction and the system itself, represented as a sequence of simple steps.''&amp;quot;[1][2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An actor who can more generally be described as the user of the system, is the external entity and can be a person or another system itself. A use case can be best described as what happens when the actor is using the system to achieve some goal. This goal is nothing but the end result which follows the sequence of events as described in the use cases. &lt;br /&gt;
&lt;br /&gt;
Every use case gives a complete list of events which occur from the time the actor starts interacting with the system till the time the final goal is achieved. A use case also records all the possible scenarios that may occur while trying to reach the desired goal. We can think of it as existence of a main course of events that will occur in normal circumstances, to which the exceptional cases are added. Anything that is not relevant to the actor/user is not a part of the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are a few links to external websites which further illustrate this concept.&lt;br /&gt;
&lt;br /&gt;
* [https://www.ibm.com/developerworks/library/ws-using-oo/ OO design process: Use cases, an introduction]&lt;br /&gt;
* [http://www.cs.uno.edu/~jaime/Courses/4210/useCaseFundamentals.html Use Case Fundamentals]&lt;br /&gt;
&lt;br /&gt;
==UML Diagrams and Use cases==&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''The Use case diagram is used to identify the primary elements and processes that form the system. The primary elements are termed as 'actors' and the processes are called &amp;quot;use cases.&amp;quot; The Use case diagram shows which actors interact with each use case.&amp;quot;''[3]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
They are useful in providing a pictorial view of the interactions between the users (actors) and sets of events (use cases) associated with the system.They also evolve as the projects or system change with time. The standard elements of a use case diagram makes comprehension easy for anyone trying to understand the use case.&lt;br /&gt;
&lt;br /&gt;
Listed below are useful links in understanding how to draw typical use case diagrams.&lt;br /&gt;
&lt;br /&gt;
* [https://www.smartdraw.com/uml-diagram/ An introduction to UML diagrams &amp;amp; Tutorial] &lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
&lt;br /&gt;
=Examples using Use Cases=&lt;br /&gt;
In this section, a few instructive examples have been outlined along with their references which illustrate different ways in which use cases can be written. The first example is a basic use-case template.&lt;br /&gt;
&lt;br /&gt;
===Basic use case template===&lt;br /&gt;
Described below are some the characteristics of a typical use case.&lt;br /&gt;
  '''CHARACTERISTIC INFORMATION'''&lt;br /&gt;
  * ''Goal in Context'':   Buyer issues request directly to our company, expects goods shipped and to be billed.&lt;br /&gt;
  * ''Scope'':  Company&lt;br /&gt;
  * ''Preconditions'':  We know Buyer, their address, etc.&lt;br /&gt;
  * ''Success End Condition'':  Buyer has goods, we have money for the goods.&lt;br /&gt;
  * ''Failed End Condition'':  We have not sent the goods, Buyer has not spent the money.&lt;br /&gt;
  * ''Primary Actor'':  Buyer, any agent (or computer) acting for the customer&lt;br /&gt;
  * ''Trigger'':  purchase request comes in.&lt;br /&gt;
  &lt;br /&gt;
  '''MAIN SUCCESS SCENARIO'''&lt;br /&gt;
  1. Buyer calls in with a purchase request.&lt;br /&gt;
  2. Company captures buyer’s name, address, requested goods, etc.&lt;br /&gt;
  3. Company gives buyer information on goods, prices, delivery dates, etc.&lt;br /&gt;
  4. Buyer signs for order.&lt;br /&gt;
  5. Company creates order, ships order to buyer.&lt;br /&gt;
  6. Company ships invoice to buyer.&lt;br /&gt;
  7. Buyers pays invoice.&lt;br /&gt;
  &lt;br /&gt;
  '''EXTENSIONS'''&lt;br /&gt;
  3a. Company is out of one of the ordered items: &lt;br /&gt;
      3a1. Renegotiate order.&lt;br /&gt;
  4a. Buyer pays directly with credit card:&lt;br /&gt;
      4a1. Take payment by credit card (use case 44)&lt;br /&gt;
  7a. Buyer returns goods:&lt;br /&gt;
      7a. Handle returned goods (use case 105)&lt;br /&gt;
The basic steps that can be followed so as to ensure writing an effective use case has been described well in [http://www.gatherspace.com/static/use_case_example.html Writing Effective Use Cases].[5]&lt;br /&gt;
&lt;br /&gt;
===Restaurant===&lt;br /&gt;
This example provides one use case but distinctly provides a step by step analysis of the events that constitute a Use Case. It mentions the actors, pre-conditions, Exceptions and Alternative scenarios.&lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/restaurant-uml-use-case-diagram-example.html Restaurant]&lt;br /&gt;
&lt;br /&gt;
===Purchase order===&lt;br /&gt;
This example provides a typical use case specification by listing the Activity, Result, Constraints and Extensions involved with a purchase order from a Finance web page.&lt;br /&gt;
&lt;br /&gt;
* [https://creately.com/diagram/example/ifq4uulr/Purchase%20Order Purchase order System]&lt;br /&gt;
&lt;br /&gt;
===ATM system===&lt;br /&gt;
This example is a little more involved in that it provides a number of use cases associated with using an ATM system including cash withdrawal,&lt;br /&gt;
transfers, deposits, balance inquiry, etc.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.cs.fsu.edu/~baker/swe1/restricted/templates/rr631gv1_stuwrk_withdraw_cash_use-case_spec.pdf ATM System]&lt;br /&gt;
&lt;br /&gt;
===A shopping website order Process===&lt;br /&gt;
This is a very good example that describes the scenarios and extensions involved in writing a use case for a online shopping order. It also describes the UML diagram.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.uml-diagrams.org/examples/online-shopping-use-case-diagram-example.html?context=uc-examples Shopping website order]&lt;br /&gt;
&lt;br /&gt;
===Self Service Machine===&lt;br /&gt;
This example provides the typical Use Cases in a self service machine. Some of the aspects of using a self service machine are: buying a product, re-stocking the machine, collecting the money etc. The following link expands on how to do this and also provides the UML diagrams which depict the interaction between the users and system through the use case&lt;br /&gt;
  &lt;br /&gt;
* [http://www.cloudbus.org/~raj/254/Lectures/RajUML2.pdf Self-Service Machine (page-3)]&lt;br /&gt;
&lt;br /&gt;
=Advanced Concepts on Use Cases=&lt;br /&gt;
&lt;br /&gt;
==Pluggable Use Cases==&lt;br /&gt;
&lt;br /&gt;
Most of the time it is found that common behavior is replicated in Use Cases. This can be handled by writing Use Cases with basic behavior which can be 'plugged-in' to write use cases which cover more behavior. This makes them reusable from one project to another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt; &amp;quot;''A pluggable use case is written in a generic form such that it may be exercised wherever needed. As the name implies a pluggable use case can be ‘plugged’ into any other use case even another pluggable use case. It contains a cohesive set of functionality that encapsulates the common behavior of a subgoal, where this subgoal exists in multiple transactions. Because a pluggable use case only constitutes a subgoal of another use case its context must be inferred from the invoking use case.&amp;quot;'' [6]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following link gives a detailed description of this concept&lt;br /&gt;
&lt;br /&gt;
* [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
* [1] Ivar Jacobson (1992). Object-Oriented Software Engineering. Addison Wesley Professional. ISBN 0-201-54435.&lt;br /&gt;
* [2] [http://en.wikipedia.org/wiki/Use_case Wikipidea Page] Basic definition of Use Case&lt;br /&gt;
* [3] [http://www.developer.com/design/article.php/2109801 Use Case Diagrams]&lt;br /&gt;
* [4] [http://alistair.cockburn.us/images/Uctempla.doc Basic Use Case Template]&lt;br /&gt;
* [5] [http://www.gatherspace.com/static/use_case_example.html#1 Writing Effective Use Cases]&lt;br /&gt;
* [6] [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
&lt;br /&gt;
* [http://alistair.cockburn.us/index.php/Use_case_fundamentals Use Case Fundamentals]&lt;br /&gt;
* [http://www.developer.com/design/article.php/2109801 Elements of a Use Case Diagram]&lt;br /&gt;
* [http://alistair.cockburn.us/index.php/Pluggable_use_cases#Pluggable_Use_Case_Concept Pluggable Use Cases]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=117508</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=117508"/>
		<updated>2018-05-08T17:27:24Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Table */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran (srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma (xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang (zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen (zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
*       [http://wiki.expertiza.ncsu.edu/index.php/Users Table of User model]&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to anonymize the usernames in the views for demo purposes. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request3.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
3.1 &amp;quot;The method should add the session ip to the list of anonymized ip's and redirect to the previous page &amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This is tested by the same test for index&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;lt;br&amp;gt;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Result ==&lt;br /&gt;
&lt;br /&gt;
Coverage percentage:&lt;br /&gt;
&lt;br /&gt;
[[File:E1823_Test_Result.png]]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=117507</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=117507"/>
		<updated>2018-05-08T17:25:47Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Table */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran (srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma (xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang (zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen (zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
*       [http://wiki.expertiza.ncsu.edu/index.php/Main_Page Main Page Expertiza] &lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who created the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to anonymize the usernames in the views for demo purposes. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request3.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
3.1 &amp;quot;The method should add the session ip to the list of anonymized ip's and redirect to the previous page &amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This is tested by the same test for index&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;lt;br&amp;gt;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Result ==&lt;br /&gt;
&lt;br /&gt;
Coverage percentage:&lt;br /&gt;
&lt;br /&gt;
[[File:E1823_Test_Result.png]]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116903</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116903"/>
		<updated>2018-04-25T02:26:43Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Result */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to anonymize the usernames in the views for demo purposes. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request3.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
3.1 &amp;quot;The method should add the session ip to the list of anonymized ip's and redirect to the previous page &amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This is tested by the same test for index&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;lt;br&amp;gt;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Result ==&lt;br /&gt;
&lt;br /&gt;
Coverage percentage:&lt;br /&gt;
&lt;br /&gt;
[[File:E1823_Test_Result.png]]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116902</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116902"/>
		<updated>2018-04-25T02:26:02Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Result */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to anonymize the usernames in the views for demo purposes. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request3.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
3.1 &amp;quot;The method should add the session ip to the list of anonymized ip's and redirect to the previous page &amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This is tested by the same test for index&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;lt;br&amp;gt;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Result ==&lt;br /&gt;
&lt;br /&gt;
Coverage:&lt;br /&gt;
&lt;br /&gt;
[[File:E1823_Test_Result.png]]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116901</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116901"/>
		<updated>2018-04-25T02:25:51Z</updated>

		<summary type="html">&lt;p&gt;Xma21: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to anonymize the usernames in the views for demo purposes. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request3.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
3.1 &amp;quot;The method should add the session ip to the list of anonymized ip's and redirect to the previous page &amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This is tested by the same test for index&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;lt;br&amp;gt;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Result ==&lt;br /&gt;
&lt;br /&gt;
Coverage:&lt;br /&gt;
[[File:E1823_Test_Result.png]]&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E1823_Test_Result.png&amp;diff=116900</id>
		<title>File:E1823 Test Result.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E1823_Test_Result.png&amp;diff=116900"/>
		<updated>2018-04-25T02:24:39Z</updated>

		<summary type="html">&lt;p&gt;Xma21: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116896</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116896"/>
		<updated>2018-04-25T01:40:06Z</updated>

		<summary type="html">&lt;p&gt;Xma21: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request3.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;lt;br&amp;gt;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
== Test Result ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116893</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116893"/>
		<updated>2018-04-25T00:56:31Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request3.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;lt;br&amp;gt;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116892</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116892"/>
		<updated>2018-04-25T00:55:30Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request3.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;lt;br&amp;gt;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116891</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116891"/>
		<updated>2018-04-25T00:53:54Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request3.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116888</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116888"/>
		<updated>2018-04-25T00:52:07Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request2.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116886</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116886"/>
		<updated>2018-04-25T00:51:26Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request2.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116884</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116884"/>
		<updated>2018-04-25T00:51:09Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request2.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116881</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116881"/>
		<updated>2018-04-25T00:50:31Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116879</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116879"/>
		<updated>2018-04-25T00:49:32Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116878</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116878"/>
		<updated>2018-04-25T00:49:06Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;check if it will render users/list_pending_requested page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to users/list page&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to users/list page&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render users/show page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;check if this will render users/new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116876</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116876"/>
		<updated>2018-04-25T00:45:57Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;request_users should contain all the RequestUsers and roles should contain all the roles, just check if it will render list page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to list&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to list&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render show&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, just check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;just need to check if this will render new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116875</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116875"/>
		<updated>2018-04-25T00:45:36Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;request_users should contain all the RequestUsers and roles should contain all the roles, just check if it will render list page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to list&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to list&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render show&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, just check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;just need to check if this will render new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116874</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116874"/>
		<updated>2018-04-25T00:44:47Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;request_users should contain all the RequestUsers and roles should contain all the roles, just check if it will render list page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to list&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to list&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render show&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, just check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;just need to check if this will render new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence.&lt;br /&gt;
 So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116873</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116873"/>
		<updated>2018-04-25T00:43:53Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user.&lt;br /&gt;
This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;request_users should contain all the RequestUsers and roles should contain all the roles, just check if it will render list page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to list&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to list&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render show&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, just check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;just need to check if this will render new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence.&lt;br /&gt;
 So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116872</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116872"/>
		<updated>2018-04-25T00:43:03Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user.&lt;br /&gt;
This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;request_users should contain all the RequestUsers and roles should contain all the roles, just check if it will render list page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to list&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to list&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render show&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, just check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;just need to check if this will render new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116494</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116494"/>
		<updated>2018-04-13T02:03:35Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;request_users should contain all the RequestUsers and roles should contain all the roles, just check if it will render list page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to list&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to list&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render show&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, just check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;just need to check if this will render new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
     (This also covers the condition that user is deleted successfully.)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116493</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116493"/>
		<updated>2018-04-13T02:01:56Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;request_users should contain all the RequestUsers and roles should contain all the roles, just check if it will render list page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to list&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to list&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render show&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, just check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;just need to check if this will render new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; &lt;br /&gt;
(This condition also covers the condition that user is deleted successfully it, so)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116492</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116492"/>
		<updated>2018-04-13T02:01:28Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;request_users should contain all the RequestUsers and roles should contain all the roles, just check if it will render list page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to list&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to list&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render show&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, just check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;just need to check if this will render new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;When user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15.1 &amp;quot;When user is not deleted successfully, it shows an error and redirects to users/list page.&amp;quot; (This condition also covers the condition that user is deleted successfully it, so)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;When params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116491</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116491"/>
		<updated>2018-04-13T01:44:08Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;request_users should contain all the RequestUsers and roles should contain all the roles, just check if it will render list page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to list&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to list&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render show&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, just check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;just need to check if this will render new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;When user is updated successfully, it shows correct flash and redirects to users/show page.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;when user is not updated successfully, it redirects to users/edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15 &amp;quot;If the attributes of users are successfully updated, check whether it shows the correct flash and redirects to users#show page after updating.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;when params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116490</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116490"/>
		<updated>2018-04-13T01:40:43Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method calls the get_user_list method in the user model which returns a list of users according to the role of the user that calls the method. This list is stored in the @users instance variable which is used by the view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtains all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detects if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the details of a user. It first detect is the user is valid. There two condition for an  invalid user: 1) the id of user is nil; 2) current user role is not student and the session id doesn't equal to the user id. Otherwise this user is valid. For a valid user, it will show his/her detailed information including name, email, password, prefs, institution and self_introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when method create is used to create a new user. &lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1.1 &amp;quot;If the user is student, we check if proper redirection is taking place&amp;quot;&lt;br /&gt;
1.2 &amp;quot;Else, the appropriate list of users should be rendered according to the role of the current user&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2.1 &amp;quot;The page should render suggestions only of those user names that are similar to the one being typed and not all user names&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
4.1 &amp;quot;The @users instance variable should contain all the users that are permitted to be viewed by the current user. This will be checked for all the different user types&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
5.1 &amp;quot;request_users should contain all the RequestUsers and roles should contain all the roles, just check if it will render list page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
6.1 &amp;quot;check if the user is nil, will the page redirect to list&amp;quot;&lt;br /&gt;
6.2 &amp;quot;check if the user is not available for editing, will it redirect to list&amp;quot;&lt;br /&gt;
6.3 &amp;quot;check if the user is available for editing, will it render show&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
7.1 &amp;quot;check if the user id is nil or if the role is student and session id equals to id, will it redirect to home&amp;quot;&lt;br /&gt;
7.2 &amp;quot;if the user is valid, just check the return value&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
8.1 &amp;quot;just need to check if this will render new page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;If the attributes of users are successfully updated, check whether it shows the correct flash and redirects to users#show page after updating.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;If the attributes of users are not successfully updated, check whether it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15 &amp;quot;If the attributes of users are successfully updated, check whether it shows the correct flash and redirects to users#show page after updating.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
16.1 &amp;quot;When params[:id] is not nil, @private_key gets correct value.&amp;quot;&lt;br /&gt;
16.2 &amp;quot;when params[:id] is nil, it redirects to /tree_display/drill page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116345</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116345"/>
		<updated>2018-04-08T21:42:03Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtain all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detect if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so we just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;If the attributes of users are successfully updated, check whether it shows the correct flash and redirects to users#show page after updating.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;If the attributes of users are not successfully updated, check whether it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116339</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116339"/>
		<updated>2018-04-08T21:38:12Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtain all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detect if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence, so just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;If successfully updates the attributes of users, check whether it shows the correct flash and redirects to users#show page after updating.&amp;quot;&lt;br /&gt;
14.2 &amp;quot;If fails to update the attributes of users, check whether it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116338</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116338"/>
		<updated>2018-04-08T21:37:28Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtain all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detect if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;Here isn't any conditional sentence, so just need to check if it renders users#edit page.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
14.1 &amp;quot;If successfully updates the attributes of users, check whether it shows the correct flash and redirects to users#show page after updating.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
14.2 &amp;quot;If fails to update the attributes of users, check whether it renders users#edit page.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116335</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116335"/>
		<updated>2018-04-08T21:33:00Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtain all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detect if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether it renders users#edit page&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116334</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116334"/>
		<updated>2018-04-08T21:31:53Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called to show all the requests which need to be reviewed. It first obtain all the request users and the roles. Then It will show those request_users who is under review and their details with a selection window--&amp;quot;status&amp;quot; which is used to determine if this request will be approved or rejected.   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to show the users. It first detect if this user is valid or not. if this user is nil, it will redirect to the &amp;quot;list&amp;quot; page. If this user is valid, it will call the get_role method to get the role information of this user. and then use the role information to determine if this user is available for editing. For users available for editing, this method will render show &amp;quot;page&amp;quot;, otherwise, this method will redirect to &amp;quot;list&amp;quot; page. In summary, this method will direct to &amp;quot;show&amp;quot; page, when the user is able to be edited, otherwise, it will go to &amp;quot;list&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
13.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116222</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116222"/>
		<updated>2018-04-07T03:23:25Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116221</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116221"/>
		<updated>2018-04-07T03:22:50Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
&lt;br /&gt;
Table corresponding to User model has the following attributes: (The unexplained attributes are easy to understand or doesn't make sense here)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. crypted_password&amp;lt;/b&amp;gt; - It is the password after encrypting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. password_salt&amp;lt;/b&amp;gt; - It stores the information of the encryption for the password verification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. role_id&amp;lt;/b&amp;gt; - It is used to distinguish the users as super-administrator, administrator, instructor or student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. fullname&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. email&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. parent_id&amp;lt;/b&amp;gt; - For an instructor, reference to an entry in administrator table, referring the administrator who accepts for the instructor; otherwise, empty.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. private_by_default&amp;lt;/b&amp;gt; - It is a boolean. Assignments and questionnaire created by the instructor should be private (not visible by others) by default.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. mru_directory_path&amp;lt;/b&amp;gt; - For an instructor, the directory that (s)he was working in the previous time he used the system. This is the path-name relative to the home_directory_path. Empty for a non-instructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. email_on_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else is reviewing my work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. email_on_submission&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else submits work I am assigned to review.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. email_on_review_of_review&amp;lt;/b&amp;gt; - It is a boolean value used to check whether someone else reviews one of my reviews.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. is_new_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. master_permission_granted&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. handle&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. digital_certificate&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;17. persistence_token&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;18. timezonepref&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;19. public_key&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;20. copy_of_emails&amp;lt;/b&amp;gt; - It is a boolean value used to check whether the system will send me copies of emails sent for assignments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;21. institution_id&amp;lt;/b&amp;gt; - Reference to an entry in institutions table, referring to the institution at which this user is registered&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;1. index&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is used to list all the users in the database. A permissions check is done first to verify that the current user has permission to view the list of users. If the user is a student, he is redirected away from the page. All other user roles have access to the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. auto_complete_for_user_name&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method finds all users who have names similar to the one being typed and displays only those that have a lower role than the current user. The page is rendered again showing all these suggestions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. set_anonymized_view&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. list&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. list_pending_requested&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;6. show_selection&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;7. show&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;8. new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Request_frame.png]]&lt;br /&gt;
&lt;br /&gt;
(This image will be helpful for the next 4 methods)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when a TA or instructor requests an Expertiza account. To register to use the Expertiza, one needs to be either a course TA or Instructor and then sends a request to Expertiza administrator to get approved. This function only serves TAs and instructors, and the students account will be created by instructors or TAs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the user wants to create accounts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called after the guest sending a request for the account to Expertiza administrator. After the guest sending a request for the account using request_new method, this method will store the request in the database and list all the requests on the pending_request page waiting for the administrator to operate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method is called when the Expertiza administrator deals with the guests' pending requests. By this method, the administrator can approve or decline the pending requests. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;resources :users&amp;quot; in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;quot;get :keys&amp;quot; under the collection block of &amp;quot;resources :users&amp;quot; will enable Rails to recognize paths such as /users/keys with GET, and route to the key action of UsersController.&lt;br /&gt;
&lt;br /&gt;
When this method is called, if no current user or current user is a student but is not the user stored in session, it will redirect to home page of the user stored in session. Otherwise generate_keys (a method of user model) will be called on the current user and the return value will be assigned to an instance variable @private_key defined in UsersController.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
This project aims to writing an integration test for users_controller.rb. There is no this Rspec file exist for this test, so a new test file shall be created and built from scratch. And before writing this test file, some prerequisites must be done.&lt;br /&gt;
1. Download and set the Expertiza environment&lt;br /&gt;
2. Determine which methods should be tested&lt;br /&gt;
3. Define all the conditions needed to be tested for each method&lt;br /&gt;
&lt;br /&gt;
The methods have already been introduced on above, here are the test plan for each method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;9. request_new&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
9.1 &amp;quot;Here isn't any conditional sentence. So only need to check whether the return value is expected.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;10. create&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
10.1 &amp;quot;Is the name new? If yes, good. Otherwise, register the user by email address.&amp;quot;&lt;br /&gt;
10.2 &amp;quot;Is the user's information valid? If yes, good. Otherwise, fail&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;11. create_requested_user_record&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
11.1 &amp;quot;does the user belong to any institution? If yes, good. Otherwise, set a new institution.&amp;quot;&lt;br /&gt;
11.2 &amp;quot;is the user already existed and valid? If both yes, good. If the user already exist, send notification. If the information is not valid, fail.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;12. create_approved_user&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
12.1 &amp;quot;does the request have one status? if yes and the parameters of the request are completed, good. Otherwise, submit a status, approve or reject.&amp;quot;&lt;br /&gt;
12.2 &amp;quot;is the status Approved or Rejected?&amp;quot;&lt;br /&gt;
12.2.1 &amp;quot;if the status is Approved, is the information valid? if yes, good. Otherwise fail&amp;quot;&lt;br /&gt;
12.2.2 &amp;quot;if the status is Rejected, is the processing correctly? if yes, reject successfully. Otherwise, error processing request.&amp;quot;    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116158</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116158"/>
		<updated>2018-04-06T15:01:04Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in UsersController.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Conditions ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116138</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116138"/>
		<updated>2018-04-06T03:53:19Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in users controller.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule makes destroy action response to the delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Conditions ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116137</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116137"/>
		<updated>2018-04-06T03:52:07Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in users controller.&lt;br /&gt;
&lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule makes destroy action response to delete method and thus accomplishing the user deletion. &lt;br /&gt;
&lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Conditions ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116136</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116136"/>
		<updated>2018-04-06T03:51:48Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in users controller. &lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule makes destroy action response to delete method and thus accomplishing the user deletion. &lt;br /&gt;
When this method is called, it will first find the relevant user via user's id that stored in params[:id] and then delete related AssignmentParticipant, TeamsUser and AssignmentQuestionnaire models if any (These models are found through their foregin key: user_id). Finally, the user is deleted from the database and it will show a success flash. If any of the above steps fails, it will throw an error flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Conditions ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116123</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116123"/>
		<updated>2018-04-06T03:28:11Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in users controller. &lt;br /&gt;
Thus, this edit method is called when accessing user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule makes update action get called when the form in user's edit page is submitted.&lt;br /&gt;
This method will first find the relevant user by user's id that stored in params[:id] and then updates the user's information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user's show page otherwise it renders user's edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Conditions ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116121</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116121"/>
		<updated>2018-04-06T03:25:56Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule maps /users/1/edit (assuming user's id is 1) to edit action in users controller. &lt;br /&gt;
Thus, this edit method is called when accessing a user's edit page and will pull the relevant user out of the database via user's id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;14. update&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule makes update action get called when the form in user’s edit page is submitted.&lt;br /&gt;
This method will first find the relevant user by user’s id that stored in params[:id] and then updates the user’s information in the database based on the submitted params hash. If the update is successful it shows a success flash and redirects to user’s show page otherwise it renders user’s edit page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;15. destroy&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;16. keys&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Conditions ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116109</id>
		<title>CSC/ECE 517 Spring 2018/E1823 Write integration tests for users controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2018/E1823_Write_integration_tests_for_users_controller.rb&amp;diff=116109"/>
		<updated>2018-04-06T02:28:16Z</updated>

		<summary type="html">&lt;p&gt;Xma21: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is a description of E1813 final project for Spring 2018, CSC/ECE 517.&lt;br /&gt;
== Project Statement ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
users_controller.rb is a file under app/controllers that manages different kinds of methods related to users. This project is to write integration tests for users_controller.rb by using rspec, so our goal is to create a file named users_controller_spec.rb under spec/controllers folder and write integration tests to make the path coverage of users_controller.rb more than 90% and achieve the highest possible branch coverage.&lt;br /&gt;
&lt;br /&gt;
All methods used in this file that can render or redirect to one or more user-related views will be thoroughly tested.(16 in total) We do not need to test private or protected methods directly because these methods should be tested when testing other public methods in the same file.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
Newly-created file:&lt;br /&gt;
&lt;br /&gt;
  spec/users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Tested file:&lt;br /&gt;
&lt;br /&gt;
  app/controllers/users_controller.rb&lt;br /&gt;
&lt;br /&gt;
Related view files:&lt;br /&gt;
&lt;br /&gt;
  app/views/users/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/keys.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/list_pending_requested.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/request_new.html.erb&lt;br /&gt;
&lt;br /&gt;
  app/views/users/show.html.erb&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
1. Sandeep Rajendran(srajend@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Xiao Ma(xma21@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Zekun Zhang(zzhang56@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Zhiyu Chen(zchen45@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
== Functionality of the Controller ==&lt;br /&gt;
=== Table ===&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&amp;lt;b&amp;gt;13. edit&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
resources :users in routing rule maps /users/1/edit (assuming user’s id is 1) to edit action in users controller. &lt;br /&gt;
Thus, this edit method is called when accessing a user’s edit page and will pull the relevant user out of the database via user’s id that stored in params[:id].&lt;br /&gt;
&lt;br /&gt;
== Testing Conditions ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Xma21</name></author>
	</entry>
</feed>