summaryrefslogtreecommitdiff
path: root/spec/features/users
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/users')
-rw-r--r--spec/features/users/login_spec.rb74
-rw-r--r--spec/features/users/show_spec.rb68
-rw-r--r--spec/features/users/signup_spec.rb117
3 files changed, 166 insertions, 93 deletions
diff --git a/spec/features/users/login_spec.rb b/spec/features/users/login_spec.rb
index 853c381fe6b..0761c1871d3 100644
--- a/spec/features/users/login_spec.rb
+++ b/spec/features/users/login_spec.rb
@@ -26,7 +26,6 @@ RSpec.describe 'Login' do
user.reload
expect(user.reset_password_token).not_to be_nil
- find('a[href="#login-pane"]').click
gitlab_sign_in(user)
expect(current_path).to eq root_path
@@ -593,42 +592,95 @@ RSpec.describe 'Login' do
describe 'UI tabs and panes' do
context 'when no defaults are changed' do
- it 'correctly renders tabs and panes' do
- ensure_tab_pane_correctness
+ it 'does not render any tabs' do
+ visit new_user_session_path
+
+ ensure_no_tabs
+ end
+
+ it 'renders link to sign up path' do
+ visit new_user_session_path
+
+ expect(page.body).to have_link('Register now', href: new_user_registration_path)
end
end
context 'when signup is disabled' do
before do
stub_application_setting(signup_enabled: false)
+
+ visit new_user_session_path
end
- it 'correctly renders tabs and panes' do
- ensure_tab_pane_correctness
+ it 'does not render any tabs' do
+ ensure_no_tabs
+ end
+
+ it 'does not render link to sign up path' do
+ visit new_user_session_path
+
+ expect(page.body).not_to have_link('Register now', href: new_user_registration_path)
end
end
context 'when ldap is enabled' do
+ include LdapHelpers
+
+ let(:provider) { 'ldapmain' }
+ let(:ldap_server_config) do
+ {
+ 'label' => 'Main LDAP',
+ 'provider_name' => provider,
+ 'attributes' => {},
+ 'encryption' => 'plain',
+ 'uid' => 'uid',
+ 'base' => 'dc=example,dc=com'
+ }
+ end
+
before do
+ stub_ldap_setting(enabled: true)
+ allow(::Gitlab::Auth::Ldap::Config).to receive_messages(enabled: true, servers: [ldap_server_config])
+ allow(Gitlab::Auth::OAuth::Provider).to receive_messages(providers: [provider.to_sym])
+
+ Ldap::OmniauthCallbacksController.define_providers!
+ Rails.application.reload_routes!
+
+ allow_next_instance_of(ActionDispatch::Routing::RoutesProxy) do |instance|
+ allow(instance).to receive(:"user_#{provider}_omniauth_callback_path")
+ .and_return("/users/auth/#{provider}/callback")
+ end
+
visit new_user_session_path
- allow(page).to receive(:form_based_providers).and_return([:ldapmain])
- allow(page).to receive(:ldap_enabled).and_return(true)
end
it 'correctly renders tabs and panes' do
- ensure_tab_pane_correctness(false)
+ ensure_tab_pane_correctness(['Main LDAP', 'Standard'])
+ end
+
+ it 'renders link to sign up path' do
+ expect(page.body).to have_link('Register now', href: new_user_registration_path)
end
end
context 'when crowd is enabled' do
before do
+ allow(Gitlab::Auth::OAuth::Provider).to receive_messages(providers: [:crowd])
+ stub_application_setting(crowd_enabled: true)
+
+ Ldap::OmniauthCallbacksController.define_providers!
+ Rails.application.reload_routes!
+
+ allow_next_instance_of(ActionDispatch::Routing::RoutesProxy) do |instance|
+ allow(instance).to receive(:user_crowd_omniauth_authorize_path)
+ .and_return("/users/auth/crowd/callback")
+ end
+
visit new_user_session_path
- allow(page).to receive(:form_based_providers).and_return([:crowd])
- allow(page).to receive(:crowd_enabled?).and_return(true)
end
it 'correctly renders tabs and panes' do
- ensure_tab_pane_correctness(false)
+ ensure_tab_pane_correctness(%w(Crowd Standard))
end
end
end
diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb
index 466b7361da9..aebe2cc602d 100644
--- a/spec/features/users/show_spec.rb
+++ b/spec/features/users/show_spec.rb
@@ -5,11 +5,13 @@ require 'spec_helper'
RSpec.describe 'User page' do
include ExternalAuthorizationServiceHelpers
- let(:user) { create(:user, bio: '**Lorem** _ipsum_ dolor sit [amet](https://example.com)') }
+ let_it_be(:user) { create(:user, bio: '**Lorem** _ipsum_ dolor sit [amet](https://example.com)') }
+
+ subject { visit(user_path(user)) }
context 'with public profile' do
it 'shows all the tabs' do
- visit(user_path(user))
+ subject
page.within '.nav-links' do
expect(page).to have_link('Overview')
@@ -22,14 +24,12 @@ RSpec.describe 'User page' do
end
it 'does not show private profile message' do
- visit(user_path(user))
+ subject
expect(page).not_to have_content("This user has a private profile")
end
context 'work information' do
- subject { visit(user_path(user)) }
-
it 'shows job title and organization details' do
user.update(organization: 'GitLab - work info test', job_title: 'Frontend Engineer')
@@ -57,24 +57,24 @@ RSpec.describe 'User page' do
end
context 'with private profile' do
- let(:user) { create(:user, private_profile: true) }
+ let_it_be(:user) { create(:user, private_profile: true) }
it 'shows no tab' do
- visit(user_path(user))
+ subject
expect(page).to have_css("div.profile-header")
expect(page).not_to have_css("ul.nav-links")
end
it 'shows private profile message' do
- visit(user_path(user))
+ subject
expect(page).to have_content("This user has a private profile")
end
it 'shows own tabs' do
sign_in(user)
- visit(user_path(user))
+ subject
page.within '.nav-links' do
expect(page).to have_link('Overview')
@@ -88,36 +88,36 @@ RSpec.describe 'User page' do
end
context 'with blocked profile' do
- let(:user) { create(:user, state: :blocked) }
+ let_it_be(:user) { create(:user, state: :blocked) }
it 'shows no tab' do
- visit(user_path(user))
+ subject
expect(page).to have_css("div.profile-header")
expect(page).not_to have_css("ul.nav-links")
end
it 'shows blocked message' do
- visit(user_path(user))
+ subject
expect(page).to have_content("This user is blocked")
end
it 'shows user name as blocked' do
- visit(user_path(user))
+ subject
expect(page).to have_css(".cover-title", text: 'Blocked user')
end
it 'shows no additional fields' do
- visit(user_path(user))
+ subject
expect(page).not_to have_css(".profile-user-bio")
expect(page).not_to have_css(".profile-link-holder")
end
it 'shows username' do
- visit(user_path(user))
+ subject
expect(page).to have_content("@#{user.username}")
end
@@ -126,7 +126,7 @@ RSpec.describe 'User page' do
it 'shows the status if there was one' do
create(:user_status, user: user, message: "Working hard!")
- visit(user_path(user))
+ subject
expect(page).to have_content("Working hard!")
end
@@ -135,7 +135,7 @@ RSpec.describe 'User page' do
it 'shows the sign in link' do
stub_application_setting(signup_enabled: false)
- visit(user_path(user))
+ subject
page.within '.navbar-nav' do
expect(page).to have_link('Sign in')
@@ -147,7 +147,7 @@ RSpec.describe 'User page' do
it 'shows the sign in and register link' do
stub_application_setting(signup_enabled: true)
- visit(user_path(user))
+ subject
page.within '.navbar-nav' do
expect(page).to have_link('Sign in / Register')
@@ -157,7 +157,7 @@ RSpec.describe 'User page' do
context 'most recent activity' do
it 'shows the most recent activity' do
- visit(user_path(user))
+ subject
expect(page).to have_content('Most Recent Activity')
end
@@ -168,7 +168,7 @@ RSpec.describe 'User page' do
end
it 'hides the most recent activity' do
- visit(user_path(user))
+ subject
expect(page).not_to have_content('Most Recent Activity')
end
@@ -177,14 +177,14 @@ RSpec.describe 'User page' do
context 'page description' do
before do
- visit(user_path(user))
+ subject
end
it_behaves_like 'page meta description', 'Lorem ipsum dolor sit amet'
end
context 'with a bot user' do
- let(:user) { create(:user, user_type: :security_bot) }
+ let_it_be(:user) { create(:user, user_type: :security_bot) }
describe 'feature flag enabled' do
before do
@@ -192,7 +192,7 @@ RSpec.describe 'User page' do
end
it 'only shows Overview and Activity tabs' do
- visit(user_path(user))
+ subject
page.within '.nav-links' do
expect(page).to have_link('Overview')
@@ -211,7 +211,7 @@ RSpec.describe 'User page' do
end
it 'only shows Overview and Activity tabs' do
- visit(user_path(user))
+ subject
page.within '.nav-links' do
expect(page).to have_link('Overview')
@@ -224,4 +224,24 @@ RSpec.describe 'User page' do
end
end
end
+
+ 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
end
diff --git a/spec/features/users/signup_spec.rb b/spec/features/users/signup_spec.rb
index c59121626f0..bfdd1e1bdb7 100644
--- a/spec/features/users/signup_spec.rb
+++ b/spec/features/users/signup_spec.rb
@@ -2,9 +2,51 @@
require 'spec_helper'
-RSpec.shared_examples 'Signup' do
+RSpec.shared_examples 'Signup name validation' do |field, max_length, label|
+ before do
+ visit new_user_registration_path
+ end
+
+ describe "#{field} validation", :js do
+ it "does not show an error border if the user's fullname length is not longer than #{max_length} characters" do
+ fill_in field, with: 'u' * max_length
+
+ expect(find('.name')).not_to have_css '.gl-field-error-outline'
+ end
+
+ it 'shows an error border if the user\'s fullname contains an emoji' do
+ simulate_input("##{field}", 'Ehsan 🦋')
+
+ expect(find('.name')).to have_css '.gl-field-error-outline'
+ end
+
+ it "shows an error border if the user\'s fullname is longer than #{max_length} characters" do
+ fill_in field, with: 'n' * (max_length + 1)
+
+ expect(find('.name')).to have_css '.gl-field-error-outline'
+ end
+
+ it "shows an error message if the user\'s #{label} is longer than #{max_length} characters" do
+ fill_in field, with: 'n' * (max_length + 1)
+
+ expect(page).to have_content("#{label} is too long (maximum is #{max_length} characters).")
+ end
+
+ it 'shows an error message if the username contains emojis' do
+ simulate_input("##{field}", 'Ehsan 🦋')
+
+ expect(page).to have_content("Invalid input, please avoid emojis")
+ end
+ end
+end
+
+RSpec.describe 'Signup' do
include TermsHelper
+ before do
+ stub_application_setting(require_admin_approval_after_user_signup: false)
+ end
+
let(:new_user) { build_stubbed(:user) }
def fill_in_signup_form
@@ -190,6 +232,22 @@ RSpec.shared_examples 'Signup' do
expect(current_path).to eq users_sign_up_welcome_path
end
end
+
+ context 'with required admin approval enabled' do
+ before do
+ stub_application_setting(require_admin_approval_after_user_signup: true)
+ end
+
+ it 'creates the user but does not sign them in' do
+ visit new_user_registration_path
+
+ fill_in_signup_form
+
+ expect { click_button 'Register' }.to change { User.count }.by(1)
+ expect(current_path).to eq new_user_session_path
+ expect(page).to have_content("You have signed up successfully. However, we could not sign you in because your account is awaiting approval from your GitLab administrator")
+ end
+ end
end
context 'with errors' do
@@ -295,64 +353,7 @@ RSpec.shared_examples 'Signup' do
expect(created_user.setup_for_company).to be_nil
expect(page).to have_current_path(new_project_path)
end
-end
-
-RSpec.shared_examples 'Signup name validation' do |field, max_length, label|
- before do
- visit new_user_registration_path
- end
-
- describe "#{field} validation", :js do
- it "does not show an error border if the user's fullname length is not longer than #{max_length} characters" do
- fill_in field, with: 'u' * max_length
-
- expect(find('.name')).not_to have_css '.gl-field-error-outline'
- end
-
- it 'shows an error border if the user\'s fullname contains an emoji' do
- simulate_input("##{field}", 'Ehsan 🦋')
-
- expect(find('.name')).to have_css '.gl-field-error-outline'
- end
-
- it "shows an error border if the user\'s fullname is longer than #{max_length} characters" do
- fill_in field, with: 'n' * (max_length + 1)
-
- expect(find('.name')).to have_css '.gl-field-error-outline'
- end
-
- it "shows an error message if the user\'s #{label} is longer than #{max_length} characters" do
- fill_in field, with: 'n' * (max_length + 1)
-
- expect(page).to have_content("#{label} is too long (maximum is #{max_length} characters).")
- end
-
- it 'shows an error message if the username contains emojis' do
- simulate_input("##{field}", 'Ehsan 🦋')
-
- expect(page).to have_content("Invalid input, please avoid emojis")
- end
- end
-end
-
-RSpec.describe 'With original flow' do
- before do
- stub_experiment(signup_flow: false)
- stub_experiment_for_user(signup_flow: false)
- end
-
- it_behaves_like 'Signup'
- it_behaves_like 'Signup name validation', 'new_user_first_name', 127, 'First name'
- it_behaves_like 'Signup name validation', 'new_user_last_name', 127, 'Last name'
-end
-
-RSpec.describe 'With experimental flow' do
- before do
- stub_experiment(signup_flow: true)
- stub_experiment_for_user(signup_flow: true)
- end
- it_behaves_like 'Signup'
it_behaves_like 'Signup name validation', 'new_user_first_name', 127, 'First name'
it_behaves_like 'Signup name validation', 'new_user_last_name', 127, 'Last name'
end