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
1b752968
Commit
1b752968
authored
Oct 02, 2017
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Linting errors + tests
parent
892b02e8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
14 deletions
+13
-14
app/helpers/lazy_image_tag_helper.rb
app/helpers/lazy_image_tag_helper.rb
+1
-1
app/models/concerns/avatarable.rb
app/models/concerns/avatarable.rb
+2
-4
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+4
-2
spec/helpers/groups_helper_spec.rb
spec/helpers/groups_helper_spec.rb
+6
-7
No files found.
app/helpers/lazy_image_tag_helper.rb
View file @
1b752968
...
...
@@ -9,7 +9,7 @@ module LazyImageTagHelper
unless
options
.
delete
(
:lazy
)
==
false
options
[
:data
]
||=
{}
unless
options
.
delete
(
:use_original_source
)
==
true
unless
options
.
delete
(
:use_original_source
)
options
[
:data
][
:src
]
=
path_to_image
(
source
)
else
options
[
:data
][
:src
]
=
source
...
...
app/models/concerns/avatarable.rb
View file @
1b752968
...
...
@@ -13,10 +13,8 @@ module Avatarable
# If asset_host is set then it is expected that assets are handled by a standalone host.
# That means we do not want to get GitLab's relative_url_root option anymore.
host
=
asset_host
.
present?
?
asset_host
:
gitlab_host
end
[
host
,
avatar
.
url
].
join
else
[
host
,
avatar
.
url
].
join
end
end
end
spec/helpers/application_helper_spec.rb
View file @
1b752968
...
...
@@ -57,6 +57,8 @@ describe ApplicationHelper do
end
describe
'project_icon'
do
let
(
:asset_host
)
{
'http://assets'
}
it
'returns an url for the avatar'
do
project
=
create
(
:project
,
avatar:
File
.
open
(
uploaded_image_temp_path
))
avatar_url
=
"/uploads/-/system/project/avatar/
#{
project
.
id
}
/banana_sample.gif"
...
...
@@ -64,8 +66,8 @@ describe ApplicationHelper do
expect
(
helper
.
project_icon
(
project
.
full_path
).
to_s
)
.
to
eq
"<img data-src=
\"
#{
avatar_url
}
\"
class=
\"
lazy
\"
src=
\"
#{
LazyImageTagHelper
.
placeholder_image
}
\"
/>"
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
gitlab
_host
)
avatar_url
=
"
#{
gitlab
_host
}
/uploads/-/system/project/avatar/
#{
project
.
id
}
/banana_sample.gif"
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
asset
_host
)
avatar_url
=
"
#{
asset
_host
}
/uploads/-/system/project/avatar/
#{
project
.
id
}
/banana_sample.gif"
expect
(
helper
.
project_icon
(
project
.
full_path
).
to_s
)
.
to
eq
"<img data-src=
\"
#{
avatar_url
}
\"
class=
\"
lazy
\"
src=
\"
#{
LazyImageTagHelper
.
placeholder_image
}
\"
/>"
...
...
spec/helpers/groups_helper_spec.rb
View file @
1b752968
...
...
@@ -3,6 +3,7 @@ require 'spec_helper'
describe
GroupsHelper
do
include
ApplicationHelper
let
(
:asset_host
)
{
'http://assets'
}
describe
'group_icon'
do
avatar_file_path
=
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
...
...
@@ -17,16 +18,14 @@ describe GroupsHelper do
expect
(
group_icon
(
group
).
to_s
)
.
to
eq
"<img data-src=
\"
#{
avatar_url
}
\"
class=
\"
lazy
\"
src=
\"
#{
LazyImageTagHelper
.
placeholder_image
}
\"
/>"
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
gitlab
_host
)
avatar_url
=
"
#{
gitlab
_host
}
/uploads/-/system/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
asset
_host
)
avatar_url
=
"
#{
asset
_host
}
/uploads/-/system/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
expect
(
group_icon
(
group
).
to_s
)
.
to
eq
"<img data-src=
\"
#{
avatar_url
}
\"
class=
\"
lazy
\"
src=
\"
#{
LazyImageTagHelper
.
placeholder_image
}
\"
/>"
end
end
describe
'group_icon_url'
do
avatar_file_path
=
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
...
...
@@ -39,16 +38,16 @@ describe GroupsHelper do
end
it
'returns an CDN url for the avatar'
do
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
gitlab
_host
)
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
asset
_host
)
group
=
create
(
:group
)
group
.
avatar
=
fixture_file_upload
(
avatar_file_path
)
group
.
save!
expect
(
group_icon_url
(
group
.
path
).
to_s
)
.
to
match
(
"
#{
gitlab
_host
}
/uploads/-/system/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
)
.
to
match
(
"
#{
asset
_host
}
/uploads/-/system/group/avatar/
#{
group
.
id
}
/banana_sample.gif"
)
end
it
'returns an based url for the avatar if private'
do
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
gitlab
_host
)
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
asset
_host
)
group
=
create
(
:group
)
group
.
avatar
=
fixture_file_upload
(
avatar_file_path
)
group
.
private
=
true
...
...
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