10629 lines
319 KiB
HTML
10629 lines
319 KiB
HTML
<!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 < 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['user_id']</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 < 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 => [</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"> #======================================>获取当前项目某状态的任务列表</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("project_id = ? AND status = ?",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 => mission.id,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="27">
|
||
|
||
|
||
<code class="ruby"> :name => mission.name,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="28">
|
||
|
||
|
||
<code class="ruby"> :content => 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 => pid).where(:status => 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 => i.id,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="36">
|
||
|
||
|
||
<code class="ruby"> # :name => i.name,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="37">
|
||
|
||
|
||
<code class="ruby"> # :content => 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 => {</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="41">
|
||
|
||
|
||
<code class="ruby"> :code => 0,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="42">
|
||
|
||
|
||
<code class="ruby"> :data => 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"> #======================================>获取任务详细信息</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("mission_id = ?",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 << 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("mission_id = ?",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 => uname,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="67">
|
||
|
||
|
||
<code class="ruby"> :content => c.content,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="68">
|
||
|
||
|
||
<code class="ruby"> :time => 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 => {</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="73">
|
||
|
||
|
||
<code class="ruby"> :code => 0,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="74">
|
||
|
||
|
||
<code class="ruby"> :data => {</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="75">
|
||
|
||
|
||
<code class="ruby"> :name => mission.name,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="76">
|
||
|
||
|
||
<code class="ruby"> :content => mission.content,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="77">
|
||
|
||
|
||
<code class="ruby"> :priority => mission.priority,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="78">
|
||
|
||
|
||
<code class="ruby"> :status => mission.status,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="79">
|
||
|
||
|
||
<code class="ruby"> :deadline => mission.deadline,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="80">
|
||
|
||
|
||
<code class="ruby"> :users => username,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="81">
|
||
|
||
|
||
<code class="ruby"> :comments => 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"> #======================================>创建任务</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 => {:code => 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 = "有新任务 <a>"+mission.name+"</a>"</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"> #======================================>修改任务信息</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(["mission_id = ?",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 = "<a>"+mission.name + "</a> 任务信息发生了变化"</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 => {:code => 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"> #======================================>当前用户发表评论</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 => {:code => 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 < 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("user_id = ? AND project_id = ? ",uid,pid).order("created_at desc").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] << {</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="19">
|
||
|
||
|
||
<code class="ruby"> :content => n.content,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="20">
|
||
|
||
|
||
<code class="ruby"> :time => time,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="21">
|
||
|
||
|
||
<code class="ruby"> :type => 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 => k,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="28">
|
||
|
||
|
||
<code class="ruby"> :notes => 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 => {</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="32">
|
||
|
||
|
||
<code class="ruby"> :code => 0,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="33">
|
||
|
||
|
||
<code class="ruby"> :data => 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 < 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 => [</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"> #=============================================>获取我的项目列表,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 => 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 => pid).size</code>
|
||
</li>
|
||
|
||
<li class="missed" data-hits="0" data-linenumber="22">
|
||
|
||
|
||
<code class="ruby"> uc = Projects_user.where(:project_id => pid).size</code>
|
||
</li>
|
||
|
||
<li class="missed" data-hits="0" data-linenumber="23">
|
||
|
||
|
||
<code class="ruby"> sc = Share.where(:project_id => 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 => pid,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="26">
|
||
|
||
|
||
<code class="ruby"> :name => p.name,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="27">
|
||
|
||
|
||
<code class="ruby"> :content => p.content,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="28">
|
||
|
||
|
||
<code class="ruby"> :mission_count => mc,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="29">
|
||
|
||
|
||
<code class="ruby"> :users_count => uc,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="30">
|
||
|
||
|
||
<code class="ruby"> :shares_count => 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 => {</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="34">
|
||
|
||
|
||
<code class="ruby"> :code => 0,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="35">
|
||
|
||
|
||
<code class="ruby"> :data => 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"> #=============================================>创建项目</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"> #=============================================>项目添加用户</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 = "<a>"+User.find_by(id: register).name + "</a> 邀请您进入项目 <a>" + Project.find_by(id: pid).name+"</a>"</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 => {:code => 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"> #=============================================>项目删除用户</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 ="<a>"+ User.find_by(id: register).name + "</a> 把您从项目 <a>" + Project.find_by(id: pid).name+"</a> 中删除"</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 => {:code => 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"> #=============================================>项目详情</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 => 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("project_id = ?",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 => i.name,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="116">
|
||
|
||
|
||
<code class="ruby"> :id => 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 => i.name,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="123">
|
||
|
||
|
||
<code class="ruby"> # :id => 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 => {</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="127">
|
||
|
||
|
||
<code class="ruby"> :code => 0,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="128">
|
||
|
||
|
||
<code class="ruby"> :data => {</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="129">
|
||
|
||
|
||
<code class="ruby"> :name => project.name,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="130">
|
||
|
||
|
||
<code class="ruby"> :content => project.content,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="131">
|
||
|
||
|
||
<code class="ruby"> :users => 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"> #=============================================>项目修改</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 => 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 => {:code => 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 < 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 => [: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 && 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: 'ok'</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: 'account or password is not correct'</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 &&= 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 'show'</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 < 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 => [</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 = "<a>"+User.find(uid).name + "</a> 分享了一些事"</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 => 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 => pid).order("created_at desc").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 => name,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="41">
|
||
|
||
|
||
<code class="ruby"> :time => i.created_at,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="42">
|
||
|
||
|
||
<code class="ruby"> :content => 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 => {</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="46">
|
||
|
||
|
||
<code class="ruby"> :code => 0,</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="47">
|
||
|
||
|
||
<code class="ruby"> :data => 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 < 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 => [</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 => '1'</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 => '0'</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 => 'exist'</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 => 'not exist'</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 'show'</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 => 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 < 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 < 1</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="18">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> errors[:content] = 'content should has at least one character'</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] = "user is not exist"</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] = "mission is not exist"</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 < 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] = "priority is not among valid values"</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] = "status is not among valid values"</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] = "project_id is not exist"</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 <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] = "mission belong to Missions_user is not exist"</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] = "user belong to Missions_user is not exist"</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 < 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 < 1</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="3" data-linenumber="20">
|
||
<span class="hits">3</span>
|
||
|
||
<code class="ruby"> errors[:content] = "note content should has at least one character"</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] = "note category is not among valid values"</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] = "user belong to Note is not exist"</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] = "project should be exist"</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 < 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] = 'at least one user in the project'</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 < 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 < 1</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="2" data-linenumber="16">
|
||
<span class="hits">2</span>
|
||
|
||
<code class="ruby"> errors[:content] = "share content should has at least one character"</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] = "user belong to Share is not exist"</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] = "user belong to Share is not exist"</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 < 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 'rails_helper'</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 "GET #getNotesList" 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 "return correct json format of noteslist" 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: "project mission update test",content: "update test"}</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 << 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: "note content 1",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: "note content 2",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 'rails_helper'</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 "GET #index " 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 "return valid projects json" 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: "project content 1",name: "project1"</code>
|
||
</li>
|
||
|
||
<li class="missed" data-hits="0" data-linenumber="16">
|
||
|
||
|
||
<code class="ruby"> post :create,content: "project content 2", name: "project2"</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 "POST #create" 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 "can create a valid project" 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: "project content 1",name: "project1"</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 "POST #addUsers" 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 "can addUsers correctly" 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: "project addUsers test",content: "addUsers test"}</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 << 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: "project content 3",name: "project3"</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 "GET #detail" 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 "can return correct json format of project " 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: "project addUsers test",content: "addUsers test"}</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 << 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 'rails_helper'</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 'POST #create' 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 'with legal account' 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 'should get correct email and password' 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 'should authenticate success' 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 'should get ok and text: ok' 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 'ok'</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 'with illegal account' 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: 'wrong_password'</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 'does not authenticate success' 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 'return with 401' 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 'account or password is not correct'</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 'should not raise error without param email or password' 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: 'wrong_password'</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 'DELETE #destroy' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="64">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> it 'should destroy user id in session' 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 'should return 401 without login' 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 'GET #show' 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 'after login' 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: 'json'</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 'should render show template' 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 'show'</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 'should return user in json' 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 'should renturn 401 without login' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="96">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> get :show, format: 'json'</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 'rails_helper'</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 "POST #create" 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 "create a correct share" 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: "project addUsers test",content: "addUsers test"}</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 << 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: "苟利国家生死以,岂因福祸避趋之"</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 "GET #getShareList" 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 "return correct share list" 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: "project test",content: " test"}</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 << 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: "苟利国家生死以,岂因福祸避趋之"</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: "too young too simple"</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: "too young too naive"</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 'rails_helper'</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: 'username2000') }</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 'GET #emailExist' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="10">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> it 'valid email' 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 '0'</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 'duplicated email' 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 '1'</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 'should not throw exception with no email param' 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: 'test'</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 'GET #usernameExist' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="28">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> it 'valid username' 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 'not exist'</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 'duplicated username' 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 'exist'</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 'should not throw exception with no username param' 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: 'test'</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 'POST #create' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="46">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> context 'success with valid attributes' 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 'should create user' 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 'should response with 201' 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 'fail with invalid attributes' 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 'does not save the new user' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="68">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> expect(User.exists? name: 'username2000').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 'should return errors' 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['email'].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['email']).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 'deal with params more or less than required' 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 => 'username', :email => '1261138729@qq.com',</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="81">
|
||
|
||
|
||
<code class="ruby"> :password => 'secret', :password_confirmation => 'secret',</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="2" data-linenumber="82">
|
||
<span class="hits">2</span>
|
||
|
||
<code class="ruby"> :more_field => 'test'} }</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 'should throw exception without param[:user]' 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 'should not throw exception' 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: 'test'</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 'should not accept other params' 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 'PATCH #update' 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 'with valid attributes' 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: 'json'</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 'should located current user' 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 'should render show' 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 'show'</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 'with invalid attributes' 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: 'json'</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 'does not change current user' 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 'should return error messages and error status' 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['email'].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['email']).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 'should login first' 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: 'json'</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 'rails_helper'</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 'has a valid comment' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="6">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> params = {name: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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:"good job",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 "content should not be empty" do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="14">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> params = {name: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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 "mission_id should not be empty" do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="22">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> params = {name: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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:"good job", 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 "content should has at least one word " 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 "user should be exist" do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="36">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> params = {name: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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: "project_1",content: "project content"}</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 << 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: "mission",deadline: "2016-10-17 10:00:00",priority: 1,status: 2,content: "mission content",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: "comment", 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 'rails_helper'</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 'has a valid mission' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="6">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> params = {name: "mission1",content: "mission content",deadline:"2016-10-17 10:00:00",priority:1,status:"进行中"}</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 'content should not be nil' 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 'deadline should not be nil' 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 'status should not be nil' 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 'priority should not be nil' 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 'priority is not among valid values' 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 'status is not among valid values' 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 'rails_helper'</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 'has a valid mission' 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 'users test' do</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="55">
|
||
|
||
|
||
<code class="ruby"># it 'has at least on user' 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 'name test' do</code>
|
||
</li>
|
||
|
||
<li class="never" data-hits="" data-linenumber="64">
|
||
|
||
|
||
<code class="ruby"># it 'does not allow absence of name' 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 'length of name in [1,20]' 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 'rails_helper'</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 "mission should exist" 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: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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: "project_1",content: "project content"}</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 << 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: "mission",deadline: "2016-10-17 10:00:00",priority: 1,status: 2,content: "mission content",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 "user should exist" 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: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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: "project_1",content: "project content"}</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 << 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: "mission",deadline: "2016-10-17 10:00:00",priority: 1,status: 2,content: "mission content",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 'rails_helper'</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 "has a valid note" 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: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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: "project_1",content: "project content"}</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 << 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: "note content",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 "notes content should at least has one character" 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: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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: " ",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 "category should be among valid values" 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: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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: " ",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 "notes user should be exist" 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: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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: "project_1",content: "project content"}</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 << 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: "note content",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 "notes project should be exist" 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: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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: "project_1",content: "project content"}</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 << 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: "note content",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 'rails_helper'</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 'has a valid factory' 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 'users test' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="10">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> it 'has at least on user' 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 'name test' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="19">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> it 'does not allow absence of name' 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 'length of name in [1,20]' 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 'does not allow duplicate name' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="28">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> create(:project, name: 'project1')</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="29">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> expect(build(:project, name: 'project1')).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 'rails_helper'</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 "its a valid share" 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: "jaxon",email: "370403488@qq.com",password_digest: "123456",phone: "15652336366"}</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: "project_1",content: "project content"}</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 << 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: "share content",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 "share content should have at least one character" 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: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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: "project_1",content: "project content"}</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 << 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: " ",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 "share's project should be exist" do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="49">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> params = {name: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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: "project_1",content: "project content"}</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 << 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: "share content",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 "share's user should be exist" do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="70">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> params = {name: "jaxon",email: "370403444@qq.com",password_digest: "123456",phone: "15652336366"}</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: "project_1",content: "project content"}</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 << 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: "share content",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 'rails_helper'</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 'has a valid factory' 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 'username test' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="10">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> it 'does not allow absence of username' 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 'does not allow name length > 30' 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 'email test' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="20">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> it 'does not allow absence of email' 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 'does not allow email length > 50' 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 'email should match /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="29">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> expect(build(:user, email: '123qq.com')).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: '@qq.com')).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: '123@qq')).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: '123@.com')).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: '123@qq.')).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 'password test' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="38">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> it 'does not allow password length < 6' 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 'password_confirmation should match password when password_confirmation not nil' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="43">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> expect(build(:user, password: '123456', password_confirmation: '654321')).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 'do not trigger match when password_confirmation nil' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="47">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> expect(build(:user, password: '123456', 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 'does not allow password absence on create' 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 'can authenticate' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="55">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> user = create(:user, password: '123456', password_confirmation: '123456')</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="56">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> expect(user.authenticate('123456')).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('654312')).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 'phone test' 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 'does not allow phone absence' 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 'does not allow character other than number' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="68">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> expect(build(:user, phone: '1371234567a')).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 'does not allow phone longer or shorter than 11' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="72">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> expect(build(:user, phone: '137123456789')).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: '1371234567')).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 'does not allow multiline' do</code>
|
||
</li>
|
||
|
||
<li class="covered" data-hits="1" data-linenumber="78">
|
||
<span class="hits">1</span>
|
||
|
||
<code class="ruby"> expect(build(:user, phone: '13712345\n78')).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>
|