Skip to content

Commit c8aee22

Browse files
committed
test that all hoc paths for all locales gets 200 response status
1 parent 53cfb6e commit c8aee22

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

deployment.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ def code_org_url(path = '', scheme = '')
192192
site_url('code.org', path, scheme)
193193
end
194194

195+
def hoc_url(path = '', scheme = '')
196+
site_url('hourofcode.com', path, scheme)
197+
end
198+
195199
def dir(*dirs)
196200
File.join(root_dir, *dirs)
197201
end

lib/cdo/languages.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ def self.get_locale()
1616
@@table.select(:locale_s)
1717
end
1818

19+
def self.get_unique_hoc_lang_codes()
20+
@@table.select(:unique_language_s)
21+
end
22+
1923
end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
require 'rack/test'
2+
require 'minitest/autorun'
3+
4+
class I18nHocRoutesTest < Minitest::Test
5+
include Rack::Test::Methods
6+
7+
def app
8+
Rack::Builder.parse_file(File.absolute_path('../config.ru', __dir__)).first
9+
end
10+
11+
def test_hoc_pages_for_all_locales
12+
header 'Host', 'hourofcode.com'
13+
languages = DB[:cdo_languages].select(:unique_language_s).where(supported_hoc_b: 1)
14+
subpages = load_hoc_subpages
15+
16+
languages.each do |prop|
17+
# Tests the homepage
18+
assert_successful_get("/us/#{prop[:unique_language_s]}")
19+
20+
# Tests all other hoc subpages
21+
subpages.each do |path|
22+
assert_successful_get("/us/#{prop[:unique_language_s]}/#{path}")
23+
end
24+
end
25+
end
26+
27+
def assert_successful_get(path)
28+
resp = get(path)
29+
assert_equal 200, resp.status, path
30+
end
31+
32+
def load_hoc_subpages()
33+
Dir.glob(pegasus_dir('sites.v3/hourofcode.com/public/', '**/*.md')).map do |path|
34+
path[/public(.*)\.md/, 1]
35+
end
36+
end
37+
end

0 commit comments

Comments
 (0)