aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorAlban Peignier2018-04-18 21:46:11 +0200
committerAlban Peignier2018-04-18 21:49:18 +0200
commit35ef1a2abe0a664b259c99538bb95f04ef6408d4 (patch)
tree4aaee79b2cd674b67308c248926e24b221a75cc9 /spec
parentfe3c330cacef3d4367c9a051e3858551986b2c14 (diff)
downloadchouette-core-35ef1a2abe0a664b259c99538bb95f04ef6408d4.tar.bz2
Manage download uri in Import::Gtfs (with or without schema or port). Refs #6368
Diffstat (limited to 'spec')
-rw-r--r--spec/models/import/gtfs_spec.rb49
1 files changed, 46 insertions, 3 deletions
diff --git a/spec/models/import/gtfs_spec.rb b/spec/models/import/gtfs_spec.rb
index b4b23be00..96b93dc62 100644
--- a/spec/models/import/gtfs_spec.rb
+++ b/spec/models/import/gtfs_spec.rb
@@ -262,10 +262,53 @@ RSpec.describe Import::Gtfs do
end
end
- describe "#download_host" do
- it "should return host defined by Rails.application.config.rails_host (without http:// schema)" do
- allow(Rails.application.config).to receive(:rails_host).and_return("http://download_host")
+ describe "#download_uri" do
+ let(:import) { Import::Gtfs.new }
+
+ before do
+ allow(import).to receive(:download_path).and_return("/download_path")
+ end
+
+ context "when download_host is 'front'" do
+ before { allow(import).to receive(:download_host).and_return("front") }
+ it "returns http://front/download_path" do
+ expect(import.download_uri.to_s).to eq('http://front/download_path')
+ end
+ end
+
+ context "when download_host is 'front:3000'" do
+ before { allow(import).to receive(:download_host).and_return("front:3000") }
+ it "returns http://front:3000/download_path" do
+ expect(import.download_uri.to_s).to eq('http://front:3000/download_path')
+ end
+ end
+
+ context "when download_host is 'http://front:3000'" do
+ before { allow(import).to receive(:download_host).and_return("http://front:3000") }
+ it "returns http://front:3000/download_path" do
+ expect(import.download_uri.to_s).to eq('http://front:3000/download_path')
+ end
+ end
+
+ context "when download_host is 'https://front:3000'" do
+ before { allow(import).to receive(:download_host).and_return("https://front:3000") }
+ it "returns https://front:3000/download_path" do
+ expect(import.download_uri.to_s).to eq('https://front:3000/download_path')
+ end
+ end
+ context "when download_host is 'http://front'" do
+ before { allow(import).to receive(:download_host).and_return("http://front") }
+ it "returns http://front/download_path" do
+ expect(import.download_uri.to_s).to eq('http://front/download_path')
+ end
+ end
+
+ end
+
+ describe "#download_host" do
+ it "should return host defined by Rails.application.config.rails_host" do
+ allow(Rails.application.config).to receive(:rails_host).and_return("download_host")
expect(Import::Gtfs.new.download_host).to eq("download_host")
end
end