Commit f2d07667 authored by Drew Blessing's avatar Drew Blessing Committed by Peter Hegman

Only display user bio for confirmed and active users

User profile content should only be displayed for active (unblocked)
users who are confirmed. We already ensure this is true for visible
content on the profile page. However, we were still showing the
user bio in page metadata. This change ensures the bio is not
shown for blocked or unconfirmed users.

Changelog: fixed
parent c3033257
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
- @hide_breadcrumbs = true - @hide_breadcrumbs = true
- @no_container = true - @no_container = true
- page_title user_display_name(@user) - page_title user_display_name(@user)
- page_description @user.bio - page_description @user.bio unless @user.blocked? || !@user.confirmed?
- header_title @user.name, user_path(@user)
- page_itemtype 'http://schema.org/Person' - page_itemtype 'http://schema.org/Person'
- link_classes = "flex-grow-1 mx-1 " - link_classes = "flex-grow-1 mx-1 "
......
...@@ -207,34 +207,31 @@ RSpec.describe 'User page' do ...@@ -207,34 +207,31 @@ RSpec.describe 'User page' do
state: :blocked, state: :blocked,
organization: 'GitLab - work info test', organization: 'GitLab - work info test',
job_title: 'Frontend Engineer', job_title: 'Frontend Engineer',
pronunciation: 'pruh-nuhn-see-ay-shn' pronunciation: 'pruh-nuhn-see-ay-shn',
bio: 'My personal bio'
) )
end end
let_it_be(:status) { create(:user_status, user: user, message: "Working hard!") } let_it_be(:status) { create(:user_status, user: user, message: "Working hard!") }
it 'shows no tab' do before do
subject visit_profile
end
it 'shows no tab' do
expect(page).to have_css("div.profile-header") expect(page).to have_css("div.profile-header")
expect(page).not_to have_css("ul.nav-links") expect(page).not_to have_css("ul.nav-links")
end end
it 'shows blocked message' do it 'shows blocked message' do
subject
expect(page).to have_content("This user is blocked") expect(page).to have_content("This user is blocked")
end end
it 'shows user name as blocked' do it 'shows user name as blocked' do
subject
expect(page).to have_css(".cover-title", text: 'Blocked user') expect(page).to have_css(".cover-title", text: 'Blocked user')
end end
it 'shows no additional fields' do it 'shows no additional fields' do
subject
expect(page).not_to have_css(".profile-user-bio") expect(page).not_to have_css(".profile-user-bio")
expect(page).not_to have_content('GitLab - work info test') expect(page).not_to have_content('GitLab - work info test')
expect(page).not_to have_content('Frontend Engineer') expect(page).not_to have_content('Frontend Engineer')
...@@ -243,10 +240,10 @@ RSpec.describe 'User page' do ...@@ -243,10 +240,10 @@ RSpec.describe 'User page' do
end end
it 'shows username' do it 'shows username' do
subject
expect(page).to have_content("@#{user.username}") expect(page).to have_content("@#{user.username}")
end end
it_behaves_like 'default brand title page meta description'
end end
context 'with unconfirmed user' do context 'with unconfirmed user' do
...@@ -256,7 +253,8 @@ RSpec.describe 'User page' do ...@@ -256,7 +253,8 @@ RSpec.describe 'User page' do
:unconfirmed, :unconfirmed,
organization: 'GitLab - work info test', organization: 'GitLab - work info test',
job_title: 'Frontend Engineer', job_title: 'Frontend Engineer',
pronunciation: 'pruh-nuhn-see-ay-shn' pronunciation: 'pruh-nuhn-see-ay-shn',
bio: 'My personal bio'
) )
end end
...@@ -287,6 +285,8 @@ RSpec.describe 'User page' do ...@@ -287,6 +285,8 @@ RSpec.describe 'User page' do
it 'shows private profile message' do it 'shows private profile message' do
expect(page).to have_content("This user has a private profile") expect(page).to have_content("This user has a private profile")
end end
it_behaves_like 'default brand title page meta description'
end end
context 'when visited by an authenticated user' do context 'when visited by an authenticated user' do
......
...@@ -7,3 +7,13 @@ RSpec.shared_examples 'page meta description' do |expected_description| ...@@ -7,3 +7,13 @@ RSpec.shared_examples 'page meta description' do |expected_description|
end end
end end
end end
RSpec.shared_examples 'default brand title page meta description' do
include AppearancesHelper
it 'renders the page with description, og:description, and twitter:description meta tags with the default brand title', :aggregate_failures do
%w(name='description' property='og:description' property='twitter:description').each do |selector|
expect(page).to have_selector("meta[#{selector}][content='#{default_brand_title}']", visible: false)
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