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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
79e24886
Commit
79e24886
authored
Jun 17, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
parents
be2a7506
73918efb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
2 deletions
+29
-2
app/controllers/profiles/two_factor_auths_controller.rb
app/controllers/profiles/two_factor_auths_controller.rb
+5
-1
app/models/user.rb
app/models/user.rb
+3
-1
spec/features/users_spec.rb
spec/features/users_spec.rb
+21
-0
No files found.
app/controllers/profiles/two_factor_auths_controller.rb
View file @
79e24886
...
...
@@ -43,8 +43,12 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
private
def
build_qr_code
issuer
=
"
GitLab
|
#{
current_user
.
email
}
"
issuer
=
"
#{
issuer_host
}
|
#{
current_user
.
email
}
"
uri
=
current_user
.
otp_provisioning_uri
(
current_user
.
email
,
issuer:
issuer
)
RQRCode
::
render_qrcode
(
uri
,
:svg
,
level: :m
,
unit:
3
)
end
def
issuer_host
Gitlab
.
config
.
gitlab
.
host
end
end
app/models/user.rb
View file @
79e24886
...
...
@@ -137,7 +137,9 @@ class User < ActiveRecord::Base
# Validations
#
validates
:name
,
presence:
true
validates
:email
,
presence:
true
,
email:
{
strict_mode:
true
},
uniqueness:
true
# Note that a 'uniqueness' and presence check is provided by devise :validatable for email. We do not need to
# duplicate that here as the validation framework will have duplicate errors in the event of a failure.
validates
:email
,
presence:
true
,
email:
{
strict_mode:
true
}
validates
:notification_email
,
presence:
true
,
email:
{
strict_mode:
true
}
validates
:public_email
,
presence:
true
,
email:
{
strict_mode:
true
},
allow_blank:
true
,
uniqueness:
true
validates
:bio
,
length:
{
maximum:
255
},
allow_blank:
true
...
...
spec/features/users_spec.rb
View file @
79e24886
...
...
@@ -27,4 +27,25 @@ feature 'Users' do
user
.
reload
expect
(
user
.
reset_password_token
).
to
be_nil
end
let!
(
:user
)
{
create
(
:user
,
username:
'user1'
,
name:
'User 1'
,
email:
'user1@gitlab.com'
)
}
scenario
'Should show one error if email is already taken'
do
visit
new_user_session_path
fill_in
'user_name'
,
with:
'Another user name'
fill_in
'user_username'
,
with:
'anotheruser'
fill_in
'user_email'
,
with:
user
.
email
fill_in
'user_password_sign_up'
,
with:
'12341234'
expect
{
click_button
'Sign up'
}.
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
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
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