Commit afcd974df81c1659e4abeacfed058c76368d4801
Committed by
João M. M. da Silva
1 parent
717ebf9a
Exists in
master
and in
29 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 | 4 | |
5 | 5 | def state |
6 | 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 | 12 | end |
9 | 13 | |
10 | 14 | def processing |
11 | 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 | 17 | render :partial => 'processing' |
18 | + else | |
19 | + render :partial => 'processing_error' | |
16 | 20 | end |
17 | 21 | end |
18 | 22 | ... | ... |
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
... | ... | @@ -55,6 +55,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController |
55 | 55 | repository.save(project_content.project_id) |
56 | 56 | |
57 | 57 | if( repository.errors.empty? ) |
58 | + repository.process | |
58 | 59 | redirect_to "/profile/#{profile.identifier}/plugin/mezuro/repository/show/#{project_content.id}?repository_id=#{repository.id}" |
59 | 60 | else |
60 | 61 | redirect_to_error_page repository.errors[0].message | ... | ... |
plugins/mezuro/public/javascripts/processing.js
... | ... | @@ -72,8 +72,9 @@ function reloadProcessing(date){ |
72 | 72 | function showProcessingFor(state){ |
73 | 73 | repository_id = processingData('repository-id'); |
74 | 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 | 76 | callAction('processing', 'processing', {repository_id: repository_id}, showReadyProcessing); |
77 | + showModuleResult(''); | |
77 | 78 | } |
78 | 79 | else if (state == 'READY') { |
79 | 80 | jQuery('#msg-time').html(''); |
... | ... | @@ -129,4 +130,4 @@ function sourceNodeToggle(id){ |
129 | 130 | var suffixes = ['_hidden', '_plus', '_minus']; |
130 | 131 | for (var i in suffixes) |
131 | 132 | jQuery('#' + id + suffixes[i]).toggle(); |
132 | -} | |
133 | 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 | 21 | |
22 | 22 | should 'find module result on kalibro' do |
23 | 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 | 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 | 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 | 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 | 31 | returns({:module_result => nil}) |
32 | 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 | 35 | assert_response 200 |
36 | 36 | #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') |
37 | 37 | end |
38 | 38 | |
39 | 39 | should 'get metric result history' do |
40 | 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 | 42 | returns({:date_metric_result => @date_metric_result_hash}) |
43 | 43 | get :metric_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id], :metric_name => metric_name |
44 | 44 | assert_equal DateTime.parse(@date_metric_result_hash[:date]), assigns(:history).first.date |
... | ... | @@ -47,7 +47,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase |
47 | 47 | end |
48 | 48 | |
49 | 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 | 51 | returns({:date_module_result => @date_module_result_hash}) |
52 | 52 | get :module_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] |
53 | 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 | 77 | should 'update a repository' do |
78 | 78 | Kalibro::Repository.expects(:new).returns(@repository) |
79 | 79 | @repository.expects(:save).with(@content.project_id).returns(true) |
80 | + Kalibro::Repository.expects(:request).with(:process_repository, {:repository_id => @repository.id}) | |
80 | 81 | get :update, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash |
81 | 82 | assert @repository.errors.empty? |
82 | 83 | assert_response :redirect | ... | ... |