Commit 184b4bc6 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rs-crowd-form-view-spec' into 'master'

Move "I should see Crowd login form" feature to a view spec

We were doing all kinds of code gymnastics to "enable" Crowd in the
feature spec and this would sometimes cause a transient failure.

Really what it's testing is if the Crowd login form shows when Crowd's
enabled, so this is much better suited to a view spec.

See merge request !2963
parent b0864a9f
......@@ -6,6 +6,10 @@ module AuthHelper
Gitlab.config.ldap.enabled
end
def omniauth_enabled?
Gitlab.config.omniauth.enabled
end
def provider_has_icon?(name)
PROVIDERS_WITH_ICONS.include?(name.to_s)
end
......
......@@ -4,7 +4,7 @@
= render 'devise/shared/signin_box'
-# Omniauth fits between signin/ldap signin and signup and does not have a surrounding box
- if Gitlab.config.omniauth.enabled && devise_mapping.omniauthable?
- if omniauth_enabled? && devise_mapping.omniauthable?
.clearfix.prepend-top-20
= render 'devise/shared/omniauth_box'
......@@ -14,6 +14,6 @@
= render 'devise/shared/signup_box'
-# Show a message if none of the mechanisms above are enabled
- if !signin_enabled? && !ldap_enabled? && !(Gitlab.config.omniauth.enabled && devise_mapping.omniauthable?)
- if !signin_enabled? && !ldap_enabled? && !(omniauth_enabled? && devise_mapping.omniauthable?)
%div
No authentication methods configured.
Feature: Login form
Scenario: I see Crowd form
Given Crowd integration enabled
When I visit sign in page
Then I should see Crowd login form
Scenario: I see Crowd form when sign-in is disabled
Given Crowd integration enabled
And Sign-in is disabled
When I visit sign in page
Then I should see Crowd login form
class Spinach::Features::LoginForm < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedSnippet
include SharedUser
include SharedSearch
step 'Sign-in is disabled' do
allow_any_instance_of(ApplicationHelper).to receive(:signin_enabled?).and_return(false)
end
step 'Crowd integration enabled' do
expect(Gitlab::OAuth::Provider).to receive(:providers).and_return([:crowd])
expect(Gitlab.config.omniauth).to receive(:enabled).and_return(true)
allow_any_instance_of(ApplicationHelper).to receive(:user_omniauth_authorize_path).and_return(root_path)
end
step 'I should see Crowd login form' do
expect(page).to have_selector '#tab-crowd form'
end
step 'I visit sign in page' do
visit new_user_session_path
end
end
require 'rails_helper'
describe 'devise/shared/_signin_box' do
describe 'Crowd form' do
before do
stub_devise
assign(:ldap_servers, [])
end
it 'is shown when Crowd is enabled' do
enable_crowd
render
expect(rendered).to have_selector('#tab-crowd form')
end
it 'is not shown when Crowd is disabled' do
render
expect(rendered).not_to have_selector('#tab-crowd')
end
end
def stub_devise
allow(view).to receive(:devise_mapping).and_return(Devise.mappings[:user])
allow(view).to receive(:resource).and_return(spy)
allow(view).to receive(:resource_name).and_return(:user)
end
def enable_crowd
allow(view).to receive(:form_based_providers).and_return([:crowd])
allow(view).to receive(:crowd_enabled?).and_return(true)
allow(view).to receive(:user_omniauth_authorize_path).with('crowd').
and_return('/crowd')
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