From 5a2e9ad1145a9db4849fb39a774006a37dd9ad5a Mon Sep 17 00:00:00 2001 From: Francisco Marcelo de Araújo Lima Júnior Date: Thu, 15 May 2014 18:40:59 -0300 Subject: [PATCH] #community dashboard - add unit test --- plugins/community_hub/lib/community_hub_plugin/hub_helper.rb | 26 ++------------------------ plugins/community_hub/test/unit/community_hub_plugin/hub_helper_test.rb | 18 ++++++++++++++++++ plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml | 2 +- 3 files changed, 21 insertions(+), 25 deletions(-) create mode 100644 plugins/community_hub/test/unit/community_hub_plugin/hub_helper_test.rb diff --git a/plugins/community_hub/lib/community_hub_plugin/hub_helper.rb b/plugins/community_hub/lib/community_hub_plugin/hub_helper.rb index 0e78365..1764aea 100644 --- a/plugins/community_hub/lib/community_hub_plugin/hub_helper.rb +++ b/plugins/community_hub/lib/community_hub_plugin/hub_helper.rb @@ -1,19 +1,5 @@ module CommunityHubPlugin::HubHelper - def post_css_classes(post_id, latest_post_id, oldest_post_id) - classes = "post" - - if post_id == latest_post_id - classes += " latest" - end - - if post_id == oldest_post_id - classes += " oldest" - end - - classes - end - def mediator?(hub) logged_in? && (hub.author.id == user.id || hub.mediators.include?(user.id)) ? true : false end @@ -31,15 +17,7 @@ module CommunityHubPlugin::HubHelper end def post_time(time) - if time - _('%{hour}:%{minutes}') % { :hour => time.hour, :minutes => time.strftime("%M") } - else - '' - end - end - - def embed_code(hub) - "" + _('%{hour}:%{minutes}') % { :hour => time.hour, :minutes => time.strftime("%M") } rescue '' end -end \ No newline at end of file +end diff --git a/plugins/community_hub/test/unit/community_hub_plugin/hub_helper_test.rb b/plugins/community_hub/test/unit/community_hub_plugin/hub_helper_test.rb new file mode 100644 index 0000000..4fdaba4 --- /dev/null +++ b/plugins/community_hub/test/unit/community_hub_plugin/hub_helper_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../../test_helper' + +class HubHelperTest < ActiveSupport::TestCase + + include CommunityHubPlugin::HubHelper + include NoosferoTestHelper + + should 'return time formated to hh:mm' do + t = Time.utc(2014,"jan",1,17,40,0) + assert_equal post_time(t), "17:40" + end + + should 'return empty string if param is not time' do + i = 1 + assert_equal post_time(i), '' + end + +end diff --git a/plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml b/plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml index c0df09c..fdccdd3 100644 --- a/plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml +++ b/plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml @@ -1,6 +1,6 @@ <% extend CommunityHubPlugin::HubHelper %> -
  • +