diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 51489fc..1259e0a 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -14,7 +14,11 @@ class RepositoriesController < ApplicationController
@configuration = KalibroEntities::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this!
@processing = @repository.last_processing
if @processing.ready?
- @root_module_result = @processing.root_module_result
+ if params[:module_result_id].nil?
+ @root_module_result = @processing.root_module_result
+ else
+ @root_module_result = ModuleResult.find(params[:module_result_id].to_i)
+ end
end
end
diff --git a/app/models/processing.rb b/app/models/processing.rb
index 2c572ab..150a809 100644
--- a/app/models/processing.rb
+++ b/app/models/processing.rb
@@ -6,6 +6,6 @@ class Processing < KalibroEntities::Entities::Processing
end
def root_module_result
- KalibroEntities::Entities::ModuleResult.find(@results_root_id)
+ ModuleResult.find(@results_root_id)
end
end
diff --git a/app/views/repositories/_module_result.html.erb b/app/views/repositories/_module_result.html.erb
index c2a9145..de948a8 100644
--- a/app/views/repositories/_module_result.html.erb
+++ b/app/views/repositories/_module_result.html.erb
@@ -6,7 +6,7 @@
icon = "folder.png"
end %>
<%= image_tag(icon, :size => "20x16") %>
- <%= module_result.module.name %>
+ <%= link_to module_result.module.name, project_repository_module_path(repository.project_id, repository.id, module_result.id) %>
<%= module_result.module.granularity %> |
<%= format_grade(module_result.grade) %> |
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb
index 6a34162..7ee666e 100644
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -60,7 +60,7 @@
Grade |
- <%= render partial: 'module_result', collection: children %>
+ <%= render partial: 'module_result', collection: children, locals: {repository: @repository} %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 0c00db2..8ac1398 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -8,7 +8,7 @@ Mezuro::Application.routes.draw do
resources :projects do
resources :repositories, except: [:update, :index]
- get '/repositories/:id/modules/:module_id' => 'repositories#show', as: :repository_module
+ get '/repositories/:id/modules/:module_result_id' => 'repositories#show', as: :repository_module
put '/repositories/:id' => 'repositories#update', as: :repository_update
end
# The priority is based upon order of creation: first created -> highest priority.
diff --git a/features/repository/show.feature b/features/repository/show.feature
index 99bd00f..e0a954c 100644
--- a/features/repository/show.feature
+++ b/features/repository/show.feature
@@ -3,7 +3,7 @@ Feature: Show Repository
As a regular user
I should see it's informations
- @kalibro_restart
+ @kalibro_restart
Scenario: With a ready processing
Given I am a regular user
And I am signed in
@@ -26,7 +26,7 @@ Feature: Show Repository
And I should see "Weight"
And I should see "Threshold"
- @kalibro_restart
+ @kalibro_restart
Scenario: Just after start to process
Given I am a regular user
And I am signed in
@@ -45,33 +45,48 @@ Feature: Show Repository
And I should not see Weight
And I should not see Threshold
- @kalibro_restart
- Scenario: Should show modules directories root when the process has been finished
- Given I am a regular user
- And I am signed in
- And I have a sample project
- And I have a sample configuration with native metrics
- And I have a sample repository within the sample project
- And I start to process that repository
- And I wait up for a ready processing
- And I ask for the last ready processing of the given repository
- And I ask for the module result of the given processing
- When I visit the repository show page
- Then I should see the given module result
+ @kalibro_restart
+ Scenario: Should show modules directories root when the process has been finished
+ Given I am a regular user
+ And I am signed in
+ And I have a sample project
+ And I have a sample configuration with native metrics
+ And I have a sample repository within the sample project
+ And I start to process that repository
+ And I wait up for a ready processing
+ And I ask for the last ready processing of the given repository
+ And I ask for the module result of the given processing
+ When I visit the repository show page
+ Then I should see the given module result
- @kalibro_restart
+ @kalibro_restart
Scenario: Should show children of root when the process has been finished
- Given I am a regular user
- And I am signed in
- And I have a sample project
- And I have a sample configuration with native metrics
- And I have a sample repository within the sample project
- And I start to process that repository
- And I wait up for a ready processing
- And I ask for the last ready processing of the given repository
- And I ask for the module result of the given processing
- When I visit the repository show page
- Then I should see a sample child's name
- And I should see "Name"
- And I should see "Granularity"
- And I should see "Grade"
\ No newline at end of file
+ Given I am a regular user
+ And I am signed in
+ And I have a sample project
+ And I have a sample configuration with native metrics
+ And I have a sample repository within the sample project
+ And I start to process that repository
+ And I wait up for a ready processing
+ And I ask for the last ready processing of the given repository
+ And I ask for the module result of the given processing
+ When I visit the repository show page
+ Then I should see a sample child's name
+ And I should see "Name"
+ And I should see "Granularity"
+ And I should see "Grade"
+
+ @kalibro_restart
+ Scenario: Module navigation
+ Given I am a regular user
+ And I am signed in
+ And I have a sample project
+ And I have a sample configuration with native metrics
+ And I have a sample repository within the sample project
+ And I start to process that repository
+ And I wait up for a ready processing
+ And I ask for the last ready processing of the given repository
+ And I ask for the module result of the given processing
+ When I visit the repository show page
+ And I click on the sample child's name
+ Then I should see a sample child's name
\ No newline at end of file
diff --git a/features/step_definitions/repository_steps.rb b/features/step_definitions/repository_steps.rb
index 226bd7f..7feb0e8 100644
--- a/features/step_definitions/repository_steps.rb
+++ b/features/step_definitions/repository_steps.rb
@@ -55,6 +55,10 @@ When(/^I visit the repository show page$/) do
visit project_repository_path(@project.id, @repository.id)
end
+When(/^I click on the sample child's name$/) do
+ click_link @module_result.children.first.module.name
+end
+
Then(/^I should see the sample repository name$/) do
page.should have_content(@repository.name)
end
diff --git a/spec/controllers/repositories_controller_spec.rb b/spec/controllers/repositories_controller_spec.rb
index baccf8a..6ffe88c 100644
--- a/spec/controllers/repositories_controller_spec.rb
+++ b/spec/controllers/repositories_controller_spec.rb
@@ -82,18 +82,37 @@ describe RepositoriesController do
describe 'show' do
let(:repository) { FactoryGirl.build(:repository) }
- before :each do
- processing = FactoryGirl.build(:processing)
+ context 'without a specific module_result' do
+ before :each do
+ processing = FactoryGirl.build(:processing)
+
+ processing.expects(:root_module_result).returns(FactoryGirl.build(:module_result))
+ repository.expects(:last_processing).returns(processing)
+ KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration))
+ Repository.expects(:find).with(repository.id).returns(repository)
- processing.expects(:root_module_result).returns(FactoryGirl.build(:module_result))
- repository.expects(:last_processing).returns(processing)
- KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration))
- Repository.expects(:find).with(repository.id).returns(repository)
+ get :show, id: repository.id.to_s, project_id: project.id.to_s
+ end
- get :show, id: repository.id.to_s, project_id: project.id.to_s
+ it { should render_template(:show) }
end
- it { should render_template(:show) }
+ context 'for an specific module_result' do
+
+ before :each do
+ processing = FactoryGirl.build(:processing)
+ module_result = FactoryGirl.build(:module_result)
+
+ ModuleResult.expects(:find).with(module_result.id)
+ repository.expects(:last_processing).returns(processing)
+ KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration))
+ Repository.expects(:find).with(repository.id).returns(repository)
+
+ get :show, id: repository.id.to_s, project_id: project.id.to_s, module_result_id: module_result.id
+ end
+
+ it { should render_template(:show) }
+ end
end
describe 'destroy' do
diff --git a/spec/models/processing_spec.rb b/spec/models/processing_spec.rb
index 2b8f8d6..15c07fb 100644
--- a/spec/models/processing_spec.rb
+++ b/spec/models/processing_spec.rb
@@ -22,7 +22,7 @@ describe Processing do
describe 'root_module_result' do
it 'should call the root_module_result method' do
- KalibroEntities::Entities::ModuleResult.expects(:find).with(subject.results_root_id).returns(FactoryGirl.build(:module_result))
+ ModuleResult.expects(:find).with(subject.results_root_id).returns(FactoryGirl.build(:module_result))
subject.root_module_result
end
diff --git a/spec/routing/repositories_routing_spec.rb b/spec/routing/repositories_routing_spec.rb
index 4519f39..01b7690 100644
--- a/spec/routing/repositories_routing_spec.rb
+++ b/spec/routing/repositories_routing_spec.rb
@@ -11,7 +11,7 @@ describe RepositoriesController do
it { should route(:get, '/projects/1/repositories/1').
to(controller: :repositories, action: :show, project_id: 1, id: 1) }
it { should route(:get, '/projects/1/repositories/1/modules/1').
- to(controller: :repositories, action: :show, project_id: 1, module_id: 1, id: 1) }
+ to(controller: :repositories, action: :show, project_id: 1, module_result_id: 1, id: 1) }
it { should route(:delete, '/projects/1/repositories/1').
to(controller: :repositories, action: :destroy, project_id: 1, id: 1) }
it { should route(:put, '/projects/1/repositories/1').
--
libgit2 0.21.2