Commit 5e84e3c668458c7d41814bc769b2e37b485963ef

Authored by Renan Fichberg
Committed by Rafael Manzo
1 parent d2e8b214

Acceptance test for show and unit test for repository controller.

And edited the show.html
And repository controller's method show

Signed-off-by: Fellipe Souto Sampaio <fllsouto@gmail.com>
app/controllers/repositories_controller.rb
@@ -11,7 +11,10 @@ class RepositoriesController &lt; ApplicationController @@ -11,7 +11,10 @@ class RepositoriesController &lt; ApplicationController
11 def show 11 def show
12 @configuration = KalibroEntities::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this! 12 @configuration = KalibroEntities::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this!
13 @processing = @repository.last_processing 13 @processing = @repository.last_processing
14 - @metric_results = @processing.metric_results if @processing.ready? 14 + if @processing.ready?
  15 + @metric_results = @processing.metric_results
  16 + @module_results = @processing.root_module_result
  17 + end
15 end 18 end
16 19
17 # GET projects/1/repositories/new 20 # GET projects/1/repositories/new
app/models/processing.rb
@@ -8,4 +8,8 @@ class Processing &lt; KalibroEntities::Entities::Processing @@ -8,4 +8,8 @@ class Processing &lt; KalibroEntities::Entities::Processing
8 def metric_results 8 def metric_results
9 KalibroEntities::Entities::MetricResult.metric_results_of(@results_root_id) 9 KalibroEntities::Entities::MetricResult.metric_results_of(@results_root_id)
10 end 10 end
  11 +
  12 + def root_module_result
  13 + KalibroEntities::Entities::ModuleResult.find(@results_root_id)
  14 + end
11 end 15 end
app/views/repositories/_module_result.html.erb 0 → 100644
@@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
  1 +<tr>
  2 + <td><%= %></td>
  3 + <td><%= metric_result.module.name %></td>
  4 +</tr>
0 \ No newline at end of file 5 \ No newline at end of file
app/views/repositories/show.html.erb
@@ -35,11 +35,16 @@ @@ -35,11 +35,16 @@
35 <% end %> 35 <% end %>
36 <% end %> 36 <% end %>
37 <hr/> 37 <hr/>
38 -<h2>Source Tree</h2>  
39 <% if @processing.ready? %> 38 <% if @processing.ready? %>
40 - <h3><%= @module_result.module.name %></h3>  
41 - <li>  
42 - </li> 39 + <h2>Source Tree</h2>
  40 + <h3><%= @module_results.module.name %></h3>
  41 + <table class="table table-hover">
  42 + <tbody>
  43 +
  44 + </tbody>
  45 +
  46 +
  47 + </table>
43 <% end %> 48 <% end %>
44 49
45 <% if @processing.ready? %> 50 <% if @processing.ready? %>
features/repository/show.feature
@@ -26,7 +26,7 @@ Feature: Show Repository @@ -26,7 +26,7 @@ Feature: Show Repository
26 And I should see "Weight" 26 And I should see "Weight"
27 And I should see "Threshold" 27 And I should see "Threshold"
28 28
29 - @kalibro_restart 29 + @kalibro_restart @wip
30 Scenario: Just after start to process 30 Scenario: Just after start to process
31 Given I am a regular user 31 Given I am a regular user
32 And I am signed in 32 And I am signed in
@@ -45,7 +45,7 @@ Feature: Show Repository @@ -45,7 +45,7 @@ Feature: Show Repository
45 And I should not see Weight 45 And I should not see Weight
46 And I should not see Threshold 46 And I should not see Threshold
47 47
48 - @kalibro_restart 48 + @kalibro_restart @wip
49 Scenario: Should show modules title 49 Scenario: Should show modules title
50 Given I am a regular user 50 Given I am a regular user
51 And I am signed in 51 And I am signed in
@@ -57,7 +57,7 @@ Feature: Show Repository @@ -57,7 +57,7 @@ Feature: Show Repository
57 When I visit the repository show page 57 When I visit the repository show page
58 Then I should see "Source Tree" 58 Then I should see "Source Tree"
59 59
60 - @kalibro_restart 60 + @kalibro_restart @wip
61 Scenario: Should show modules directories root when the process has been finished 61 Scenario: Should show modules directories root when the process has been finished
62 Given I am a regular user 62 Given I am a regular user
63 And I am signed in 63 And I am signed in
@@ -71,7 +71,7 @@ Feature: Show Repository @@ -71,7 +71,7 @@ Feature: Show Repository
71 When I visit the repository show page 71 When I visit the repository show page
72 Then I should see the given module result 72 Then I should see the given module result
73 73
74 - @kalibro_restart 74 + @kalibro_restart @wip
75 Scenario: Should show childrens of root when the process has been finished 75 Scenario: Should show childrens of root when the process has been finished
76 Given I am a regular user 76 Given I am a regular user
77 And I am signed in 77 And I am signed in
spec/controllers/repositories_controller_spec.rb
@@ -86,6 +86,7 @@ describe RepositoriesController do @@ -86,6 +86,7 @@ describe RepositoriesController do
86 processing = FactoryGirl.build(:processing) 86 processing = FactoryGirl.build(:processing)
87 87
88 processing.expects(:metric_results).returns(nil) 88 processing.expects(:metric_results).returns(nil)
  89 + processing.expects(:root_module_result).returns(FactoryGirl.build(:module_result))
89 repository.expects(:last_processing).returns(processing) 90 repository.expects(:last_processing).returns(processing)
90 KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) 91 KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration))
91 Repository.expects(:find).with(repository.id).returns(repository) 92 Repository.expects(:find).with(repository.id).returns(repository)
spec/factories/module_results.rb 0 → 100644
@@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
  1 +FactoryGirl.define do
  2 + factory :module_result, class: KalibroEntities::Entities::ModuleResult do
  3 + id "42"
  4 + self.module { FactoryGirl.build(:module) }
  5 + grade "10.0"
  6 + parent_id "21"
  7 + height "6"
  8 + end
  9 +
  10 + factory :root_module_result, class: KalibroEntities::Entities::ModuleResult do
  11 + id "21"
  12 + self.module { FactoryGirl.build(:module) }
  13 + grade "6.0"
  14 + parent_id nil
  15 + height "1"
  16 + end
  17 +end
0 \ No newline at end of file 18 \ No newline at end of file
spec/factories/modules.rb 0 → 100644
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
  1 +FactoryGirl.define do
  2 + factory :module, class: KalibroEntities::Entities::Module do
  3 + name 'Qt-Calculator'
  4 + granularity 'APPLICATION'
  5 + end
  6 +end
0 \ No newline at end of file 7 \ No newline at end of file
spec/models/processing_spec.rb
@@ -27,5 +27,13 @@ describe Processing do @@ -27,5 +27,13 @@ describe Processing do
27 subject.metric_results 27 subject.metric_results
28 end 28 end
29 end 29 end
  30 +
  31 + describe 'root_module_result' do
  32 + it 'should call the root_module_result method' do
  33 + KalibroEntities::Entities::ModuleResult.expects(:find).with(subject.results_root_id).returns(FactoryGirl.build(:module_result))
  34 +
  35 + subject.root_module_result
  36 + end
  37 + end
30 end 38 end
31 end 39 end
32 \ No newline at end of file 40 \ No newline at end of file