extra tweaks for i18n (#16192)
* extra tweaks for i18n * fix for PR * fix for #16115 * fix for rubocop * fixes for spec
This commit is contained in:
parent
24d02b6a53
commit
c5faab1736
4 changed files with 13 additions and 6 deletions
|
|
@ -16,7 +16,7 @@ module URL
|
|||
base_url = "#{protocol}#{domain}"
|
||||
return base_url unless uri
|
||||
|
||||
URI.parse(base_url).merge(uri).to_s
|
||||
Addressable::URI.parse(base_url).join(uri).normalize.to_s
|
||||
end
|
||||
|
||||
# Creates an article URL
|
||||
|
|
|
|||
13
db/seeds.rb
13
db/seeds.rb
|
|
@ -36,7 +36,7 @@ end
|
|||
seeder.create_if_none(Organization) do
|
||||
3.times do
|
||||
Organization.create!(
|
||||
name: Faker::TvShows::SiliconValley.company,
|
||||
name: Faker::Company.name,
|
||||
summary: Faker::Company.bs,
|
||||
profile_image: logo = File.open(Rails.root.join("app/assets/images/#{rand(1..40)}.png")),
|
||||
nav_image: logo,
|
||||
|
|
@ -68,9 +68,12 @@ users_in_random_order = seeder.create_if_none(User, num_users) do
|
|||
user = User.create!(
|
||||
name: name,
|
||||
profile_image: File.open(Rails.root.join("app/assets/images/#{rand(1..40)}.png")),
|
||||
twitter_username: Faker::Internet.username(specifier: username),
|
||||
# Twitter username should be always ASCII
|
||||
twitter_username: Faker::Internet.username(specifier: username.transliterate),
|
||||
# Emails limited to 50 characters
|
||||
email: Faker::Internet.email(name: username, separators: "+", domain: Faker::Internet.domain_word.first(20)),
|
||||
email: Faker::Internet.email(
|
||||
name: username.transliterate, separators: "+", domain: Faker::Internet.domain_word.first(20),
|
||||
),
|
||||
confirmed_at: Time.current,
|
||||
registered_at: Time.current,
|
||||
registered: true,
|
||||
|
|
@ -556,6 +559,9 @@ end
|
|||
|
||||
##############################################################################
|
||||
|
||||
# change locale to en to work around non-ascii slug problem
|
||||
loc = I18n.locale
|
||||
Faker::Config.locale = "en"
|
||||
seeder.create_if_none(Page) do
|
||||
5.times do
|
||||
Page.create!(
|
||||
|
|
@ -567,6 +573,7 @@ seeder.create_if_none(Page) do
|
|||
)
|
||||
end
|
||||
end
|
||||
Faker::Config.locale = loc
|
||||
|
||||
##############################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ RSpec.describe ApplicationHelper, type: :helper do
|
|||
end
|
||||
|
||||
it "works when called with an URI object" do
|
||||
uri = URI::Generic.build(path: "resource_admin", fragment: "test")
|
||||
uri = URI::Generic.build(path: "resource_admin", fragment: "test").to_s
|
||||
expect(app_url(uri)).to eq("https://dev.to/resource_admin#test")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ RSpec.describe URL, type: :lib do
|
|||
end
|
||||
|
||||
it "works when called with an URI object" do
|
||||
uri = URI::Generic.build(path: "admin", fragment: "test")
|
||||
uri = URI::Generic.build(path: "admin", fragment: "test").to_s
|
||||
expect(described_class.url(uri)).to eq("https://dev.to/admin#test")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue