Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Milan
diaspora
Commits
8d725160
Commit
8d725160
authored
Aug 21, 2016
by
Benjamin Neff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use https for the pod_uri if require_ssl is true
parent
08c6d485
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
lib/configuration_methods.rb
lib/configuration_methods.rb
+4
-3
spec/lib/configuration_methods_spec.rb
spec/lib/configuration_methods_spec.rb
+13
-0
No files found.
lib/configuration_methods.rb
View file @
8d725160
...
...
@@ -6,15 +6,16 @@ module Configuration
return
@pod_uri
.
dup
unless
@pod_uri
.
nil?
url
=
environment
.
url
.
get
url
=
"http://
#{
url
}
"
unless
url
=~
/^(https?:\/\/)/
url
<<
"/"
unless
url
.
end_with?
(
"/"
)
begin
@pod_uri
=
Addressable
::
URI
.
parse
(
url
)
@pod_uri
=
Addressable
::
URI
.
heuristic_
parse
(
url
)
rescue
puts
"WARNING: pod url
#{
url
}
is not a legal URI"
end
@pod_uri
.
scheme
=
"https"
if
environment
.
require_ssl?
@pod_uri
.
path
=
"/"
@pod_uri
.
dup
end
...
...
spec/lib/configuration_methods_spec.rb
View file @
8d725160
...
...
@@ -12,6 +12,7 @@ describe Configuration::Methods do
describe
"#pod_uri"
do
before
do
@settings
.
environment
.
url
=
nil
@settings
.
environment
.
require_ssl
=
false
@settings
.
instance_variable_set
(
:@pod_uri
,
nil
)
end
...
...
@@ -36,6 +37,18 @@ describe Configuration::Methods do
expect
(
@settings
.
pod_uri
.
to_s
).
to
eq
(
"http://example.org/"
)
end
it
"adds https:// on the front if require_ssl is true"
do
@settings
.
environment
.
require_ssl
=
true
@settings
.
environment
.
url
=
"example.org"
expect
(
@settings
.
pod_uri
.
to_s
).
to
eq
(
"https://example.org/"
)
end
it
"changes http to https if require_ssl is true"
do
@settings
.
environment
.
require_ssl
=
true
@settings
.
environment
.
url
=
"http://example.org/"
expect
(
@settings
.
pod_uri
.
to_s
).
to
eq
(
"https://example.org/"
)
end
it
"does not add a prefix if there already is https:// on the front"
do
@settings
.
environment
.
url
=
"https://example.org/"
expect
(
@settings
.
pod_uri
.
to_s
).
to
eq
(
"https://example.org/"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment