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
Boxiang Sun
gitlab-ce
Commits
fc7f1aa2
Commit
fc7f1aa2
authored
Feb 22, 2018
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix user feature specs that were hardcoding 'user1'
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
1e52d1f6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
194 additions
and
144 deletions
+194
-144
spec/features/users/login_spec.rb
spec/features/users/login_spec.rb
+20
-0
spec/features/users/logout_spec.rb
spec/features/users/logout_spec.rb
+0
-0
spec/features/users/projects_spec.rb
spec/features/users/projects_spec.rb
+0
-29
spec/features/users/signup_spec.rb
spec/features/users/signup_spec.rb
+135
-0
spec/features/users/user_browses_projects_on_user_page_spec.rb
...features/users/user_browses_projects_on_user_page_spec.rb
+23
-1
spec/features/users_spec.rb
spec/features/users_spec.rb
+0
-114
spec/routing/routing_spec.rb
spec/routing/routing_spec.rb
+16
-0
No files found.
spec/features/login_spec.rb
→
spec/features/
users/
login_spec.rb
View file @
fc7f1aa2
require
'spec_helper'
require
'spec_helper'
feature
'Login'
do
feature
'Login'
do
scenario
'Successful user signin invalidates password reset token'
do
user
=
create
(
:user
)
expect
(
user
.
reset_password_token
).
to
be_nil
visit
new_user_password_path
fill_in
'user_email'
,
with:
user
.
email
click_button
'Reset password'
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
user
.
reload
expect
(
user
.
reset_password_token
).
to
be_nil
end
describe
'initial login after setup'
do
describe
'initial login after setup'
do
it
'allows the initial admin to create a password'
do
it
'allows the initial admin to create a password'
do
# This behavior is dependent on there only being one user
# This behavior is dependent on there only being one user
...
...
spec/features/logout_spec.rb
→
spec/features/
users/
logout_spec.rb
View file @
fc7f1aa2
File moved
spec/features/users/projects_spec.rb
deleted
100644 → 0
View file @
1e52d1f6
require
'spec_helper'
describe
'Projects tab on a user profile'
,
:js
do
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:project2
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
before
do
allow
(
Project
).
to
receive
(
:default_per_page
).
and_return
(
1
)
sign_in
(
user
)
visit
user_path
(
user
)
page
.
within
(
'.user-profile-nav'
)
do
click_link
(
'Personal projects'
)
end
wait_for_requests
end
it
'paginates results'
do
expect
(
page
).
to
have_content
(
project2
.
name
)
click_link
(
'Next'
)
expect
(
page
).
to
have_content
(
project
.
name
)
end
end
spec/features/signup_spec.rb
→
spec/features/
users/
signup_spec.rb
View file @
fc7f1aa2
require
'spec_helper'
require
'spec_helper'
feature
'Signup'
do
describe
'Signup'
do
describe
'signup with no errors'
do
let
(
:new_user
)
{
build_stubbed
(
:user
)
}
describe
'username validation'
,
:js
do
before
do
visit
root_path
click_link
'Register'
end
it
'does not show an error border if the username is available'
do
fill_in
'new_user_username'
,
with:
'new-user'
wait_for_requests
expect
(
find
(
'.username'
)).
not_to
have_css
'.gl-field-error-outline'
end
it
'does not show an error border if the username contains dots (.)'
do
fill_in
'new_user_username'
,
with:
'new.user.username'
wait_for_requests
expect
(
find
(
'.username'
)).
not_to
have_css
'.gl-field-error-outline'
end
it
'shows an error border if the username already exists'
do
existing_user
=
create
(
:user
)
fill_in
'new_user_username'
,
with:
existing_user
.
username
wait_for_requests
expect
(
find
(
'.username'
)).
to
have_css
'.gl-field-error-outline'
end
it
'shows an error border if the username contains special characters'
do
fill_in
'new_user_username'
,
with:
'new$user!username'
wait_for_requests
expect
(
find
(
'.username'
)).
to
have_css
'.gl-field-error-outline'
end
end
context
'with no errors'
do
context
"when sending confirmation email"
do
context
"when sending confirmation email"
do
before
do
before
do
stub_application_setting
(
send_user_confirmation_email:
true
)
stub_application_setting
(
send_user_confirmation_email:
true
)
end
end
it
'creates the user account and sends a confirmation email'
do
it
'creates the user account and sends a confirmation email'
do
user
=
build
(
:user
)
visit
root_path
visit
root_path
fill_in
'new_user_name'
,
with:
user
.
name
fill_in
'new_user_name'
,
with:
new_user
.
name
fill_in
'new_user_username'
,
with:
user
.
username
fill_in
'new_user_username'
,
with:
new_user
.
username
fill_in
'new_user_email'
,
with:
user
.
email
fill_in
'new_user_email'
,
with:
new_user
.
email
fill_in
'new_user_email_confirmation'
,
with:
user
.
email
fill_in
'new_user_email_confirmation'
,
with:
new_user
.
email
fill_in
'new_user_password'
,
with:
user
.
password
fill_in
'new_user_password'
,
with:
new_user
.
password
click_button
"Register"
expect
{
click_button
'Register'
}.
to
change
{
User
.
count
}.
by
(
1
)
expect
(
current_path
).
to
eq
users_almost_there_path
expect
(
current_path
).
to
eq
users_almost_there_path
expect
(
page
).
to
have_content
(
"Please check your email to confirm your account"
)
expect
(
page
).
to
have_content
(
"Please check your email to confirm your account"
)
...
@@ -26,15 +64,13 @@ feature 'Signup' do
...
@@ -26,15 +64,13 @@ feature 'Signup' do
context
"when sigining up with different cased emails"
do
context
"when sigining up with different cased emails"
do
it
"creates the user successfully"
do
it
"creates the user successfully"
do
user
=
build
(
:user
)
visit
root_path
visit
root_path
fill_in
'new_user_name'
,
with:
user
.
name
fill_in
'new_user_name'
,
with:
new_
user
.
name
fill_in
'new_user_username'
,
with:
user
.
username
fill_in
'new_user_username'
,
with:
new_
user
.
username
fill_in
'new_user_email'
,
with:
user
.
email
fill_in
'new_user_email'
,
with:
new_
user
.
email
fill_in
'new_user_email_confirmation'
,
with:
user
.
email
.
capitalize
fill_in
'new_user_email_confirmation'
,
with:
new_
user
.
email
.
capitalize
fill_in
'new_user_password'
,
with:
user
.
password
fill_in
'new_user_password'
,
with:
new_
user
.
password
click_button
"Register"
click_button
"Register"
expect
(
current_path
).
to
eq
dashboard_projects_path
expect
(
current_path
).
to
eq
dashboard_projects_path
...
@@ -48,15 +84,13 @@ feature 'Signup' do
...
@@ -48,15 +84,13 @@ feature 'Signup' do
end
end
it
'creates the user account and goes to dashboard'
do
it
'creates the user account and goes to dashboard'
do
user
=
build
(
:user
)
visit
root_path
visit
root_path
fill_in
'new_user_name'
,
with:
user
.
name
fill_in
'new_user_name'
,
with:
new_
user
.
name
fill_in
'new_user_username'
,
with:
user
.
username
fill_in
'new_user_username'
,
with:
new_
user
.
username
fill_in
'new_user_email'
,
with:
user
.
email
fill_in
'new_user_email'
,
with:
new_
user
.
email
fill_in
'new_user_email_confirmation'
,
with:
user
.
email
fill_in
'new_user_email_confirmation'
,
with:
new_
user
.
email
fill_in
'new_user_password'
,
with:
user
.
password
fill_in
'new_user_password'
,
with:
new_
user
.
password
click_button
"Register"
click_button
"Register"
expect
(
current_path
).
to
eq
dashboard_projects_path
expect
(
current_path
).
to
eq
dashboard_projects_path
...
@@ -65,17 +99,16 @@ feature 'Signup' do
...
@@ -65,17 +99,16 @@ feature 'Signup' do
end
end
end
end
describe
'signup
with errors'
do
context
'
with errors'
do
it
"displays the errors"
do
it
"displays the errors"
do
existing_user
=
create
(
:user
)
existing_user
=
create
(
:user
)
user
=
build
(
:user
)
visit
root_path
visit
root_path
fill_in
'new_user_name'
,
with:
user
.
name
fill_in
'new_user_name'
,
with:
new_
user
.
name
fill_in
'new_user_username'
,
with:
user
.
username
fill_in
'new_user_username'
,
with:
new_
user
.
username
fill_in
'new_user_email'
,
with:
existing_user
.
email
fill_in
'new_user_email'
,
with:
existing_user
.
email
fill_in
'new_user_password'
,
with:
user
.
password
fill_in
'new_user_password'
,
with:
new_
user
.
password
click_button
"Register"
click_button
"Register"
expect
(
current_path
).
to
eq
user_registration_path
expect
(
current_path
).
to
eq
user_registration_path
...
@@ -86,18 +119,17 @@ feature 'Signup' do
...
@@ -86,18 +119,17 @@ feature 'Signup' do
it
'does not redisplay the password'
do
it
'does not redisplay the password'
do
existing_user
=
create
(
:user
)
existing_user
=
create
(
:user
)
user
=
build
(
:user
)
visit
root_path
visit
root_path
fill_in
'new_user_name'
,
with:
user
.
name
fill_in
'new_user_name'
,
with:
new_
user
.
name
fill_in
'new_user_username'
,
with:
user
.
username
fill_in
'new_user_username'
,
with:
new_
user
.
username
fill_in
'new_user_email'
,
with:
existing_user
.
email
fill_in
'new_user_email'
,
with:
existing_user
.
email
fill_in
'new_user_password'
,
with:
user
.
password
fill_in
'new_user_password'
,
with:
new_
user
.
password
click_button
"Register"
click_button
"Register"
expect
(
current_path
).
to
eq
user_registration_path
expect
(
current_path
).
to
eq
user_registration_path
expect
(
page
.
body
).
not_to
match
(
/
#{
user
.
password
}
/
)
expect
(
page
.
body
).
not_to
match
(
/
#{
new_
user
.
password
}
/
)
end
end
end
end
end
end
spec/features/user_page_spec.rb
→
spec/features/user
s/user_browses_projects_on_user
_page_spec.rb
View file @
fc7f1aa2
require
'spec_helper'
require
'spec_helper'
describe
'User page'
,
:js
do
describe
'User
s > User browses projects on user
page'
,
:js
do
let!
(
:user
)
{
create
:user
}
let!
(
:user
)
{
create
:user
}
let!
(
:private_project
)
do
let!
(
:private_project
)
do
create
:project
,
:private
,
name:
'private'
,
namespace:
user
.
namespace
do
|
project
|
create
:project
,
:private
,
name:
'private'
,
namespace:
user
.
namespace
do
|
project
|
...
@@ -26,6 +26,28 @@ describe 'User page', :js do
...
@@ -26,6 +26,28 @@ describe 'User page', :js do
end
end
end
end
it
'paginates projects'
,
:js
do
project
=
create
(
:project
,
namespace:
user
.
namespace
)
project2
=
create
(
:project
,
namespace:
user
.
namespace
)
allow
(
Project
).
to
receive
(
:default_per_page
).
and_return
(
1
)
sign_in
(
user
)
visit
user_path
(
user
)
page
.
within
(
'.user-profile-nav'
)
do
click_link
(
'Personal projects'
)
end
wait_for_requests
expect
(
page
).
to
have_content
(
project2
.
name
)
click_link
(
'Next'
)
expect
(
page
).
to
have_content
(
project
.
name
)
end
context
'when not signed in'
do
context
'when not signed in'
do
it
'renders user public project'
do
it
'renders user public project'
do
visit
user_path
(
user
)
visit
user_path
(
user
)
...
...
spec/features/users_spec.rb
deleted
100644 → 0
View file @
1e52d1f6
require
'spec_helper'
feature
'Users'
,
:js
do
let
(
:user
)
{
create
(
:user
,
username:
'user1'
,
name:
'User 1'
,
email:
'user1@gitlab.com'
)
}
scenario
'GET /users/sign_in creates a new user account'
do
visit
new_user_session_path
click_link
'Register'
fill_in
'new_user_name'
,
with:
'Name Surname'
fill_in
'new_user_username'
,
with:
'Great'
fill_in
'new_user_email'
,
with:
'name@mail.com'
fill_in
'new_user_email_confirmation'
,
with:
'name@mail.com'
fill_in
'new_user_password'
,
with:
'password1234'
expect
{
click_button
'Register'
}.
to
change
{
User
.
count
}.
by
(
1
)
end
scenario
'Successful user signin invalidates password reset token'
do
expect
(
user
.
reset_password_token
).
to
be_nil
visit
new_user_password_path
fill_in
'user_email'
,
with:
user
.
email
click_button
'Reset password'
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
user
.
reload
expect
(
user
.
reset_password_token
).
to
be_nil
end
scenario
'Should show one error if email is already taken'
do
visit
new_user_session_path
click_link
'Register'
fill_in
'new_user_name'
,
with:
'Another user name'
fill_in
'new_user_username'
,
with:
'anotheruser'
fill_in
'new_user_email'
,
with:
user
.
email
fill_in
'new_user_email_confirmation'
,
with:
user
.
email
fill_in
'new_user_password'
,
with:
'12341234'
expect
{
click_button
'Register'
}.
to
change
{
User
.
count
}.
by
(
0
)
expect
(
page
).
to
have_text
(
'Email has already been taken'
)
expect
(
number_of_errors_on_page
(
page
)).
to
be
(
1
),
'errors on page:\n #{errors_on_page page}'
end
describe
'redirect alias routes'
do
before
do
expect
(
user
).
to
be_persisted
end
scenario
'/u/user1 redirects to user page'
do
visit
'/u/user1'
expect
(
current_path
).
to
eq
user_path
(
user
)
expect
(
page
).
to
have_text
(
user
.
name
)
end
scenario
'/u/user1/groups redirects to user groups page'
do
visit
'/u/user1/groups'
expect
(
current_path
).
to
eq
user_groups_path
(
user
)
end
scenario
'/u/user1/projects redirects to user projects page'
do
visit
'/u/user1/projects'
expect
(
current_path
).
to
eq
user_projects_path
(
user
)
end
end
feature
'username validation'
do
let
(
:loading_icon
)
{
'.fa.fa-spinner'
}
let
(
:username_input
)
{
'new_user_username'
}
before
do
visit
new_user_session_path
click_link
'Register'
end
scenario
'doesn\'t show an error border if the username is available'
do
fill_in
username_input
,
with:
'new-user'
wait_for_requests
expect
(
find
(
'.username'
)).
not_to
have_css
'.gl-field-error-outline'
end
scenario
'does not show an error border if the username contains dots (.)'
do
fill_in
username_input
,
with:
'new.user.username'
wait_for_requests
expect
(
find
(
'.username'
)).
not_to
have_css
'.gl-field-error-outline'
end
scenario
'shows an error border if the username already exists'
do
fill_in
username_input
,
with:
user
.
username
wait_for_requests
expect
(
find
(
'.username'
)).
to
have_css
'.gl-field-error-outline'
end
scenario
'shows an error border if the username contains special characters'
do
fill_in
username_input
,
with:
'new$user!username'
wait_for_requests
expect
(
find
(
'.username'
)).
to
have_css
'.gl-field-error-outline'
end
end
def
errors_on_page
(
page
)
page
.
find
(
'#error_explanation'
).
find
(
'ul'
).
all
(
'li'
).
map
{
|
item
|
item
.
text
}.
join
(
"
\n
"
)
end
def
number_of_errors_on_page
(
page
)
page
.
find
(
'#error_explanation'
).
find
(
'ul'
).
all
(
'li'
).
count
end
end
spec/routing/routing_spec.rb
View file @
fc7f1aa2
...
@@ -37,6 +37,22 @@ describe UsersController, "routing" do
...
@@ -37,6 +37,22 @@ describe UsersController, "routing" do
it
"to #calendar_activities"
do
it
"to #calendar_activities"
do
expect
(
get
(
"/users/User/calendar_activities"
)).
to
route_to
(
'users#calendar_activities'
,
username:
'User'
)
expect
(
get
(
"/users/User/calendar_activities"
)).
to
route_to
(
'users#calendar_activities'
,
username:
'User'
)
end
end
describe
'redirect alias routes'
do
include
RSpec
::
Rails
::
RequestExampleGroup
it
'/u/user1 redirects to /user1'
do
expect
(
get
(
"/u/user1"
)).
to
redirect_to
(
'/user1'
)
end
it
'/u/user1/groups redirects to /user1/groups'
do
expect
(
get
(
"/u/user1/groups"
)).
to
redirect_to
(
'/users/user1/groups'
)
end
it
'/u/user1/projects redirects to /user1/projects'
do
expect
(
get
(
"/u/user1/projects"
)).
to
redirect_to
(
'/users/user1/projects'
)
end
end
end
end
# search GET /search(.:format) search#show
# search GET /search(.:format) search#show
...
...
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