Commit 1e53c6f7cd006224e3ca8e83c990fb84e3e1d2cd

Authored by Alessandro Palmeira + Diego Araújo + João M. M. da Silva
Committed by Alessandro Palmeira
1 parent 60ff8362

[Mezuro] Added TODOs and renamed project_controller -> processing_controller

plugins/mezuro/controllers/profile/mezuro_plugin_module_controller.rb
  1 +#TODO refatorar todo o controller e seus testes funcionais
1 2 class MezuroPluginModuleController < MezuroPluginProfileController
2 3  
3 4 append_view_path File.join(File.dirname(__FILE__) + '/../../views')
... ...
plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb 0 → 100644
... ... @@ -0,0 +1,70 @@
  1 +#TODO refatorar todo o controller e seus testes funcionais
  2 +class MezuroPluginProjectController < MezuroPluginProfileController
  3 +
  4 + append_view_path File.join(File.dirname(__FILE__) + '/../../views')
  5 +
  6 + def processing_state
  7 + @content = profile.articles.find(params[:id])
  8 + processing = @content.processing
  9 + if project_content_has_errors?
  10 + redirect_to_error_page(@content.errors[:base])
  11 + else
  12 + render :text => processing.state
  13 + end
  14 + end
  15 +
  16 + def processing_error
  17 + @content = profile.articles.find(params[:id])
  18 + @processing = @content.processing
  19 + if project_content_has_errors?
  20 + redirect_to_error_page(@content.errors[:base])
  21 + else
  22 + render :partial => 'processing_error'
  23 + end
  24 + end
  25 +
  26 + def processing
  27 + @content = profile.articles.find(params[:id])
  28 + date = params[:date]
  29 + @processing = date.nil? ? @content.processing : @content.processing_with_date(date)
  30 + if project_content_has_errors?
  31 + redirect_to_error_page(@content.errors[:base])
  32 + else
  33 + render :partial => 'processing'
  34 + end
  35 + end
  36 +
  37 + def project_tree
  38 + @content = profile.articles.find(params[:id])
  39 + date = params[:date]
  40 + project_result = date.nil? ? @content.project_result : @content.project_result_with_date(date)
  41 + @project_name = @content.project.name if not @content.project.nil?
  42 + if project_content_has_errors?
  43 + redirect_to_error_page(@content.errors[:base])
  44 + else
  45 + @source_tree = project_result.node(params[:module_name])
  46 + render :partial =>'source_tree'
  47 + end
  48 + end
  49 +
  50 + private
  51 +
  52 + def module_result(repository_id, date = nil)
  53 + @processing ||= date.nil? ? processing(repository_id) : processing_with_date(repository_id, date)
  54 + begin
  55 + @module_result ||= Kalibro::ModuleResult.find(@processing.results_root_id)
  56 + rescue Exception => error
  57 + errors.add_to_base(error.message)
  58 + end
  59 + @module_result
  60 + end
  61 +
  62 + def result_history(module_result_id)
  63 + begin
  64 + @result_history ||= Kalibro::MetricResult.history_of(module_result_id)
  65 + rescue Exception => error
  66 + errors.add_to_base(error.message)
  67 + end
  68 + end
  69 +
  70 +end
... ...
plugins/mezuro/controllers/profile/mezuro_plugin_project_controller.rb
... ... @@ -1,49 +0,0 @@
1   -class MezuroPluginProjectController < MezuroPluginProfileController
2   -
3   - append_view_path File.join(File.dirname(__FILE__) + '/../../views')
4   -
5   - def processing_state
6   - @content = profile.articles.find(params[:id])
7   - processing = @content.processing
8   - if project_content_has_errors?
9   - redirect_to_error_page(@content.errors[:base])
10   - else
11   - render :text => processing.state
12   - end
13   - end
14   -
15   - def processing_error
16   - @content = profile.articles.find(params[:id])
17   - @processing = @content.processing
18   - if project_content_has_errors?
19   - redirect_to_error_page(@content.errors[:base])
20   - else
21   - render :partial => 'processing_error'
22   - end
23   - end
24   -
25   - def processing
26   - @content = profile.articles.find(params[:id])
27   - date = params[:date]
28   - @processing = date.nil? ? @content.processing : @content.processing_with_date(date)
29   - if project_content_has_errors?
30   - redirect_to_error_page(@content.errors[:base])
31   - else
32   - render :partial => 'processing'
33   - end
34   - end
35   -
36   - def project_tree
37   - @content = profile.articles.find(params[:id])
38   - date = params[:date]
39   - project_result = date.nil? ? @content.project_result : @content.project_result_with_date(date)
40   - @project_name = @content.project.name if not @content.project.nil?
41   - if project_content_has_errors?
42   - redirect_to_error_page(@content.errors[:base])
43   - else
44   - @source_tree = project_result.node(params[:module_name])
45   - render :partial =>'source_tree'
46   - end
47   - end
48   -
49   -end
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
  1 +#TODO terminar esse controler e seus testes funcionais
  2 +#TODO falta o destroy
1 3 class MezuroPluginRepositoryController < MezuroPluginProfileController
2 4  
3 5 append_view_path File.join(File.dirname(__FILE__) + '/../../views')
... ... @@ -59,7 +61,7 @@ class MezuroPluginRepositoryController &lt; MezuroPluginProfileController
59 61 @project_name = project_content.name
60 62 @repository = project_content.repositories.select{ |repository| repository.id == params[:repository_id].to_s }.first
61 63 @configuration_name = Kalibro::Configuration.configuration_of(@repository.id).name
62   - @processing = processing(@repository.id)
  64 + @processing = Kalibro::Processing.processing_of(@repository.id)
63 65 end
64 66  
65 67 def destroy
... ... @@ -72,25 +74,5 @@ class MezuroPluginRepositoryController &lt; MezuroPluginProfileController
72 74 redirect_to_error_page repository.errors[0].message
73 75 end
74 76 end
75   -
76   - private
77   -
78   - def module_result(repository_id, date = nil)
79   - @processing ||= date.nil? ? processing(repository_id) : processing_with_date(repository_id, date)
80   - begin
81   - @module_result ||= Kalibro::ModuleResult.find(@processing.results_root_id)
82   - rescue Exception => error
83   - errors.add_to_base(error.message)
84   - end
85   - @module_result
86   - end
87   -
88   - def result_history(module_result_id)
89   - begin
90   - @result_history ||= Kalibro::MetricResult.history_of(module_result_id)
91   - rescue Exception => error
92   - errors.add_to_base(error.message)
93   - end
94   - end
95 77  
96 78 end
... ...
plugins/mezuro/lib/kalibro/processing.rb
  1 +#TODO arrumar esse modelo e seus testes de unidade
1 2 class Kalibro::Processing < Kalibro::Model
2 3  
3 4 attr_accessor :id, :date, :state, :error, :process_time, :results_root_id
... ...
plugins/mezuro/lib/kalibro/repository.rb
... ... @@ -13,7 +13,7 @@ class Kalibro::Repository &lt; Kalibro::Model
13 13 def self.repositories_of(project_id)
14 14 response = request(:repositories_of, {:project_id => project_id})[:repository]
15 15 response = [] if response.nil?
16   - response = [response] if response.is_a? (Hash)
  16 + response = [response] if response.is_a?(Hash)
17 17 response.map {|repository| new repository}
18 18 end
19 19  
... ...
plugins/mezuro/test/functional/profile/mezuro_plugin_module_controller_test.rb
... ... @@ -4,6 +4,7 @@ require &quot;#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures&quot;
4 4 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures"
5 5 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_fixtures"
6 6  
  7 +#TODO refatorar todos os testes
7 8 class MezuroPluginModuleControllerTest < ActionController::TestCase
8 9  
9 10 def setup
... ...
plugins/mezuro/test/functional/profile/mezuro_plugin_processing_controller_test.rb 0 → 100644
... ... @@ -0,0 +1,94 @@
  1 +require 'test_helper'
  2 +
  3 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/processing_fixtures"
  4 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/throwable_fixtures"
  5 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures"
  6 +
  7 +
  8 +#TODO refatorar todos os testes
  9 +class MezuroPluginProjectControllerTest < ActionController::TestCase
  10 + def setup
  11 + @controller = MezuroPluginProjectController.new
  12 + @request = ActionController::TestRequest.new
  13 + @response = ActionController::TestResponse.new
  14 + @profile = fast_create(Community)
  15 +
  16 + @project_result = ProcessingFixtures.project_result
  17 + @repository_url = RepositoryFixtures.repository.address
  18 + @project = @project_result.project
  19 + @date = "2012-04-13T20:39:41+04:00"
  20 +
  21 + Kalibro::Project.expects(:all_names).returns([])
  22 + @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @project.name, :repository_url => @repository_url)
  23 + @content.expects(:send_project_to_service).returns(nil)
  24 + @content.save
  25 + end
  26 +
  27 + should 'test project state without kalibro_error' do
  28 + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash})
  29 + get :project_state, :profile => @profile.identifier, :id => @content.id
  30 + assert_response 200
  31 + assert_equal @content, assigns(:content)
  32 + end
  33 +
  34 + should 'test project state with kalibro_error' do
  35 + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ThrowableFixtures.throwable_hash})})
  36 + get :project_state, :profile => @profile.identifier, :id => @content.id
  37 + assert_response 200
  38 + assert_equal "ERROR", @response.body
  39 + assert_equal @content, assigns(:content)
  40 + end
  41 +
  42 + should 'test project error' do
  43 + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ThrowableFixtures.throwable_hash})})
  44 + get :project_error, :profile => @profile.identifier, :id => @content.id
  45 + assert_response 200
  46 + assert_select('h3', 'ERROR')
  47 + assert_equal @content, assigns(:content)
  48 + assert_equal @project.name, assigns(:project).name
  49 + end
  50 +
  51 + should 'test project result without date' do
  52 + Kalibro::Processing.expects(:request).with("Processing", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash})
  53 + get :project_result, :profile => @profile.identifier, :id => @content.id, :date => nil
  54 + assert_equal @content, assigns(:content)
  55 + assert_equal @project_result.project.name, assigns(:project_result).project.name
  56 + assert_response 200
  57 + assert_select('h4', 'Last Result')
  58 + end
  59 +
  60 + should 'test project results from a specific date' do
  61 + request_body = {:project_name => @project.name, :date => @date}
  62 + Kalibro::Processing.expects(:request).with("Processing", :has_results_before, request_body).returns({:has_results => true})
  63 + Kalibro::Processing.expects(:request).with("Processing", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash})
  64 + get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @date
  65 + assert_equal @content, assigns(:content)
  66 + assert_equal @project_result.project.name, assigns(:project_result).project.name
  67 + assert_response 200
  68 + assert_select('h4', 'Last Result')
  69 + end
  70 +
  71 + should 'test project tree without date' do
  72 + Kalibro::Processing.expects(:request).with("Processing", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash})
  73 + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash})
  74 + get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => nil
  75 + assert_equal @content, assigns(:content)
  76 + assert_equal @project.name, assigns(:project_name)
  77 + assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name
  78 + assert_response 200
  79 + assert_select('h2', /Qt-Calculator/)
  80 + end
  81 +
  82 + should 'test project tree with a specific date' do
  83 + request_body = {:project_name => @project.name, :date => @project_result.date}
  84 + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash})
  85 + Kalibro::Processing.expects(:request).with("Processing", :has_results_before, request_body).returns({:has_results => true})
  86 + Kalibro::Processing.expects(:request).with("Processing", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash})
  87 + get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => @project_result.date
  88 + assert_equal @content, assigns(:content)
  89 + assert_equal @project.name, assigns(:project_name)
  90 + assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name
  91 + assert_response 200
  92 + end
  93 +
  94 +end
... ...
plugins/mezuro/test/functional/profile/mezuro_plugin_project_controller_test.rb
... ... @@ -1,92 +0,0 @@
1   -require 'test_helper'
2   -
3   -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/processing_fixtures"
4   -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/throwable_fixtures"
5   -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures"
6   -
7   -class MezuroPluginProjectControllerTest < ActionController::TestCase
8   - def setup
9   - @controller = MezuroPluginProjectController.new
10   - @request = ActionController::TestRequest.new
11   - @response = ActionController::TestResponse.new
12   - @profile = fast_create(Community)
13   -
14   - @project_result = ProcessingFixtures.project_result
15   - @repository_url = RepositoryFixtures.repository.address
16   - @project = @project_result.project
17   - @date = "2012-04-13T20:39:41+04:00"
18   -
19   - Kalibro::Project.expects(:all_names).returns([])
20   - @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @project.name, :repository_url => @repository_url)
21   - @content.expects(:send_project_to_service).returns(nil)
22   - @content.save
23   - end
24   -
25   - should 'test project state without kalibro_error' do
26   - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash})
27   - get :project_state, :profile => @profile.identifier, :id => @content.id
28   - assert_response 200
29   - assert_equal @content, assigns(:content)
30   - end
31   -
32   - should 'test project state with kalibro_error' do
33   - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ThrowableFixtures.throwable_hash})})
34   - get :project_state, :profile => @profile.identifier, :id => @content.id
35   - assert_response 200
36   - assert_equal "ERROR", @response.body
37   - assert_equal @content, assigns(:content)
38   - end
39   -
40   - should 'test project error' do
41   - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ThrowableFixtures.throwable_hash})})
42   - get :project_error, :profile => @profile.identifier, :id => @content.id
43   - assert_response 200
44   - assert_select('h3', 'ERROR')
45   - assert_equal @content, assigns(:content)
46   - assert_equal @project.name, assigns(:project).name
47   - end
48   -
49   - should 'test project result without date' do
50   - Kalibro::Processing.expects(:request).with("Processing", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash})
51   - get :project_result, :profile => @profile.identifier, :id => @content.id, :date => nil
52   - assert_equal @content, assigns(:content)
53   - assert_equal @project_result.project.name, assigns(:project_result).project.name
54   - assert_response 200
55   - assert_select('h4', 'Last Result')
56   - end
57   -
58   - should 'test project results from a specific date' do
59   - request_body = {:project_name => @project.name, :date => @date}
60   - Kalibro::Processing.expects(:request).with("Processing", :has_results_before, request_body).returns({:has_results => true})
61   - Kalibro::Processing.expects(:request).with("Processing", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash})
62   - get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @date
63   - assert_equal @content, assigns(:content)
64   - assert_equal @project_result.project.name, assigns(:project_result).project.name
65   - assert_response 200
66   - assert_select('h4', 'Last Result')
67   - end
68   -
69   - should 'test project tree without date' do
70   - Kalibro::Processing.expects(:request).with("Processing", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash})
71   - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash})
72   - get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => nil
73   - assert_equal @content, assigns(:content)
74   - assert_equal @project.name, assigns(:project_name)
75   - assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name
76   - assert_response 200
77   - assert_select('h2', /Qt-Calculator/)
78   - end
79   -
80   - should 'test project tree with a specific date' do
81   - request_body = {:project_name => @project.name, :date => @project_result.date}
82   - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash})
83   - Kalibro::Processing.expects(:request).with("Processing", :has_results_before, request_body).returns({:has_results => true})
84   - Kalibro::Processing.expects(:request).with("Processing", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash})
85   - get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => @project_result.date
86   - assert_equal @content, assigns(:content)
87   - assert_equal @project.name, assigns(:project_name)
88   - assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name
89   - assert_response 200
90   - end
91   -
92   -end
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
... ... @@ -6,6 +6,7 @@ require &quot;#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures&quot;
6 6 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_content_fixtures"
7 7 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures"
8 8  
  9 +#TODO terminar os testes
9 10 class MezuroPluginRepositoryControllerTest < ActionController::TestCase
10 11  
11 12 def setup
... ...
plugins/mezuro/test/unit/kalibro/processing_test.rb
1 1 require "test_helper"
2 2  
3 3 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/processing_fixtures"
4   -
  4 +#TODO arrumar os testes de unidade
5 5 class ProcessingTest < ActiveSupport::TestCase
6 6  
7 7 def setup
... ... @@ -93,5 +93,57 @@ class ProcessingTest &lt; ActiveSupport::TestCase
93 93 Kalibro::Processing.expects(:request).with(:last_processing_before, {:repository_id => @repository_id, :date => @processing.date}).returns({:processing => @hash})
94 94 assert_equal @processing.id, Kalibro::Processing.last_processing_before(@repository_id, @processing.date).id
95 95 end
  96 +
  97 +=begin
  98 + should 'get processing of a repository' do
  99 + Kalibro::Processing.expects(:has_ready_processing).with(@repository.id).returns(true)
  100 + Kalibro::Processing.expects(:last_ready_processing_of).with(@repository.id).returns(@processing)
  101 + assert_equal @processing, @project_content.processing(@repository.id)
  102 + end
  103 +
  104 + should 'get not ready processing of a repository' do
  105 + Kalibro::Processing.expects(:has_ready_processing).with(@repository.id).returns(false)
  106 + Kalibro::Processing.expects(:last_processing_of).with(@repository.id).returns(@processing)
  107 + assert_equal @processing, @project_content.processing(@repository.id)
  108 + end
  109 +
  110 + should 'get processing of a repository after date' do
  111 + Kalibro::Processing.expects(:has_processing_after).with(@repository.id, @date).returns(true)
  112 + Kalibro::Processing.expects(:first_processing_after).with(@repository.id, @date).returns(@processing)
  113 + assert_equal @processing, @project_content.processing_with_date(@repository.id, @date)
  114 + end
  115 +
  116 + should 'get processing of a repository before date' do
  117 + Kalibro::Processing.expects(:has_processing_after).with(@repository.id, @date).returns(false)
  118 + Kalibro::Processing.expects(:has_processing_before).with(@repository.id, @date).returns(true)
  119 + Kalibro::Processing.expects(:last_processing_before).with(@repository.id, @date).returns(@processing)
  120 + assert_equal @processing, @project_content.processing_with_date(@repository.id, @date)
  121 + end
  122 +
  123 + should 'get module result' do
  124 + @project_content.expects(:processing).with(@repository.id).returns(@processing)
  125 + Kalibro::ModuleResult.expects(:find).with(@processing.results_root_id).returns(@module_result)
  126 + assert_equal @module_result, @project_content.module_result(@repository.id)
  127 +
  128 + end
  129 +
  130 + should 'get module result with date' do
  131 + @project_content.expects(:processing_with_date).with(@repository.id,@date.to_s).returns(@processing)
  132 + Kalibro::ModuleResult.expects(:find).with(@processing.results_root_id).returns(@module_result)
  133 + assert_equal @module_result, @project_content.module_result(@repository.id, @date.to_s)
  134 + end
  135 +
  136 + should 'get result history' do
  137 + Kalibro::MetricResult.expects(:history_of).with(@module_result.id).returns([@date_metric_result])
  138 + assert_equal [@date_metric_result], @project_content.result_history(@module_result.id)
  139 + end
  140 +
  141 + should 'add error to base when the module_result does not exist' do
  142 + Kalibro::MetricResult.expects(:history_of).with(@module_result.id).raises(Kalibro::Errors::RecordNotFound)
  143 + assert_nil @project_content.errors[:base]
  144 + @project_content.result_history(@module_result.id)
  145 + assert_not_nil @project_content.errors[:base]
  146 + end
  147 +=end
96 148  
97 149 end
... ...
plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb
... ... @@ -55,55 +55,5 @@ class ProjectContentTest &lt; ActiveSupport::TestCase
55 55 @project_content.repositories
56 56 assert_not_nil @project_content.errors[:base]
57 57 end
58   -
59   - should 'get processing of a repository' do
60   - Kalibro::Processing.expects(:has_ready_processing).with(@repository.id).returns(true)
61   - Kalibro::Processing.expects(:last_ready_processing_of).with(@repository.id).returns(@processing)
62   - assert_equal @processing, @project_content.processing(@repository.id)
63   - end
64   -
65   - should 'get not ready processing of a repository' do
66   - Kalibro::Processing.expects(:has_ready_processing).with(@repository.id).returns(false)
67   - Kalibro::Processing.expects(:last_processing_of).with(@repository.id).returns(@processing)
68   - assert_equal @processing, @project_content.processing(@repository.id)
69   - end
70   -
71   - should 'get processing of a repository after date' do
72   - Kalibro::Processing.expects(:has_processing_after).with(@repository.id, @date).returns(true)
73   - Kalibro::Processing.expects(:first_processing_after).with(@repository.id, @date).returns(@processing)
74   - assert_equal @processing, @project_content.processing_with_date(@repository.id, @date)
75   - end
76   -
77   - should 'get processing of a repository before date' do
78   - Kalibro::Processing.expects(:has_processing_after).with(@repository.id, @date).returns(false)
79   - Kalibro::Processing.expects(:has_processing_before).with(@repository.id, @date).returns(true)
80   - Kalibro::Processing.expects(:last_processing_before).with(@repository.id, @date).returns(@processing)
81   - assert_equal @processing, @project_content.processing_with_date(@repository.id, @date)
82   - end
83   -
84   - should 'get module result' do
85   - @project_content.expects(:processing).with(@repository.id).returns(@processing)
86   - Kalibro::ModuleResult.expects(:find).with(@processing.results_root_id).returns(@module_result)
87   - assert_equal @module_result, @project_content.module_result(@repository.id)
88   -
89   - end
90   -
91   - should 'get module result with date' do
92   - @project_content.expects(:processing_with_date).with(@repository.id,@date.to_s).returns(@processing)
93   - Kalibro::ModuleResult.expects(:find).with(@processing.results_root_id).returns(@module_result)
94   - assert_equal @module_result, @project_content.module_result(@repository.id, @date.to_s)
95   - end
96   -
97   - should 'get result history' do
98   - Kalibro::MetricResult.expects(:history_of).with(@module_result.id).returns([@date_metric_result])
99   - assert_equal [@date_metric_result], @project_content.result_history(@module_result.id)
100   - end
101   -
102   - should 'add error to base when the module_result does not exist' do
103   - Kalibro::MetricResult.expects(:history_of).with(@module_result.id).raises(Kalibro::Errors::RecordNotFound)
104   - assert_nil @project_content.errors[:base]
105   - @project_content.result_history(@module_result.id)
106   - assert_not_nil @project_content.errors[:base]
107   - end
108 58  
109 59 end
... ...