ambition/coverage/index.html

10629 lines
319 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Code coverage for Ambition</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src='./assets/0.10.0/application.js' type='text/javascript'></script>
<link href='./assets/0.10.0/application.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
<link rel="shortcut icon" type="image/png" href="./assets/0.10.0/favicon_yellow.png" />
<link rel="icon" type="image/png" href="./assets/0.10.0/favicon.png" />
</head>
<body>
<div id="loading">
<img src="./assets/0.10.0/loading.gif" alt="loading"/>
</div>
<div id="wrapper" style="display:none;">
<div class="timestamp">Generated <abbr class="timeago" title="2017-01-03T10:44:37+08:00">2017-01-03T10:44:37+08:00</abbr></div>
<ul class="group_tabs"></ul>
<div id="content">
<div class="file_list_container" id="AllFiles">
<h2>
<span class="group_name">All Files</span>
(<span class="covered_percent"><span class="yellow">87.05%</span></span>
covered at
<span class="covered_strength">
<span class="green">
1.37
</span>
</span> hits/line)
</h2>
<a name="AllFiles"></a>
<div>
<b>26</b> files in total.
<b>865</b> relevant lines.
<span class="green"><b>753</b> lines covered</span> and
<span class="red"><b>112</b> lines missed </span>
</div>
<table class="file_list">
<thead>
<tr>
<th>File</th>
<th>% covered</th>
<th>Lines</th>
<th>Relevant Lines</th>
<th>Lines covered</th>
<th>Lines missed</th>
<th>Avg. Hits / Line</th>
</tr>
</thead>
<tbody>
<tr>
<td class="strong"><a href="#21a8a4d37a25eeae46a4b4e7882837279db625f6" class="src_link" title="app/controllers/application_controller.rb">app/controllers/application_controller.rb</a></td>
<td class="green strong">100.0 %</td>
<td>16</td>
<td>8</td>
<td>8</td>
<td>0</td>
<td>3.5</td>
</tr>
<tr>
<td class="strong"><a href="#479de84fe6df2ab07a531646b3fe830347df060e" class="src_link" title="app/controllers/missions_controller.rb">app/controllers/missions_controller.rb</a></td>
<td class="red strong">59.42 %</td>
<td>154</td>
<td>69</td>
<td>41</td>
<td>28</td>
<td>0.9</td>
</tr>
<tr>
<td class="strong"><a href="#848e5d85436bd98a9ff164a8c102f8dcd0205601" class="src_link" title="app/controllers/notes_controller.rb">app/controllers/notes_controller.rb</a></td>
<td class="green strong">100.0 %</td>
<td>37</td>
<td>16</td>
<td>16</td>
<td>0</td>
<td>1.2</td>
</tr>
<tr>
<td class="strong"><a href="#0372be451d4207e57c60fe0ae29614b1407e2907" class="src_link" title="app/controllers/projects_controller.rb">app/controllers/projects_controller.rb</a></td>
<td class="red strong">21.13 %</td>
<td>150</td>
<td>71</td>
<td>15</td>
<td>56</td>
<td>0.3</td>
</tr>
<tr>
<td class="strong"><a href="#c555c2a7405663c6de0bf97fda1795476e0e6b24" class="src_link" title="app/controllers/sessions_controller.rb">app/controllers/sessions_controller.rb</a></td>
<td class="green strong">100.0 %</td>
<td>29</td>
<td>15</td>
<td>15</td>
<td>0</td>
<td>3.3</td>
</tr>
<tr>
<td class="strong"><a href="#e9733564f675453b1f324b65b93eafbfe1d97185" class="src_link" title="app/controllers/shares_controller.rb">app/controllers/shares_controller.rb</a></td>
<td class="red strong">37.04 %</td>
<td>55</td>
<td>27</td>
<td>10</td>
<td>17</td>
<td>0.5</td>
</tr>
<tr>
<td class="strong"><a href="#f5389d49ff8c02c5a9e6eeda4d22eec2a913ee28" class="src_link" title="app/controllers/users_controller.rb">app/controllers/users_controller.rb</a></td>
<td class="green strong">100.0 %</td>
<td>53</td>
<td>26</td>
<td>26</td>
<td>0</td>
<td>2.9</td>
</tr>
<tr>
<td class="strong"><a href="#bee33d336c194b40053da6e55f73ab6b09c29625" class="src_link" title="app/models/comment.rb">app/models/comment.rb</a></td>
<td class="green strong">100.0 %</td>
<td>44</td>
<td>16</td>
<td>16</td>
<td>0</td>
<td>2.6</td>
</tr>
<tr>
<td class="strong"><a href="#0db745639a46a8e60ee3be5e867105508b239689" class="src_link" title="app/models/mission.rb">app/models/mission.rb</a></td>
<td class="green strong">100.0 %</td>
<td>47</td>
<td>22</td>
<td>22</td>
<td>0</td>
<td>5.0</td>
</tr>
<tr>
<td class="strong"><a href="#c68b2223ecc316803aa9a1fac8d0269aef908c42" class="src_link" title="app/models/missions_user.rb">app/models/missions_user.rb</a></td>
<td class="green strong">100.0 %</td>
<td>30</td>
<td>14</td>
<td>14</td>
<td>0</td>
<td>2.0</td>
</tr>
<tr>
<td class="strong"><a href="#62e9dd18e626544eade9ed0b20dc3545557473d1" class="src_link" title="app/models/note.rb">app/models/note.rb</a></td>
<td class="green strong">100.0 %</td>
<td>50</td>
<td>26</td>
<td>26</td>
<td>0</td>
<td>3.8</td>
</tr>
<tr>
<td class="strong"><a href="#3c949a9cef12a5b36b0ed70b82e018448b1c2725" class="src_link" title="app/models/project.rb">app/models/project.rb</a></td>
<td class="yellow strong">87.5 %</td>
<td>15</td>
<td>8</td>
<td>7</td>
<td>1</td>
<td>2.0</td>
</tr>
<tr>
<td class="strong"><a href="#e782303906061f982438021be1eaffe0f682fbfa" class="src_link" title="app/models/share.rb">app/models/share.rb</a></td>
<td class="green strong">100.0 %</td>
<td>37</td>
<td>20</td>
<td>20</td>
<td>0</td>
<td>3.1</td>
</tr>
<tr>
<td class="strong"><a href="#a6d30df0f04fd500a43246d8a960f4502230d398" class="src_link" title="app/models/user.rb">app/models/user.rb</a></td>
<td class="green strong">100.0 %</td>
<td>15</td>
<td>9</td>
<td>9</td>
<td>0</td>
<td>1.0</td>
</tr>
<tr>
<td class="strong"><a href="#b3d517a211a3d4d496fb9b56b2a98d9ad4fcd088" class="src_link" title="spec/controllers/notes_controller_spec.rb">spec/controllers/notes_controller_spec.rb</a></td>
<td class="green strong">100.0 %</td>
<td>34</td>
<td>19</td>
<td>19</td>
<td>0</td>
<td>1.0</td>
</tr>
<tr>
<td class="strong"><a href="#0d8d52d02a89ffe8095903af971d301c9b63d7cb" class="src_link" title="spec/controllers/projects_controller_spec.rb">spec/controllers/projects_controller_spec.rb</a></td>
<td class="yellow strong">86.05 %</td>
<td>83</td>
<td>43</td>
<td>37</td>
<td>6</td>
<td>0.9</td>
</tr>
<tr>
<td class="strong"><a href="#4f6628a02d637cae9a2dfc99e7f8d551123b2dec" class="src_link" title="spec/controllers/sessions_controller_spec.rb">spec/controllers/sessions_controller_spec.rb</a></td>
<td class="green strong">100.0 %</td>
<td>100</td>
<td>53</td>
<td>53</td>
<td>0</td>
<td>1.3</td>
</tr>
<tr>
<td class="strong"><a href="#d407126ea6537d4b4103ecb42ef3011588b05501" class="src_link" title="spec/controllers/shares_controller_spec.rb">spec/controllers/shares_controller_spec.rb</a></td>
<td class="yellow strong">84.62 %</td>
<td>56</td>
<td>26</td>
<td>22</td>
<td>4</td>
<td>0.8</td>
</tr>
<tr>
<td class="strong"><a href="#a90d8b92a95e33dbb254552eff7ef68960b46cdc" class="src_link" title="spec/controllers/users_controller_spec.rb">spec/controllers/users_controller_spec.rb</a></td>
<td class="green strong">100.0 %</td>
<td>150</td>
<td>82</td>
<td>82</td>
<td>0</td>
<td>1.3</td>
</tr>
<tr>
<td class="strong"><a href="#b600d7aa19393eb5a1f4faf82ab8fb94c8cd39de" class="src_link" title="spec/models/comment_spec.rb">spec/models/comment_spec.rb</a></td>
<td class="green strong">100.0 %</td>
<td>56</td>
<td>42</td>
<td>42</td>
<td>0</td>
<td>1.0</td>
</tr>
<tr>
<td class="strong"><a href="#87b629c591df97bdf14bc514434df11b3ebafb35" class="src_link" title="spec/models/mission_spec.rb">spec/models/mission_spec.rb</a></td>
<td class="green strong">100.0 %</td>
<td>73</td>
<td>23</td>
<td>23</td>
<td>0</td>
<td>1.0</td>
</tr>
<tr>
<td class="strong"><a href="#83262d161db87629764629c21c55880068f2d2a8" class="src_link" title="spec/models/missions_user_spec.rb">spec/models/missions_user_spec.rb</a></td>
<td class="green strong">100.0 %</td>
<td>61</td>
<td>42</td>
<td>42</td>
<td>0</td>
<td>1.0</td>
</tr>
<tr>
<td class="strong"><a href="#71c2d0c14437171dd4c650c3f917d2dd65d5ebd6" class="src_link" title="spec/models/note_spec.rb">spec/models/note_spec.rb</a></td>
<td class="green strong">100.0 %</td>
<td>90</td>
<td>62</td>
<td>62</td>
<td>0</td>
<td>1.0</td>
</tr>
<tr>
<td class="strong"><a href="#56dbd95b9485fb6f6ff887a57154ea9b82fec369" class="src_link" title="spec/models/project_spec.rb">spec/models/project_spec.rb</a></td>
<td class="green strong">100.0 %</td>
<td>32</td>
<td>18</td>
<td>18</td>
<td>0</td>
<td>1.0</td>
</tr>
<tr>
<td class="strong"><a href="#aa9b4c95b53bc4794e31c2234c228d3027468638" class="src_link" title="spec/models/share_spec.rb">spec/models/share_spec.rb</a></td>
<td class="green strong">100.0 %</td>
<td>90</td>
<td>65</td>
<td>65</td>
<td>0</td>
<td>1.0</td>
</tr>
<tr>
<td class="strong"><a href="#86b35fc5fa71440aad12e812bf9657aa85e487db" class="src_link" title="spec/models/user_spec.rb">spec/models/user_spec.rb</a></td>
<td class="green strong">100.0 %</td>
<td>81</td>
<td>43</td>
<td>43</td>
<td>0</td>
<td>1.0</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="footer">
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.12.0
and simplecov-html v0.10.0<br/>
using RSpec
</div>
<div class="source_files">
<div class="source_table" id="21a8a4d37a25eeae46a4b4e7882837279db625f6">
<div class="header">
<h3>app/controllers/application_controller.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>8</b> relevant lines.
<span class="green"><b>8</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class ApplicationController &lt; ActionController::Base</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"> # Prevent CSRF attacks by raising an exception.</code>
</li>
<li class="never" data-hits="" data-linenumber="3">
<code class="ruby"> # For APIs, you may want to use :null_session instead.</code>
</li>
<li class="covered" data-hits="1" data-linenumber="4">
<span class="hits">1</span>
<code class="ruby"> protect_from_forgery with: :exception</code>
</li>
<li class="never" data-hits="" data-linenumber="5">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
<code class="ruby"> def authenticate</code>
</li>
<li class="covered" data-hits="20" data-linenumber="7">
<span class="hits">20</span>
<code class="ruby"> render status: :unauthorized, nothing: true unless session[&#39;user_id&#39;]</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="9">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> private</code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> def current_user</code>
</li>
<li class="covered" data-hits="2" data-linenumber="12">
<span class="hits">2</span>
<code class="ruby"> @current_user ||= User.find(session[:user_id]) if session[:user_id]</code>
</li>
<li class="never" data-hits="" data-linenumber="13">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="14">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> helper_method :current_user</code>
</li>
<li class="never" data-hits="" data-linenumber="16">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="479de84fe6df2ab07a531646b3fe830347df060e">
<div class="header">
<h3>app/controllers/missions_controller.rb</h3>
<h4><span class="red">59.42 %</span> covered</h4>
<div>
<b>69</b> relevant lines.
<span class="green"><b>41</b> lines covered</span> and
<span class="red"><b>28</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class MissionsController &lt; ApplicationController</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby"> before_action :authenticate</code>
</li>
<li class="covered" data-hits="1" data-linenumber="4">
<span class="hits">1</span>
<code class="ruby"> skip_before_action :verify_authenticity_token, :only =&gt; [</code>
</li>
<li class="never" data-hits="" data-linenumber="5">
<code class="ruby"> :create,</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> :getlist,</code>
</li>
<li class="never" data-hits="" data-linenumber="7">
<code class="ruby"> :detail,</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> :update,</code>
</li>
<li class="never" data-hits="" data-linenumber="9">
<code class="ruby"> :commentPublish</code>
</li>
<li class="never" data-hits="" data-linenumber="10">
<code class="ruby"> ]</code>
</li>
<li class="never" data-hits="" data-linenumber="11">
<code class="ruby"> #======================================&gt;获取当前项目某状态的任务列表</code>
</li>
<li class="never" data-hits="" data-linenumber="12">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> def getlist</code>
</li>
<li class="never" data-hits="" data-linenumber="14">
<code class="ruby"> #Todo</code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> pid = params[:project_id]</code>
</li>
<li class="covered" data-hits="1" data-linenumber="16">
<span class="hits">1</span>
<code class="ruby"> stu = params[:status_type]</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> #missions = []</code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> details = []</code>
</li>
<li class="covered" data-hits="1" data-linenumber="19">
<span class="hits">1</span>
<code class="ruby"> missions = Mission.where(&quot;project_id = ? AND status = ?&quot;,pid,stu).all</code>
</li>
<li class="never" data-hits="" data-linenumber="20">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="21">
<span class="hits">1</span>
<code class="ruby"> missions.each do |mission|</code>
</li>
<li class="never" data-hits="" data-linenumber="22">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="23">
<code class="ruby"> #puts mission.inspect</code>
</li>
<li class="never" data-hits="" data-linenumber="24">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="25">
<span class="hits">1</span>
<code class="ruby"> details += [{</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"> :id =&gt; mission.id,</code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> :name =&gt; mission.name,</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> :content =&gt; mission.content</code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> }]</code>
</li>
<li class="never" data-hits="" data-linenumber="30">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="31">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="32">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> # Mission.where(:project_id =&gt; pid).where(:status =&gt; stu) do |i|</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> # missions += [{</code>
</li>
<li class="never" data-hits="" data-linenumber="35">
<code class="ruby"> # :id =&gt; i.id,</code>
</li>
<li class="never" data-hits="" data-linenumber="36">
<code class="ruby"> # :name =&gt; i.name,</code>
</li>
<li class="never" data-hits="" data-linenumber="37">
<code class="ruby"> # :content =&gt; i.content</code>
</li>
<li class="never" data-hits="" data-linenumber="38">
<code class="ruby"> # }]</code>
</li>
<li class="never" data-hits="" data-linenumber="39">
<code class="ruby"> # end</code>
</li>
<li class="covered" data-hits="1" data-linenumber="40">
<span class="hits">1</span>
<code class="ruby"> render :json =&gt; {</code>
</li>
<li class="never" data-hits="" data-linenumber="41">
<code class="ruby"> :code =&gt; 0,</code>
</li>
<li class="never" data-hits="" data-linenumber="42">
<code class="ruby"> :data =&gt; missions</code>
</li>
<li class="never" data-hits="" data-linenumber="43">
<code class="ruby"> }</code>
</li>
<li class="never" data-hits="" data-linenumber="44">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="45">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="46">
<code class="ruby"> #======================================&gt;获取任务详细信息</code>
</li>
<li class="never" data-hits="" data-linenumber="47">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="48">
<span class="hits">1</span>
<code class="ruby"> def detail</code>
</li>
<li class="never" data-hits="" data-linenumber="49">
<code class="ruby"> #Todo</code>
</li>
<li class="covered" data-hits="1" data-linenumber="50">
<span class="hits">1</span>
<code class="ruby"> username = []</code>
</li>
<li class="covered" data-hits="1" data-linenumber="51">
<span class="hits">1</span>
<code class="ruby"> comments_s = []</code>
</li>
<li class="covered" data-hits="1" data-linenumber="52">
<span class="hits">1</span>
<code class="ruby"> mission_id = params[:id]</code>
</li>
<li class="covered" data-hits="1" data-linenumber="53">
<span class="hits">1</span>
<code class="ruby"> mission = Mission.find_by(id: mission_id)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="54">
<span class="hits">1</span>
<code class="ruby"> m_us = Missions_user.where(&quot;mission_id = ?&quot;,mission_id).all</code>
</li>
<li class="never" data-hits="" data-linenumber="55">
<code class="ruby"> #puts m_us.inspect</code>
</li>
<li class="covered" data-hits="1" data-linenumber="56">
<span class="hits">1</span>
<code class="ruby"> m_us.each do |m_u|</code>
</li>
<li class="missed" data-hits="0" data-linenumber="57">
<code class="ruby"> user_id = m_u.user_id</code>
</li>
<li class="missed" data-hits="0" data-linenumber="58">
<code class="ruby"> user = User.find_by(id: user_id)</code>
</li>
<li class="never" data-hits="" data-linenumber="59">
<code class="ruby"> #puts user.inspect</code>
</li>
<li class="missed" data-hits="0" data-linenumber="60">
<code class="ruby"> username &lt;&lt; user.name</code>
</li>
<li class="never" data-hits="" data-linenumber="61">
<code class="ruby"> end</code>
</li>
<li class="covered" data-hits="1" data-linenumber="62">
<span class="hits">1</span>
<code class="ruby"> comments = Comment.where(&quot;mission_id = ?&quot;,mission_id).all</code>
</li>
<li class="covered" data-hits="1" data-linenumber="63">
<span class="hits">1</span>
<code class="ruby"> comments.each do |c|</code>
</li>
<li class="covered" data-hits="2" data-linenumber="64">
<span class="hits">2</span>
<code class="ruby"> uname = User.find_by(id: c.user_id).name</code>
</li>
<li class="covered" data-hits="2" data-linenumber="65">
<span class="hits">2</span>
<code class="ruby"> comments_s += [{</code>
</li>
<li class="never" data-hits="" data-linenumber="66">
<code class="ruby"> :nickname =&gt; uname,</code>
</li>
<li class="never" data-hits="" data-linenumber="67">
<code class="ruby"> :content =&gt; c.content,</code>
</li>
<li class="never" data-hits="" data-linenumber="68">
<code class="ruby"> :time =&gt; c.created_at</code>
</li>
<li class="never" data-hits="" data-linenumber="69">
<code class="ruby"> }]</code>
</li>
<li class="never" data-hits="" data-linenumber="70">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="71">
<code class="ruby"> #puts comments_s.inspect</code>
</li>
<li class="covered" data-hits="1" data-linenumber="72">
<span class="hits">1</span>
<code class="ruby"> render :json =&gt; {</code>
</li>
<li class="never" data-hits="" data-linenumber="73">
<code class="ruby"> :code =&gt; 0,</code>
</li>
<li class="never" data-hits="" data-linenumber="74">
<code class="ruby"> :data =&gt; {</code>
</li>
<li class="never" data-hits="" data-linenumber="75">
<code class="ruby"> :name =&gt; mission.name,</code>
</li>
<li class="never" data-hits="" data-linenumber="76">
<code class="ruby"> :content =&gt; mission.content,</code>
</li>
<li class="never" data-hits="" data-linenumber="77">
<code class="ruby"> :priority =&gt; mission.priority,</code>
</li>
<li class="never" data-hits="" data-linenumber="78">
<code class="ruby"> :status =&gt; mission.status,</code>
</li>
<li class="never" data-hits="" data-linenumber="79">
<code class="ruby"> :deadline =&gt; mission.deadline,</code>
</li>
<li class="never" data-hits="" data-linenumber="80">
<code class="ruby"> :users =&gt; username,</code>
</li>
<li class="never" data-hits="" data-linenumber="81">
<code class="ruby"> :comments =&gt; comments_s</code>
</li>
<li class="never" data-hits="" data-linenumber="82">
<code class="ruby"> }</code>
</li>
<li class="never" data-hits="" data-linenumber="83">
<code class="ruby"> }</code>
</li>
<li class="never" data-hits="" data-linenumber="84">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="85">
<code class="ruby"> #======================================&gt;创建任务</code>
</li>
<li class="never" data-hits="" data-linenumber="86">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="87">
<span class="hits">1</span>
<code class="ruby"> def create</code>
</li>
<li class="never" data-hits="" data-linenumber="88">
<code class="ruby"> #Todo</code>
</li>
<li class="covered" data-hits="2" data-linenumber="89">
<span class="hits">2</span>
<code class="ruby"> params_mission = {name: params[:name],project_id: params[:project_id],content: params[:content],deadline: params[:deadline],priority: params[:priority],status: params[:status]}</code>
</li>
<li class="covered" data-hits="2" data-linenumber="90">
<span class="hits">2</span>
<code class="ruby"> mission = Mission.new(params_mission)</code>
</li>
<li class="covered" data-hits="2" data-linenumber="91">
<span class="hits">2</span>
<code class="ruby"> if mission.save</code>
</li>
<li class="covered" data-hits="2" data-linenumber="92">
<span class="hits">2</span>
<code class="ruby"> render :json =&gt; {:code =&gt; 0}</code>
</li>
<li class="never" data-hits="" data-linenumber="93">
<code class="ruby"> else</code>
</li>
<li class="missed" data-hits="0" data-linenumber="94">
<code class="ruby"> render json: mission.errors, status: :unprocessable_entity</code>
</li>
<li class="never" data-hits="" data-linenumber="95">
<code class="ruby"> end</code>
</li>
<li class="covered" data-hits="2" data-linenumber="96">
<span class="hits">2</span>
<code class="ruby"> userids = params[:users]</code>
</li>
<li class="covered" data-hits="2" data-linenumber="97">
<span class="hits">2</span>
<code class="ruby"> userids.each do |id|</code>
</li>
<li class="covered" data-hits="2" data-linenumber="98">
<span class="hits">2</span>
<code class="ruby"> user_enties = User.find_by(id: id)</code>
</li>
<li class="never" data-hits="" data-linenumber="99">
<code class="ruby"> #puts user_enties.inspect</code>
</li>
<li class="covered" data-hits="2" data-linenumber="100">
<span class="hits">2</span>
<code class="ruby"> params_mu = {mission_id: mission.id,user_id: user_enties.id}</code>
</li>
<li class="missed" data-hits="0" data-linenumber="101">
<code class="ruby"> missions_user = Missions_user.new(params_mu)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="102">
<code class="ruby"> missions_user.save</code>
</li>
<li class="missed" data-hits="0" data-linenumber="103">
<code class="ruby"> content = &quot;有新任务 &lt;a&gt;&quot;+mission.name+&quot;&lt;/a&gt;&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="104">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="105">
<code class="ruby"> params_note = {content: content,user_id: user_enties.id,category: 3,project_id: mission.project_id}</code>
</li>
<li class="missed" data-hits="0" data-linenumber="106">
<code class="ruby"> note = Note.new(params_note)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="107">
<code class="ruby"> note.save</code>
</li>
<li class="never" data-hits="" data-linenumber="108">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="109">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="110">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="111">
<code class="ruby"> #======================================&gt;修改任务信息</code>
</li>
<li class="never" data-hits="" data-linenumber="112">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="113">
<span class="hits">1</span>
<code class="ruby"> def update</code>
</li>
<li class="never" data-hits="" data-linenumber="114">
<code class="ruby"> #Todo</code>
</li>
<li class="never" data-hits="" data-linenumber="115">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="116">
<code class="ruby"> id = params[:id]</code>
</li>
<li class="never" data-hits="" data-linenumber="117">
<code class="ruby"> #now = Datetime.now</code>
</li>
<li class="missed" data-hits="0" data-linenumber="118">
<code class="ruby"> mission = Mission.find_by(id: id)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="119">
<code class="ruby"> params_mission = {name: params[:name],content: params[:content],deadline: params[:deadline],priority: params[:priority]}</code>
</li>
<li class="never" data-hits="" data-linenumber="120">
<code class="ruby"> #puts params_mission</code>
</li>
<li class="missed" data-hits="0" data-linenumber="121">
<code class="ruby"> mission.update(params_mission)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="122">
<code class="ruby"> mission.save</code>
</li>
<li class="missed" data-hits="0" data-linenumber="123">
<code class="ruby"> Missions_user.delete_all([&quot;mission_id = ?&quot;,id])</code>
</li>
<li class="missed" data-hits="0" data-linenumber="124">
<code class="ruby"> userids = params[:users]</code>
</li>
<li class="missed" data-hits="0" data-linenumber="125">
<code class="ruby"> userids.each do |name|</code>
</li>
<li class="missed" data-hits="0" data-linenumber="126">
<code class="ruby"> user_enties = User.find_by(id: id)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="127">
<code class="ruby"> params = {mission_id: id,user_id: user_enties.id}</code>
</li>
<li class="missed" data-hits="0" data-linenumber="128">
<code class="ruby"> missions_user = Missions_user.new(params)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="129">
<code class="ruby"> missions_user.save</code>
</li>
<li class="missed" data-hits="0" data-linenumber="130">
<code class="ruby"> content = &quot;&lt;a&gt;&quot;+mission.name + &quot;&lt;/a&gt; 任务信息发生了变化&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="131">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="132">
<code class="ruby"> params_note = {content: content,user_id: user_enties.id,category: 3,project_id: mission.project_id}</code>
</li>
<li class="missed" data-hits="0" data-linenumber="133">
<code class="ruby"> note = Note.new(params_note)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="134">
<code class="ruby"> note.save</code>
</li>
<li class="never" data-hits="" data-linenumber="135">
<code class="ruby"> end</code>
</li>
<li class="missed" data-hits="0" data-linenumber="136">
<code class="ruby"> render :json =&gt; {:code =&gt; 0}</code>
</li>
<li class="never" data-hits="" data-linenumber="137">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="138">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="139">
<code class="ruby"> #======================================&gt;当前用户发表评论</code>
</li>
<li class="never" data-hits="" data-linenumber="140">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="141">
<span class="hits">1</span>
<code class="ruby"> def commentPublish</code>
</li>
<li class="never" data-hits="" data-linenumber="142">
<code class="ruby"> #Todo</code>
</li>
<li class="covered" data-hits="3" data-linenumber="143">
<span class="hits">3</span>
<code class="ruby"> mission_id = params[:mission_id]</code>
</li>
<li class="covered" data-hits="3" data-linenumber="144">
<span class="hits">3</span>
<code class="ruby"> content = params[:content]</code>
</li>
<li class="covered" data-hits="3" data-linenumber="145">
<span class="hits">3</span>
<code class="ruby"> user_id = session[:user_id]</code>
</li>
<li class="covered" data-hits="3" data-linenumber="146">
<span class="hits">3</span>
<code class="ruby"> params = {content: content, mission_id: mission_id, user_id: user_id}</code>
</li>
<li class="covered" data-hits="3" data-linenumber="147">
<span class="hits">3</span>
<code class="ruby"> comment = Comment.new(params)</code>
</li>
<li class="covered" data-hits="3" data-linenumber="148">
<span class="hits">3</span>
<code class="ruby"> if comment.save</code>
</li>
<li class="covered" data-hits="3" data-linenumber="149">
<span class="hits">3</span>
<code class="ruby"> render :json =&gt; {:code =&gt; 0}</code>
</li>
<li class="never" data-hits="" data-linenumber="150">
<code class="ruby"> else</code>
</li>
<li class="missed" data-hits="0" data-linenumber="151">
<code class="ruby"> render json: mission.errors, status: :unprocessable_entity</code>
</li>
<li class="never" data-hits="" data-linenumber="152">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="153">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="154">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="848e5d85436bd98a9ff164a8c102f8dcd0205601">
<div class="header">
<h3>app/controllers/notes_controller.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>16</b> relevant lines.
<span class="green"><b>16</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class NotesController &lt; ApplicationController</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby"> before_action :authenticate</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="5">
<code class="ruby"> #获取用户当前的通知列表</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> def getNotesList</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> #Todo</code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> pid = params[:project_id]</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> uid = session[:user_id]</code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> notes = Note.where(&quot;user_id = ? AND project_id = ? &quot;,uid,pid).order(&quot;created_at desc&quot;).all</code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> note = Hash.new do |h,k|</code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> h[k] = []</code>
</li>
<li class="never" data-hits="" data-linenumber="14">
<code class="ruby"> end</code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> notes.each do |n|</code>
</li>
<li class="covered" data-hits="2" data-linenumber="16">
<span class="hits">2</span>
<code class="ruby"> date = n.created_at.to_s[/([\d\-]*)\s(.*)/,1]</code>
</li>
<li class="covered" data-hits="2" data-linenumber="17">
<span class="hits">2</span>
<code class="ruby"> time = n.created_at.to_s[/(.*)\s([\d\:]*)/,2]</code>
</li>
<li class="never" data-hits="" data-linenumber="18">
<code class="ruby"> note[date] &lt;&lt; {</code>
</li>
<li class="never" data-hits="" data-linenumber="19">
<code class="ruby"> :content =&gt; n.content,</code>
</li>
<li class="never" data-hits="" data-linenumber="20">
<code class="ruby"> :time =&gt; time,</code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> :type =&gt; n.category</code>
</li>
<li class="covered" data-hits="2" data-linenumber="22">
<span class="hits">2</span>
<code class="ruby"> }</code>
</li>
<li class="never" data-hits="" data-linenumber="23">
<code class="ruby"> end</code>
</li>
<li class="covered" data-hits="1" data-linenumber="24">
<span class="hits">1</span>
<code class="ruby"> data = []</code>
</li>
<li class="covered" data-hits="1" data-linenumber="25">
<span class="hits">1</span>
<code class="ruby"> note.each do |k,v|</code>
</li>
<li class="covered" data-hits="1" data-linenumber="26">
<span class="hits">1</span>
<code class="ruby"> data += [{</code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> :time =&gt; k,</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> :notes =&gt; v</code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> }]</code>
</li>
<li class="never" data-hits="" data-linenumber="30">
<code class="ruby"> end</code>
</li>
<li class="covered" data-hits="1" data-linenumber="31">
<span class="hits">1</span>
<code class="ruby"> render :json =&gt; {</code>
</li>
<li class="never" data-hits="" data-linenumber="32">
<code class="ruby"> :code =&gt; 0,</code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> :data =&gt; data</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> }</code>
</li>
<li class="never" data-hits="" data-linenumber="35">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="36">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="37">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="0372be451d4207e57c60fe0ae29614b1407e2907">
<div class="header">
<h3>app/controllers/projects_controller.rb</h3>
<h4><span class="red">21.13 %</span> covered</h4>
<div>
<b>71</b> relevant lines.
<span class="green"><b>15</b> lines covered</span> and
<span class="red"><b>56</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class ProjectsController &lt; ApplicationController</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby"> before_action :authenticate</code>
</li>
<li class="covered" data-hits="1" data-linenumber="4">
<span class="hits">1</span>
<code class="ruby"> skip_before_action :verify_authenticity_token, :only =&gt; [</code>
</li>
<li class="never" data-hits="" data-linenumber="5">
<code class="ruby"> :index,</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> :create,</code>
</li>
<li class="never" data-hits="" data-linenumber="7">
<code class="ruby"> :addUsers,</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> :detail,</code>
</li>
<li class="never" data-hits="" data-linenumber="9">
<code class="ruby"> :update,</code>
</li>
<li class="never" data-hits="" data-linenumber="10">
<code class="ruby"> :deleteUsers</code>
</li>
<li class="never" data-hits="" data-linenumber="11">
<code class="ruby"> ]</code>
</li>
<li class="never" data-hits="" data-linenumber="12">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="13">
<code class="ruby"> #=============================================&gt;获取我的项目列表user_id保存在session中.</code>
</li>
<li class="covered" data-hits="1" data-linenumber="14">
<span class="hits">1</span>
<code class="ruby"> def index</code>
</li>
<li class="never" data-hits="" data-linenumber="15">
<code class="ruby"> #Todo</code>
</li>
<li class="missed" data-hits="0" data-linenumber="16">
<code class="ruby"> uid = session[:user_id]</code>
</li>
<li class="missed" data-hits="0" data-linenumber="17">
<code class="ruby"> data=[]</code>
</li>
<li class="missed" data-hits="0" data-linenumber="18">
<code class="ruby"> Projects_user.where(:user_id =&gt; uid).each do |i|</code>
</li>
<li class="missed" data-hits="0" data-linenumber="19">
<code class="ruby"> pid=i.project_id</code>
</li>
<li class="missed" data-hits="0" data-linenumber="20">
<code class="ruby"> p=Project.find_by(id:pid)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="21">
<code class="ruby"> mc = Mission.where(:project_id =&gt; pid).size</code>
</li>
<li class="missed" data-hits="0" data-linenumber="22">
<code class="ruby"> uc = Projects_user.where(:project_id =&gt; pid).size</code>
</li>
<li class="missed" data-hits="0" data-linenumber="23">
<code class="ruby"> sc = Share.where(:project_id =&gt; pid).size</code>
</li>
<li class="missed" data-hits="0" data-linenumber="24">
<code class="ruby"> data+=[{</code>
</li>
<li class="never" data-hits="" data-linenumber="25">
<code class="ruby"> :id =&gt; pid,</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"> :name =&gt; p.name,</code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> :content =&gt; p.content,</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> :mission_count =&gt; mc,</code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> :users_count =&gt; uc,</code>
</li>
<li class="never" data-hits="" data-linenumber="30">
<code class="ruby"> :shares_count =&gt; sc</code>
</li>
<li class="never" data-hits="" data-linenumber="31">
<code class="ruby"> }]</code>
</li>
<li class="never" data-hits="" data-linenumber="32">
<code class="ruby"> end</code>
</li>
<li class="missed" data-hits="0" data-linenumber="33">
<code class="ruby"> render :json =&gt; {</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> :code =&gt; 0,</code>
</li>
<li class="never" data-hits="" data-linenumber="35">
<code class="ruby"> :data =&gt; data</code>
</li>
<li class="never" data-hits="" data-linenumber="36">
<code class="ruby"> }</code>
</li>
<li class="never" data-hits="" data-linenumber="37">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="38">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="39">
<code class="ruby"> #=============================================&gt;创建项目</code>
</li>
<li class="never" data-hits="" data-linenumber="40">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="41">
<span class="hits">1</span>
<code class="ruby"> def create</code>
</li>
<li class="covered" data-hits="2" data-linenumber="42">
<span class="hits">2</span>
<code class="ruby"> uid = session[:user_id]</code>
</li>
<li class="covered" data-hits="2" data-linenumber="43">
<span class="hits">2</span>
<code class="ruby"> project = Project.new(project_params)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="44">
<code class="ruby"> if project.save</code>
</li>
<li class="missed" data-hits="0" data-linenumber="45">
<code class="ruby"> Projects_user.create(project_id:project.id,user_id:uid)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="46">
<code class="ruby"> render status: :created, nothing: true</code>
</li>
<li class="never" data-hits="" data-linenumber="47">
<code class="ruby"> else</code>
</li>
<li class="missed" data-hits="0" data-linenumber="48">
<code class="ruby"> render json: project.errors, status: :unprocessable_entity</code>
</li>
<li class="never" data-hits="" data-linenumber="49">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="50">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="51">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="52">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="53">
<code class="ruby"> #=============================================&gt;项目添加用户</code>
</li>
<li class="never" data-hits="" data-linenumber="54">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="55">
<span class="hits">1</span>
<code class="ruby"> def addUsers</code>
</li>
<li class="covered" data-hits="2" data-linenumber="56">
<span class="hits">2</span>
<code class="ruby"> uid = User.find_by(email:params[:email]).id# 需要添加的用户</code>
</li>
<li class="missed" data-hits="0" data-linenumber="57">
<code class="ruby"> register = session[:user_id]# 当前用户</code>
</li>
<li class="missed" data-hits="0" data-linenumber="58">
<code class="ruby"> pid = params[:project_id]</code>
</li>
<li class="never" data-hits="" data-linenumber="59">
<code class="ruby"> # 检查该项目中是否已经有要添加的用户</code>
</li>
<li class="missed" data-hits="0" data-linenumber="60">
<code class="ruby"> pu_exist=Projects_user.find_by(project_id:pid,user_id:uid)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="61">
<code class="ruby"> if pu_exist.nil?# 不存在</code>
</li>
<li class="missed" data-hits="0" data-linenumber="62">
<code class="ruby"> params_pu = {project_id: pid,user_id: uid}</code>
</li>
<li class="missed" data-hits="0" data-linenumber="63">
<code class="ruby"> pu = Projects_user.new(params_pu)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="64">
<code class="ruby"> pu.save</code>
</li>
<li class="never" data-hits="" data-linenumber="65">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="66">
<code class="ruby"> content = &quot;&lt;a&gt;&quot;+User.find_by(id: register).name + &quot;&lt;/a&gt; 邀请您进入项目 &lt;a&gt;&quot; + Project.find_by(id: pid).name+&quot;&lt;/a&gt;&quot;</code>
</li>
<li class="missed" data-hits="0" data-linenumber="67">
<code class="ruby"> puts content</code>
</li>
<li class="missed" data-hits="0" data-linenumber="68">
<code class="ruby"> params_note = {user_id: uid,content: content,category: 2,project_id: pid}</code>
</li>
<li class="missed" data-hits="0" data-linenumber="69">
<code class="ruby"> note = Note.new(params_note)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="70">
<code class="ruby"> note.save!</code>
</li>
<li class="missed" data-hits="0" data-linenumber="71">
<code class="ruby"> render :json =&gt; {:code =&gt; 0}</code>
</li>
<li class="never" data-hits="" data-linenumber="72">
<code class="ruby"> else# 存在</code>
</li>
<li class="missed" data-hits="0" data-linenumber="73">
<code class="ruby"> render json:current_user.errors, status: :unprocessable_entity</code>
</li>
<li class="never" data-hits="" data-linenumber="74">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="75">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="76">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="77">
<code class="ruby"> #=============================================&gt;项目删除用户</code>
</li>
<li class="covered" data-hits="1" data-linenumber="78">
<span class="hits">1</span>
<code class="ruby"> def deleteUsers</code>
</li>
<li class="missed" data-hits="0" data-linenumber="79">
<code class="ruby"> uid = params[:user_id]# 需要添加的用户</code>
</li>
<li class="missed" data-hits="0" data-linenumber="80">
<code class="ruby"> register = session[:user_id]# 当前用户</code>
</li>
<li class="missed" data-hits="0" data-linenumber="81">
<code class="ruby"> pid = params[:project_id]</code>
</li>
<li class="never" data-hits="" data-linenumber="82">
<code class="ruby"> # 检查该项目中是否已经有要添加的用户</code>
</li>
<li class="missed" data-hits="0" data-linenumber="83">
<code class="ruby"> projects_user=Projects_user.find_by(project_id:pid,user_id:uid)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="84">
<code class="ruby"> if projects_user.nil?# 不存在</code>
</li>
<li class="missed" data-hits="0" data-linenumber="85">
<code class="ruby"> render json:current_user.errors, status: :unprocessable_entity</code>
</li>
<li class="never" data-hits="" data-linenumber="86">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="87">
<code class="ruby"> # 存在</code>
</li>
<li class="missed" data-hits="0" data-linenumber="88">
<code class="ruby"> puts projects_user.user_id</code>
</li>
<li class="missed" data-hits="0" data-linenumber="89">
<code class="ruby"> puts projects_user.project_id</code>
</li>
<li class="missed" data-hits="0" data-linenumber="90">
<code class="ruby"> Projects_user.where(project_id:pid,user_id:uid).delete_all</code>
</li>
<li class="never" data-hits="" data-linenumber="91">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="92">
<code class="ruby"> content =&quot;&lt;a&gt;&quot;+ User.find_by(id: register).name + &quot;&lt;/a&gt; 把您从项目 &lt;a&gt;&quot; + Project.find_by(id: pid).name+&quot;&lt;/a&gt; 中删除&quot;</code>
</li>
<li class="missed" data-hits="0" data-linenumber="93">
<code class="ruby"> puts content</code>
</li>
<li class="missed" data-hits="0" data-linenumber="94">
<code class="ruby"> params_note = {user_id: uid,content: content,category: 2,project_id: pid}</code>
</li>
<li class="missed" data-hits="0" data-linenumber="95">
<code class="ruby"> note = Note.new(params_note)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="96">
<code class="ruby"> note.save!</code>
</li>
<li class="never" data-hits="" data-linenumber="97">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="98">
<code class="ruby"> render :json =&gt; {:code =&gt; 0}</code>
</li>
<li class="never" data-hits="" data-linenumber="99">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="100">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="101">
<code class="ruby"> #=============================================&gt;项目详情</code>
</li>
<li class="never" data-hits="" data-linenumber="102">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="103">
<span class="hits">1</span>
<code class="ruby"> def detail</code>
</li>
<li class="never" data-hits="" data-linenumber="104">
<code class="ruby"> #Todo </code>
</li>
<li class="missed" data-hits="0" data-linenumber="105">
<code class="ruby"> pid = params[:id]</code>
</li>
<li class="missed" data-hits="0" data-linenumber="106">
<code class="ruby"> project = Project.find_by(id: pid)</code>
</li>
<li class="never" data-hits="" data-linenumber="107">
<code class="ruby"> #uid = Projects_user.where(:project_id =&gt; pid)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="108">
<code class="ruby"> users = []</code>
</li>
<li class="missed" data-hits="0" data-linenumber="109">
<code class="ruby"> projects_users = Projects_user.where(&quot;project_id = ?&quot;,pid).all</code>
</li>
<li class="never" data-hits="" data-linenumber="110">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="111">
<code class="ruby"> projects_users.each do |projects_user|</code>
</li>
<li class="missed" data-hits="0" data-linenumber="112">
<code class="ruby"> uid = projects_user.user_id</code>
</li>
<li class="missed" data-hits="0" data-linenumber="113">
<code class="ruby"> i = User.find_by(id: uid)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="114">
<code class="ruby"> users += [{</code>
</li>
<li class="never" data-hits="" data-linenumber="115">
<code class="ruby"> :name =&gt; i.name,</code>
</li>
<li class="never" data-hits="" data-linenumber="116">
<code class="ruby"> :id =&gt; i.id</code>
</li>
<li class="never" data-hits="" data-linenumber="117">
<code class="ruby"> }]</code>
</li>
<li class="never" data-hits="" data-linenumber="118">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="119">
<code class="ruby"> #puts users.inspect </code>
</li>
<li class="never" data-hits="" data-linenumber="120">
<code class="ruby"> # Users.find(uid).each do |i|</code>
</li>
<li class="never" data-hits="" data-linenumber="121">
<code class="ruby"> # users += [{</code>
</li>
<li class="never" data-hits="" data-linenumber="122">
<code class="ruby"> # :nickname =&gt; i.name,</code>
</li>
<li class="never" data-hits="" data-linenumber="123">
<code class="ruby"> # :id =&gt; i.id</code>
</li>
<li class="never" data-hits="" data-linenumber="124">
<code class="ruby"> # }]</code>
</li>
<li class="never" data-hits="" data-linenumber="125">
<code class="ruby"> # end</code>
</li>
<li class="missed" data-hits="0" data-linenumber="126">
<code class="ruby"> render :json =&gt; {</code>
</li>
<li class="never" data-hits="" data-linenumber="127">
<code class="ruby"> :code =&gt; 0,</code>
</li>
<li class="never" data-hits="" data-linenumber="128">
<code class="ruby"> :data =&gt; {</code>
</li>
<li class="never" data-hits="" data-linenumber="129">
<code class="ruby"> :name =&gt; project.name,</code>
</li>
<li class="never" data-hits="" data-linenumber="130">
<code class="ruby"> :content =&gt; project.content,</code>
</li>
<li class="never" data-hits="" data-linenumber="131">
<code class="ruby"> :users =&gt; users</code>
</li>
<li class="never" data-hits="" data-linenumber="132">
<code class="ruby"> }</code>
</li>
<li class="never" data-hits="" data-linenumber="133">
<code class="ruby"> }</code>
</li>
<li class="never" data-hits="" data-linenumber="134">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="135">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="136">
<code class="ruby"> #=============================================&gt;项目修改</code>
</li>
<li class="covered" data-hits="1" data-linenumber="137">
<span class="hits">1</span>
<code class="ruby"> def update</code>
</li>
<li class="missed" data-hits="0" data-linenumber="138">
<code class="ruby"> project = Project.find_by(:id =&gt; params[:project][:id])</code>
</li>
<li class="missed" data-hits="0" data-linenumber="139">
<code class="ruby"> if project.update(project_params)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="140">
<code class="ruby"> render :json =&gt; {:code =&gt; 0}</code>
</li>
<li class="never" data-hits="" data-linenumber="141">
<code class="ruby"> else</code>
</li>
<li class="missed" data-hits="0" data-linenumber="142">
<code class="ruby"> render json:current_user.errors, status: :unprocessable_entity</code>
</li>
<li class="never" data-hits="" data-linenumber="143">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="144">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="145">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="146">
<span class="hits">1</span>
<code class="ruby"> private</code>
</li>
<li class="covered" data-hits="1" data-linenumber="147">
<span class="hits">1</span>
<code class="ruby"> def project_params</code>
</li>
<li class="covered" data-hits="2" data-linenumber="148">
<span class="hits">2</span>
<code class="ruby"> params.require(:project).permit(:name,:content,:id)</code>
</li>
<li class="never" data-hits="" data-linenumber="149">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="150">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="c555c2a7405663c6de0bf97fda1795476e0e6b24">
<div class="header">
<h3>app/controllers/sessions_controller.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>15</b> relevant lines.
<span class="green"><b>15</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class SessionsController &lt; ApplicationController</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="3">
<code class="ruby"> # 除登录之外,其余接口必须在登录状态下访问</code>
</li>
<li class="covered" data-hits="1" data-linenumber="4">
<span class="hits">1</span>
<code class="ruby"> before_action :authenticate, except: [ :create ]</code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> skip_before_action :verify_authenticity_token, :only =&gt; [:create,:destroy,:show]</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="7">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> # 用户登录</code>
</li>
<li class="never" data-hits="" data-linenumber="9">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> def create</code>
</li>
<li class="covered" data-hits="11" data-linenumber="11">
<span class="hits">11</span>
<code class="ruby"> user = User.find_by(email: params[:email])</code>
</li>
<li class="covered" data-hits="11" data-linenumber="12">
<span class="hits">11</span>
<code class="ruby"> if user &amp;&amp; user.authenticate(params[:password])</code>
</li>
<li class="covered" data-hits="6" data-linenumber="13">
<span class="hits">6</span>
<code class="ruby"> session[:user_id] = user.id</code>
</li>
<li class="covered" data-hits="6" data-linenumber="14">
<span class="hits">6</span>
<code class="ruby"> render status: :ok, text: &#39;ok&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="15">
<code class="ruby"> else</code>
</li>
<li class="covered" data-hits="5" data-linenumber="16">
<span class="hits">5</span>
<code class="ruby"> render status: :unauthorized, text: &#39;account or password is not correct&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="18">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="19">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
<code class="ruby"> def destroy</code>
</li>
<li class="covered" data-hits="1" data-linenumber="21">
<span class="hits">1</span>
<code class="ruby"> session.delete :user_id</code>
</li>
<li class="covered" data-hits="1" data-linenumber="22">
<span class="hits">1</span>
<code class="ruby"> @current_user &amp;&amp;= nil</code>
</li>
<li class="covered" data-hits="1" data-linenumber="23">
<span class="hits">1</span>
<code class="ruby"> render status: :ok, nothing: true</code>
</li>
<li class="never" data-hits="" data-linenumber="24">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="25">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="26">
<span class="hits">1</span>
<code class="ruby"> def show</code>
</li>
<li class="covered" data-hits="2" data-linenumber="27">
<span class="hits">2</span>
<code class="ruby"> render &#39;show&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="e9733564f675453b1f324b65b93eafbfe1d97185">
<div class="header">
<h3>app/controllers/shares_controller.rb</h3>
<h4><span class="red">37.04 %</span> covered</h4>
<div>
<b>27</b> relevant lines.
<span class="green"><b>10</b> lines covered</span> and
<span class="red"><b>17</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class SharesController &lt; ApplicationController</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby"> before_action :authenticate</code>
</li>
<li class="covered" data-hits="1" data-linenumber="4">
<span class="hits">1</span>
<code class="ruby"> skip_before_action :verify_authenticity_token, :only =&gt; [</code>
</li>
<li class="never" data-hits="" data-linenumber="5">
<code class="ruby"> :create,</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> :getShareList</code>
</li>
<li class="never" data-hits="" data-linenumber="7">
<code class="ruby"> ]</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> #当前用户创建分享</code>
</li>
<li class="never" data-hits="" data-linenumber="9">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> def create</code>
</li>
<li class="covered" data-hits="2" data-linenumber="11">
<span class="hits">2</span>
<code class="ruby"> uid = session[:user_id].to_i</code>
</li>
<li class="covered" data-hits="2" data-linenumber="12">
<span class="hits">2</span>
<code class="ruby"> share=Share.new(share_params)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="13">
<code class="ruby"> share.user_id=uid</code>
</li>
<li class="missed" data-hits="0" data-linenumber="14">
<code class="ruby"> if share.save</code>
</li>
<li class="missed" data-hits="0" data-linenumber="15">
<code class="ruby"> content = &quot;&lt;a&gt;&quot;+User.find(uid).name + &quot;&lt;/a&gt; 分享了一些事&quot;</code>
</li>
<li class="missed" data-hits="0" data-linenumber="16">
<code class="ruby"> pid=share.project_id</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="18">
<code class="ruby"> Projects_user.where(:project_id =&gt; pid).each do |i|</code>
</li>
<li class="missed" data-hits="0" data-linenumber="19">
<code class="ruby"> params_note = {user_id: i.user_id,content: content,category: 1,project_id: pid}</code>
</li>
<li class="missed" data-hits="0" data-linenumber="20">
<code class="ruby"> note = Note.new(params_note)</code>
</li>
<li class="missed" data-hits="0" data-linenumber="21">
<code class="ruby"> note.save!</code>
</li>
<li class="never" data-hits="" data-linenumber="22">
<code class="ruby"> end</code>
</li>
<li class="missed" data-hits="0" data-linenumber="23">
<code class="ruby"> render status: :created, nothing: true</code>
</li>
<li class="never" data-hits="" data-linenumber="24">
<code class="ruby"> else</code>
</li>
<li class="missed" data-hits="0" data-linenumber="25">
<code class="ruby"> render json: project.errors, status: :unprocessable_entity</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> #获取项目的分享列表</code>
</li>
<li class="never" data-hits="" data-linenumber="30">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="31">
<span class="hits">1</span>
<code class="ruby"> def getShareList</code>
</li>
<li class="never" data-hits="" data-linenumber="32">
<code class="ruby"> #Todo</code>
</li>
<li class="missed" data-hits="0" data-linenumber="33">
<code class="ruby"> pid = params[:project_id]</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="35">
<code class="ruby"> data = []</code>
</li>
<li class="missed" data-hits="0" data-linenumber="36">
<code class="ruby"> Share.where(:project_id =&gt; pid).order(&quot;created_at desc&quot;).each do |i|</code>
</li>
<li class="missed" data-hits="0" data-linenumber="37">
<code class="ruby"> puts i.content</code>
</li>
<li class="missed" data-hits="0" data-linenumber="38">
<code class="ruby"> name = User.find(i.user_id).name</code>
</li>
<li class="missed" data-hits="0" data-linenumber="39">
<code class="ruby"> data += [{</code>
</li>
<li class="never" data-hits="" data-linenumber="40">
<code class="ruby"> :name =&gt; name,</code>
</li>
<li class="never" data-hits="" data-linenumber="41">
<code class="ruby"> :time =&gt; i.created_at,</code>
</li>
<li class="never" data-hits="" data-linenumber="42">
<code class="ruby"> :content =&gt; i.content</code>
</li>
<li class="never" data-hits="" data-linenumber="43">
<code class="ruby"> }]</code>
</li>
<li class="never" data-hits="" data-linenumber="44">
<code class="ruby"> end</code>
</li>
<li class="missed" data-hits="0" data-linenumber="45">
<code class="ruby"> render :json =&gt; {</code>
</li>
<li class="never" data-hits="" data-linenumber="46">
<code class="ruby"> :code =&gt; 0,</code>
</li>
<li class="never" data-hits="" data-linenumber="47">
<code class="ruby"> :data =&gt; data</code>
</li>
<li class="never" data-hits="" data-linenumber="48">
<code class="ruby"> }</code>
</li>
<li class="never" data-hits="" data-linenumber="49">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="50">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="51">
<span class="hits">1</span>
<code class="ruby"> private</code>
</li>
<li class="covered" data-hits="1" data-linenumber="52">
<span class="hits">1</span>
<code class="ruby"> def share_params</code>
</li>
<li class="covered" data-hits="2" data-linenumber="53">
<span class="hits">2</span>
<code class="ruby"> params.require(:share).permit(:project_id,:content)</code>
</li>
<li class="never" data-hits="" data-linenumber="54">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="55">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="f5389d49ff8c02c5a9e6eeda4d22eec2a913ee28">
<div class="header">
<h3>app/controllers/users_controller.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>26</b> relevant lines.
<span class="green"><b>26</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class UsersController &lt; ApplicationController</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby"> before_action :authenticate, except: [ :emailExist, :usernameExist, :create ]</code>
</li>
<li class="covered" data-hits="1" data-linenumber="4">
<span class="hits">1</span>
<code class="ruby"> skip_before_action :verify_authenticity_token, :only =&gt; [</code>
</li>
<li class="never" data-hits="" data-linenumber="5">
<code class="ruby"> :emailExist,</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> :usernameExist,</code>
</li>
<li class="never" data-hits="" data-linenumber="7">
<code class="ruby"> :create,</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> :update</code>
</li>
<li class="never" data-hits="" data-linenumber="9">
<code class="ruby"> ]</code>
</li>
<li class="never" data-hits="" data-linenumber="10">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> def emailExist</code>
</li>
<li class="covered" data-hits="4" data-linenumber="12">
<span class="hits">4</span>
<code class="ruby"> if checkExist?(:email, params[:email])</code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> render :text =&gt; &#39;1&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="14">
<code class="ruby"> else</code>
</li>
<li class="covered" data-hits="3" data-linenumber="15">
<span class="hits">3</span>
<code class="ruby"> render :text =&gt; &#39;0&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="16">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="18">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="19">
<span class="hits">1</span>
<code class="ruby"> def usernameExist</code>
</li>
<li class="covered" data-hits="4" data-linenumber="20">
<span class="hits">4</span>
<code class="ruby"> if checkExist?(:name, params[:username])</code>
</li>
<li class="covered" data-hits="1" data-linenumber="21">
<span class="hits">1</span>
<code class="ruby"> render :text =&gt; &#39;exist&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="22">
<code class="ruby"> else</code>
</li>
<li class="covered" data-hits="3" data-linenumber="23">
<span class="hits">3</span>
<code class="ruby"> render :text =&gt; &#39;not exist&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="24">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="25">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="27">
<span class="hits">1</span>
<code class="ruby"> def create</code>
</li>
<li class="covered" data-hits="7" data-linenumber="28">
<span class="hits">7</span>
<code class="ruby"> @user = User.new(user_params)</code>
</li>
<li class="covered" data-hits="6" data-linenumber="29">
<span class="hits">6</span>
<code class="ruby"> if @user.save</code>
</li>
<li class="covered" data-hits="2" data-linenumber="30">
<span class="hits">2</span>
<code class="ruby"> render status: :created, nothing: true</code>
</li>
<li class="never" data-hits="" data-linenumber="31">
<code class="ruby"> else</code>
</li>
<li class="covered" data-hits="4" data-linenumber="32">
<span class="hits">4</span>
<code class="ruby"> render json: @user.errors, status: :unprocessable_entity</code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="35">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="36">
<span class="hits">1</span>
<code class="ruby"> def update</code>
</li>
<li class="covered" data-hits="4" data-linenumber="37">
<span class="hits">4</span>
<code class="ruby"> @user = current_user</code>
</li>
<li class="covered" data-hits="4" data-linenumber="38">
<span class="hits">4</span>
<code class="ruby"> if @user.update(user_params)</code>
</li>
<li class="covered" data-hits="2" data-linenumber="39">
<span class="hits">2</span>
<code class="ruby"> render &#39;show&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="40">
<code class="ruby"> else</code>
</li>
<li class="covered" data-hits="2" data-linenumber="41">
<span class="hits">2</span>
<code class="ruby"> render json:current_user.errors, status: :unprocessable_entity</code>
</li>
<li class="never" data-hits="" data-linenumber="42">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="43">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="44">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="45">
<span class="hits">1</span>
<code class="ruby"> private</code>
</li>
<li class="covered" data-hits="1" data-linenumber="46">
<span class="hits">1</span>
<code class="ruby"> def checkExist?(field_name, value)</code>
</li>
<li class="covered" data-hits="8" data-linenumber="47">
<span class="hits">8</span>
<code class="ruby"> User.exists?(field_name =&gt; value)</code>
</li>
<li class="never" data-hits="" data-linenumber="48">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="49">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="50">
<span class="hits">1</span>
<code class="ruby"> def user_params</code>
</li>
<li class="covered" data-hits="11" data-linenumber="51">
<span class="hits">11</span>
<code class="ruby"> params.require(:user).permit(:name,:password, :password_confirmation, :email, :phone)</code>
</li>
<li class="never" data-hits="" data-linenumber="52">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="53">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="bee33d336c194b40053da6e55f73ab6b09c29625">
<div class="header">
<h3>app/models/comment.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>16</b> relevant lines.
<span class="green"><b>16</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class Comment &lt; ActiveRecord::Base</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby"> belongs_to :mission</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> validates :content, presence: true</code>
</li>
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
<code class="ruby"> validates :mission_id, presence: true</code>
</li>
<li class="never" data-hits="" data-linenumber="7">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="8">
<span class="hits">1</span>
<code class="ruby"> validates :user_id, presence: true</code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> validate :comment_has_atleast_one_character, on: :create</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> validate :user_id_exist, on: :create</code>
</li>
<li class="never" data-hits="" data-linenumber="11">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> private </code>
</li>
<li class="never" data-hits="" data-linenumber="13">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="14">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> def comment_has_atleast_one_character</code>
</li>
<li class="covered" data-hits="8" data-linenumber="16">
<span class="hits">8</span>
<code class="ruby"> tmp = content.strip</code>
</li>
<li class="covered" data-hits="7" data-linenumber="17">
<span class="hits">7</span>
<code class="ruby"> if tmp.length &lt; 1</code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> errors[:content] = &#39;content should has at least one character&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="19">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="20">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="22">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="23">
<span class="hits">1</span>
<code class="ruby"> def user_id_exist</code>
</li>
<li class="never" data-hits="" data-linenumber="24">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="7" data-linenumber="25">
<span class="hits">7</span>
<code class="ruby"> user = User.find_by(id: user_id)</code>
</li>
<li class="covered" data-hits="7" data-linenumber="26">
<span class="hits">7</span>
<code class="ruby"> if user == nil</code>
</li>
<li class="covered" data-hits="1" data-linenumber="27">
<span class="hits">1</span>
<code class="ruby"> errors[:user] = &quot;user is not exist&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="30">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="31">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="32">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> # mission 是否存在的验证将放在controller中进行</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="35">
<code class="ruby"> # def mission_id_should_be_exist</code>
</li>
<li class="never" data-hits="" data-linenumber="36">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="37">
<code class="ruby"> # @mission = Mission.find(:mission_id)</code>
</li>
<li class="never" data-hits="" data-linenumber="38">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="39">
<code class="ruby"> # if @mission == nil</code>
</li>
<li class="never" data-hits="" data-linenumber="40">
<code class="ruby"> # errors[:mission_id] = &quot;mission is not exist&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="41">
<code class="ruby"> # end</code>
</li>
<li class="never" data-hits="" data-linenumber="42">
<code class="ruby"> # end </code>
</li>
<li class="never" data-hits="" data-linenumber="43">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="44">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="0db745639a46a8e60ee3be5e867105508b239689">
<div class="header">
<h3>app/models/mission.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>22</b> relevant lines.
<span class="green"><b>22</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class Mission &lt; ActiveRecord:: Base</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby"> has_many :comments</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="5">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
<code class="ruby"> validates :name, presence: true</code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> validates :deadline, presence: true</code>
</li>
<li class="covered" data-hits="1" data-linenumber="8">
<span class="hits">1</span>
<code class="ruby"> validates :priority, presence: true</code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> validates :status, presence: true</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> validates :content, presence: true</code>
</li>
<li class="never" data-hits="" data-linenumber="11">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> validates :project_id, presence: true</code>
</li>
<li class="never" data-hits="" data-linenumber="13">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="14">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> validate :priority_is_among_valid_values</code>
</li>
<li class="covered" data-hits="1" data-linenumber="16">
<span class="hits">1</span>
<code class="ruby"> validate :status_is_among_valid_values</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> validate :project_exists, on: :create</code>
</li>
<li class="never" data-hits="" data-linenumber="19">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
<code class="ruby"> private </code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="22">
<span class="hits">1</span>
<code class="ruby"> def priority_is_among_valid_values</code>
</li>
<li class="never" data-hits="" data-linenumber="23">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="21" data-linenumber="24">
<span class="hits">21</span>
<code class="ruby"> if priority != 1 and priority != 2 and priority != 3</code>
</li>
<li class="covered" data-hits="2" data-linenumber="25">
<span class="hits">2</span>
<code class="ruby"> errors[:priority] = &quot;priority is not among valid values&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="29">
<span class="hits">1</span>
<code class="ruby"> def status_is_among_valid_values</code>
</li>
<li class="never" data-hits="" data-linenumber="30">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="21" data-linenumber="31">
<span class="hits">21</span>
<code class="ruby"> if status != 1 and status != 2 and status != 3 and status != 4</code>
</li>
<li class="covered" data-hits="8" data-linenumber="32">
<span class="hits">8</span>
<code class="ruby"> errors[:status] = &quot;status is not among valid values&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="35">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="36">
<span class="hits">1</span>
<code class="ruby"> def project_exists</code>
</li>
<li class="never" data-hits="" data-linenumber="37">
<code class="ruby"> #puts project_id</code>
</li>
<li class="covered" data-hits="18" data-linenumber="38">
<span class="hits">18</span>
<code class="ruby"> project = Project.find_by(id: project_id)</code>
</li>
<li class="never" data-hits="" data-linenumber="39">
<code class="ruby"> #puts project.inspect</code>
</li>
<li class="covered" data-hits="18" data-linenumber="40">
<span class="hits">18</span>
<code class="ruby"> if project == nil</code>
</li>
<li class="covered" data-hits="8" data-linenumber="41">
<span class="hits">8</span>
<code class="ruby"> errors[:project_id] = &quot;project_id is not exist&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="42">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="43">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="44">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="45">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="46">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="47">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="c68b2223ecc316803aa9a1fac8d0269aef908c42">
<div class="header">
<h3>app/models/missions_user.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>14</b> relevant lines.
<span class="green"><b>14</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class Missions_user &lt;ActiveRecord:: Base</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby"> validates :mission_id, presence: true</code>
</li>
<li class="covered" data-hits="1" data-linenumber="4">
<span class="hits">1</span>
<code class="ruby"> validates :user_id, presence: true</code>
</li>
<li class="never" data-hits="" data-linenumber="5">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
<code class="ruby"> validate :mission_exist, on: :create</code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> validate :user_exist, on: :create</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> private </code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> def mission_exist</code>
</li>
<li class="never" data-hits="" data-linenumber="11">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="4" data-linenumber="12">
<span class="hits">4</span>
<code class="ruby"> mission = Mission.find_by(id: mission_id)</code>
</li>
<li class="covered" data-hits="4" data-linenumber="13">
<span class="hits">4</span>
<code class="ruby"> if mission == nil</code>
</li>
<li class="covered" data-hits="2" data-linenumber="14">
<span class="hits">2</span>
<code class="ruby"> errors[:mission] = &quot;mission belong to Missions_user is not exist&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="15">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="16">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="18">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="19">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
<code class="ruby"> def user_exist</code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="4" data-linenumber="22">
<span class="hits">4</span>
<code class="ruby"> user = User.find_by(id: user_id)</code>
</li>
<li class="covered" data-hits="4" data-linenumber="23">
<span class="hits">4</span>
<code class="ruby"> if user == nil</code>
</li>
<li class="covered" data-hits="2" data-linenumber="24">
<span class="hits">2</span>
<code class="ruby"> errors[:user] = &quot;user belong to Missions_user is not exist&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="25">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="30">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="62e9dd18e626544eade9ed0b20dc3545557473d1">
<div class="header">
<h3>app/models/note.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>26</b> relevant lines.
<span class="green"><b>26</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class Note &lt; ActiveRecord:: Base</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby"> belongs_to :user</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> validates :content, presence: true</code>
</li>
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
<code class="ruby"> validates :user_id, presence: true</code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> validates :project_id, presence: true</code>
</li>
<li class="covered" data-hits="1" data-linenumber="8">
<span class="hits">1</span>
<code class="ruby"> validates :category, presence: true</code>
</li>
<li class="never" data-hits="" data-linenumber="9">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> validate :note_has_atleast_one_character</code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> validate :note_category_should_among_valid_values</code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> validate :user_exist, on: :create</code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> validate :project_exist, on: :create</code>
</li>
<li class="never" data-hits="" data-linenumber="14">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="15">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="16">
<span class="hits">1</span>
<code class="ruby"> private </code>
</li>
<li class="covered" data-hits="1" data-linenumber="17">
<span class="hits">1</span>
<code class="ruby"> def note_has_atleast_one_character</code>
</li>
<li class="covered" data-hits="11" data-linenumber="18">
<span class="hits">11</span>
<code class="ruby"> tmp = content.strip</code>
</li>
<li class="covered" data-hits="11" data-linenumber="19">
<span class="hits">11</span>
<code class="ruby"> if tmp.length &lt; 1</code>
</li>
<li class="covered" data-hits="3" data-linenumber="20">
<span class="hits">3</span>
<code class="ruby"> errors[:content] = &quot;note content should has at least one character&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="22">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="23">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="24">
<span class="hits">1</span>
<code class="ruby"> def note_category_should_among_valid_values</code>
</li>
<li class="never" data-hits="" data-linenumber="25">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="11" data-linenumber="26">
<span class="hits">11</span>
<code class="ruby"> if category != 1 and category != 2 and category !=3</code>
</li>
<li class="covered" data-hits="2" data-linenumber="27">
<span class="hits">2</span>
<code class="ruby"> errors[:category] = &quot;note category is not among valid values&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="30">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="31">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="32">
<span class="hits">1</span>
<code class="ruby"> def user_exist</code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="10" data-linenumber="34">
<span class="hits">10</span>
<code class="ruby"> user = User.find_by(id: user_id)</code>
</li>
<li class="covered" data-hits="10" data-linenumber="35">
<span class="hits">10</span>
<code class="ruby"> if user == nil</code>
</li>
<li class="covered" data-hits="2" data-linenumber="36">
<span class="hits">2</span>
<code class="ruby"> errors[:user] = &quot;user belong to Note is not exist&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="37">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="38">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="39">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="40">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="41">
<span class="hits">1</span>
<code class="ruby"> def project_exist</code>
</li>
<li class="never" data-hits="" data-linenumber="42">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="10" data-linenumber="43">
<span class="hits">10</span>
<code class="ruby"> project = Project.find_by(id: project_id)</code>
</li>
<li class="covered" data-hits="10" data-linenumber="44">
<span class="hits">10</span>
<code class="ruby"> if project == nil</code>
</li>
<li class="covered" data-hits="5" data-linenumber="45">
<span class="hits">5</span>
<code class="ruby"> errors[:project] = &quot;project should be exist&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="46">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="47">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="48">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="49">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="50">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="3c949a9cef12a5b36b0ed70b82e018448b1c2725">
<div class="header">
<h3>app/models/project.rb</h3>
<h4><span class="yellow">87.5 %</span> covered</h4>
<div>
<b>8</b> relevant lines.
<span class="green"><b>7</b> lines covered</span> and
<span class="red"><b>1</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class Project &lt; ActiveRecord::Base</code>
</li>
<li class="covered" data-hits="1" data-linenumber="2">
<span class="hits">1</span>
<code class="ruby"> has_and_belongs_to_many :users</code>
</li>
<li class="never" data-hits="" data-linenumber="3">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="4">
<span class="hits">1</span>
<code class="ruby"> validate :require_at_least_on_user,on: :update # 项目中最少要有一个用户</code>
</li>
<li class="never" data-hits="" data-linenumber="5">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
<code class="ruby"> validates :name, presence: true, length: { minimum: 1, maximum: 50 }, uniqueness: true</code>
</li>
<li class="never" data-hits="" data-linenumber="7">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="8">
<span class="hits">1</span>
<code class="ruby"> private</code>
</li>
<li class="never" data-hits="" data-linenumber="9">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> def require_at_least_on_user</code>
</li>
<li class="covered" data-hits="10" data-linenumber="11">
<span class="hits">10</span>
<code class="ruby"> if !users || users.size == 0 # 这里使用size可以智能选择需不需要查询数据库</code>
</li>
<li class="missed" data-hits="0" data-linenumber="12">
<code class="ruby"> errors[:users] = &#39;at least one user in the project&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="13">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="14">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="15">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="e782303906061f982438021be1eaffe0f682fbfa">
<div class="header">
<h3>app/models/share.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>20</b> relevant lines.
<span class="green"><b>20</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class Share &lt; ActiveRecord::Base</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby"> validates :content, presence: true</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> validates :project_id, presence: true</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> validates :user_id, presence: true</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> validate :share_has_atleast_one_character </code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> validate :user_exists,on: :create</code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> validate :project_exists,on: :create</code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> private </code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> def share_has_atleast_one_character</code>
</li>
<li class="covered" data-hits="8" data-linenumber="14">
<span class="hits">8</span>
<code class="ruby"> tmp = content.strip</code>
</li>
<li class="covered" data-hits="8" data-linenumber="15">
<span class="hits">8</span>
<code class="ruby"> if tmp.length &lt; 1</code>
</li>
<li class="covered" data-hits="2" data-linenumber="16">
<span class="hits">2</span>
<code class="ruby"> errors[:content] = &quot;share content should has at least one character&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="18">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="19">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
<code class="ruby"> def user_exists</code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="7" data-linenumber="22">
<span class="hits">7</span>
<code class="ruby"> user = User.find_by(id: user_id)</code>
</li>
<li class="covered" data-hits="7" data-linenumber="23">
<span class="hits">7</span>
<code class="ruby"> if user == nil</code>
</li>
<li class="covered" data-hits="2" data-linenumber="24">
<span class="hits">2</span>
<code class="ruby"> errors[:user] = &quot;user belong to Share is not exist&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="25">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> end</code>
</li>
<li class="covered" data-hits="1" data-linenumber="28">
<span class="hits">1</span>
<code class="ruby"> def project_exists</code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="7" data-linenumber="30">
<span class="hits">7</span>
<code class="ruby"> project = Project.find_by(id: project_id)</code>
</li>
<li class="covered" data-hits="7" data-linenumber="31">
<span class="hits">7</span>
<code class="ruby"> if project == nil</code>
</li>
<li class="covered" data-hits="2" data-linenumber="32">
<span class="hits">2</span>
<code class="ruby"> errors[:project] = &quot;user belong to Share is not exist&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="35">
<code class="ruby"> end </code>
</li>
<li class="never" data-hits="" data-linenumber="36">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="37">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="a6d30df0f04fd500a43246d8a960f4502230d398">
<div class="header">
<h3>app/models/user.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>9</b> relevant lines.
<span class="green"><b>9</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">class User &lt; ActiveRecord::Base</code>
</li>
<li class="covered" data-hits="1" data-linenumber="2">
<span class="hits">1</span>
<code class="ruby"> has_and_belongs_to_many :projects</code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby"> has_and_belongs_to_many :missions</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> has_many :notes</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> has_secure_password # 等价于验证password_confirm和password是否相等并且验证password是否存在</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> validates :name, presence: true, length: { maximum: 30 }</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> validates :email, presence: true, uniqueness: true, length: { maximum: 50},</code>
</li>
<li class="never" data-hits="" data-linenumber="11">
<code class="ruby"> format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }</code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> validates :password, length: { minimum: 6 },on:create</code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> validates :phone, presence: true, format: { with: /\A[0-9]{11,11}\Z/i },</code>
</li>
<li class="never" data-hits="" data-linenumber="14">
<code class="ruby"> multiline: false</code>
</li>
<li class="never" data-hits="" data-linenumber="15">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="b3d517a211a3d4d496fb9b56b2a98d9ad4fcd088">
<div class="header">
<h3>spec/controllers/notes_controller_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>19</b> relevant lines.
<span class="green"><b>19</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe NotesController,type: :controller do</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> describe &quot;GET #getNotesList&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> it &quot;return correct json format of noteslist&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> register = create(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> user = User.find_by(email: register.email)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> session[:user_id] = user.id </code>
</li>
<li class="never" data-hits="" data-linenumber="12">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project mission update test&quot;,content: &quot;update test&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="14">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; register</code>
</li>
<li class="covered" data-hits="1" data-linenumber="16">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> params_note = {content: &quot;note content 1&quot;,user_id: user.id,category: 2,project_id: project.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="19">
<span class="hits">1</span>
<code class="ruby"> note = Note.new(params_note)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
<code class="ruby"> note.save</code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="22">
<span class="hits">1</span>
<code class="ruby"> params_note2 = {content: &quot;note content 2&quot;,user_id: user.id,category: 1,project_id: project.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="23">
<span class="hits">1</span>
<code class="ruby"> note2 = Note.new(params_note2)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="24">
<span class="hits">1</span>
<code class="ruby"> note2.save</code>
</li>
<li class="never" data-hits="" data-linenumber="25">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="27">
<span class="hits">1</span>
<code class="ruby"> post :getNotesList,project_id: project.id</code>
</li>
<li class="covered" data-hits="1" data-linenumber="28">
<span class="hits">1</span>
<code class="ruby"> puts response.body</code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="30">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="31">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="32">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby">end</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> </code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="0d8d52d02a89ffe8095903af971d301c9b63d7cb">
<div class="header">
<h3>spec/controllers/projects_controller_spec.rb</h3>
<h4><span class="yellow">86.05 %</span> covered</h4>
<div>
<b>43</b> relevant lines.
<span class="green"><b>37</b> lines covered</span> and
<span class="red"><b>6</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe ProjectsController, type: :controller do</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="5">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> describe &quot;GET #index &quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> it &quot;return valid projects json&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="10">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> register = create(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> user = User.find_by(email: register.email)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> session[:user_id] = user.id </code>
</li>
<li class="never" data-hits="" data-linenumber="14">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> post :create,content: &quot;project content 1&quot;,name: &quot;project1&quot;</code>
</li>
<li class="missed" data-hits="0" data-linenumber="16">
<code class="ruby"> post :create,content: &quot;project content 2&quot;, name: &quot;project2&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="18">
<code class="ruby"> get :index</code>
</li>
<li class="never" data-hits="" data-linenumber="19">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="20">
<code class="ruby"> puts response.body</code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="22">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="23">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="24">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="25">
<span class="hits">1</span>
<code class="ruby"> describe &quot;POST #create&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="27">
<span class="hits">1</span>
<code class="ruby"> it &quot;can create a valid project&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="29">
<span class="hits">1</span>
<code class="ruby"> register = create(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
<code class="ruby"> user = User.find_by(email: register.email)</code>
</li>
<li class="never" data-hits="" data-linenumber="31">
<code class="ruby"> #puts user.inspect</code>
</li>
<li class="covered" data-hits="1" data-linenumber="32">
<span class="hits">1</span>
<code class="ruby"> session[:user_id] = user.id </code>
</li>
<li class="covered" data-hits="1" data-linenumber="33">
<span class="hits">1</span>
<code class="ruby"> post :create,content: &quot;project content 1&quot;,name: &quot;project1&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> #puts response.body</code>
</li>
<li class="never" data-hits="" data-linenumber="35">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="36">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="37">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="38">
<span class="hits">1</span>
<code class="ruby"> describe &quot;POST #addUsers&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="39">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="40">
<span class="hits">1</span>
<code class="ruby"> it &quot;can addUsers correctly&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="41">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="42">
<span class="hits">1</span>
<code class="ruby"> register = create(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="43">
<span class="hits">1</span>
<code class="ruby"> user = User.find_by(email: register.email)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="44">
<span class="hits">1</span>
<code class="ruby"> session[:user_id] = user.id </code>
</li>
<li class="never" data-hits="" data-linenumber="45">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="46">
<code class="ruby"> #user1 = create(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="47">
<span class="hits">1</span>
<code class="ruby"> user2 = create(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="48">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project addUsers test&quot;,content: &quot;addUsers test&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="49">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="50">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; register</code>
</li>
<li class="covered" data-hits="1" data-linenumber="51">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="never" data-hits="" data-linenumber="52">
<code class="ruby"> #post :create,content: &quot;project content 3&quot;,name: &quot;project3&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="53">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="54">
<span class="hits">1</span>
<code class="ruby"> post :addUsers,user_id: user2.id,project_id: project.id</code>
</li>
<li class="never" data-hits="" data-linenumber="55">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="56">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="57">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="58">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="59">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="60">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="61">
<span class="hits">1</span>
<code class="ruby"> describe &quot;GET #detail&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="62">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="63">
<span class="hits">1</span>
<code class="ruby"> it &quot;can return correct json format of project &quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="64">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="65">
<span class="hits">1</span>
<code class="ruby"> register = create(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="66">
<span class="hits">1</span>
<code class="ruby"> user = User.find_by(email: register.email)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="67">
<span class="hits">1</span>
<code class="ruby"> session[:user_id] = user.id </code>
</li>
<li class="never" data-hits="" data-linenumber="68">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="69">
<span class="hits">1</span>
<code class="ruby"> user1 = create(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="70">
<span class="hits">1</span>
<code class="ruby"> user2 = create(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="71">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project addUsers test&quot;,content: &quot;addUsers test&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="72">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="73">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; register</code>
</li>
<li class="covered" data-hits="1" data-linenumber="74">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="75">
<span class="hits">1</span>
<code class="ruby"> post :addUsers,user_id: user2.id,project_id: project.id</code>
</li>
<li class="missed" data-hits="0" data-linenumber="76">
<code class="ruby"> post :addUsers,user_id: user1.id,project_id: project.id</code>
</li>
<li class="missed" data-hits="0" data-linenumber="77">
<code class="ruby"> post :detail,id: project.id</code>
</li>
<li class="missed" data-hits="0" data-linenumber="78">
<code class="ruby"> puts response.body</code>
</li>
<li class="never" data-hits="" data-linenumber="79">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="80">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="81">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="82">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="83">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="4f6628a02d637cae9a2dfc99e7f8d551123b2dec">
<div class="header">
<h3>spec/controllers/sessions_controller_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>53</b> relevant lines.
<span class="green"><b>53</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe SessionsController, type: :controller do</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> before :each do</code>
</li>
<li class="covered" data-hits="11" data-linenumber="6">
<span class="hits">11</span>
<code class="ruby"> @user1 = create(:user)</code>
</li>
<li class="never" data-hits="" data-linenumber="7">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> describe &#39;POST #create&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="10">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="11">
<code class="ruby"> # 合法流程校验</code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> context &#39;with legal account&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="13">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="14">
<span class="hits">1</span>
<code class="ruby"> before :each do</code>
</li>
<li class="covered" data-hits="3" data-linenumber="15">
<span class="hits">3</span>
<code class="ruby"> post :create, email: @user1.email, password: @user1.password</code>
</li>
<li class="never" data-hits="" data-linenumber="16">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> it &#39;should get correct email and password&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="19">
<span class="hits">1</span>
<code class="ruby"> actual_email = @user1.email</code>
</li>
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
<code class="ruby"> actual_password = @user1.password</code>
</li>
<li class="covered" data-hits="1" data-linenumber="21">
<span class="hits">1</span>
<code class="ruby"> expect(controller.params[:email]).to eq(actual_email)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="22">
<span class="hits">1</span>
<code class="ruby"> expect(controller.params[:password]).to eq(actual_password)</code>
</li>
<li class="never" data-hits="" data-linenumber="23">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="24">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="25">
<span class="hits">1</span>
<code class="ruby"> it &#39;should authenticate success&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="26">
<span class="hits">1</span>
<code class="ruby"> expect(controller.session[:user_id]).to eq @user1.id</code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="29">
<span class="hits">1</span>
<code class="ruby"> it &#39;should get ok and text: ok&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
<code class="ruby"> expect(response).to have_http_status :ok</code>
</li>
<li class="covered" data-hits="1" data-linenumber="31">
<span class="hits">1</span>
<code class="ruby"> expect(response.body).to eq &#39;ok&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="32">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="35">
<code class="ruby"> # 非法参数测试</code>
</li>
<li class="covered" data-hits="1" data-linenumber="36">
<span class="hits">1</span>
<code class="ruby"> context &#39;with illegal account&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="37">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="38">
<span class="hits">1</span>
<code class="ruby"> before :each do</code>
</li>
<li class="covered" data-hits="3" data-linenumber="39">
<span class="hits">3</span>
<code class="ruby"> post :create, email: @user1.email, password: &#39;wrong_password&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="40">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="41">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="42">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not authenticate success&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="43">
<span class="hits">1</span>
<code class="ruby"> expect(controller.session[:user_id].nil?).to be true</code>
</li>
<li class="never" data-hits="" data-linenumber="44">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="45">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="46">
<span class="hits">1</span>
<code class="ruby"> it &#39;return with 401&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="47">
<span class="hits">1</span>
<code class="ruby"> expect(response).to have_http_status :unauthorized</code>
</li>
<li class="covered" data-hits="1" data-linenumber="48">
<span class="hits">1</span>
<code class="ruby"> expect(response.body).to eq &#39;account or password is not correct&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="49">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="50">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="51">
<span class="hits">1</span>
<code class="ruby"> it &#39;should not raise error without param email or password&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="52">
<span class="hits">1</span>
<code class="ruby"> expect {</code>
</li>
<li class="covered" data-hits="1" data-linenumber="53">
<span class="hits">1</span>
<code class="ruby"> post :create, email: @user1.email</code>
</li>
<li class="never" data-hits="" data-linenumber="54">
<code class="ruby"> }.not_to raise_error</code>
</li>
<li class="covered" data-hits="1" data-linenumber="55">
<span class="hits">1</span>
<code class="ruby"> expect {</code>
</li>
<li class="covered" data-hits="1" data-linenumber="56">
<span class="hits">1</span>
<code class="ruby"> post :create, password: &#39;wrong_password&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="57">
<code class="ruby"> }.not_to raise_error</code>
</li>
<li class="never" data-hits="" data-linenumber="58">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="59">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="60">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="61">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="62">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="63">
<span class="hits">1</span>
<code class="ruby"> describe &#39;DELETE #destroy&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="64">
<span class="hits">1</span>
<code class="ruby"> it &#39;should destroy user id in session&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="65">
<span class="hits">1</span>
<code class="ruby"> post :create, email:@user1.email, password: @user1.password</code>
</li>
<li class="covered" data-hits="1" data-linenumber="66">
<span class="hits">1</span>
<code class="ruby"> expect(controller.session[:user_id].nil?).to be false</code>
</li>
<li class="covered" data-hits="1" data-linenumber="67">
<span class="hits">1</span>
<code class="ruby"> delete :destroy</code>
</li>
<li class="covered" data-hits="1" data-linenumber="68">
<span class="hits">1</span>
<code class="ruby"> expect(controller.session[:user_id].nil?).to be true</code>
</li>
<li class="never" data-hits="" data-linenumber="69">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="70">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="71">
<span class="hits">1</span>
<code class="ruby"> it &#39;should return 401 without login&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="72">
<span class="hits">1</span>
<code class="ruby"> delete :destroy</code>
</li>
<li class="covered" data-hits="1" data-linenumber="73">
<span class="hits">1</span>
<code class="ruby"> expect(response).to have_http_status :unauthorized</code>
</li>
<li class="never" data-hits="" data-linenumber="74">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="75">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="76">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="77">
<span class="hits">1</span>
<code class="ruby"> describe &#39;GET #show&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="78">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="79">
<span class="hits">1</span>
<code class="ruby"> context &#39;after login&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="80">
<span class="hits">1</span>
<code class="ruby"> before :each do</code>
</li>
<li class="covered" data-hits="2" data-linenumber="81">
<span class="hits">2</span>
<code class="ruby"> post :create, email:@user1.email, password: @user1.password</code>
</li>
<li class="covered" data-hits="2" data-linenumber="82">
<span class="hits">2</span>
<code class="ruby"> get :show, format: &#39;json&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="83">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="84">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="85">
<span class="hits">1</span>
<code class="ruby"> it &#39;should render show template&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="86">
<span class="hits">1</span>
<code class="ruby"> expect(response).to render_template &#39;show&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="87">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="88">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="89">
<span class="hits">1</span>
<code class="ruby"> it &#39;should return user in json&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="90">
<span class="hits">1</span>
<code class="ruby"> userInfo = assigns[:current_user]</code>
</li>
<li class="covered" data-hits="1" data-linenumber="91">
<span class="hits">1</span>
<code class="ruby"> expect(userInfo.id).to eq @user1.id</code>
</li>
<li class="never" data-hits="" data-linenumber="92">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="93">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="94">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="95">
<span class="hits">1</span>
<code class="ruby"> it &#39;should renturn 401 without login&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="96">
<span class="hits">1</span>
<code class="ruby"> get :show, format: &#39;json&#39;</code>
</li>
<li class="covered" data-hits="1" data-linenumber="97">
<span class="hits">1</span>
<code class="ruby"> expect(response).to have_http_status :unauthorized</code>
</li>
<li class="never" data-hits="" data-linenumber="98">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="99">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="100">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="d407126ea6537d4b4103ecb42ef3011588b05501">
<div class="header">
<h3>spec/controllers/shares_controller_spec.rb</h3>
<h4><span class="yellow">84.62 %</span> covered</h4>
<div>
<b>26</b> relevant lines.
<span class="green"><b>22</b> lines covered</span> and
<span class="red"><b>4</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe SharesController,type: :controller do</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> describe &quot;POST #create&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> it &quot;create a correct share&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> register = create(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> user = User.find_by(email: register.email)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> session[:user_id] = user.id </code>
</li>
<li class="never" data-hits="" data-linenumber="12">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project addUsers test&quot;,content: &quot;addUsers test&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="14">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; register</code>
</li>
<li class="covered" data-hits="1" data-linenumber="16">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> post :create,project_id: project.id,content: &quot;苟利国家生死以,岂因福祸避趋之&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="19">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="20">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="22">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="23">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="24">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="25">
<span class="hits">1</span>
<code class="ruby"> describe &quot;GET #getShareList&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="27">
<span class="hits">1</span>
<code class="ruby"> it &quot;return correct share list&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
<code class="ruby"> register = create(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="31">
<span class="hits">1</span>
<code class="ruby"> user = User.find_by(email: register.email)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="32">
<span class="hits">1</span>
<code class="ruby"> session[:user_id] = user.id </code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="34">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project test&quot;,content: &quot; test&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="35">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="36">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; register</code>
</li>
<li class="covered" data-hits="1" data-linenumber="37">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="never" data-hits="" data-linenumber="38">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="39">
<span class="hits">1</span>
<code class="ruby"> post :create,project_id: project.id,content: &quot;苟利国家生死以,岂因福祸避趋之&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="40">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="41">
<code class="ruby"> post :create,project_id: project.id,content: &quot;too young too simple&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="42">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="43">
<code class="ruby"> post :create,project_id: project.id,content: &quot;too young too naive&quot;</code>
</li>
<li class="never" data-hits="" data-linenumber="44">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="45">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="46">
<code class="ruby"> get :getShareList,project_id: project.id</code>
</li>
<li class="never" data-hits="" data-linenumber="47">
<code class="ruby"> </code>
</li>
<li class="missed" data-hits="0" data-linenumber="48">
<code class="ruby"> puts response.body</code>
</li>
<li class="never" data-hits="" data-linenumber="49">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="50">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="51">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="52">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="53">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="54">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="55">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="56">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="a90d8b92a95e33dbb254552eff7ef68960b46cdc">
<div class="header">
<h3>spec/controllers/users_controller_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>82</b> relevant lines.
<span class="green"><b>82</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe UsersController, type: :controller do</code>
</li>
<li class="covered" data-hits="3" data-linenumber="4">
<span class="hits">3</span>
<code class="ruby"> let(:user) { build(:user_with_sequence_number) }</code>
</li>
<li class="covered" data-hits="5" data-linenumber="5">
<span class="hits">5</span>
<code class="ruby"> let(:user_with_fixed_info){ create(:user)}</code>
</li>
<li class="covered" data-hits="6" data-linenumber="6">
<span class="hits">6</span>
<code class="ruby"> let(:valid_attributes){ attributes_for(:user) }</code>
</li>
<li class="covered" data-hits="5" data-linenumber="7">
<span class="hits">5</span>
<code class="ruby"> let(:invalid_attributes){ attributes_for(:user, email: nil, name: &#39;username2000&#39;) }</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> describe &#39;GET #emailExist&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> it &#39;valid email&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> get :emailExist, email: user.email</code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> expect(response.body).to eq &#39;0&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="13">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="14">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> it &#39;duplicated email&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="16">
<span class="hits">1</span>
<code class="ruby"> user = create(:user_with_sequence_number)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="17">
<span class="hits">1</span>
<code class="ruby"> get :emailExist, email: user.email</code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> expect(response.body).to eq &#39;1&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="19">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="20">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="21">
<span class="hits">1</span>
<code class="ruby"> it &#39;should not throw exception with no email param&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="22">
<span class="hits">1</span>
<code class="ruby"> get :emailExist # 不会失败,则证明没有异常</code>
</li>
<li class="covered" data-hits="1" data-linenumber="23">
<span class="hits">1</span>
<code class="ruby"> get :emailExist, other_param: &#39;test&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="24">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="25">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="27">
<span class="hits">1</span>
<code class="ruby"> describe &#39;GET #usernameExist&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="28">
<span class="hits">1</span>
<code class="ruby"> it &#39;valid username&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="29">
<span class="hits">1</span>
<code class="ruby"> get :usernameExist, username: user.name</code>
</li>
<li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
<code class="ruby"> expect(response.body).to eq &#39;not exist&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="31">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="32">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="33">
<span class="hits">1</span>
<code class="ruby"> it &#39;duplicated username&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="34">
<span class="hits">1</span>
<code class="ruby"> user = create(:user_with_sequence_number)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="35">
<span class="hits">1</span>
<code class="ruby"> get :usernameExist, username: user.name</code>
</li>
<li class="covered" data-hits="1" data-linenumber="36">
<span class="hits">1</span>
<code class="ruby"> expect(response.body).to eq &#39;exist&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="37">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="38">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="39">
<span class="hits">1</span>
<code class="ruby"> it &#39;should not throw exception with no username param&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="40">
<span class="hits">1</span>
<code class="ruby"> get :usernameExist</code>
</li>
<li class="covered" data-hits="1" data-linenumber="41">
<span class="hits">1</span>
<code class="ruby"> get :usernameExist, other_param: &#39;test&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="42">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="43">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="44">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="45">
<span class="hits">1</span>
<code class="ruby"> describe &#39;POST #create&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="46">
<span class="hits">1</span>
<code class="ruby"> context &#39;success with valid attributes&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="47">
<span class="hits">1</span>
<code class="ruby"> before :each do</code>
</li>
<li class="covered" data-hits="2" data-linenumber="48">
<span class="hits">2</span>
<code class="ruby"> post :create, user: valid_attributes</code>
</li>
<li class="never" data-hits="" data-linenumber="49">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="50">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="51">
<span class="hits">1</span>
<code class="ruby"> it &#39;should create user&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="52">
<span class="hits">1</span>
<code class="ruby"> expect(User.exists?(assigns[:user].id)).to be true</code>
</li>
<li class="never" data-hits="" data-linenumber="53">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="54">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="55">
<span class="hits">1</span>
<code class="ruby"> it &#39;should response with 201&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="56">
<span class="hits">1</span>
<code class="ruby"> expect(response).to have_http_status :created</code>
</li>
<li class="never" data-hits="" data-linenumber="57">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="58">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="59">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="60">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="61">
<span class="hits">1</span>
<code class="ruby"> context &#39;fail with invalid attributes&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="62">
<code class="ruby"> # 已经在model测试中充分验证校对条件所以这里只对使用电子邮箱为空的非法条件</code>
</li>
<li class="covered" data-hits="1" data-linenumber="63">
<span class="hits">1</span>
<code class="ruby"> before :each do</code>
</li>
<li class="covered" data-hits="2" data-linenumber="64">
<span class="hits">2</span>
<code class="ruby"> post :create, user: invalid_attributes</code>
</li>
<li class="never" data-hits="" data-linenumber="65">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="66">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="67">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not save the new user&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="68">
<span class="hits">1</span>
<code class="ruby"> expect(User.exists? name: &#39;username2000&#39;).to be false</code>
</li>
<li class="never" data-hits="" data-linenumber="69">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="70">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="71">
<span class="hits">1</span>
<code class="ruby"> it &#39;should return errors&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="72">
<span class="hits">1</span>
<code class="ruby"> error_message = JSON.parse response.body</code>
</li>
<li class="covered" data-hits="1" data-linenumber="73">
<span class="hits">1</span>
<code class="ruby"> expect(error_message[&#39;email&#39;].nil?).to be false</code>
</li>
<li class="covered" data-hits="1" data-linenumber="74">
<span class="hits">1</span>
<code class="ruby"> expect(error_message[&#39;email&#39;]).not_to be_empty</code>
</li>
<li class="never" data-hits="" data-linenumber="75">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="76">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="77">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="78">
<span class="hits">1</span>
<code class="ruby"> context &#39;deal with params more or less than required&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="79">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="80">
<span class="hits">1</span>
<code class="ruby"> let(:data_to_send) { { :name =&gt; &#39;username&#39;, :email =&gt; &#39;1261138729@qq.com&#39;,</code>
</li>
<li class="never" data-hits="" data-linenumber="81">
<code class="ruby"> :password =&gt; &#39;secret&#39;, :password_confirmation =&gt; &#39;secret&#39;,</code>
</li>
<li class="covered" data-hits="2" data-linenumber="82">
<span class="hits">2</span>
<code class="ruby"> :more_field =&gt; &#39;test&#39;} }</code>
</li>
<li class="never" data-hits="" data-linenumber="83">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="84">
<span class="hits">1</span>
<code class="ruby"> it &#39;should throw exception without param[:user]&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="85">
<span class="hits">1</span>
<code class="ruby"> expect {</code>
</li>
<li class="covered" data-hits="1" data-linenumber="86">
<span class="hits">1</span>
<code class="ruby"> post :create</code>
</li>
<li class="never" data-hits="" data-linenumber="87">
<code class="ruby"> }.to raise_error ActionController::ParameterMissing</code>
</li>
<li class="never" data-hits="" data-linenumber="88">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="89">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="90">
<span class="hits">1</span>
<code class="ruby"> it &#39;should not throw exception&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="91">
<span class="hits">1</span>
<code class="ruby"> expect {</code>
</li>
<li class="covered" data-hits="1" data-linenumber="92">
<span class="hits">1</span>
<code class="ruby"> post :create, user: data_to_send, other_param: &#39;test&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="93">
<code class="ruby"> }.to_not raise_error</code>
</li>
<li class="never" data-hits="" data-linenumber="94">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="95">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="96">
<span class="hits">1</span>
<code class="ruby"> it &#39;should not accept other params&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="97">
<span class="hits">1</span>
<code class="ruby"> post :create, user: data_to_send</code>
</li>
<li class="covered" data-hits="1" data-linenumber="98">
<span class="hits">1</span>
<code class="ruby"> user = assigns(:user)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="99">
<span class="hits">1</span>
<code class="ruby"> expect(user.has_attribute? :more_field).to eq false</code>
</li>
<li class="never" data-hits="" data-linenumber="100">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="101">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="102">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="103">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="104">
<span class="hits">1</span>
<code class="ruby"> describe &#39;PATCH #update&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="105">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="106">
<span class="hits">1</span>
<code class="ruby"> context &#39;with valid attributes&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="107">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="108">
<span class="hits">1</span>
<code class="ruby"> before :each do</code>
</li>
<li class="never" data-hits="" data-linenumber="109">
<code class="ruby"> # 假设已经登录了</code>
</li>
<li class="covered" data-hits="4" data-linenumber="110">
<span class="hits">4</span>
<code class="ruby"> allow(controller).to receive(:authenticate){ true }</code>
</li>
<li class="covered" data-hits="2" data-linenumber="111">
<span class="hits">2</span>
<code class="ruby"> allow(controller).to receive(:current_user).and_return(User.find user_with_fixed_info.id)</code>
</li>
<li class="covered" data-hits="2" data-linenumber="112">
<span class="hits">2</span>
<code class="ruby"> patch :update, user: valid_attributes, format: &#39;json&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="113">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="114">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="115">
<span class="hits">1</span>
<code class="ruby"> it &#39;should located current user&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="116">
<span class="hits">1</span>
<code class="ruby"> expect(assigns[:user]).to eq user_with_fixed_info</code>
</li>
<li class="never" data-hits="" data-linenumber="117">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="118">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="119">
<span class="hits">1</span>
<code class="ruby"> it &#39;should render show&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="120">
<span class="hits">1</span>
<code class="ruby"> expect(response).to render_template &#39;show&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="121">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="122">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="123">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="124">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="125">
<span class="hits">1</span>
<code class="ruby"> context &#39;with invalid attributes&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="126">
<span class="hits">1</span>
<code class="ruby"> before :each do</code>
</li>
<li class="never" data-hits="" data-linenumber="127">
<code class="ruby"> # 假设已经登录了</code>
</li>
<li class="covered" data-hits="4" data-linenumber="128">
<span class="hits">4</span>
<code class="ruby"> allow(controller).to receive(:authenticate){ true }</code>
</li>
<li class="covered" data-hits="2" data-linenumber="129">
<span class="hits">2</span>
<code class="ruby"> allow(controller).to receive(:current_user).and_return(User.find user_with_fixed_info.id)</code>
</li>
<li class="covered" data-hits="2" data-linenumber="130">
<span class="hits">2</span>
<code class="ruby"> patch :update, user: invalid_attributes, format: &#39;json&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="131">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="132">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="133">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not change current user&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="134">
<span class="hits">1</span>
<code class="ruby"> expect(assigns[:user]).to eq user_with_fixed_info</code>
</li>
<li class="never" data-hits="" data-linenumber="135">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="136">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="137">
<span class="hits">1</span>
<code class="ruby"> it &#39;should return error messages and error status&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="138">
<span class="hits">1</span>
<code class="ruby"> error_message = JSON.parse response.body</code>
</li>
<li class="covered" data-hits="1" data-linenumber="139">
<span class="hits">1</span>
<code class="ruby"> expect(error_message[&#39;email&#39;].nil?).to be false</code>
</li>
<li class="covered" data-hits="1" data-linenumber="140">
<span class="hits">1</span>
<code class="ruby"> expect(error_message[&#39;email&#39;]).not_to be_empty</code>
</li>
<li class="never" data-hits="" data-linenumber="141">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="142">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="143">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="144">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="145">
<span class="hits">1</span>
<code class="ruby"> it &#39;should login first&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="146">
<span class="hits">1</span>
<code class="ruby"> patch :update, user:valid_attributes, format: &#39;json&#39;</code>
</li>
<li class="covered" data-hits="1" data-linenumber="147">
<span class="hits">1</span>
<code class="ruby"> expect(response).to have_http_status :unauthorized</code>
</li>
<li class="never" data-hits="" data-linenumber="148">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="149">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="150">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="b600d7aa19393eb5a1f4faf82ab8fb94c8cd39de">
<div class="header">
<h3>spec/models/comment_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>42</b> relevant lines.
<span class="green"><b>42</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe Comment , type: :model do</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> it &#39;has a valid comment&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="8">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> params = {content:&quot;good job&quot;,mission_id:123,user_id: user.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> expect(Comment.new(params)).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="11">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="12">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> it &quot;content should not be empty&quot; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="14">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="16">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="17">
<span class="hits">1</span>
<code class="ruby"> params = {content: nil,mission_id: 123,user_id: user.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> expect(Comment.new(params)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="19">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="20">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="21">
<span class="hits">1</span>
<code class="ruby"> it &quot;mission_id should not be empty&quot; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="22">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="23">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="24">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="25">
<span class="hits">1</span>
<code class="ruby"> params = {content:&quot;good job&quot;, mission_id: nil,user_id: user.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="26">
<span class="hits">1</span>
<code class="ruby"> expect(Comment.new(params)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="29">
<span class="hits">1</span>
<code class="ruby"> it &quot;content should has at least one word &quot; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
<code class="ruby"> comment_with_allspace = build(:comment_content_allspace)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="31">
<span class="hits">1</span>
<code class="ruby"> comment_with_allspace.validate</code>
</li>
<li class="covered" data-hits="1" data-linenumber="32">
<span class="hits">1</span>
<code class="ruby"> expect(comment_with_allspace.errors[:content].size).to eq(1)</code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="35">
<span class="hits">1</span>
<code class="ruby"> it &quot;user should be exist&quot; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="36">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="37">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="38">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="39">
<span class="hits">1</span>
<code class="ruby"> expect(user).to be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="40">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project_1&quot;,content: &quot;project content&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="41">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="42">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; user</code>
</li>
<li class="covered" data-hits="1" data-linenumber="43">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="44">
<span class="hits">1</span>
<code class="ruby"> expect(project).to be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="45">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;mission&quot;,deadline: &quot;2016-10-17 10:00:00&quot;,priority: 1,status: 2,content: &quot;mission content&quot;,project_id: project.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="46">
<span class="hits">1</span>
<code class="ruby"> mission = Mission.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="47">
<span class="hits">1</span>
<code class="ruby"> mission.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="48">
<span class="hits">1</span>
<code class="ruby"> expect(mission).to be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="49">
<span class="hits">1</span>
<code class="ruby"> expect(mission.errors[:project_id].size).to eq(0)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="50">
<span class="hits">1</span>
<code class="ruby"> params = {content: &quot;comment&quot;, mission_id: mission.id, user_id: user.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="51">
<span class="hits">1</span>
<code class="ruby"> comment = Comment.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="52">
<span class="hits">1</span>
<code class="ruby"> expect(comment).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="53">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="54">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="55">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="56">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="87b629c591df97bdf14bc514434df11b3ebafb35">
<div class="header">
<h3>spec/models/mission_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>23</b> relevant lines.
<span class="green"><b>23</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe Mission , type: :model do</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> it &#39;has a valid mission&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;mission1&quot;,content: &quot;mission content&quot;,deadline:&quot;2016-10-17 10:00:00&quot;,priority:1,status:&quot;进行中&quot;}</code>
</li>
<li class="never" data-hits="" data-linenumber="7">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="8">
<span class="hits">1</span>
<code class="ruby"> mission = Mission.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> mission.validate</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> expect(mission).to be_valid </code>
</li>
<li class="never" data-hits="" data-linenumber="11">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="12">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> it &#39;content should not be nil&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="14">
<span class="hits">1</span>
<code class="ruby"> expect(build(:no_content_mission)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="15">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="16">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="17">
<span class="hits">1</span>
<code class="ruby"> it &#39;deadline should not be nil&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> expect(build(:no_deadline_mission)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="19">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="20">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="21">
<span class="hits">1</span>
<code class="ruby"> it &#39;status should not be nil&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="22">
<span class="hits">1</span>
<code class="ruby"> expect(build(:no_status_mission)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="23">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="24">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="25">
<span class="hits">1</span>
<code class="ruby"> it &#39;priority should not be nil&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="26">
<span class="hits">1</span>
<code class="ruby"> expect(build(:no_priority_mission)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="29">
<span class="hits">1</span>
<code class="ruby"> it &#39;priority is not among valid values&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
<code class="ruby"> mission = build(:priority_not_among_valid_values)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="31">
<span class="hits">1</span>
<code class="ruby"> mission.validate</code>
</li>
<li class="covered" data-hits="1" data-linenumber="32">
<span class="hits">1</span>
<code class="ruby"> expect(mission.errors[:priority].size).to eq(1)</code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="35">
<span class="hits">1</span>
<code class="ruby"> it &#39;status is not among valid values&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="36">
<span class="hits">1</span>
<code class="ruby"> mission = build(:status_not_among_valid_values)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="37">
<span class="hits">1</span>
<code class="ruby"> mission.validate</code>
</li>
<li class="covered" data-hits="1" data-linenumber="38">
<span class="hits">1</span>
<code class="ruby"> expect(mission.errors[:status].size).to eq(1)</code>
</li>
<li class="never" data-hits="" data-linenumber="39">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="40">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="41">
<code class="ruby">end</code>
</li>
<li class="never" data-hits="" data-linenumber="42">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="43">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="44">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="45">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="46">
<code class="ruby"># require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="47">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="48">
<code class="ruby"># RSpec.describe Mission, type: :model do</code>
</li>
<li class="never" data-hits="" data-linenumber="49">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="50">
<code class="ruby"># it &#39;has a valid mission&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="51">
<code class="ruby"># expect(build(:project)).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="52">
<code class="ruby"># end</code>
</li>
<li class="never" data-hits="" data-linenumber="53">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="54">
<code class="ruby"># describe &#39;users test&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="55">
<code class="ruby"># it &#39;has at least on user&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="56">
<code class="ruby"># mission_with_no_user = build(:mission)</code>
</li>
<li class="never" data-hits="" data-linenumber="57">
<code class="ruby"># mission_with_no_user.users = []</code>
</li>
<li class="never" data-hits="" data-linenumber="58">
<code class="ruby"># mission_with_no_user.valid?</code>
</li>
<li class="never" data-hits="" data-linenumber="59">
<code class="ruby"># expect(mission_with_no_user.errors[:users].size).to eq(1)</code>
</li>
<li class="never" data-hits="" data-linenumber="60">
<code class="ruby"># end</code>
</li>
<li class="never" data-hits="" data-linenumber="61">
<code class="ruby"># end</code>
</li>
<li class="never" data-hits="" data-linenumber="62">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="63">
<code class="ruby"># describe &#39;name test&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="64">
<code class="ruby"># it &#39;does not allow absence of name&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="65">
<code class="ruby"># expect(build(:mission, name: nil)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="66">
<code class="ruby"># end</code>
</li>
<li class="never" data-hits="" data-linenumber="67">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="68">
<code class="ruby"># it &#39;length of name in [1,20]&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="69">
<code class="ruby"># expect(build(:mission_name_length_gt_20)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="70">
<code class="ruby"># end</code>
</li>
<li class="never" data-hits="" data-linenumber="71">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="72">
<code class="ruby"># end</code>
</li>
<li class="never" data-hits="" data-linenumber="73">
<code class="ruby"># end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="83262d161db87629764629c21c55880068f2d2a8">
<div class="header">
<h3>spec/models/missions_user_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>42</b> relevant lines.
<span class="green"><b>42</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe Missions_user , type: :model do</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> it &quot;mission should exist&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="8">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> expect(user).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="11">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project_1&quot;,content: &quot;project content&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="14">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; user</code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="16">
<span class="hits">1</span>
<code class="ruby"> expect(project).to be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="17">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;mission&quot;,deadline: &quot;2016-10-17 10:00:00&quot;,priority: 1,status: 2,content: &quot;mission content&quot;,project_id: project.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> mission = Mission.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="19">
<span class="hits">1</span>
<code class="ruby"> mission.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
<code class="ruby"> expect(mission).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="22">
<span class="hits">1</span>
<code class="ruby"> params = {mission_id: 5,user_id: user.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="23">
<span class="hits">1</span>
<code class="ruby"> missions_user = Missions_user.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="24">
<span class="hits">1</span>
<code class="ruby"> missions_user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="25">
<span class="hits">1</span>
<code class="ruby"> expect(missions_user).to_not be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="26">
<span class="hits">1</span>
<code class="ruby"> expect(missions_user.errors[:mission].size).to eq(1)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="27">
<span class="hits">1</span>
<code class="ruby"> expect(Missions_user.find_by(user_id: user.id)).to eq(nil)</code>
</li>
<li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="30">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="31">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="32">
<span class="hits">1</span>
<code class="ruby"> it &quot;user should exist&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="33">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="34">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="35">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="36">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="37">
<span class="hits">1</span>
<code class="ruby"> expect(user).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="38">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="39">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project_1&quot;,content: &quot;project content&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="40">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="41">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; user</code>
</li>
<li class="covered" data-hits="1" data-linenumber="42">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="43">
<span class="hits">1</span>
<code class="ruby"> expect(project).to be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="44">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;mission&quot;,deadline: &quot;2016-10-17 10:00:00&quot;,priority: 1,status: 2,content: &quot;mission content&quot;,project_id: project.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="45">
<span class="hits">1</span>
<code class="ruby"> mission = Mission.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="46">
<span class="hits">1</span>
<code class="ruby"> mission.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="47">
<span class="hits">1</span>
<code class="ruby"> expect(mission).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="48">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="49">
<span class="hits">1</span>
<code class="ruby"> params = {mission_id: mission.id,user_id: 2}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="50">
<span class="hits">1</span>
<code class="ruby"> missions_user = Missions_user.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="51">
<span class="hits">1</span>
<code class="ruby"> missions_user.save</code>
</li>
<li class="never" data-hits="" data-linenumber="52">
<code class="ruby"> #puts missions_user.inspect</code>
</li>
<li class="covered" data-hits="1" data-linenumber="53">
<span class="hits">1</span>
<code class="ruby"> expect(missions_user).to_not be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="54">
<span class="hits">1</span>
<code class="ruby"> expect(missions_user.errors[:user].size).to eq(1)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="55">
<span class="hits">1</span>
<code class="ruby"> expect(Missions_user.find_by(mission_id: mission.id)).to eq(nil)</code>
</li>
<li class="never" data-hits="" data-linenumber="56">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="57">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="58">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="59">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="60">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="61">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="71c2d0c14437171dd4c650c3f917d2dd65d5ebd6">
<div class="header">
<h3>spec/models/note_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>62</b> relevant lines.
<span class="green"><b>62</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe Note , type: :model do</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> it &quot;has a valid note&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="8">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="never" data-hits="" data-linenumber="10">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project_1&quot;,content: &quot;project content&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; user</code>
</li>
<li class="covered" data-hits="1" data-linenumber="14">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> expect(project).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="16">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="17">
<span class="hits">1</span>
<code class="ruby"> params = {content: &quot;note content&quot;,user_id: user.id,project_id: project.id,category: 1}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> note = Note.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="19">
<span class="hits">1</span>
<code class="ruby"> note.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
<code class="ruby"> expect(note).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="22">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="23">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="24">
<span class="hits">1</span>
<code class="ruby"> it &quot;notes content should at least has one character&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="25">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="26">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="27">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="28">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
<code class="ruby"> params = {content: &quot; &quot;,user_id: user.id,category: 1}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="31">
<span class="hits">1</span>
<code class="ruby"> note = Note.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="32">
<span class="hits">1</span>
<code class="ruby"> note.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="33">
<span class="hits">1</span>
<code class="ruby"> expect(note.errors[:content].size).to eq(2)</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="35">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="36">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="37">
<span class="hits">1</span>
<code class="ruby"> it &quot;category should be among valid values&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="38">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="39">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="40">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="41">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="42">
<span class="hits">1</span>
<code class="ruby"> params = {content: &quot; &quot;,user_id: user.id,category: 4}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="43">
<span class="hits">1</span>
<code class="ruby"> note = Note.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="44">
<span class="hits">1</span>
<code class="ruby"> note.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="45">
<span class="hits">1</span>
<code class="ruby"> expect(note.errors[:category].size).to eq(1)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="46">
<span class="hits">1</span>
<code class="ruby"> expect(note).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="47">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="48">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="49">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="50">
<span class="hits">1</span>
<code class="ruby"> it &quot;notes user should be exist&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="51">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="52">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="53">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="54">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="never" data-hits="" data-linenumber="55">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="56">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project_1&quot;,content: &quot;project content&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="57">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="58">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; user</code>
</li>
<li class="covered" data-hits="1" data-linenumber="59">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="60">
<span class="hits">1</span>
<code class="ruby"> expect(project).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="61">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="62">
<span class="hits">1</span>
<code class="ruby"> params = {content: &quot;note content&quot;,user_id: user.id,project_id: 5,category: 1}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="63">
<span class="hits">1</span>
<code class="ruby"> note = Note.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="64">
<span class="hits">1</span>
<code class="ruby"> note.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="65">
<span class="hits">1</span>
<code class="ruby"> expect(note).to_not be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="66">
<span class="hits">1</span>
<code class="ruby"> expect(note.errors[:project].size).to eq(1)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="67">
<span class="hits">1</span>
<code class="ruby"> expect(Note.find_by(project_id: 5)).to eq(nil)</code>
</li>
<li class="never" data-hits="" data-linenumber="68">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="69">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="70">
<span class="hits">1</span>
<code class="ruby"> it &quot;notes project should be exist&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="71">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="72">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="73">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="74">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="never" data-hits="" data-linenumber="75">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="76">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project_1&quot;,content: &quot;project content&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="77">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="78">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; user</code>
</li>
<li class="covered" data-hits="1" data-linenumber="79">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="80">
<span class="hits">1</span>
<code class="ruby"> expect(project).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="81">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="82">
<span class="hits">1</span>
<code class="ruby"> params = {content: &quot;note content&quot;,user_id: 5,project_id: project.id,category: 1}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="83">
<span class="hits">1</span>
<code class="ruby"> note = Note.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="84">
<span class="hits">1</span>
<code class="ruby"> note.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="85">
<span class="hits">1</span>
<code class="ruby"> expect(note).to_not be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="86">
<span class="hits">1</span>
<code class="ruby"> expect(note.errors[:user].size).to eq(1)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="87">
<span class="hits">1</span>
<code class="ruby"> expect(Note.find_by(user_id: 5)).to eq(nil)</code>
</li>
<li class="never" data-hits="" data-linenumber="88">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="89">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="90">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="56dbd95b9485fb6f6ff887a57154ea9b82fec369">
<div class="header">
<h3>spec/models/project_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>18</b> relevant lines.
<span class="green"><b>18</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe Project, type: :model do</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> it &#39;has a valid factory&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
<code class="ruby"> expect(build(:project)).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="7">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> describe &#39;users test&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> it &#39;has at least on user&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> project_with_no_user = build(:project)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> project_with_no_user.users = []</code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> project_with_no_user.valid?</code>
</li>
<li class="covered" data-hits="1" data-linenumber="14">
<span class="hits">1</span>
<code class="ruby"> expect(project_with_no_user.errors[:users].size).to eq(1)</code>
</li>
<li class="never" data-hits="" data-linenumber="15">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="16">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> describe &#39;name test&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="19">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow absence of name&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
<code class="ruby"> expect(build(:project, name: nil)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="21">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="22">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="23">
<span class="hits">1</span>
<code class="ruby"> it &#39;length of name in [1,20]&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="24">
<span class="hits">1</span>
<code class="ruby"> expect(build(:project_name_length_gt_20)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="25">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="27">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow duplicate name&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="28">
<span class="hits">1</span>
<code class="ruby"> create(:project, name: &#39;project1&#39;)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="29">
<span class="hits">1</span>
<code class="ruby"> expect(build(:project, name: &#39;project1&#39;)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="30">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="31">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="32">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="aa9b4c95b53bc4794e31c2234c228d3027468638">
<div class="header">
<h3>spec/models/share_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>65</b> relevant lines.
<span class="green"><b>65</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe Share, type: :model do</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> it &quot;its a valid share&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="6">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403488@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="8">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> expect(user).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="11">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project_1&quot;,content: &quot;project content&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="14">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; user</code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="16">
<span class="hits">1</span>
<code class="ruby"> expect(project).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="18">
<span class="hits">1</span>
<code class="ruby"> params = {content: &quot;share content&quot;,project_id: project.id,user_id: user.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="19">
<span class="hits">1</span>
<code class="ruby"> share = Share.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
<code class="ruby"> share.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="21">
<span class="hits">1</span>
<code class="ruby"> expect(share).to be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="22">
<span class="hits">1</span>
<code class="ruby"> expect(Share.find_by(id: share.id)).to_not eq(nil)</code>
</li>
<li class="never" data-hits="" data-linenumber="23">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="24">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="25">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="26">
<span class="hits">1</span>
<code class="ruby"> it &quot;share content should have at least one character&quot; do</code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="28">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="29">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="31">
<span class="hits">1</span>
<code class="ruby"> expect(user).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="32">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="33">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project_1&quot;,content: &quot;project content&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="34">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="35">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; user</code>
</li>
<li class="covered" data-hits="1" data-linenumber="36">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="37">
<span class="hits">1</span>
<code class="ruby"> expect(project).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="38">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="39">
<span class="hits">1</span>
<code class="ruby"> params = {content: &quot; &quot;,project_id: project.id,user_id: user.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="40">
<span class="hits">1</span>
<code class="ruby"> share = Share.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="41">
<span class="hits">1</span>
<code class="ruby"> share.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="42">
<span class="hits">1</span>
<code class="ruby"> expect(share).to_not be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="43">
<span class="hits">1</span>
<code class="ruby"> expect(share.errors[:content].size).to eq(2)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="44">
<span class="hits">1</span>
<code class="ruby"> expect(Share.find_by(id: share.id)).to eq(nil)</code>
</li>
<li class="never" data-hits="" data-linenumber="45">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="46">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="47">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="48">
<span class="hits">1</span>
<code class="ruby"> it &quot;share&#39;s project should be exist&quot; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="49">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="50">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="51">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="52">
<span class="hits">1</span>
<code class="ruby"> expect(user).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="53">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="54">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project_1&quot;,content: &quot;project content&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="55">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="56">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; user</code>
</li>
<li class="covered" data-hits="1" data-linenumber="57">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="58">
<span class="hits">1</span>
<code class="ruby"> expect(project).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="59">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="60">
<span class="hits">1</span>
<code class="ruby"> params = {content: &quot;share content&quot;,project_id: 5,user_id: user.id}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="61">
<span class="hits">1</span>
<code class="ruby"> share = Share.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="62">
<span class="hits">1</span>
<code class="ruby"> share.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="63">
<span class="hits">1</span>
<code class="ruby"> expect(share).to_not be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="64">
<span class="hits">1</span>
<code class="ruby"> expect(share.errors[:project].size).to eq(1)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="65">
<span class="hits">1</span>
<code class="ruby"> expect(Share.find_by(id: share.id)).to eq(nil)</code>
</li>
<li class="never" data-hits="" data-linenumber="66">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="67">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="68">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="69">
<span class="hits">1</span>
<code class="ruby"> it &quot;share&#39;s user should be exist&quot; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="70">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;jaxon&quot;,email: &quot;370403444@qq.com&quot;,password_digest: &quot;123456&quot;,phone: &quot;15652336366&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="71">
<span class="hits">1</span>
<code class="ruby"> user = User.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="72">
<span class="hits">1</span>
<code class="ruby"> user.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="73">
<span class="hits">1</span>
<code class="ruby"> expect(user).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="74">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="75">
<span class="hits">1</span>
<code class="ruby"> params = {name: &quot;project_1&quot;,content: &quot;project content&quot;}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="76">
<span class="hits">1</span>
<code class="ruby"> project = Project.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="77">
<span class="hits">1</span>
<code class="ruby"> project.users &lt;&lt; user</code>
</li>
<li class="covered" data-hits="1" data-linenumber="78">
<span class="hits">1</span>
<code class="ruby"> project.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="79">
<span class="hits">1</span>
<code class="ruby"> expect(project).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="80">
<code class="ruby"> </code>
</li>
<li class="covered" data-hits="1" data-linenumber="81">
<span class="hits">1</span>
<code class="ruby"> params = {content: &quot;share content&quot;,project_id: project.id,user_id: 10}</code>
</li>
<li class="covered" data-hits="1" data-linenumber="82">
<span class="hits">1</span>
<code class="ruby"> share = Share.new(params)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="83">
<span class="hits">1</span>
<code class="ruby"> share.save</code>
</li>
<li class="covered" data-hits="1" data-linenumber="84">
<span class="hits">1</span>
<code class="ruby"> expect(share).to_not be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="85">
<span class="hits">1</span>
<code class="ruby"> expect(share.errors[:user].size).to eq(1)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="86">
<span class="hits">1</span>
<code class="ruby"> expect(Share.find_by(id: share.id)).to eq(nil)</code>
</li>
<li class="never" data-hits="" data-linenumber="87">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="88">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="89">
<code class="ruby"> </code>
</li>
<li class="never" data-hits="" data-linenumber="90">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
<div class="source_table" id="86b35fc5fa71440aad12e812bf9657aa85e487db">
<div class="header">
<h3>spec/models/user_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
<b>43</b> relevant lines.
<span class="green"><b>43</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
<pre>
<ol>
<li class="covered" data-hits="1" data-linenumber="1">
<span class="hits">1</span>
<code class="ruby">require &#39;rails_helper&#39;</code>
</li>
<li class="never" data-hits="" data-linenumber="2">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
<code class="ruby">RSpec.describe User, type: :model do</code>
</li>
<li class="never" data-hits="" data-linenumber="4">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
<code class="ruby"> it &#39;has a valid factory&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user)).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="7">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="8">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
<code class="ruby"> describe &#39;username test&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow absence of username&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, name: nil)).not_to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="12">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="13">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="14">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow name length &gt; 30&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user_name_length_gt_30)).not_to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="16">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="17">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="18">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="19">
<span class="hits">1</span>
<code class="ruby"> describe &#39;email test&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow absence of email&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="21">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, email: nil)).not_to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="22">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="23">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="24">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow email length &gt; 50&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="25">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user_email_length_gt_50)).not_to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="26">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="27">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="28">
<span class="hits">1</span>
<code class="ruby"> it &#39;email should match /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="29">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, email: &#39;123qq.com&#39;)).not_to be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, email: &#39;@qq.com&#39;)).not_to be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="31">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, email: &#39;123@qq&#39;)).not_to be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="32">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, email: &#39;123@.com&#39;)).not_to be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="33">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, email: &#39;123@qq.&#39;)).not_to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="34">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="35">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="36">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="37">
<span class="hits">1</span>
<code class="ruby"> describe &#39;password test&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="38">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow password length &lt; 6&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="39">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user_password_length_lt_6)).not_to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="40">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="41">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="42">
<span class="hits">1</span>
<code class="ruby"> it &#39;password_confirmation should match password when password_confirmation not nil&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="43">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, password: &#39;123456&#39;, password_confirmation: &#39;654321&#39;)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="44">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="45">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="46">
<span class="hits">1</span>
<code class="ruby"> it &#39;do not trigger match when password_confirmation nil&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="47">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, password: &#39;123456&#39;, password_confirmation: nil)).to be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="48">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="49">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="50">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow password absence on create&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="51">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, password: nil, password_confirmation: nil)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="52">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="53">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="54">
<span class="hits">1</span>
<code class="ruby"> it &#39;can authenticate&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="55">
<span class="hits">1</span>
<code class="ruby"> user = create(:user, password: &#39;123456&#39;, password_confirmation: &#39;123456&#39;)</code>
</li>
<li class="covered" data-hits="1" data-linenumber="56">
<span class="hits">1</span>
<code class="ruby"> expect(user.authenticate(&#39;123456&#39;)).to be_instance_of User</code>
</li>
<li class="covered" data-hits="1" data-linenumber="57">
<span class="hits">1</span>
<code class="ruby"> expect(user.authenticate(&#39;654312&#39;)).to be false</code>
</li>
<li class="never" data-hits="" data-linenumber="58">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="59">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="60">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="61">
<span class="hits">1</span>
<code class="ruby"> describe &#39;phone test&#39; do</code>
</li>
<li class="never" data-hits="" data-linenumber="62">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="63">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow phone absence&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="64">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, phone: nil)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="65">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="66">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="67">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow character other than number&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="68">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, phone: &#39;1371234567a&#39;)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="69">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="70">
<code class="ruby"></code>
</li>
<li class="covered" data-hits="1" data-linenumber="71">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow phone longer or shorter than 11&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="72">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, phone: &#39;137123456789&#39;)).to_not be_valid</code>
</li>
<li class="covered" data-hits="1" data-linenumber="73">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, phone: &#39;1371234567&#39;)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="74">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="75">
<code class="ruby"></code>
</li>
<li class="never" data-hits="" data-linenumber="76">
<code class="ruby"> # 防js注入</code>
</li>
<li class="covered" data-hits="1" data-linenumber="77">
<span class="hits">1</span>
<code class="ruby"> it &#39;does not allow multiline&#39; do</code>
</li>
<li class="covered" data-hits="1" data-linenumber="78">
<span class="hits">1</span>
<code class="ruby"> expect(build(:user, phone: &#39;13712345\n78&#39;)).to_not be_valid</code>
</li>
<li class="never" data-hits="" data-linenumber="79">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="80">
<code class="ruby"> end</code>
</li>
<li class="never" data-hits="" data-linenumber="81">
<code class="ruby">end</code>
</li>
</ol>
</pre>
</div>
</div>
</div>
</body>
</html>