diff --git a/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb b/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
index 8907b4a..71f5cfe 100644
--- a/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
+++ b/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
@@ -43,8 +43,16 @@ class MezuroPluginProfileController < ProfileController
metric_name = params[:metric_name]
content = profile.articles.find(params[:id])
module_history = content.result_history(params[:module_name])
- date_history = module_history.collect { |x| x.date }
- metric_history = module_history.collect { |x| (x.metric_results.select { |y| y.metric.name.delete("() ") == metric_name })[0] }
- render :partial => 'content_viewer/metric_history', :locals => {:metric_history => metric_history, :date_history => date_history }
+ date_history = module_history.collect { |module_result| module_result.date }
+ score_history = (module_history.collect { |module_result| (module_result.metric_results.select { |metric_result| metric_result.metric.name.delete("() ") == metric_name })[0] }).collect { |metric_result| metric_result.value }
+ render :partial => 'content_viewer/score_history', :locals => {:score_history => score_history, :date_history => date_history }
+ end
+
+ def module_grade_history
+ content = profile.articles.find(params[:id])
+ modules_results = content.result_history(params[:module_name])
+ date_history = modules_results.collect { |module_result| module_result.date }
+ score_history = modules_results.collect { |module_result| module_result.grade }
+ render :partial => 'content_viewer/score_history', :locals => {:date_history => date_history, :score_history => score_history }
end
end
diff --git a/plugins/mezuro/public/javascripts/project_content.js b/plugins/mezuro/public/javascripts/project_content.js
index 68ec968..c3fbf20 100644
--- a/plugins/mezuro/public/javascripts/project_content.js
+++ b/plugins/mezuro/public/javascripts/project_content.js
@@ -22,7 +22,8 @@ function display_metric_history() {
}
function display_grade_history() {
- alert(jQuery(this).attr('show-grade-history'));
+ var module_name = jQuery(this).attr('show-grade-history');
+ callAction('module_grade_history', {module_name: module_name}, show_grades);
return false;
}
@@ -30,6 +31,10 @@ function show_metrics(content) {
jQuery('#historical-' + metricName).html(content);
}
+function show_grades(content) {
+ jQuery('#historical-grade').html(content);
+}
+
function toggle_mezuro(){
var element = jQuery(this).attr('data-show');
jQuery(element).toggle();
diff --git a/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb b/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
index 3f9d844..465aa17 100644
--- a/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
+++ b/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
@@ -20,7 +20,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
@project = @project_result.project
@name = @project.name
- @date = "2012-04-13T20:39:41+04:00"
+ @date = "2012-04-13T20:39:41+04:00"
end
should 'not find module result for inexistent project content' do
@@ -92,7 +92,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
end
should 'get project tree without date' do
- create_project_content
+ create_project_content
Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result)
Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project)
get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @name
@@ -101,13 +101,23 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
end
should 'get project tree from a specific date' do
- create_project_content
+ create_project_content
mock_project_result
Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project)
get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @name, :date => "2012-04-13T20:39:41+04:00"
assert_response 200
end
+ should 'get grade history' do
+ create_project_content
+ client = mock
+ Kalibro::Client::ModuleResultClient.expects(:new).returns(client)
+ client.expects(:result_history).returns([@module_result])
+ get :module_grade_history, :profile => @profile.identifier, :id => @content.id, :module_name => @name
+ assert_equal assings(:modules_results)[0].grade, 10.0
+ assert_response 200
+ end
+
private
def create_project_content
diff --git a/plugins/mezuro/views/content_viewer/_metric_history.rhtml b/plugins/mezuro/views/content_viewer/_metric_history.rhtml
deleted file mode 100644
index 9e155a3..0000000
--- a/plugins/mezuro/views/content_viewer/_metric_history.rhtml
+++ /dev/null
@@ -1,10 +0,0 @@
-
- <% cont = 0 %>
- <% date_history.each do |date| %>
-
- <%= date %> |
- <%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_history[cont].value) %> |
-
- <% cont = cont + 1 %>
- <% end %>
-
diff --git a/plugins/mezuro/views/content_viewer/_module_result.rhtml b/plugins/mezuro/views/content_viewer/_module_result.rhtml
index e22f9e1..adb0392 100644
--- a/plugins/mezuro/views/content_viewer/_module_result.rhtml
+++ b/plugins/mezuro/views/content_viewer/_module_result.rhtml
@@ -26,25 +26,29 @@
" style="display: none;">
-
+
|
<%= range.comments.nil? ? '' : range.comments %>
|
- <% end %>
+ <% end %>
<% end %>
-
-
- <%= _('Grade:') %>
- <%= "%.02f" % module_result.grade %>
-
-
+ |
+
+ |
+
+
+
+ <%= _('Grade:') %>
+ <%= "%.02f" % module_result.grade %>
+
+
|
diff --git a/plugins/mezuro/views/content_viewer/_score_history.rhtml b/plugins/mezuro/views/content_viewer/_score_history.rhtml
new file mode 100644
index 0000000..c6cf73a
--- /dev/null
+++ b/plugins/mezuro/views/content_viewer/_score_history.rhtml
@@ -0,0 +1,10 @@
+
+ <% cont = 0 %>
+ <% date_history.each do |date| %>
+
+ <%= date %> |
+ <%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(score_history[cont]) %> |
+
+ <% cont = cont + 1 %>
+ <% end %>
+
--
libgit2 0.21.2