mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 05:53:55 +08:00
6edadeab27
This commit changes `DiscourseIpInfo.mmdb_download` to use `File.join` instead of `URI.join` when `GlobalSetting.maxmind_mirror_url` has been configured. This is necessary because `URI.join` does not work the way I expect it to work when I implemented it previously. `URI.join("http://www.example.com/mirror", "test.tar.gz") results in `http://www.example.com/test.tar.gz` instead of our expected `http://www.exmaple.com/mirror/test.tar.gz`. For our simple use case here, `File.join` is sufficient.
28 lines
953 B
Ruby
28 lines
953 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe DiscourseIpInfo do
|
|
describe ".mmdb_download" do
|
|
it "should download the MaxMind databases from the right URL when `maxmind_mirror_url` global setting has been configured" do
|
|
global_setting :maxmind_mirror_url, "https://b.www.example.com/mirror"
|
|
|
|
stub_request(:get, "https://b.www.example.com/mirror/GeoLite2-City.tar.gz").to_return(
|
|
status: 200,
|
|
body: "",
|
|
)
|
|
|
|
described_class.mmdb_download("GeoLite2-City")
|
|
end
|
|
|
|
it "should download the MaxMind databases from the right URL when `maxmind_mirror_url` global setting has been configured and has a trailing slash" do
|
|
global_setting :maxmind_mirror_url, "https://b.www.example.com/mirror/"
|
|
|
|
stub_request(:get, "https://b.www.example.com/mirror/GeoLite2-City.tar.gz").to_return(
|
|
status: 200,
|
|
body: "",
|
|
)
|
|
|
|
described_class.mmdb_download("GeoLite2-City")
|
|
end
|
|
end
|
|
end
|