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