-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OTWO-7292 Handle missing flag images for Stacks (#1796)
- Loading branch information
Showing
2 changed files
with
46 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class StacksHelperTest < ActionView::TestCase | ||
include StacksHelper | ||
|
||
describe 'stack_country_flag' do | ||
it 'must return an html with the flag image' do | ||
dummy_html = '<img/>' | ||
expects(:haml_tag).once.returns(dummy_html) | ||
|
||
_(stack_country_flag('Us')).must_equal dummy_html | ||
end | ||
|
||
it 'must handle invalid country codes' do | ||
_(stack_country_flag('invalid')).must_be :blank? | ||
end | ||
|
||
it 'must handle blank codes' do | ||
_(stack_country_flag(nil)).must_be :blank? | ||
end | ||
|
||
it 'must handle missing flag images' do | ||
_(stack_country_flag('uk')).must_be :blank? | ||
end | ||
|
||
it 'must use the assets_manifest when assets are not compiled' do | ||
Rails.configuration.assets.stubs(:compile).returns(false) | ||
Rails.application.assets_manifest.expects(:assets).once.returns({}) | ||
|
||
_(stack_country_flag('')).must_be :blank? | ||
end | ||
end | ||
end |