BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
51abeaa1
Commit
51abeaa1
authored
Mar 01, 2015
by
sue445
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose avatar_url in projects API
* Impl Project#avatar_url * Refactor ApplicationHelper: Use Project#avatar_url * Update changelog
parent
7fef8456
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
9 deletions
+55
-9
CHANGELOG
CHANGELOG
+1
-0
application_helper.rb
app/helpers/application_helper.rb
+2
-4
project.rb
app/models/project.rb
+10
-0
projects.md
doc/api/projects.md
+6
-3
entities.rb
lib/api/entities.rb
+1
-0
application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+4
-2
project_spec.rb
spec/models/project_spec.rb
+31
-0
No files found.
CHANGELOG
View file @
51abeaa1
...
...
@@ -10,6 +10,7 @@ v 7.9.0 (unreleased)
- Save web edit in new branch
- Fix ordering of imported but unchanged projects (Marco Wessel)
- Mobile UI improvements: make aside content expandable
- Expose avatar_url in projects API
- Generalize image upload in drag and drop in markdown to all files (Hannes Rosenögger)
v 7.8.1
...
...
app/helpers/application_helper.rb
View file @
51abeaa1
...
...
@@ -58,10 +58,8 @@ module ApplicationHelper
Project
.
find_with_namespace
(
project_id
)
end
if
project
.
avatar
.
present?
image_tag
project
.
avatar
.
url
,
options
elsif
project
.
avatar_in_git
image_tag
namespace_project_avatar_path
(
project
.
namespace
,
project
),
options
if
project
.
avatar_url
image_tag
project
.
avatar_url
,
options
else
# generated icon
project_identicon
(
project
,
options
)
end
...
...
app/models/project.rb
View file @
51abeaa1
...
...
@@ -37,6 +37,8 @@ class Project < ActiveRecord::Base
include
Gitlab
::
ShellAdapter
include
Gitlab
::
VisibilityLevel
include
Gitlab
::
ConfigHelper
include
Rails
.
application
.
routes
.
url_helpers
extend
Gitlab
::
ConfigHelper
extend
Enumerize
...
...
@@ -408,6 +410,14 @@ class Project < ActiveRecord::Base
@avatar_file
end
def
avatar_url
if
avatar
.
present?
[
gitlab_config
.
url
,
avatar
.
url
].
join
elsif
avatar_in_git
[
gitlab_config
.
url
,
namespace_project_avatar_path
(
namespace
,
self
)].
join
end
end
# For compatibility with old code
def
code
path
...
...
doc/api/projects.md
View file @
51abeaa1
...
...
@@ -68,7 +68,8 @@ Parameters:
"path"
:
"diaspora"
,
"updated_at"
:
"2013-09-30T13: 46: 02Z"
},
"archived"
:
false
"archived"
:
false
,
"avatar_url"
:
"http://example.com/uploads/project/avatar/4/uploads/avatar.png"
},
{
"id"
:
6
,
...
...
@@ -103,7 +104,8 @@ Parameters:
"path"
:
"brightbox"
,
"updated_at"
:
"2013-09-30T13:46:02Z"
},
"archived"
:
false
"archived"
:
false
,
"avatar_url"
:
null
}
]
```
...
...
@@ -195,7 +197,8 @@ Parameters:
"notification_level"
:
3
}
},
"archived"
:
false
"archived"
:
false
,
"avatar_url"
:
"http://example.com/uploads/project/avatar/3/uploads/avatar.png"
}
```
...
...
lib/api/entities.rb
View file @
51abeaa1
...
...
@@ -56,6 +56,7 @@ module API
expose
:issues_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
:snippets_enabled
,
:created_at
,
:last_activity_at
expose
:namespace
expose
:forked_from_project
,
using:
Entities
::
ForkedFromProject
,
if:
lambda
{
|
project
,
options
|
project
.
forked?
}
expose
:avatar_url
end
class
ProjectMember
<
UserBasic
...
...
spec/helpers/application_helper_spec.rb
View file @
51abeaa1
...
...
@@ -64,8 +64,9 @@ describe ApplicationHelper do
project
=
create
(
:project
)
project
.
avatar
=
File
.
open
(
avatar_file_path
)
project
.
save!
avatar_url
=
"http://localhost/uploads/project/avatar/
#{
project
.
id
}
/gitlab_logo.png"
expect
(
project_icon
(
"
#{
project
.
namespace
.
to_param
}
/
#{
project
.
to_param
}
"
).
to_s
).
to
eq
(
"<img alt=
\"
Gitlab logo
\"
src=
\"
/uploads/project/avatar/
#{
project
.
id
}
/gitlab_logo.png
\"
/>"
"<img alt=
\"
Gitlab logo
\"
src=
\"
#{
avatar_url
}
\"
/>"
)
end
...
...
@@ -75,8 +76,9 @@ describe ApplicationHelper do
allow_any_instance_of
(
Project
).
to
receive
(
:avatar_in_git
).
and_return
(
true
)
avatar_url
=
'http://localhost'
+
namespace_project_avatar_path
(
project
.
namespace
,
project
)
expect
(
project_icon
(
"
#{
project
.
namespace
.
to_param
}
/
#{
project
.
to_param
}
"
).
to_s
).
to
match
(
image_tag
(
namespace_project_avatar_path
(
project
.
namespace
,
project
)
))
image_tag
(
avatar_url
))
end
end
...
...
spec/models/project_spec.rb
View file @
51abeaa1
...
...
@@ -326,4 +326,35 @@ describe Project do
expect
(
project
.
avatar_type
).
to
eq
([
'only images allowed'
])
end
end
describe
:avatar_url
do
subject
{
project
.
avatar_url
}
let
(
:project
)
{
create
(
:project
)
}
context
'When avatar file is uploaded'
do
before
do
project
.
update_columns
(
avatar:
'uploads/avatar.png'
)
allow
(
project
.
avatar
).
to
receive
(
:present?
)
{
true
}
end
let
(
:avatar_path
)
do
"/uploads/project/avatar/
#{
project
.
id
}
/uploads/avatar.png"
end
it
{
should
eq
"http://localhost
#{
avatar_path
}
"
}
end
context
'When avatar file in git'
do
before
do
allow
(
project
).
to
receive
(
:avatar_in_git
)
{
true
}
end
let
(
:avatar_path
)
do
"/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/avatar"
end
it
{
should
eq
"http://localhost
#{
avatar_path
}
"
}
end
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