Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
diaspora
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Milan
diaspora
Commits
ae2cecef
Unverified
Commit
ae2cecef
authored
Aug 22, 2016
by
Dennis Schubert
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7018 from SuperTux88/fix-reshare-metadata
Fix regressions from #6998
parents
cd4f2841
4b020b8d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
6 deletions
+49
-6
app/presenters/post_presenter.rb
app/presenters/post_presenter.rb
+4
-5
spec/presenters/post_presenter_spec.rb
spec/presenters/post_presenter_spec.rb
+45
-1
No files found.
app/presenters/post_presenter.rb
View file @
ae2cecef
...
...
@@ -20,7 +20,7 @@ class PostPresenter < BasePresenter
description:
{
name:
"description"
,
content:
description
},
og_url:
{
property:
"og:url"
,
content:
url
},
og_title:
{
property:
"og:title"
,
content:
title
},
og_image:
{
property:
"og:image"
,
content:
images
},
og_image:
{
property:
"og:image"
,
content:
images
},
og_description:
{
property:
"og:description"
,
content:
description
},
og_article_tag:
{
property:
"og:article:tag"
,
content:
tags
},
og_article_author:
{
property:
"og:article:author"
,
content:
author_name
},
...
...
@@ -138,9 +138,8 @@ class PostPresenter < BasePresenter
end
def
tags
tags
=
@post
.
is_a?
(
Reshare
)
?
@post
.
root
.
tags
:
@post
.
tags
return
tags
.
map
(
&
:name
)
if
tags
[]
tags
=
@post
.
is_a?
(
Reshare
)
?
@post
.
absolute_root
.
try
(
:tags
)
:
@post
.
tags
tags
?
tags
.
map
(
&
:name
)
:
[]
end
def
comma_separated_tags
...
...
@@ -152,6 +151,6 @@ class PostPresenter < BasePresenter
end
def
description
message
.
plain_text_without_markdown
(
truncate:
1000
)
message
.
try
(
:plain_text_without_markdown
,
truncate:
1000
)
end
end
spec/presenters/post_presenter_spec.rb
View file @
ae2cecef
...
...
@@ -75,7 +75,7 @@ describe PostPresenter do
end
context
"with posts without text"
do
it
"
displays a messaage with the post class"
do
it
"displays a messaage with the post class"
do
@sm
=
double
(
message:
double
(
present?:
false
),
author:
bob
.
person
,
author_name:
bob
.
person
.
name
)
@presenter
.
post
=
@sm
expect
(
@presenter
.
send
(
:title
)).
to
eq
(
"A post from
#{
@sm
.
author
.
name
}
"
)
...
...
@@ -89,4 +89,48 @@ describe PostPresenter do
expect
(
presenter
.
as_json
).
to
be_a
(
Hash
)
end
end
describe
"#tags"
do
it
"returns the tag of the post"
do
post
=
FactoryGirl
.
create
(
:status_message
,
text:
"#hello #world"
,
public:
true
)
expect
(
PostPresenter
.
new
(
post
).
send
(
:tags
)).
to
match_array
(
%w(hello world)
)
end
it
"returns the tag of the absolute_root of a Reshare"
do
post
=
FactoryGirl
.
create
(
:status_message
,
text:
"#hello #world"
,
public:
true
)
first_reshare
=
FactoryGirl
.
create
(
:reshare
,
root:
post
)
second_reshare
=
FactoryGirl
.
create
(
:reshare
,
root:
first_reshare
)
expect
(
PostPresenter
.
new
(
second_reshare
).
send
(
:tags
)).
to
match_array
(
%w(hello world)
)
end
it
"does not raise if the root of a reshare does not exist anymore"
do
reshare
=
FactoryGirl
.
create
(
:reshare
)
reshare
.
root
=
nil
expect
(
PostPresenter
.
new
(
reshare
).
send
(
:tags
)).
to
eq
([])
end
end
describe
"#description"
do
it
"returns the first 1000 chars of the text"
do
post
=
FactoryGirl
.
create
(
:status_message
,
text:
"a"
*
1001
,
public:
true
)
expect
(
PostPresenter
.
new
(
post
).
send
(
:description
)).
to
eq
(
"
#{
'a'
*
997
}
..."
)
end
it
"does not change the message if less or equal 1000 chars"
do
post
=
FactoryGirl
.
create
(
:status_message
,
text:
"a"
*
1000
,
public:
true
)
expect
(
PostPresenter
.
new
(
post
).
send
(
:description
)).
to
eq
(
"a"
*
1000
)
end
it
"does not raise if the root of a reshare does not exist anymore"
do
reshare
=
FactoryGirl
.
create
(
:reshare
)
reshare
.
root
=
nil
expect
(
PostPresenter
.
new
(
reshare
).
send
(
:description
)).
to
eq
(
nil
)
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