]> git.openstreetmap.org Git - rails.git/blob - test/lib/osm_community_index_test.rb
Remove unused myOpenID icon
[rails.git] / test / lib / osm_community_index_test.rb
1 require "test_helper"
2
3 class CountryTest < ActiveSupport::TestCase
4   def test_community_name_fallback
5     # If there is no translations and no name for the chapter, use the community name
6     community = Community.new({ "id" => "foo-chapter", "type" => "osm-lc", "strings" => { "community" => "Community Name" } })
7     community_locale_yaml = {}
8
9     name = OsmCommunityIndex.resolve_name(community, community_locale_yaml)
10     assert_equal("Community Name", name)
11   end
12
13   def test_resource_name_fallback
14     # If there is a name for the chapter, prefer that to the community name
15     community = Community.new({ "id" => "foo-chapter", "type" => "osm-lc", "strings" => { "community" => "Community Name", "name" => "Chapter Name" } })
16     community_locale_yaml = {}
17
18     name = OsmCommunityIndex.resolve_name(community, community_locale_yaml)
19     assert_equal("Chapter Name", name)
20   end
21
22   def test_i18n_explicit_name
23     # If there is an explicitly translated name for the chapter, use that
24     community = Community.new({ "id" => "foo-chapter", "type" => "osm-lc", "strings" => { "community" => "Community Name", "name" => "Chapter Name" } })
25     community_locale_yaml = { "foo-chapter" => { "name" => "Translated Chapter Name" } }
26
27     name = OsmCommunityIndex.resolve_name(community, community_locale_yaml)
28     assert_equal("Translated Chapter Name", name)
29   end
30
31   def test_i18n_fallback_name
32     # If there's no explicitly translated name for the chapter, use the default name and interpolate the community name if required.
33     community = Community.new({ "id" => "foo-chapter", "type" => "osm-lc", "strings" => { "community" => "Community Name", "communityID" => "communityname" } })
34     community_locale_yaml = { "_communities" => { "communityname" => "Translated Community" }, "_defaults" => { "osm-lc" => { "name" => "{community} Chapter" } } }
35
36     name = OsmCommunityIndex.resolve_name(community, community_locale_yaml)
37     assert_equal("Translated Community Chapter", name)
38   end
39 end