Commit 65f4e861 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch '321544-fj-fix-gitpod-url-in-user-preferences' into 'master'

Fix Gitpod url in user preferences

See merge request gitlab-org/gitlab!62544
parents 654cb525 85a3357a
...@@ -83,13 +83,17 @@ module PreferencesHelper ...@@ -83,13 +83,17 @@ module PreferencesHelper
def integration_views def integration_views
[].tap do |views| [].tap do |views|
views << { name: 'gitpod', message: gitpod_enable_description, message_url: 'https://gitpod.io/', help_link: help_page_path('integration/gitpod.md') } if Gitlab::CurrentSettings.gitpod_enabled views << { name: 'gitpod', message: gitpod_enable_description, message_url: gitpod_url_placeholder, help_link: help_page_path('integration/gitpod.md') } if Gitlab::CurrentSettings.gitpod_enabled
views << { name: 'sourcegraph', message: sourcegraph_url_message, message_url: Gitlab::CurrentSettings.sourcegraph_url, help_link: help_page_path('user/profile/preferences.md', anchor: 'sourcegraph') } if Gitlab::Sourcegraph.feature_available? && Gitlab::CurrentSettings.sourcegraph_enabled views << { name: 'sourcegraph', message: sourcegraph_url_message, message_url: Gitlab::CurrentSettings.sourcegraph_url, help_link: help_page_path('user/profile/preferences.md', anchor: 'sourcegraph') } if Gitlab::Sourcegraph.feature_available? && Gitlab::CurrentSettings.sourcegraph_enabled
end end
end end
private private
def gitpod_url_placeholder
Gitlab::CurrentSettings.gitpod_url.presence || 'https://gitpod.io/'
end
# Ensure that anyone adding new options updates `DASHBOARD_CHOICES` too # Ensure that anyone adding new options updates `DASHBOARD_CHOICES` too
def validate_dashboard_choices!(user_dashboards) def validate_dashboard_choices!(user_dashboards)
if user_dashboards.size != localized_dashboard_choices.size if user_dashboards.size != localized_dashboard_choices.size
......
...@@ -143,4 +143,41 @@ RSpec.describe PreferencesHelper do ...@@ -143,4 +143,41 @@ RSpec.describe PreferencesHelper do
.and_return(double('user', messages)) .and_return(double('user', messages))
end end
end end
describe '#integration_views' do
let(:gitpod_url) { 'http://gitpod.test' }
before do
allow(Gitlab::CurrentSettings).to receive(:gitpod_enabled).and_return(gitpod_enabled)
allow(Gitlab::CurrentSettings).to receive(:gitpod_url).and_return(gitpod_url)
end
context 'when Gitpod is not enabled' do
let(:gitpod_enabled) { false }
it 'does not include Gitpod integration' do
expect(helper.integration_views).to be_empty
end
end
context 'when Gitpod is enabled' do
let(:gitpod_enabled) { true }
it 'includes Gitpod integration' do
expect(helper.integration_views[0][:name]).to eq 'gitpod'
end
it 'returns the Gitpod url configured in settings' do
expect(helper.integration_views[0][:message_url]).to eq gitpod_url
end
context 'when Gitpod url is not set' do
let(:gitpod_url) { '' }
it 'returns the Gitpod default url' do
expect(helper.integration_views[0][:message_url]).to eq 'https://gitpod.io/'
end
end
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment