Commit c574b3275e10bd798a3acb81f4b96cf94ea62dbd
1 parent
dd27350b
Exists in
colab
and in
4 other branches
Refactored method metric_results from Processing to ModuleResult
So it gets easier to implement the navigation through Modules Signed-off by: João M. M. da Silva <jaodsilv@linux.ime.usp.br>
Showing
10 changed files
with
28 additions
and
18 deletions
Show diff stats
app/controllers/repositories_controller.rb
... | ... | @@ -8,11 +8,12 @@ class RepositoriesController < ApplicationController |
8 | 8 | |
9 | 9 | # GET /projects/1/repositories/1 |
10 | 10 | # GET /projects/1/repositories/1.json |
11 | + # GET /projects/1/repositories/1/modules/1 | |
12 | + # GET /projects/1/repositories/1/modules/1.json | |
11 | 13 | def show |
12 | 14 | @configuration = KalibroEntities::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this! |
13 | 15 | @processing = @repository.last_processing |
14 | 16 | if @processing.ready? |
15 | - @metric_results = @processing.metric_results | |
16 | 17 | @root_module_result = @processing.root_module_result |
17 | 18 | end |
18 | 19 | end | ... | ... |
app/models/module_result.rb
app/models/processing.rb
... | ... | @@ -5,10 +5,6 @@ class Processing < KalibroEntities::Entities::Processing |
5 | 5 | @state == "READY" |
6 | 6 | end |
7 | 7 | |
8 | - def metric_results | |
9 | - KalibroEntities::Entities::MetricResult.metric_results_of(@results_root_id) | |
10 | - end | |
11 | - | |
12 | 8 | def root_module_result |
13 | 9 | KalibroEntities::Entities::ModuleResult.find(@results_root_id) |
14 | 10 | end | ... | ... |
app/views/repositories/show.html.erb
... | ... | @@ -60,7 +60,7 @@ |
60 | 60 | <th>Grade</th> |
61 | 61 | </thead> |
62 | 62 | <tbody> |
63 | - <%= render partial: 'module_result', collection: children %> | |
63 | + <%= render partial: 'module_result', collection: children %> | |
64 | 64 | </tbody> |
65 | 65 | </table> |
66 | 66 | <% end %> |
... | ... | @@ -77,7 +77,7 @@ |
77 | 77 | </thead> |
78 | 78 | |
79 | 79 | <tbody> |
80 | - <%= render partial: 'metric_result', collection: @metric_results %> | |
80 | + <%= render partial: 'metric_result', collection: @root_module_result.metric_results %> | |
81 | 81 | </tbody> |
82 | 82 | |
83 | 83 | </table> | ... | ... |
config/routes.rb
... | ... | @@ -8,6 +8,7 @@ Mezuro::Application.routes.draw do |
8 | 8 | |
9 | 9 | resources :projects do |
10 | 10 | resources :repositories, except: [:update, :index] |
11 | + get '/repositories/:id/modules/:module_id' => 'repositories#show', as: :repository_module | |
11 | 12 | put '/repositories/:id' => 'repositories#update', as: :repository_update |
12 | 13 | end |
13 | 14 | # The priority is based upon order of creation: first created -> highest priority. | ... | ... |
spec/controllers/repositories_controller_spec.rb
... | ... | @@ -85,7 +85,6 @@ describe RepositoriesController do |
85 | 85 | before :each do |
86 | 86 | processing = FactoryGirl.build(:processing) |
87 | 87 | |
88 | - processing.expects(:metric_results).returns(nil) | |
89 | 88 | processing.expects(:root_module_result).returns(FactoryGirl.build(:module_result)) |
90 | 89 | repository.expects(:last_processing).returns(processing) |
91 | 90 | KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) | ... | ... |
spec/factories/module_results.rb
1 | 1 | FactoryGirl.define do |
2 | - factory :module_result, class: KalibroEntities::Entities::ModuleResult do | |
2 | + factory :module_result, class: ModuleResult do | |
3 | 3 | id "42" |
4 | 4 | self.module { FactoryGirl.build(:module) } |
5 | 5 | grade "10.0" |
... | ... | @@ -7,7 +7,7 @@ FactoryGirl.define do |
7 | 7 | height "6" |
8 | 8 | end |
9 | 9 | |
10 | - factory :root_module_result, class: KalibroEntities::Entities::ModuleResult do | |
10 | + factory :root_module_result, class: ModuleResult do | |
11 | 11 | id "21" |
12 | 12 | self.module { FactoryGirl.build(:module) } |
13 | 13 | grade "6.0" | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +require 'spec_helper' | |
2 | + | |
3 | +describe ModuleResult do | |
4 | + describe 'methods' do | |
5 | + describe 'metric_results' do | |
6 | + subject { FactoryGirl.build(:module_result) } | |
7 | + | |
8 | + it 'should call the metric_results_of method' do | |
9 | + KalibroEntities::Entities::MetricResult.expects(:metric_results_of).with(subject.id).returns(nil) | |
10 | + | |
11 | + subject.metric_results | |
12 | + end | |
13 | + end | |
14 | + end | |
15 | +end | |
0 | 16 | \ No newline at end of file | ... | ... |
spec/models/processing_spec.rb
... | ... | @@ -20,14 +20,6 @@ describe Processing do |
20 | 20 | end |
21 | 21 | end |
22 | 22 | |
23 | - describe 'metric_results' do | |
24 | - it 'should call the metric_results_of method' do | |
25 | - KalibroEntities::Entities::MetricResult.expects(:metric_results_of).with(subject.results_root_id).returns(nil) | |
26 | - | |
27 | - subject.metric_results | |
28 | - end | |
29 | - end | |
30 | - | |
31 | 23 | describe 'root_module_result' do |
32 | 24 | it 'should call the root_module_result method' do |
33 | 25 | KalibroEntities::Entities::ModuleResult.expects(:find).with(subject.results_root_id).returns(FactoryGirl.build(:module_result)) | ... | ... |
spec/routing/repositories_routing_spec.rb
... | ... | @@ -10,6 +10,8 @@ describe RepositoriesController do |
10 | 10 | to(controller: :repositories, action: :edit, project_id: 1, id: 1) } |
11 | 11 | it { should route(:get, '/projects/1/repositories/1'). |
12 | 12 | to(controller: :repositories, action: :show, project_id: 1, id: 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) } | |
13 | 15 | it { should route(:delete, '/projects/1/repositories/1'). |
14 | 16 | to(controller: :repositories, action: :destroy, project_id: 1, id: 1) } |
15 | 17 | it { should route(:put, '/projects/1/repositories/1'). | ... | ... |