-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from GQuirino/translate-dates-on-workers-table
Improve translations for pt-br dates
- Loading branch information
Showing
5 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
# encoding: utf-8 | ||
|
||
require 'minitest_helper' | ||
|
||
module Sidekiq | ||
class Helper < Sidekiq::WebAction | ||
include Sidekiq::Statistic::WebExtensionHelper | ||
end | ||
|
||
describe 'WebExtensionHelper' do | ||
include Rack::Test::Methods | ||
|
||
describe '.format_date' do | ||
let(:header) { { 'HTTP_ACCEPT_LANGUAGE' => 'pt-br' } } | ||
let(:datetime) { Time.now } | ||
let(:helper) { Helper.new(header, {}) } | ||
|
||
describe "when doesn't have translation" do | ||
before { header['HTTP_ACCEPT_LANGUAGE'] = 'xx-xx' } | ||
|
||
it 'return date with en format' do | ||
assert_equal helper.format_date(datetime), datetime.strftime('%m/%d/%Y') | ||
end | ||
end | ||
|
||
describe 'when have translation' do | ||
it 'return date with default format' do | ||
default_format = helper.get_locale.dig('date', 'formats', 'default') | ||
assert_equal helper.format_date(datetime), datetime.strftime(default_format) | ||
end | ||
|
||
it 'return date with datetime format' do | ||
datetime_format = helper.get_locale.dig('date', 'formats', 'datetime') | ||
assert_equal helper.format_date(datetime, 'datetime'), datetime.strftime(datetime_format) | ||
end | ||
end | ||
end | ||
end | ||
end |