discourse/spec/integrity/i18n_spec.rb

61 lines
1.8 KiB
Ruby
Raw Normal View History

2013-02-05 14:16:51 -05:00
require 'spec_helper'
describe "i18n integrity checks" do
it 'should have an i18n key for all trust levels' do
TrustLevel.all.each do |ts|
expect(ts.name).not_to match(/translation missing/)
2013-02-05 14:16:51 -05:00
end
end
it "needs an i18n key (description) for each Site Setting" do
SiteSetting.all_settings.each do |s|
next if s[:setting] =~ /^test/
expect(s[:description]).not_to match(/translation missing/)
2013-02-05 14:16:51 -05:00
end
end
it "needs an i18n key (notification_types) for each Notification type" do
Notification.types.each_key do |type|
2015-06-15 02:34:35 -04:00
next if type == :custom
expect(I18n.t("notification_types.#{type}")).not_to match(/translation missing/)
2013-02-05 14:16:51 -05:00
end
end
it "has valid YAML for client" do
Dir["#{Rails.root}/config/locales/client.*.yml"].each do |f|
locale = /.*\.([^.]{2,})\.yml$/.match(f)[1]
client = YAML.load_file("#{Rails.root}/config/locales/client.#{locale}.yml")
expect(client.count).to eq(1)
expect(client[locale]).not_to eq(nil)
expect(client[locale].count).to eq(2)
expect(client[locale]["js"]).not_to eq(nil)
expect(client[locale]["admin_js"]).not_to eq(nil)
end
end
it "has valid YAML for server" do
Dir["#{Rails.root}/config/locales/server.*.yml"].each do |f|
locale = /.*\.([^.]{2,})\.yml$/.match(f)[1]
server = YAML.load_file("#{Rails.root}/config/locales/server.#{locale}.yml")
expect(server.count).to eq(1)
expect(server[locale]).not_to eq(nil)
end
end
2013-03-22 12:49:46 -04:00
it "does not overwrite another language" do
2013-03-20 05:51:28 -04:00
Dir["#{Rails.root}/config/locales/*.yml"].each do |f|
locale = /.*\.([^.]{2,})\.yml$/.match(f)[1] + ':'
IO.foreach(f) do |line|
line.strip!
2013-03-20 05:51:28 -04:00
next if line.start_with? "#"
next if line.start_with? "---"
next if line.blank?
expect(line).to eq locale
2013-03-20 05:51:28 -04:00
break
end
end
end
2013-02-05 14:16:51 -05:00
end