Commit 61a40c895da980a6d7646460268219c7fac2fdf0
1 parent
7ac8a6a2
Exists in
master
Make Problem#url use the configured protocol
Showing
2 changed files
with
23 additions
and
0 deletions
Show diff stats
app/models/problem.rb
@@ -160,6 +160,7 @@ class Problem | @@ -160,6 +160,7 @@ class Problem | ||
160 | Rails.application.routes.url_helpers.app_problem_url( | 160 | Rails.application.routes.url_helpers.app_problem_url( |
161 | app, | 161 | app, |
162 | self, | 162 | self, |
163 | + protocol: Errbit::Config.protocol, | ||
163 | host: Errbit::Config.host, | 164 | host: Errbit::Config.host, |
164 | port: Errbit::Config.port | 165 | port: Errbit::Config.port |
165 | ) | 166 | ) |
spec/models/problem_spec.rb
@@ -475,4 +475,26 @@ describe Problem, type: 'model' do | @@ -475,4 +475,26 @@ describe Problem, type: 'model' do | ||
475 | end | 475 | end |
476 | end | 476 | end |
477 | end | 477 | end |
478 | + | ||
479 | + context "#url" do | ||
480 | + subject { Fabricate(:problem) } | ||
481 | + | ||
482 | + it "uses the configured protocol" do | ||
483 | + allow(Errbit::Config).to receive(:protocol).and_return("https") | ||
484 | + | ||
485 | + expect(subject.url).to eq "https://errbit.example.com/apps/#{subject.app.id}/problems/#{subject.id}" | ||
486 | + end | ||
487 | + | ||
488 | + it "uses the configured host" do | ||
489 | + allow(Errbit::Config).to receive(:host).and_return("memyselfandi.com") | ||
490 | + | ||
491 | + expect(subject.url).to eq "http://memyselfandi.com/apps/#{subject.app.id}/problems/#{subject.id}" | ||
492 | + end | ||
493 | + | ||
494 | + it "uses the configured port" do | ||
495 | + allow(Errbit::Config).to receive(:port).and_return(8123) | ||
496 | + | ||
497 | + expect(subject.url).to eq "http://errbit.example.com:8123/apps/#{subject.app.id}/problems/#{subject.id}" | ||
498 | + end | ||
499 | + end | ||
478 | end | 500 | end |