From 61a40c895da980a6d7646460268219c7fac2fdf0 Mon Sep 17 00:00:00 2001 From: François Beausoleil Date: Wed, 6 Jan 2016 17:01:46 +0000 Subject: [PATCH] Make Problem#url use the configured protocol --- app/models/problem.rb | 1 + spec/models/problem_spec.rb | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 0 deletions(-) diff --git a/app/models/problem.rb b/app/models/problem.rb index 55403fa..928fc41 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -160,6 +160,7 @@ class Problem Rails.application.routes.url_helpers.app_problem_url( app, self, + protocol: Errbit::Config.protocol, host: Errbit::Config.host, port: Errbit::Config.port ) diff --git a/spec/models/problem_spec.rb b/spec/models/problem_spec.rb index 9ed1dab..ba3d0c5 100644 --- a/spec/models/problem_spec.rb +++ b/spec/models/problem_spec.rb @@ -475,4 +475,26 @@ describe Problem, type: 'model' do end end end + + context "#url" do + subject { Fabricate(:problem) } + + it "uses the configured protocol" do + allow(Errbit::Config).to receive(:protocol).and_return("https") + + expect(subject.url).to eq "https://errbit.example.com/apps/#{subject.app.id}/problems/#{subject.id}" + end + + it "uses the configured host" do + allow(Errbit::Config).to receive(:host).and_return("memyselfandi.com") + + expect(subject.url).to eq "http://memyselfandi.com/apps/#{subject.app.id}/problems/#{subject.id}" + end + + it "uses the configured port" do + allow(Errbit::Config).to receive(:port).and_return(8123) + + expect(subject.url).to eq "http://errbit.example.com:8123/apps/#{subject.app.id}/problems/#{subject.id}" + end + end end -- libgit2 0.21.2