Commit 2606843e6552a36bb1586acaa59d26f6e3751720
1 parent
c574b327
Exists in
colab
and in
4 other branches
ModuleResult navigation
Signed-off by: João M. M. da Silva <jaodsilv@linux.ime.usp.br>
Showing
10 changed files
with
87 additions
and
45 deletions
Show diff stats
app/controllers/repositories_controller.rb
@@ -14,7 +14,11 @@ class RepositoriesController < ApplicationController | @@ -14,7 +14,11 @@ class RepositoriesController < ApplicationController | ||
14 | @configuration = KalibroEntities::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this! | 14 | @configuration = KalibroEntities::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this! |
15 | @processing = @repository.last_processing | 15 | @processing = @repository.last_processing |
16 | if @processing.ready? | 16 | if @processing.ready? |
17 | - @root_module_result = @processing.root_module_result | 17 | + if params[:module_result_id].nil? |
18 | + @root_module_result = @processing.root_module_result | ||
19 | + else | ||
20 | + @root_module_result = ModuleResult.find(params[:module_result_id].to_i) | ||
21 | + end | ||
18 | end | 22 | end |
19 | end | 23 | end |
20 | 24 |
app/models/processing.rb
@@ -6,6 +6,6 @@ class Processing < KalibroEntities::Entities::Processing | @@ -6,6 +6,6 @@ class Processing < KalibroEntities::Entities::Processing | ||
6 | end | 6 | end |
7 | 7 | ||
8 | def root_module_result | 8 | def root_module_result |
9 | - KalibroEntities::Entities::ModuleResult.find(@results_root_id) | 9 | + ModuleResult.find(@results_root_id) |
10 | end | 10 | end |
11 | end | 11 | end |
app/views/repositories/_module_result.html.erb
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | icon = "folder.png" | 6 | icon = "folder.png" |
7 | end %> | 7 | end %> |
8 | <%= image_tag(icon, :size => "20x16") %> | 8 | <%= image_tag(icon, :size => "20x16") %> |
9 | - <%= module_result.module.name %> | 9 | + <%= link_to module_result.module.name, project_repository_module_path(repository.project_id, repository.id, module_result.id) %> |
10 | </td> | 10 | </td> |
11 | <td><%= module_result.module.granularity %></td> | 11 | <td><%= module_result.module.granularity %></td> |
12 | <td><%= format_grade(module_result.grade) %></td> | 12 | <td><%= format_grade(module_result.grade) %></td> |
app/views/repositories/show.html.erb
@@ -60,7 +60,7 @@ | @@ -60,7 +60,7 @@ | ||
60 | <th>Grade</th> | 60 | <th>Grade</th> |
61 | </thead> | 61 | </thead> |
62 | <tbody> | 62 | <tbody> |
63 | - <%= render partial: 'module_result', collection: children %> | 63 | + <%= render partial: 'module_result', collection: children, locals: {repository: @repository} %> |
64 | </tbody> | 64 | </tbody> |
65 | </table> | 65 | </table> |
66 | <% end %> | 66 | <% end %> |
config/routes.rb
@@ -8,7 +8,7 @@ Mezuro::Application.routes.draw do | @@ -8,7 +8,7 @@ Mezuro::Application.routes.draw do | ||
8 | 8 | ||
9 | resources :projects do | 9 | resources :projects do |
10 | resources :repositories, except: [:update, :index] | 10 | resources :repositories, except: [:update, :index] |
11 | - get '/repositories/:id/modules/:module_id' => 'repositories#show', as: :repository_module | 11 | + get '/repositories/:id/modules/:module_result_id' => 'repositories#show', as: :repository_module |
12 | put '/repositories/:id' => 'repositories#update', as: :repository_update | 12 | put '/repositories/:id' => 'repositories#update', as: :repository_update |
13 | end | 13 | end |
14 | # The priority is based upon order of creation: first created -> highest priority. | 14 | # The priority is based upon order of creation: first created -> highest priority. |
features/repository/show.feature
@@ -3,7 +3,7 @@ Feature: Show Repository | @@ -3,7 +3,7 @@ Feature: Show Repository | ||
3 | As a regular user | 3 | As a regular user |
4 | I should see it's informations | 4 | I should see it's informations |
5 | 5 | ||
6 | - @kalibro_restart | 6 | + @kalibro_restart |
7 | Scenario: With a ready processing | 7 | Scenario: With a ready processing |
8 | Given I am a regular user | 8 | Given I am a regular user |
9 | And I am signed in | 9 | And I am signed in |
@@ -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 |
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,33 +45,48 @@ Feature: Show Repository | @@ -45,33 +45,48 @@ 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 | ||
49 | - Scenario: Should show modules directories root when the process has been finished | ||
50 | - Given I am a regular user | ||
51 | - And I am signed in | ||
52 | - And I have a sample project | ||
53 | - And I have a sample configuration with native metrics | ||
54 | - And I have a sample repository within the sample project | ||
55 | - And I start to process that repository | ||
56 | - And I wait up for a ready processing | ||
57 | - And I ask for the last ready processing of the given repository | ||
58 | - And I ask for the module result of the given processing | ||
59 | - When I visit the repository show page | ||
60 | - Then I should see the given module result | 48 | + @kalibro_restart |
49 | + Scenario: Should show modules directories root when the process has been finished | ||
50 | + Given I am a regular user | ||
51 | + And I am signed in | ||
52 | + And I have a sample project | ||
53 | + And I have a sample configuration with native metrics | ||
54 | + And I have a sample repository within the sample project | ||
55 | + And I start to process that repository | ||
56 | + And I wait up for a ready processing | ||
57 | + And I ask for the last ready processing of the given repository | ||
58 | + And I ask for the module result of the given processing | ||
59 | + When I visit the repository show page | ||
60 | + Then I should see the given module result | ||
61 | 61 | ||
62 | - @kalibro_restart | 62 | + @kalibro_restart |
63 | Scenario: Should show children of root when the process has been finished | 63 | Scenario: Should show children of root when the process has been finished |
64 | - Given I am a regular user | ||
65 | - And I am signed in | ||
66 | - And I have a sample project | ||
67 | - And I have a sample configuration with native metrics | ||
68 | - And I have a sample repository within the sample project | ||
69 | - And I start to process that repository | ||
70 | - And I wait up for a ready processing | ||
71 | - And I ask for the last ready processing of the given repository | ||
72 | - And I ask for the module result of the given processing | ||
73 | - When I visit the repository show page | ||
74 | - Then I should see a sample child's name | ||
75 | - And I should see "Name" | ||
76 | - And I should see "Granularity" | ||
77 | - And I should see "Grade" | ||
78 | \ No newline at end of file | 64 | \ No newline at end of file |
65 | + Given I am a regular user | ||
66 | + And I am signed in | ||
67 | + And I have a sample project | ||
68 | + And I have a sample configuration with native metrics | ||
69 | + And I have a sample repository within the sample project | ||
70 | + And I start to process that repository | ||
71 | + And I wait up for a ready processing | ||
72 | + And I ask for the last ready processing of the given repository | ||
73 | + And I ask for the module result of the given processing | ||
74 | + When I visit the repository show page | ||
75 | + Then I should see a sample child's name | ||
76 | + And I should see "Name" | ||
77 | + And I should see "Granularity" | ||
78 | + And I should see "Grade" | ||
79 | + | ||
80 | + @kalibro_restart | ||
81 | + Scenario: Module navigation | ||
82 | + Given I am a regular user | ||
83 | + And I am signed in | ||
84 | + And I have a sample project | ||
85 | + And I have a sample configuration with native metrics | ||
86 | + And I have a sample repository within the sample project | ||
87 | + And I start to process that repository | ||
88 | + And I wait up for a ready processing | ||
89 | + And I ask for the last ready processing of the given repository | ||
90 | + And I ask for the module result of the given processing | ||
91 | + When I visit the repository show page | ||
92 | + And I click on the sample child's name | ||
93 | + Then I should see a sample child's name | ||
79 | \ No newline at end of file | 94 | \ No newline at end of file |
features/step_definitions/repository_steps.rb
@@ -55,6 +55,10 @@ When(/^I visit the repository show page$/) do | @@ -55,6 +55,10 @@ When(/^I visit the repository show page$/) do | ||
55 | visit project_repository_path(@project.id, @repository.id) | 55 | visit project_repository_path(@project.id, @repository.id) |
56 | end | 56 | end |
57 | 57 | ||
58 | +When(/^I click on the sample child's name$/) do | ||
59 | + click_link @module_result.children.first.module.name | ||
60 | +end | ||
61 | + | ||
58 | Then(/^I should see the sample repository name$/) do | 62 | Then(/^I should see the sample repository name$/) do |
59 | page.should have_content(@repository.name) | 63 | page.should have_content(@repository.name) |
60 | end | 64 | end |
spec/controllers/repositories_controller_spec.rb
@@ -82,18 +82,37 @@ describe RepositoriesController do | @@ -82,18 +82,37 @@ describe RepositoriesController do | ||
82 | describe 'show' do | 82 | describe 'show' do |
83 | let(:repository) { FactoryGirl.build(:repository) } | 83 | let(:repository) { FactoryGirl.build(:repository) } |
84 | 84 | ||
85 | - before :each do | ||
86 | - processing = FactoryGirl.build(:processing) | 85 | + context 'without a specific module_result' do |
86 | + before :each do | ||
87 | + processing = FactoryGirl.build(:processing) | ||
88 | + | ||
89 | + processing.expects(:root_module_result).returns(FactoryGirl.build(:module_result)) | ||
90 | + repository.expects(:last_processing).returns(processing) | ||
91 | + KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) | ||
92 | + Repository.expects(:find).with(repository.id).returns(repository) | ||
87 | 93 | ||
88 | - processing.expects(:root_module_result).returns(FactoryGirl.build(:module_result)) | ||
89 | - repository.expects(:last_processing).returns(processing) | ||
90 | - KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) | ||
91 | - Repository.expects(:find).with(repository.id).returns(repository) | 94 | + get :show, id: repository.id.to_s, project_id: project.id.to_s |
95 | + end | ||
92 | 96 | ||
93 | - get :show, id: repository.id.to_s, project_id: project.id.to_s | 97 | + it { should render_template(:show) } |
94 | end | 98 | end |
95 | 99 | ||
96 | - it { should render_template(:show) } | 100 | + context 'for an specific module_result' do |
101 | + | ||
102 | + before :each do | ||
103 | + processing = FactoryGirl.build(:processing) | ||
104 | + module_result = FactoryGirl.build(:module_result) | ||
105 | + | ||
106 | + ModuleResult.expects(:find).with(module_result.id) | ||
107 | + repository.expects(:last_processing).returns(processing) | ||
108 | + KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) | ||
109 | + Repository.expects(:find).with(repository.id).returns(repository) | ||
110 | + | ||
111 | + get :show, id: repository.id.to_s, project_id: project.id.to_s, module_result_id: module_result.id | ||
112 | + end | ||
113 | + | ||
114 | + it { should render_template(:show) } | ||
115 | + end | ||
97 | end | 116 | end |
98 | 117 | ||
99 | describe 'destroy' do | 118 | describe 'destroy' do |
spec/models/processing_spec.rb
@@ -22,7 +22,7 @@ describe Processing do | @@ -22,7 +22,7 @@ describe Processing do | ||
22 | 22 | ||
23 | describe 'root_module_result' do | 23 | describe 'root_module_result' do |
24 | it 'should call the root_module_result method' do | 24 | it 'should call the root_module_result method' do |
25 | - KalibroEntities::Entities::ModuleResult.expects(:find).with(subject.results_root_id).returns(FactoryGirl.build(:module_result)) | 25 | + ModuleResult.expects(:find).with(subject.results_root_id).returns(FactoryGirl.build(:module_result)) |
26 | 26 | ||
27 | subject.root_module_result | 27 | subject.root_module_result |
28 | end | 28 | end |
spec/routing/repositories_routing_spec.rb
@@ -11,7 +11,7 @@ describe RepositoriesController do | @@ -11,7 +11,7 @@ describe RepositoriesController do | ||
11 | it { should route(:get, '/projects/1/repositories/1'). | 11 | it { should route(:get, '/projects/1/repositories/1'). |
12 | to(controller: :repositories, action: :show, project_id: 1, id: 1) } | 12 | to(controller: :repositories, action: :show, project_id: 1, id: 1) } |
13 | it { should route(:get, '/projects/1/repositories/1/modules/1'). | 13 | it { should route(:get, '/projects/1/repositories/1/modules/1'). |
14 | - to(controller: :repositories, action: :show, project_id: 1, module_id: 1, id: 1) } | 14 | + to(controller: :repositories, action: :show, project_id: 1, module_result_id: 1, id: 1) } |
15 | it { should route(:delete, '/projects/1/repositories/1'). | 15 | it { should route(:delete, '/projects/1/repositories/1'). |
16 | to(controller: :repositories, action: :destroy, project_id: 1, id: 1) } | 16 | to(controller: :repositories, action: :destroy, project_id: 1, id: 1) } |
17 | it { should route(:put, '/projects/1/repositories/1'). | 17 | it { should route(:put, '/projects/1/repositories/1'). |