Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Milan
diaspora
Commits
04035c3e
Unverified
Commit
04035c3e
authored
Aug 27, 2017
by
Benjamin Neff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to receive reshares without root
closes #7590
parent
163ffdb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
app/models/reshare.rb
app/models/reshare.rb
+1
-1
spec/models/reshare_spec.rb
spec/models/reshare_spec.rb
+7
-2
No files found.
app/models/reshare.rb
View file @
04035c3e
...
...
@@ -5,7 +5,7 @@
class
Reshare
<
Post
belongs_to
:root
,
class_name:
"Post"
,
foreign_key: :root_guid
,
primary_key: :guid
,
optional:
true
validate
:root_must_be_public
validates
_presence_of
:root
,
:on
=>
:create
validates
:root
,
presence:
true
,
on: :create
,
if:
proc
{
|
reshare
|
reshare
.
author
.
local?
}
validates
:root_guid
,
uniqueness:
{
scope: :author_id
},
allow_nil:
true
delegate
:author
,
to: :root
,
prefix:
true
...
...
spec/models/reshare_spec.rb
View file @
04035c3e
...
...
@@ -4,11 +4,16 @@ describe Reshare, type: :model do
end
context
"validation"
do
it
"requires root"
do
reshare
=
FactoryGirl
.
build
(
:reshare
,
root:
nil
)
it
"requires root
when the author is local
"
do
reshare
=
FactoryGirl
.
build
(
:reshare
,
root:
nil
,
author:
alice
.
person
)
expect
(
reshare
).
not_to
be_valid
end
it
"doesn't require root when the author is remote"
do
reshare
=
FactoryGirl
.
build
(
:reshare
,
root:
nil
,
author:
remote_raphael
)
expect
(
reshare
).
to
be_valid
end
it
"require public root"
do
reshare
=
FactoryGirl
.
build
(
:reshare
,
root:
FactoryGirl
.
create
(
:status_message
,
public:
false
))
expect
(
reshare
).
not_to
be_valid
...
...
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