Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
87c571f8
Commit
87c571f8
authored
Dec 02, 2018
by
Scott Escue
Committed by
Mike Greiling
Jan 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addressing feedback from most recent reviews.
parent
2cbc475e
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
64 deletions
+72
-64
app/assets/javascripts/lib/utils/common_utils.js
app/assets/javascripts/lib/utils/common_utils.js
+0
-8
app/assets/javascripts/lib/utils/url_utility.js
app/assets/javascripts/lib/utils/url_utility.js
+2
-4
app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js
...s/javascripts/pages/sessions/new/preserve_url_fragment.js
+2
-2
spec/javascripts/fixtures/sessions.rb
spec/javascripts/fixtures/sessions.rb
+26
-0
spec/javascripts/fixtures/signin_forms_and_buttons.html.haml
spec/javascripts/fixtures/signin_forms_and_buttons.html.haml
+0
-21
spec/javascripts/lib/utils/url_utility_spec.js
spec/javascripts/lib/utils/url_utility_spec.js
+1
-15
spec/javascripts/pages/sessions/new/preserve_url_fragment_spec.js
...ascripts/pages/sessions/new/preserve_url_fragment_spec.js
+41
-14
No files found.
app/assets/javascripts/lib/utils/common_utils.js
View file @
87c571f8
...
...
@@ -4,14 +4,6 @@ import { getLocationHash } from './url_utility';
import
{
convertToCamelCase
}
from
'
./text_utility
'
;
import
{
isObject
}
from
'
./type_utility
'
;
/**
* Simply returns `window.location`. This function exists to provide a means to spy
* `window.location` in unit tests.
*
* @returns {Location | string | any} The browser's `window.location`
*/
export
const
windowLocation
=
()
=>
window
.
location
;
export
const
getPagePath
=
(
index
=
0
)
=>
{
const
page
=
$
(
'
body
'
).
attr
(
'
data-page
'
)
||
''
;
...
...
app/assets/javascripts/lib/utils/url_utility.js
View file @
87c571f8
import
{
windowLocation
}
from
'
./common_utils
'
;
// Returns an array containing the value(s) of the
// of the key passed as an argument
export
function
getParameterValues
(
sParam
)
{
...
...
@@ -53,11 +51,11 @@ export function mergeUrlParams(params, url) {
* @param {string} [url=windowLocation().href] - url from which the query param will be removed
* @returns {string} A copy of the original url but without the query param
*/
export
function
removeParams
(
params
,
url
=
window
Location
()
.
href
)
{
export
function
removeParams
(
params
,
url
=
window
.
location
.
href
)
{
const
[
rootAndQuery
,
fragment
]
=
url
.
split
(
'
#
'
);
const
[
root
,
query
]
=
rootAndQuery
.
split
(
'
?
'
);
if
(
query
===
undefined
)
{
if
(
!
query
)
{
return
url
;
}
...
...
app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js
View file @
87c571f8
...
...
@@ -6,8 +6,8 @@ import { mergeUrlParams, setUrlFragment } from '~/lib/utils/url_utility';
*
* @param fragment {string} - url fragment to be preserved
*/
export
default
function
preserveUrlFragment
(
fragment
)
{
if
(
fragment
&&
fragment
!==
''
)
{
export
default
function
preserveUrlFragment
(
fragment
=
''
)
{
if
(
fragment
)
{
const
normalFragment
=
fragment
.
replace
(
/^#/
,
''
);
// Append the fragment to all sign-in/sign-up form actions so it is preserved when the user is
...
...
spec/javascripts/fixtures/sessions.rb
0 → 100644
View file @
87c571f8
require
'spec_helper'
describe
'Sessions (JavaScript fixtures)'
do
include
JavaScriptFixturesHelpers
before
(
:all
)
do
clean_frontend_fixtures
(
'sessions/'
)
end
describe
SessionsController
,
'(JavaScript fixtures)'
,
type: :controller
do
include
DeviseHelpers
render_views
before
do
set_devise_mapping
(
context:
@request
)
end
it
'sessions/new.html.raw'
do
|
example
|
get
:new
expect
(
response
).
to
be_success
store_frontend_fixture
(
response
,
example
.
description
)
end
end
end
spec/javascripts/fixtures/signin_forms_and_buttons.html.haml
deleted
100644 → 0
View file @
2cbc475e
#signin-container
.tab-content
.active.login-box.tab-pane
.login-body
%form
#new_ldap_user
{
action:
'/users/auth/ldapmain/callback'
,
method:
'post'
}
.login-box.tab-pane
.login-body
%form
#new_user
.new_user
{
action:
'/users/sign_in'
,
method:
'post'
}
#register-pane
.login-box.tab-pane
.login-body
%form
#new_new_user
.new_new_user
{
action:
'/users'
,
method:
'post'
}
.omniauth-container
%span
.light
%a
#oauth-login-auth0
.oauth-login.btn
{
href:
'/users/auth/auth0'
}
Auth0
%span
.light
%a
#oauth-login-facebook
.oauth-login.btn
{
href
:'/users/auth/facebook?remember_me=1'
}
Facebook
%span
.light
%a
#oauth-login-saml
.oauth-login.btn
{
href
:'/users/auth/saml'
}
SAML
spec/javascripts/lib/utils/url_utility_spec.js
View file @
87c571f8
import
UrlUtility
,
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
describe
(
'
URL utility
'
,
()
=>
{
describe
(
'
webIDEUrl
'
,
()
=>
{
...
...
@@ -86,20 +86,6 @@ describe('URL utility', () => {
expect
(
url
).
toBe
(
'
/home?l=en_US#H2
'
);
});
});
describe
(
'
when no url is passed
'
,
()
=>
{
it
(
'
should remove params from window.location.href
'
,
()
=>
{
spyOnDependency
(
UrlUtility
,
'
windowLocation
'
).
and
.
callFake
(()
=>
{
const
anchor
=
document
.
createElement
(
'
a
'
);
anchor
.
href
=
'
https://mysite.com/?zip=11111&locale=en_US&ads=false#privacy
'
;
return
anchor
;
});
const
url
=
urlUtils
.
removeParams
([
'
locale
'
]);
expect
(
url
).
toBe
(
'
https://mysite.com/?zip=11111&ads=false#privacy
'
);
});
});
});
describe
(
'
setUrlFragment
'
,
()
=>
{
...
...
spec/javascripts/pages/sessions/new/preserve_url_fragment_spec.js
View file @
87c571f8
...
...
@@ -2,33 +2,60 @@ import $ from 'jquery';
import
preserveUrlFragment
from
'
~/pages/sessions/new/preserve_url_fragment
'
;
describe
(
'
preserve_url_fragment
'
,
()
=>
{
preloadFixtures
(
'
s
tatic/signin_forms_and_buttons
.html.raw
'
);
preloadFixtures
(
'
s
essions/new
.html.raw
'
);
beforeEach
(()
=>
{
loadFixtures
(
'
s
tatic/signin_forms_and_buttons
.html.raw
'
);
loadFixtures
(
'
s
essions/new
.html.raw
'
);
});
it
(
'
adds the url fragment to all login and sign up form actions
'
,
()
=>
{
preserveUrlFragment
(
'
#L65
'
);
expect
(
$
(
'
#new_ldap_user
'
).
attr
(
'
action
'
)).
toBe
(
'
/users/auth/ldapmain/callback#L65
'
);
expect
(
$
(
'
#new_user
'
).
attr
(
'
action
'
)).
toBe
(
'
/users/sign_in#L65
'
);
expect
(
$
(
'
#new_new_user
'
).
attr
(
'
action
'
)).
toBe
(
'
/users#L65
'
);
expect
(
$
(
'
#new_user
'
).
attr
(
'
action
'
)).
toBe
(
'
http://test.host/users/sign_in#L65
'
);
expect
(
$
(
'
#new_new_user
'
).
attr
(
'
action
'
)).
toBe
(
'
http://test.host/users#L65
'
);
});
it
(
'
adds the "redirect_fragment" query parameter to all OAuth and SAML login buttons
'
,
()
=>
{
it
(
'
does not add an empty url fragment to login and sign up form actions
'
,
()
=>
{
preserveUrlFragment
();
expect
(
$
(
'
#new_user
'
).
attr
(
'
action
'
)).
toBe
(
'
http://test.host/users/sign_in
'
);
expect
(
$
(
'
#new_new_user
'
).
attr
(
'
action
'
)).
toBe
(
'
http://test.host/users
'
);
});
it
(
'
does not add an empty query parameter to OmniAuth login buttons
'
,
()
=>
{
preserveUrlFragment
();
expect
(
$
(
'
#oauth-login-cas3
'
).
attr
(
'
href
'
)).
toBe
(
'
http://test.host/users/auth/cas3
'
);
expect
(
$
(
'
.omniauth-container #oauth-login-auth0
'
).
attr
(
'
href
'
)).
toBe
(
'
http://test.host/users/auth/auth0
'
,
);
});
describe
(
'
adds "redirect_fragment" query parameter to OmniAuth login buttons
'
,
()
=>
{
it
(
'
when "remember_me" is not present
'
,
()
=>
{
preserveUrlFragment
(
'
#L65
'
);
expect
(
$
(
'
#oauth-login-cas3
'
).
attr
(
'
href
'
)).
toBe
(
'
http://test.host/users/auth/cas3?redirect_fragment=L65
'
,
);
expect
(
$
(
'
.omniauth-container #oauth-login-auth0
'
).
attr
(
'
href
'
)).
toBe
(
'
/users/auth/auth0?redirect_fragment=L65
'
,
'
http://test.host
/users/auth/auth0?redirect_fragment=L65
'
,
);
});
expect
(
$
(
'
.omniauth-container #oauth-login-facebook
'
).
attr
(
'
href
'
)).
toBe
(
'
/users/auth/facebook?remember_me=1&redirect_fragment=L65
'
,
it
(
'
when "remember-me" is present
'
,
()
=>
{
$
(
'
a.omniauth-btn
'
).
attr
(
'
href
'
,
(
i
,
href
)
=>
`
${
href
}
?remember_me=1`
);
preserveUrlFragment
(
'
#L65
'
);
expect
(
$
(
'
#oauth-login-cas3
'
).
attr
(
'
href
'
)).
toBe
(
'
http://test.host/users/auth/cas3?remember_me=1&redirect_fragment=L65
'
,
);
expect
(
$
(
'
.omniauth-container #oauth-login-saml
'
).
attr
(
'
href
'
)).
toBe
(
'
/users/auth/saml?
redirect_fragment=L65
'
,
expect
(
$
(
'
#oauth-login-auth0
'
).
attr
(
'
href
'
)).
toBe
(
'
http://test.host/users/auth/auth0?remember_me=1&
redirect_fragment=L65
'
,
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment