2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-11 09:21:06 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'User page' do
|
2019-04-09 11:38:58 -04:00
|
|
|
include ExternalAuthorizationServiceHelpers
|
|
|
|
|
2020-11-05 13:08:48 -05:00
|
|
|
let_it_be(:user) { create(:user, bio: '**Lorem** _ipsum_ dolor sit [amet](https://example.com)') }
|
|
|
|
|
2020-11-26 07:09:48 -05:00
|
|
|
subject(:visit_profile) { visit(user_path(user)) }
|
2017-12-11 09:21:06 -05:00
|
|
|
|
2018-07-24 08:46:19 -04:00
|
|
|
context 'with public profile' do
|
|
|
|
it 'shows all the tabs' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2018-07-24 08:46:19 -04:00
|
|
|
|
|
|
|
page.within '.nav-links' do
|
2018-10-04 03:55:37 -04:00
|
|
|
expect(page).to have_link('Overview')
|
2018-07-24 08:46:19 -04:00
|
|
|
expect(page).to have_link('Activity')
|
|
|
|
expect(page).to have_link('Groups')
|
|
|
|
expect(page).to have_link('Contributed projects')
|
|
|
|
expect(page).to have_link('Personal projects')
|
|
|
|
expect(page).to have_link('Snippets')
|
2021-02-15 16:08:59 -05:00
|
|
|
expect(page).to have_link('Followers')
|
|
|
|
expect(page).to have_link('Following')
|
2018-07-24 08:46:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show private profile message' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2018-07-24 08:46:19 -04:00
|
|
|
|
|
|
|
expect(page).not_to have_content("This user has a private profile")
|
|
|
|
end
|
2020-03-16 08:09:12 -04:00
|
|
|
|
|
|
|
context 'work information' do
|
|
|
|
it 'shows job title and organization details' do
|
2021-03-31 08:08:55 -04:00
|
|
|
user.update!(organization: 'GitLab - work info test', job_title: 'Frontend Engineer')
|
2020-03-16 08:09:12 -04:00
|
|
|
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page).to have_content('Frontend Engineer at GitLab - work info test')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows job title' do
|
2021-03-31 08:08:55 -04:00
|
|
|
user.update!(organization: nil, job_title: 'Frontend Engineer - work info test')
|
2020-03-16 08:09:12 -04:00
|
|
|
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page).to have_content('Frontend Engineer - work info test')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows organization details' do
|
2021-03-31 08:08:55 -04:00
|
|
|
user.update!(organization: 'GitLab - work info test', job_title: '')
|
2020-03-16 08:09:12 -04:00
|
|
|
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page).to have_content('GitLab - work info test')
|
|
|
|
end
|
|
|
|
end
|
2021-02-15 16:08:59 -05:00
|
|
|
|
|
|
|
context 'follow/unfollow and followers/following' do
|
|
|
|
let_it_be(:followee) { create(:user) }
|
|
|
|
let_it_be(:follower) { create(:user) }
|
|
|
|
|
|
|
|
it 'does not show link to follow' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page).not_to have_link(text: 'Follow', class: 'gl-button')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows 0 followers and 0 following' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page).to have_content('0 followers')
|
|
|
|
expect(page).to have_content('0 following')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows 1 followers and 1 following' do
|
|
|
|
follower.follow(user)
|
|
|
|
user.follow(followee)
|
|
|
|
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page).to have_content('1 follower')
|
|
|
|
expect(page).to have_content('1 following')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does show link to follow' do
|
|
|
|
sign_in(user)
|
|
|
|
visit user_path(followee)
|
|
|
|
|
|
|
|
expect(page).to have_link(text: 'Follow', class: 'gl-button')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does show link to unfollow' do
|
|
|
|
sign_in(user)
|
|
|
|
user.follow(followee)
|
|
|
|
|
|
|
|
visit user_path(followee)
|
|
|
|
|
|
|
|
expect(page).to have_link(text: 'Unfollow', class: 'gl-button')
|
|
|
|
end
|
|
|
|
end
|
2018-07-24 08:46:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with private profile' do
|
2020-11-05 13:08:48 -05:00
|
|
|
let_it_be(:user) { create(:user, private_profile: true) }
|
2018-07-24 08:46:19 -04:00
|
|
|
|
|
|
|
it 'shows no tab' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2018-07-24 08:46:19 -04:00
|
|
|
|
|
|
|
expect(page).to have_css("div.profile-header")
|
|
|
|
expect(page).not_to have_css("ul.nav-links")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows private profile message' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2018-07-24 08:46:19 -04:00
|
|
|
|
|
|
|
expect(page).to have_content("This user has a private profile")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows own tabs' do
|
|
|
|
sign_in(user)
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2018-07-24 08:46:19 -04:00
|
|
|
|
|
|
|
page.within '.nav-links' do
|
2018-10-04 03:55:37 -04:00
|
|
|
expect(page).to have_link('Overview')
|
2018-07-24 08:46:19 -04:00
|
|
|
expect(page).to have_link('Activity')
|
|
|
|
expect(page).to have_link('Groups')
|
|
|
|
expect(page).to have_link('Contributed projects')
|
|
|
|
expect(page).to have_link('Personal projects')
|
|
|
|
expect(page).to have_link('Snippets')
|
2021-02-15 16:08:59 -05:00
|
|
|
expect(page).to have_link('Followers')
|
|
|
|
expect(page).to have_link('Following')
|
2018-07-24 08:46:19 -04:00
|
|
|
end
|
2017-12-11 09:21:06 -05:00
|
|
|
end
|
|
|
|
end
|
2018-07-09 10:49:33 -04:00
|
|
|
|
2019-12-16 13:08:22 -05:00
|
|
|
context 'with blocked profile' do
|
2020-11-05 13:08:48 -05:00
|
|
|
let_it_be(:user) { create(:user, state: :blocked) }
|
2019-12-16 13:08:22 -05:00
|
|
|
|
|
|
|
it 'shows no tab' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2019-12-16 13:08:22 -05:00
|
|
|
|
|
|
|
expect(page).to have_css("div.profile-header")
|
|
|
|
expect(page).not_to have_css("ul.nav-links")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows blocked message' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2019-12-16 13:08:22 -05:00
|
|
|
|
|
|
|
expect(page).to have_content("This user is blocked")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows user name as blocked' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2019-12-16 13:08:22 -05:00
|
|
|
|
|
|
|
expect(page).to have_css(".cover-title", text: 'Blocked user')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows no additional fields' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2019-12-16 13:08:22 -05:00
|
|
|
|
|
|
|
expect(page).not_to have_css(".profile-user-bio")
|
|
|
|
expect(page).not_to have_css(".profile-link-holder")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows username' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2019-12-16 13:08:22 -05:00
|
|
|
|
|
|
|
expect(page).to have_content("@#{user.username}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-26 07:09:48 -05:00
|
|
|
context 'with unconfirmed user' do
|
|
|
|
let_it_be(:user) { create(:user, :unconfirmed) }
|
|
|
|
|
2020-12-01 13:09:42 -05:00
|
|
|
shared_examples 'unconfirmed user profile' do
|
|
|
|
before do
|
|
|
|
visit_profile
|
|
|
|
end
|
2020-11-26 07:09:48 -05:00
|
|
|
|
2020-12-01 13:09:42 -05:00
|
|
|
it 'shows user name as unconfirmed' do
|
|
|
|
expect(page).to have_css(".cover-title", text: 'Unconfirmed user')
|
|
|
|
end
|
2020-11-26 07:09:48 -05:00
|
|
|
|
2020-12-01 13:09:42 -05:00
|
|
|
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 no additional fields' do
|
|
|
|
expect(page).not_to have_css(".profile-user-bio")
|
|
|
|
expect(page).not_to have_css(".profile-link-holder")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows private profile message' do
|
|
|
|
expect(page).to have_content("This user has a private profile")
|
|
|
|
end
|
2020-11-26 07:09:48 -05:00
|
|
|
end
|
|
|
|
|
2020-12-01 13:09:42 -05:00
|
|
|
context 'when visited by an authenticated user' do
|
|
|
|
before do
|
|
|
|
authenticated_user = create(:user)
|
|
|
|
sign_in(authenticated_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'unconfirmed user profile'
|
2020-11-26 07:09:48 -05:00
|
|
|
end
|
|
|
|
|
2020-12-01 13:09:42 -05:00
|
|
|
context 'when visited by an unauthenticated user' do
|
|
|
|
it_behaves_like 'unconfirmed user profile'
|
2020-11-26 07:09:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-16 12:18:52 -04:00
|
|
|
it 'shows the status if there was one' do
|
|
|
|
create(:user_status, user: user, message: "Working hard!")
|
|
|
|
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2018-07-16 12:18:52 -04:00
|
|
|
|
|
|
|
expect(page).to have_content("Working hard!")
|
|
|
|
end
|
|
|
|
|
2021-06-07 17:10:00 -04:00
|
|
|
it 'shows the pronouns of the user if there was one' do
|
|
|
|
user.user_detail.update_column(:pronouns, 'they/them')
|
|
|
|
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page).to have_content("(they/them)")
|
|
|
|
end
|
|
|
|
|
2018-07-09 10:49:33 -04:00
|
|
|
context 'signup disabled' do
|
|
|
|
it 'shows the sign in link' do
|
|
|
|
stub_application_setting(signup_enabled: false)
|
|
|
|
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2018-07-09 10:49:33 -04:00
|
|
|
|
|
|
|
page.within '.navbar-nav' do
|
|
|
|
expect(page).to have_link('Sign in')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'signup enabled' do
|
|
|
|
it 'shows the sign in and register link' do
|
|
|
|
stub_application_setting(signup_enabled: true)
|
|
|
|
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2018-07-09 10:49:33 -04:00
|
|
|
|
|
|
|
page.within '.navbar-nav' do
|
|
|
|
expect(page).to have_link('Sign in / Register')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-04-09 11:38:58 -04:00
|
|
|
|
|
|
|
context 'most recent activity' do
|
|
|
|
it 'shows the most recent activity' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2019-04-09 11:38:58 -04:00
|
|
|
|
|
|
|
expect(page).to have_content('Most Recent Activity')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when external authorization is enabled' do
|
|
|
|
before do
|
|
|
|
enable_external_authorization_service_check
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'hides the most recent activity' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2019-04-09 11:38:58 -04:00
|
|
|
|
|
|
|
expect(page).not_to have_content('Most Recent Activity')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-10-01 02:09:59 -04:00
|
|
|
|
|
|
|
context 'page description' do
|
|
|
|
before do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2020-10-01 02:09:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page meta description', 'Lorem ipsum dolor sit amet'
|
|
|
|
end
|
2020-10-15 14:08:43 -04:00
|
|
|
|
|
|
|
context 'with a bot user' do
|
2020-11-05 13:08:48 -05:00
|
|
|
let_it_be(:user) { create(:user, user_type: :security_bot) }
|
2020-10-15 14:08:43 -04:00
|
|
|
|
|
|
|
describe 'feature flag enabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(security_auto_fix: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'only shows Overview and Activity tabs' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2020-10-15 14:08:43 -04:00
|
|
|
|
|
|
|
page.within '.nav-links' do
|
|
|
|
expect(page).to have_link('Overview')
|
|
|
|
expect(page).to have_link('Activity')
|
|
|
|
expect(page).not_to have_link('Groups')
|
|
|
|
expect(page).not_to have_link('Contributed projects')
|
|
|
|
expect(page).not_to have_link('Personal projects')
|
|
|
|
expect(page).not_to have_link('Snippets')
|
2021-02-15 16:08:59 -05:00
|
|
|
expect(page).not_to have_link('Followers')
|
|
|
|
expect(page).not_to have_link('Following')
|
2020-10-15 14:08:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'feature flag disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(security_auto_fix: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'only shows Overview and Activity tabs' do
|
2020-11-05 13:08:48 -05:00
|
|
|
subject
|
2020-10-15 14:08:43 -04:00
|
|
|
|
|
|
|
page.within '.nav-links' do
|
|
|
|
expect(page).to have_link('Overview')
|
|
|
|
expect(page).to have_link('Activity')
|
|
|
|
expect(page).to have_link('Groups')
|
|
|
|
expect(page).to have_link('Contributed projects')
|
|
|
|
expect(page).to have_link('Personal projects')
|
|
|
|
expect(page).to have_link('Snippets')
|
2021-02-15 16:08:59 -05:00
|
|
|
expect(page).to have_link('Followers')
|
|
|
|
expect(page).to have_link('Following')
|
2020-10-15 14:08:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-11-05 13:08:48 -05:00
|
|
|
|
|
|
|
context 'structured markup' do
|
|
|
|
let_it_be(:user) { create(:user, website_url: 'https://gitlab.com', organization: 'GitLab', job_title: 'Frontend Engineer', email: 'public@example.com', public_email: 'public@example.com', location: 'Country', created_at: Time.now, updated_at: Time.now) }
|
|
|
|
|
|
|
|
it 'shows Person structured markup' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
aggregate_failures do
|
|
|
|
expect(page).to have_selector('[itemscope][itemtype="http://schema.org/Person"]')
|
|
|
|
expect(page).to have_selector('img[itemprop="image"]')
|
|
|
|
expect(page).to have_selector('[itemprop="name"]')
|
|
|
|
expect(page).to have_selector('[itemprop="address"][itemscope][itemtype="https://schema.org/PostalAddress"]')
|
|
|
|
expect(page).to have_selector('[itemprop="addressLocality"]')
|
|
|
|
expect(page).to have_selector('[itemprop="url"]')
|
|
|
|
expect(page).to have_selector('[itemprop="email"]')
|
|
|
|
expect(page).to have_selector('span[itemprop="jobTitle"]')
|
|
|
|
expect(page).to have_selector('span[itemprop="worksFor"]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-12-11 09:21:06 -05:00
|
|
|
end
|