Commit afcd974df81c1659e4abeacfed058c76368d4801
Committed by
João M. M. da Silva
1 parent
717ebf9a
Exists in
master
and in
23 other branches
[Mezuro] fixed message error when occurs an error in processing.
Showing
5 changed files
with
21 additions
and
14 deletions
Show diff stats
plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb
| @@ -4,15 +4,19 @@ class MezuroPluginProcessingController < MezuroPluginProfileController | @@ -4,15 +4,19 @@ class MezuroPluginProcessingController < MezuroPluginProfileController | ||
| 4 | 4 | ||
| 5 | def state | 5 | def state |
| 6 | processing = processing_for_date(params[:repository_id].to_i, params[:date]) | 6 | processing = processing_for_date(params[:repository_id].to_i, params[:date]) |
| 7 | - render :text => processing.state | 7 | + if processing.error.nil? |
| 8 | + render :text => processing.state | ||
| 9 | + else | ||
| 10 | + render :text => 'ERROR' | ||
| 11 | + end | ||
| 8 | end | 12 | end |
| 9 | 13 | ||
| 10 | def processing | 14 | def processing |
| 11 | @processing = processing_for_date(params[:repository_id].to_i, params[:date]) | 15 | @processing = processing_for_date(params[:repository_id].to_i, params[:date]) |
| 12 | - if @processing.state == 'ERROR' | ||
| 13 | - render :partial => 'processing_error' | ||
| 14 | - else | 16 | + if @processing.error.nil? |
| 15 | render :partial => 'processing' | 17 | render :partial => 'processing' |
| 18 | + else | ||
| 19 | + render :partial => 'processing_error' | ||
| 16 | end | 20 | end |
| 17 | end | 21 | end |
| 18 | 22 |
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
| @@ -55,6 +55,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | @@ -55,6 +55,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | ||
| 55 | repository.save(project_content.project_id) | 55 | repository.save(project_content.project_id) |
| 56 | 56 | ||
| 57 | if( repository.errors.empty? ) | 57 | if( repository.errors.empty? ) |
| 58 | + repository.process | ||
| 58 | redirect_to "/profile/#{profile.identifier}/plugin/mezuro/repository/show/#{project_content.id}?repository_id=#{repository.id}" | 59 | redirect_to "/profile/#{profile.identifier}/plugin/mezuro/repository/show/#{project_content.id}?repository_id=#{repository.id}" |
| 59 | else | 60 | else |
| 60 | redirect_to_error_page repository.errors[0].message | 61 | redirect_to_error_page repository.errors[0].message |
plugins/mezuro/public/javascripts/processing.js
| @@ -72,8 +72,9 @@ function reloadProcessing(date){ | @@ -72,8 +72,9 @@ function reloadProcessing(date){ | ||
| 72 | function showProcessingFor(state){ | 72 | function showProcessingFor(state){ |
| 73 | repository_id = processingData('repository-id'); | 73 | repository_id = processingData('repository-id'); |
| 74 | if (state == 'ERROR') { | 74 | if (state == 'ERROR') { |
| 75 | - jQuery('#project-state').html('<div style="color:Red">ERROR</div>'); | 75 | + jQuery('#processing-state').html('<div style="color:Red">ERROR</div>'); |
| 76 | callAction('processing', 'processing', {repository_id: repository_id}, showReadyProcessing); | 76 | callAction('processing', 'processing', {repository_id: repository_id}, showReadyProcessing); |
| 77 | + showModuleResult(''); | ||
| 77 | } | 78 | } |
| 78 | else if (state == 'READY') { | 79 | else if (state == 'READY') { |
| 79 | jQuery('#msg-time').html(''); | 80 | jQuery('#msg-time').html(''); |
| @@ -129,4 +130,4 @@ function sourceNodeToggle(id){ | @@ -129,4 +130,4 @@ function sourceNodeToggle(id){ | ||
| 129 | var suffixes = ['_hidden', '_plus', '_minus']; | 130 | var suffixes = ['_hidden', '_plus', '_minus']; |
| 130 | for (var i in suffixes) | 131 | for (var i in suffixes) |
| 131 | jQuery('#' + id + suffixes[i]).toggle(); | 132 | jQuery('#' + id + suffixes[i]).toggle(); |
| 132 | -} | ||
| 133 | \ No newline at end of file | 133 | \ No newline at end of file |
| 134 | +} |
plugins/mezuro/test/functional/profile/mezuro_plugin_module_result_controller_test.rb
| @@ -21,24 +21,24 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | @@ -21,24 +21,24 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | ||
| 21 | 21 | ||
| 22 | should 'find module result on kalibro' do | 22 | should 'find module result on kalibro' do |
| 23 | parent_module_result = ModuleResultFixtures.parent_module_result_hash | 23 | parent_module_result = ModuleResultFixtures.parent_module_result_hash |
| 24 | - Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:id] }). | 24 | + Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:id].to_i }). |
| 25 | returns({:module_result => @module_result_hash}) | 25 | returns({:module_result => @module_result_hash}) |
| 26 | - Kalibro::MetricResult.expects(:request).with(:metric_results_of, { :module_result_id => @module_result_hash[:id] }). | 26 | + Kalibro::MetricResult.expects(:request).with(:metric_results_of, { :module_result_id => @module_result_hash[:id].to_i }). |
| 27 | returns({:metric_result => @metric_result_hash}) | 27 | returns({:metric_result => @metric_result_hash}) |
| 28 | - Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:parent_id] }). | 28 | + Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:parent_id].to_i }). |
| 29 | returns({:module_result => parent_module_result}) | 29 | returns({:module_result => parent_module_result}) |
| 30 | - Kalibro::ModuleResult.expects(:request).with(:children_of, {:module_result_id => @module_result_hash[:id]}). | 30 | + Kalibro::ModuleResult.expects(:request).with(:children_of, {:module_result_id => @module_result_hash[:id].to_i}). |
| 31 | returns({:module_result => nil}) | 31 | returns({:module_result => nil}) |
| 32 | get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] | 32 | get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] |
| 33 | - assert_equal @module_result_hash[:grade], assigns(:module_result).grade | ||
| 34 | - assert_equal @metric_result_hash[:value], assigns(:metric_results).first.value | 33 | + assert_equal @module_result_hash[:grade].to_f, assigns(:module_result).grade |
| 34 | + assert_equal @metric_result_hash[:value].to_f, assigns(:metric_results).first.value | ||
| 35 | assert_response 200 | 35 | assert_response 200 |
| 36 | #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | 36 | #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') |
| 37 | end | 37 | end |
| 38 | 38 | ||
| 39 | should 'get metric result history' do | 39 | should 'get metric result history' do |
| 40 | metric_name = @metric_result_hash[:configuration][:metric][:name] | 40 | metric_name = @metric_result_hash[:configuration][:metric][:name] |
| 41 | - Kalibro::MetricResult.expects(:request).with(:history_of_metric, { :metric_name => metric_name, :module_result_id => @module_result_hash[:id] }). | 41 | + Kalibro::MetricResult.expects(:request).with(:history_of_metric, { :metric_name => metric_name, :module_result_id => @module_result_hash[:id].to_i }). |
| 42 | returns({:date_metric_result => @date_metric_result_hash}) | 42 | returns({:date_metric_result => @date_metric_result_hash}) |
| 43 | get :metric_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id], :metric_name => metric_name | 43 | get :metric_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id], :metric_name => metric_name |
| 44 | assert_equal DateTime.parse(@date_metric_result_hash[:date]), assigns(:history).first.date | 44 | assert_equal DateTime.parse(@date_metric_result_hash[:date]), assigns(:history).first.date |
| @@ -47,7 +47,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | @@ -47,7 +47,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | ||
| 47 | end | 47 | end |
| 48 | 48 | ||
| 49 | should 'get module result history' do | 49 | should 'get module result history' do |
| 50 | - Kalibro::ModuleResult.expects(:request).with(:history_of_module, { :module_result_id => @module_result_hash[:id] }). | 50 | + Kalibro::ModuleResult.expects(:request).with(:history_of_module, { :module_result_id => @module_result_hash[:id].to_i }). |
| 51 | returns({:date_module_result => @date_module_result_hash}) | 51 | returns({:date_module_result => @date_module_result_hash}) |
| 52 | get :module_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] | 52 | get :module_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] |
| 53 | assert_equal DateTime.parse(@date_module_result_hash[:date]), assigns(:history).first.date | 53 | assert_equal DateTime.parse(@date_module_result_hash[:date]), assigns(:history).first.date |
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
| @@ -77,6 +77,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | @@ -77,6 +77,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | ||
| 77 | should 'update a repository' do | 77 | should 'update a repository' do |
| 78 | Kalibro::Repository.expects(:new).returns(@repository) | 78 | Kalibro::Repository.expects(:new).returns(@repository) |
| 79 | @repository.expects(:save).with(@content.project_id).returns(true) | 79 | @repository.expects(:save).with(@content.project_id).returns(true) |
| 80 | + Kalibro::Repository.expects(:request).with(:process_repository, {:repository_id => @repository.id}) | ||
| 80 | get :update, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | 81 | get :update, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash |
| 81 | assert @repository.errors.empty? | 82 | assert @repository.errors.empty? |
| 82 | assert_response :redirect | 83 | assert_response :redirect |