Improve wording and add test
[rails.git] / test / helpers / user_blocks_helper_test.rb
1 # coding: utf-8
2 require "test_helper"
3 include ApplicationHelper
4
5 class UserBlocksHelperTest < ActionView::TestCase
6
7   def setup
8     I18n.locale = "en"
9   end
10
11   def teardown
12     I18n.locale = "en"
13   end
14
15   def test_block_status
16     block = UserBlock.create(
17       :user_id => 1,
18       :creator_id => 2,
19       :reason => "testing",
20       :needs_view => true,
21       :ends_at => Time.now.getutc
22     )
23     assert_equal I18n.t("user_block.helper.until_login"), block_status(block)
24     block_end = Time.now.getutc + 60.minutes
25     block = UserBlock.create(
26       :user_id => 1,
27       :creator_id => 2,
28       :reason => "testing",
29       :needs_view => true,
30       :ends_at => Time.now.getutc + 60.minutes
31     )
32     assert_equal I18n.t("user_block.helper.time_future_and_until_login", :time => friendly_date(block_end)).html_safe, block_status(block)
33     block_end = Time.now.getutc + 60.minutes
34     block = UserBlock.create(
35       :user_id => 1,
36       :creator_id => 2,
37       :reason => "testing",
38       :needs_view => false,
39       :ends_at => Time.now.getutc + 60.minutes
40     )
41     assert_equal I18n.t("user_block.helper.time_future", :time => friendly_date(block_end)).html_safe, block_status(block)
42   end
43 end