Commit f9116a97e8555114d5bab5972a03903ea927f6f4

Authored by Diego Camarinha
Committed by Caio
1 parent 3cdc22b2

[Mezuro] Completed helper tests

plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb
1 class MezuroPlugin::Helpers::ContentViewerHelper 1 class MezuroPlugin::Helpers::ContentViewerHelper
2 def self.format_grade(grade) 2 def self.format_grade(grade)
3 - grade.slice(/[0-9]+\.[0-9]{1,2}/) 3 + sprintf("%.2f", grade.to_f)
4 end 4 end
5 end 5 end
plugins/mezuro/test/unit/mezuro_plugin/helpers/content_viewer_helper_test.rb 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +require "test_helper"
  2 +
  3 +class ContentViewerHelperTest < ActiveSupport::TestCase
  4 +
  5 + should 'get the number rounded by two decimal points' do
  6 + assert_equal '4.22', MezuroPlugin::Helpers::ContentViewerHelper.format_grade('4.22344')
  7 + assert_equal '4.10', MezuroPlugin::Helpers::ContentViewerHelper.format_grade('4.1')
  8 + assert_equal '4.00', MezuroPlugin::Helpers::ContentViewerHelper.format_grade('4')
  9 + end
  10 +end
plugins/mezuro/views/content_viewer/_module_result.rhtml
1 -<% require "#{RAILS_ROOT}/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb" %>  
2 -  
3 <% the_module = module_result.module %> 1 <% the_module = module_result.module %>
4 <% module_label = "#{the_module.name} (#{the_module.granularity})" %> 2 <% module_label = "#{the_module.name} (#{the_module.granularity})" %>
5 3
@@ -47,4 +45,3 @@ @@ -47,4 +45,3 @@
47 </tr> 45 </tr>
48 </tfoot> 46 </tfoot>
49 </table> 47 </table>
50 -