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
93e62826
Commit
93e62826
authored
Feb 24, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `:with_avatar` trait to User factory
parent
0104ab79
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
7 deletions
+26
-7
app/models/user.rb
app/models/user.rb
+1
-1
spec/controllers/namespaces_controller_spec.rb
spec/controllers/namespaces_controller_spec.rb
+1
-1
spec/controllers/profiles/avatars_controller_spec.rb
spec/controllers/profiles/avatars_controller_spec.rb
+1
-1
spec/controllers/uploads_controller_spec.rb
spec/controllers/uploads_controller_spec.rb
+1
-1
spec/factories.rb
spec/factories.rb
+7
-0
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+3
-3
spec/models/user_spec.rb
spec/models/user_spec.rb
+12
-0
No files found.
app/models/user.rb
View file @
93e62826
...
@@ -169,7 +169,7 @@ class User < ActiveRecord::Base
...
@@ -169,7 +169,7 @@ class User < ActiveRecord::Base
validates
:avatar_crop_x
,
:avatar_crop_y
,
:avatar_crop_size
,
validates
:avatar_crop_x
,
:avatar_crop_y
,
:avatar_crop_size
,
numericality:
{
only_integer:
true
},
numericality:
{
only_integer:
true
},
presence:
true
,
presence:
true
,
if:
->
(
user
)
{
user
.
avatar
_changed
?
}
if:
->
(
user
)
{
user
.
avatar?
}
before_validation
:generate_password
,
on: :create
before_validation
:generate_password
,
on: :create
before_validation
:restricted_signup_domains
,
on: :create
before_validation
:restricted_signup_domains
,
on: :create
...
...
spec/controllers/namespaces_controller_spec.rb
View file @
93e62826
require
'spec_helper'
require
'spec_helper'
describe
NamespacesController
do
describe
NamespacesController
do
let!
(
:user
)
{
create
(
:user
,
avatar:
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"image/png"
)
)
}
let!
(
:user
)
{
create
(
:user
,
:with_avatar
)
}
describe
"GET show"
do
describe
"GET show"
do
context
"when the namespace belongs to a user"
do
context
"when the namespace belongs to a user"
do
...
...
spec/controllers/profiles/avatars_controller_spec.rb
View file @
93e62826
require
'spec_helper'
require
'spec_helper'
describe
Profiles
::
AvatarsController
do
describe
Profiles
::
AvatarsController
do
let
(
:user
)
{
create
(
:user
,
avatar:
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
)
)
}
let
(
:user
)
{
create
(
:user
,
:with_avatar
)
}
before
do
before
do
sign_in
(
user
)
sign_in
(
user
)
...
...
spec/controllers/uploads_controller_spec.rb
View file @
93e62826
require
'spec_helper'
require
'spec_helper'
describe
UploadsController
do
describe
UploadsController
do
let!
(
:user
)
{
create
(
:user
,
avatar:
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"image/png"
)
)
}
let!
(
:user
)
{
create
(
:user
,
:with_avatar
)
}
describe
"GET show"
do
describe
"GET show"
do
context
"when viewing a user avatar"
do
context
"when viewing a user avatar"
do
...
...
spec/factories.rb
View file @
93e62826
...
@@ -36,6 +36,13 @@ FactoryGirl.define do
...
@@ -36,6 +36,13 @@ FactoryGirl.define do
end
end
end
end
trait
:with_avatar
do
avatar
{
fixture_file_upload
(
Rails
.
root
.
join
(
*
%w(spec fixtures dk.png)
),
'image/png'
)
}
avatar_crop_x
0
avatar_crop_y
0
avatar_crop_size
256
end
factory
:omniauth_user
do
factory
:omniauth_user
do
ignore
do
ignore
do
extern_uid
'123456'
extern_uid
'123456'
...
...
spec/helpers/application_helper_spec.rb
View file @
93e62826
...
@@ -77,7 +77,7 @@ describe ApplicationHelper do
...
@@ -77,7 +77,7 @@ describe ApplicationHelper do
let
(
:avatar_file_path
)
{
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
}
let
(
:avatar_file_path
)
{
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
}
it
'should return an url for the avatar'
do
it
'should return an url for the avatar'
do
user
=
create
(
:user
,
avatar:
File
.
open
(
avatar_file_path
))
user
=
create
(
:user
,
:with_avatar
,
avatar:
File
.
open
(
avatar_file_path
))
expect
(
helper
.
avatar_icon
(
user
.
email
).
to_s
).
expect
(
helper
.
avatar_icon
(
user
.
email
).
to_s
).
to
match
(
"/uploads/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
to
match
(
"/uploads/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
...
@@ -88,7 +88,7 @@ describe ApplicationHelper do
...
@@ -88,7 +88,7 @@ describe ApplicationHelper do
# Must be stubbed after the stub above, and separately
# Must be stubbed after the stub above, and separately
stub_config_setting
(
url:
Settings
.
send
(
:build_gitlab_url
))
stub_config_setting
(
url:
Settings
.
send
(
:build_gitlab_url
))
user
=
create
(
:user
,
avatar:
File
.
open
(
avatar_file_path
))
user
=
create
(
:user
,
:with_avatar
,
avatar:
File
.
open
(
avatar_file_path
))
expect
(
helper
.
avatar_icon
(
user
.
email
).
to_s
).
expect
(
helper
.
avatar_icon
(
user
.
email
).
to_s
).
to
match
(
"/gitlab/uploads/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
to
match
(
"/gitlab/uploads/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
...
@@ -102,7 +102,7 @@ describe ApplicationHelper do
...
@@ -102,7 +102,7 @@ describe ApplicationHelper do
describe
'using a User'
do
describe
'using a User'
do
it
'should return an URL for the avatar'
do
it
'should return an URL for the avatar'
do
user
=
create
(
:user
,
avatar:
File
.
open
(
avatar_file_path
))
user
=
create
(
:user
,
:with_avatar
,
avatar:
File
.
open
(
avatar_file_path
))
expect
(
helper
.
avatar_icon
(
user
).
to_s
).
expect
(
helper
.
avatar_icon
(
user
).
to_s
).
to
match
(
"/uploads/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
to
match
(
"/uploads/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
...
...
spec/models/user_spec.rb
View file @
93e62826
...
@@ -174,6 +174,18 @@ describe User, models: true do
...
@@ -174,6 +174,18 @@ describe User, models: true do
end
end
end
end
end
end
describe
'avatar'
do
it
'only validates when avatar is present'
do
user
=
build
(
:user
,
:with_avatar
)
user
.
avatar_crop_x
=
nil
user
.
avatar_crop_y
=
nil
user
.
avatar_crop_size
=
nil
expect
(
user
).
not_to
be_valid
end
end
end
end
describe
"Respond to"
do
describe
"Respond to"
do
...
...
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