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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b31462ae
Commit
b31462ae
authored
Nov 23, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specs for displaying avatars in Geo secondary node
parent
0a74ee3f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
5 deletions
+93
-5
spec/helpers/groups_helper_spec.rb
spec/helpers/groups_helper_spec.rb
+23
-5
spec/models/group_spec.rb
spec/models/group_spec.rb
+30
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+11
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+29
-0
No files found.
spec/helpers/groups_helper_spec.rb
View file @
b31462ae
require
'spec_helper'
describe
GroupsHelper
do
let
(
:group
)
{
create
(
:group
)
}
describe
'group_icon'
do
avatar_file_path
=
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
it
'returns an url for the avatar'
do
group
=
create
(
:group
)
group
.
avatar
=
File
.
open
(
avatar_file_path
)
group
.
save!
expect
(
group_icon
(
group
.
path
).
to_s
).
to
match
(
"/uploads/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
)
expect
(
group_icon
(
group
.
path
).
to_s
).
to
match
(
"/uploads/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
)
end
it
'gives default avatar_icon when no avatar is present'
do
group
=
create
(
:group
)
group
.
save!
expect
(
group_icon
(
group
.
path
)).
to
match
(
'group_avatar.png'
)
end
context
'in a geo secondary node'
do
let
(
:geo_url
)
{
'http://geo.example.com'
}
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive_message_chain
(
:primary_node
,
:url
)
{
geo_url
}
end
it
'returns an url for the avatar pointing to the primary node base url'
do
group
.
avatar
=
File
.
open
(
avatar_file_path
)
group
.
save!
expect
(
group_icon
(
group
.
path
).
to_s
).
to
match
(
"
#{
geo_url
}
/uploads/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
)
end
it
'gives default avatar_icon when no avatar is present'
do
group
.
save!
expect
(
group_icon
(
group
.
path
)).
to
match
(
'group_avatar.png'
)
end
end
end
describe
'group_lfs_status'
do
let
(
:group
)
{
create
(
:group
)
}
let!
(
:project
)
{
create
(
:empty_project
,
namespace_id:
group
.
id
)
}
before
do
...
...
spec/models/group_spec.rb
View file @
b31462ae
...
...
@@ -140,6 +140,36 @@ describe Group, models: true do
end
end
describe
'#avatar_url'
do
let
(
:user
)
{
create
(
:user
)
}
subject
{
group
.
avatar_url
}
context
'when avatar file is uploaded'
do
before
do
group
.
add_user
(
user
,
GroupMember
::
MASTER
)
group
.
update_columns
(
avatar:
'avatar.png'
)
allow
(
group
.
avatar
).
to
receive
(
:present?
)
{
true
}
end
let
(
:avatar_path
)
do
"/uploads/group/avatar/
#{
group
.
id
}
/avatar.png"
end
it
{
should
eq
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}#{
avatar_path
}
"
}
context
'when in a geo secondary node'
do
let
(
:geo_url
)
{
'http://geo.example.com'
}
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive_message_chain
(
:primary_node
,
:url
)
{
geo_url
}
end
it
{
should
eq
"
#{
geo_url
}#{
avatar_path
}
"
}
end
end
end
describe
'.search'
do
it
'returns groups with a matching name'
do
expect
(
described_class
.
search
(
group
.
name
)).
to
eq
([
group
])
...
...
spec/models/project_spec.rb
View file @
b31462ae
...
...
@@ -811,6 +811,17 @@ describe Project, models: true do
end
it
{
should
eq
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}#{
avatar_path
}
"
}
context
'When in a geo secondary node'
do
let
(
:geo_url
)
{
'http://geo.example.com'
}
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive_message_chain
(
:primary_node
,
:url
)
{
geo_url
}
end
it
{
should
eq
"
#{
geo_url
}#{
avatar_path
}
"
}
end
end
context
'When avatar file in git'
do
...
...
spec/models/user_spec.rb
View file @
b31462ae
...
...
@@ -803,6 +803,35 @@ describe User, models: true do
end
end
describe
'#avatar_url'
do
let
(
:user
)
{
create
(
:user
)
}
subject
{
user
.
avatar_url
}
context
'when avatar file is uploaded'
do
before
do
user
.
update_columns
(
avatar:
'uploads/avatar.png'
)
allow
(
user
.
avatar
).
to
receive
(
:present?
)
{
true
}
end
let
(
:avatar_path
)
do
"/uploads/user/avatar/
#{
user
.
id
}
/uploads/avatar.png"
end
it
{
should
eq
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}#{
avatar_path
}
"
}
context
'when in a geo secondary node'
do
let
(
:geo_url
)
{
'http://geo.example.com'
}
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive_message_chain
(
:primary_node
,
:url
)
{
geo_url
}
end
it
{
should
eq
"
#{
geo_url
}#{
avatar_path
}
"
}
end
end
end
describe
'#requires_ldap_check?'
do
let
(
:user
)
{
User
.
new
}
...
...
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