Commit d0a7610131ca41ccc67ce9c240957ed05da15a3f

Authored by Caio
Committed by Paulo Meireles
1 parent a851177b

[Mezuro] re-organizing controllers methods

plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb
... ... @@ -99,14 +99,6 @@ class MezuroPluginMyprofileController < ProfileController
99 99 redirect_to "/#{profile.identifier}/#{configuration_name.downcase.gsub(/\s/, '-')}"
100 100 end
101 101  
102   - def module_metrics_history
103   - metric_name = params[:metric_name]
104   - content = profile.articles.find(params[:id])
105   - module_history = content.result_history(params[:module_name])
106   - date_history = module_history.collect { |x| x.date }
107   - metric_history = module_history.collect { |x| (x.metric_results.select { |y| y.metric.name.delete("() ") == metric_name })[0] }
108   - render :partial => 'content_viewer/metric_history', :locals => {:metric_history => metric_history, :date_history => date_history }
109   - end
110 102 private
111 103  
112 104 def new_metric_configuration_instance
... ...
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
... ... @@ -26,7 +26,8 @@ class MezuroPluginProfileController < ProfileController
26 26 def module_result
27 27 content = profile.articles.find(params[:id])
28 28 date = params[:date]
29   - module_result = content.module_result(params[:module_name], date)
  29 + project_result = date.nil? ? content.project_result : content.get_date_result(date)
  30 + module_result = content.module_result(params[:module_name])
30 31 render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result}
31 32 end
32 33  
... ... @@ -38,4 +39,13 @@ class MezuroPluginProfileController < ProfileController
38 39 render :partial =>'content_viewer/source_tree', :locals => { :source_tree => source_tree, :project_name => content.project.name}
39 40 end
40 41  
  42 + def module_metrics_history
  43 + metric_name = params[:metric_name]
  44 + content = profile.articles.find(params[:id])
  45 + module_history = content.result_history(params[:module_name])
  46 + date_history = module_history.collect { |x| x.date }
  47 + metric_history = module_history.collect { |x| (x.metric_results.select { |y| y.metric.name.delete("() ") == metric_name })[0] }
  48 + render :partial => 'content_viewer/metric_history', :locals => {:metric_history => metric_history, :date_history => date_history }
  49 + end
  50 +
41 51 end
... ...
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
... ... @@ -64,11 +64,11 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
64 64  
65 65 should 'get project results from a specific date' do
66 66 create_project_content
67   - client = mock
68   - Kalibro::Client::ProjectResultClient.expects(:new).returns(client)
69   - client.expects(:has_results_before).returns(true)
70   - client.expects(:last_result_before).returns(@project_result)
71   - get :project_result, :profile => @profile.identifier, :id => @content.id, :date => "2012-04-13T20:39:41+04:00"
  67 + client = mock
  68 + Kalibro::Client::ProjectResultClient.expects(:new).returns(client)
  69 + client.expects(:has_results_before).returns(true)
  70 + client.expects(:last_result_before).returns(@project_result)
  71 + get :project_result, :profile => @profile.identifier, :id => @content.id, :date => "2012-04-13T20:39:41+04:00"
72 72 assert_response 200
73 73 end
74 74  
... ...