summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bodenmiller <bbodenmiller@hotmail.com>2015-08-05 00:48:16 -0700
committerBen Bodenmiller <bbodenmiller@hotmail.com>2015-08-05 00:48:16 -0700
commit0f785bbc7ecf932e81c84ec98636ffd305994b47 (patch)
treeb6b2e70cf0c1897ca30bfea68891ff266059d77c
parent88a3cfe1070bbd7db450f68b8fc2b509c795e413 (diff)
downloadgitlab-ce-0f785bbc7ecf932e81c84ec98636ffd305994b47.tar.gz
ink to configured gravatar host on profile page
-rw-r--r--CHANGELOG1
-rw-r--r--app/views/profiles/show.html.haml4
-rw-r--r--config/initializers/1_settings.rb10
-rw-r--r--features/profile/profile.feature2
-rw-r--r--features/steps/profile/profile.rb4
5 files changed, 19 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 8a24bf412d2..3e8c43b1d5c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -28,6 +28,7 @@ v 7.14.0 (unreleased)
- Show buttons to add license, changelog and contribution guide if they're missing.
- Disabled autocapitalize and autocorrect on login field (Daryl Chan)
- Mention group and project name in creation, update and deletion notices (Achilleas Pipinellis)
+ - Update gravatar link on profile page to link to configured gravatar host (Ben Bodenmiller)
- Remove redis-store TTL monkey patch
v 7.13.2
diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml
index 37a3952635e..9fdeddfcc7a 100644
--- a/app/views/profiles/show.html.haml
+++ b/app/views/profiles/show.html.haml
@@ -82,12 +82,12 @@
You can change your avatar here
- if Gitlab.config.gravatar.enabled
%br
- or remove the current avatar to revert to #{link_to "gravatar.com", "http://gravatar.com"}
+ or remove the current avatar to revert to #{link_to Gitlab.config.gravatar.host, "http://" + Gitlab.config.gravatar.host}
- else
You can upload an avatar here
- if Gitlab.config.gravatar.enabled
%br
- or change it at #{link_to "gravatar.com", "http://gravatar.com"}
+ or change it at #{link_to Gitlab.config.gravatar.host, "http://" + Gitlab.config.gravatar.host}
%hr
%a.choose-btn.btn.btn-sm.js-choose-user-avatar-button
%i.fa.fa-paperclip
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index bd76c918485..026c1a5792c 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -8,6 +8,15 @@ class Settings < Settingslogic
def gitlab_on_standard_port?
gitlab.port.to_i == (gitlab.https ? 443 : 80)
end
+
+ # get host without www, thanks to http://stackoverflow.com/a/6674363/1233435
+ def get_host_without_www(url)
+ url = URI.encode(url)
+ uri = URI.parse(url)
+ uri = URI.parse("http://#{url}") if uri.scheme.nil?
+ host = uri.host.downcase
+ host.start_with?('www.') ? host[4..-1] : host
+ end
private
@@ -147,6 +156,7 @@ Settings['gravatar'] ||= Settingslogic.new({})
Settings.gravatar['enabled'] = true if Settings.gravatar['enabled'].nil?
Settings.gravatar['plain_url'] ||= 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
Settings.gravatar['ssl_url'] ||= 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
+Settings.gravatar['host'] = Settings.get_host_without_www(Settings.gravatar['plain_url'])
#
# GitLab Shell
diff --git a/features/profile/profile.feature b/features/profile/profile.feature
index 7a1345f2b37..27c0bde364e 100644
--- a/features/profile/profile.feature
+++ b/features/profile/profile.feature
@@ -35,6 +35,7 @@ Feature: Profile
Then I change my avatar
And I should see new avatar
And I should see the "Remove avatar" button
+ And I should see the gravatar host link
Scenario: I remove my avatar
Given I visit profile page
@@ -42,6 +43,7 @@ Feature: Profile
When I remove my avatar
Then I should see my gravatar
And I should not see the "Remove avatar" button
+ And I should see the gravatar host link
Scenario: My password is expired
Given my password is expired
diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb
index 2b6b8b167f6..8cf24705a5e 100644
--- a/features/steps/profile/profile.rb
+++ b/features/steps/profile/profile.rb
@@ -59,6 +59,10 @@ class Spinach::Features::Profile < Spinach::FeatureSteps
step 'I should not see the "Remove avatar" button' do
expect(page).not_to have_link("Remove avatar")
end
+
+ step 'I should see the gravatar host link' do
+ expect(page).to have_link("gravatar.com")
+ end
step 'I try change my password w/o old one' do
page.within '.update-password' do