Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
diaspora
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Milan
diaspora
Commits
bef6d76b
Commit
bef6d76b
authored
14 years ago
by
Raphael
Browse files
Options
Downloads
Patches
Plain Diff
Refactor specs a little more
parent
e1cdcc68
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spec/models/aspect_spec.rb
+2
-12
2 additions, 12 deletions
spec/models/aspect_spec.rb
spec/models/comments_spec.rb
+86
-99
86 additions, 99 deletions
spec/models/comments_spec.rb
with
88 additions
and
111 deletions
spec/models/aspect_spec.rb
+
2
−
12
View file @
bef6d76b
...
...
@@ -63,10 +63,6 @@ describe Aspect do
before
do
aspect
user
.
activate_friend
(
friend
,
aspect
)
aspect2
friend_users
(
user
,
aspect
,
user2
,
aspect2
)
aspect
.
reload
user
.
reload
end
it
'belong to a user'
do
...
...
@@ -76,7 +72,7 @@ describe Aspect do
it
'should have people'
do
aspect
.
people
.
all
.
include?
(
friend
).
should
be
true
aspect
.
people
.
size
.
should
==
2
aspect
.
people
.
size
.
should
==
1
end
describe
'#aspects_with_person'
do
...
...
@@ -85,10 +81,7 @@ describe Aspect do
user
.
reload
aspects
=
user
.
aspects_with_person
(
friend
)
aspects
.
size
.
should
==
1
aspects
.
first
.
id
.
should
==
aspect
.
id
aspects
.
first
.
people
.
size
.
should
==
2
aspects
.
first
.
people
.
include?
(
friend
).
should
be
true
aspects
.
first
.
people
.
include?
(
user2
.
person
).
should
be
true
aspects
.
first
.
should
==
aspect
end
it
'returns multiple aspects if the person is there'
do
...
...
@@ -99,7 +92,6 @@ describe Aspect do
aspects
.
each
{
|
asp
|
asp
.
people
.
include?
(
friend
)
}
aspects
.
should_not
include
aspect_without_friend
end
end
end
...
...
@@ -150,8 +142,6 @@ describe Aspect do
end
context
"aspect management"
do
before
do
friend_users
(
user
,
aspect
,
user2
,
aspect2
)
aspect
.
reload
...
...
This diff is collapsed.
Click to expand it.
spec/models/comments_spec.rb
+
86
−
99
View file @
bef6d76b
...
...
@@ -5,140 +5,127 @@
require
'spec_helper'
describe
Comment
do
describe
"user"
do
before
do
@user
=
Factory
.
create
:user
@aspect
=
@user
.
aspect
(
:name
=>
"Doofuses"
)
let
(
:user
)
{
Factory
.
create
:user
}
let
(
:aspect
)
{
user
.
aspect
(
:name
=>
"Doofuses"
)}
@user2
=
Factory
.
create
(
:user
)
@aspect2
=
@user2
.
aspect
(
:name
=>
"Lame-faces"
)
end
let
(
:user2
)
{
Factory
.
create
(
:user
)}
let
(
:aspect2
)
{
user2
.
aspect
(
:name
=>
"Lame-faces"
)}
describe
'User#comment'
do
let
(
:status
)
{
user
.
post
(
:status_message
,
:message
=>
"hello"
,
:to
=>
aspect
)}
it
"should be able to comment on his own status"
do
status
=
Factory
.
create
(
:status_message
,
:person
=>
@user
.
person
)
status
.
comments
.
should
==
[]
@
user
.
comment
"Yeah, it was great"
,
:on
=>
status
user
.
comment
"Yeah, it was great"
,
:on
=>
status
status
.
reload
.
comments
.
first
.
text
.
should
==
"Yeah, it was great"
end
it
"should be able to comment on a person's status"
do
person
=
Factory
.
create
:person
status
=
Factory
.
create
(
:status_message
,
:person
=>
person
)
@user
.
comment
"sup dog"
,
:on
=>
status
user2
.
comment
"sup dog"
,
:on
=>
status
status
.
reload
.
comments
.
first
.
text
.
should
==
"sup dog"
status
.
reload
.
comments
.
first
.
person
.
should
==
@user
.
person
end
end
it
'should not send out comments when we have no people'
do
status
=
Factory
.
create
(
:status_message
,
:person
=>
@
user
.
person
)
User
::
QUEUE
.
should_not_receive
(
:add_post_request
)
@
user
.
comment
"sup dog"
,
:on
=>
status
end
it
'should not send out comments when we have no people'
do
status
=
Factory
.
create
(
:status_message
,
:person
=>
user
.
person
)
User
::
QUEUE
.
should_not_receive
(
:add_post_request
)
user
.
comment
"sup dog"
,
:on
=>
status
end
describe
'comment propagation'
do
before
do
friend_users
(
@
user
,
Aspect
.
first
(
:id
=>
@
aspect
.
id
)
,
@
user2
,
@
aspect2
)
describe
'comment propagation'
do
before
do
friend_users
(
user
,
aspect
,
user2
,
aspect2
)
@person
=
Factory
.
create
(
:person
)
@
user
.
activate_friend
(
@person
,
Aspect
.
first
(
:id
=>
@
aspect
.
id
))
@person
=
Factory
.
create
(
:person
)
user
.
activate_friend
(
@person
,
Aspect
.
first
(
:id
=>
aspect
.
id
))
@person2
=
Factory
.
create
(
:person
)
@person_status
=
Factory
.
build
(
:status_message
,
:person
=>
@person
)
@person2
=
Factory
.
create
(
:person
)
@person_status
=
Factory
.
build
(
:status_message
,
:person
=>
@person
)
@
user
.
reload
@
user_status
=
@
user
.
post
:status_message
,
:message
=>
"hi"
,
:to
=>
@
aspect
.
id
user
.
reload
user_status
=
user
.
post
:status_message
,
:message
=>
"hi"
,
:to
=>
aspect
.
id
@
aspect
.
reload
@
user
.
reload
end
aspect
.
reload
user
.
reload
end
it
'should receive a comment from a person not on the pod'
do
user3
=
Factory
.
create
:user
aspect3
=
user3
.
aspect
(
:name
=>
"blah"
)
it
'should receive a comment from a person not on the pod'
do
user3
=
Factory
.
create
:user
aspect3
=
user3
.
aspect
(
:name
=>
"blah"
)
friend_users
(
@user
,
@aspect
,
user3
,
aspect3
)
comment
=
Comment
.
new
(
:person_id
=>
user3
.
person
.
id
,
:text
=>
"hey"
,
:post
=>
@user_status
)
comment
.
creator_signature
=
comment
.
sign_with_key
(
user3
.
encryption_key
)
friend_users
(
user
,
aspect
,
user3
,
aspect3
)
comment
=
Comment
.
new
(
:person_id
=>
user3
.
person
.
id
,
:text
=>
"hey"
,
:post
=>
user_status
)
comment
.
creator_signature
=
comment
.
sign_with_key
(
user3
.
encryption_key
)
comment
.
post_creator_signature
=
comment
.
sign_with_key
(
@user
.
encryption_key
)
xml
=
@user
.
salmon
(
comment
).
xml_for
(
@user2
)
user3
.
person
.
delete
user3
.
delete
comment
.
post_creator_signature
=
comment
.
sign_with_key
(
user
.
encryption_key
)
xml
=
user
.
salmon
(
comment
).
xml_for
(
user2
)
@user_status
.
reload
@user_status
.
comments
.
should
==
[]
@user2
.
receive_salmon
(
xml
)
@user_status
.
reload
@user_status
.
comments
.
include?
(
comment
).
should
be
true
end
user3
.
person
.
delete
user3
.
delete
it
'should have the post in the aspects post list'
do
aspect
=
Aspect
.
first
(
:id
=>
@aspect
.
id
)
aspect
.
people
.
size
.
should
==
2
aspect
.
post_ids
.
include?
(
@user_status
.
id
).
should
be
true
end
it
"should send a user's comment on a person's post to that person"
do
User
::
QUEUE
.
should_receive
(
:add_post_request
)
@user
.
comment
"yo"
,
:on
=>
@person_status
end
user_status
.
reload
user_status
.
comments
.
should
==
[]
user
.
receive_salmon
(
xml
)
user_status
.
reload
user_status
.
comments
.
include?
(
comment
).
should
be
true
end
it
'should send a user comment on his own post to lots of people'
do
it
"should send a user's comment on a person's post to that person"
do
User
::
QUEUE
.
should_receive
(
:add_post_request
)
user
.
comment
"yo"
,
:on
=>
@person_status
end
User
::
QUEUE
.
should_receive
(
:add_post_request
).
twice
@user
.
comment
"yo"
,
:on
=>
@user_status
end
it
'should send a user comment on his own post to lots of people'
do
it
'should send a comment a person made on your post to all people'
do
comment
=
Comment
.
new
(
:person_id
=>
@person
.
id
,
:text
=>
"balls"
,
:post
=>
@user_status
)
User
::
QUEUE
.
should_receive
(
:add_post_request
).
twice
@user
.
receive
comment
.
to_diaspora_xml
,
@person
end
User
::
QUEUE
.
should_receive
(
:add_post_request
).
twice
user
.
comment
"yo"
,
:on
=>
user_status
end
it
'should send a comment a user made on your post to all people'
do
it
'should send a comment a person made on your post to all people'
do
comment
=
Comment
.
new
(
:person_id
=>
@person
.
id
,
:text
=>
"balls"
,
:post
=>
user_status
)
User
::
QUEUE
.
should_receive
(
:add_post_request
).
twice
user
.
receive
comment
.
to_diaspora_xml
,
@person
end
comment
=
@user2
.
comment
(
"balls"
,
:on
=>
@user_status
)
User
::
QUEUE
.
should_receive
(
:add_post_request
).
twice
@user
.
receive
comment
.
to_diaspora_xml
,
@user2
.
person
end
it
'should send a comment a user made on your post to all people'
do
comment
=
user2
.
comment
(
"balls"
,
:on
=>
user_status
)
User
::
QUEUE
.
should_receive
(
:add_post_request
).
twice
user
.
receive
comment
.
to_diaspora_xml
,
user2
.
person
end
it
'should not send a comment a person made on his own post to anyone'
do
User
::
QUEUE
.
should_not_receive
(
:add_post_request
)
comment
=
Comment
.
new
(
:person_id
=>
@person
.
id
,
:text
=>
"balls"
,
:post
=>
@person_status
)
@
user
.
receive
comment
.
to_diaspora_xml
,
@person
end
it
'should not send a comment a person made on his own post to anyone'
do
User
::
QUEUE
.
should_not_receive
(
:add_post_request
)
comment
=
Comment
.
new
(
:person_id
=>
@person
.
id
,
:text
=>
"balls"
,
:post
=>
@person_status
)
user
.
receive
comment
.
to_diaspora_xml
,
@person
end
it
'should not send a comment a person made on a person post to anyone'
do
User
::
QUEUE
.
should_not_receive
(
:add_post_request
)
comment
=
Comment
.
new
(
:person_id
=>
@person2
.
id
,
:text
=>
"balls"
,
:post
=>
@person_status
)
@
user
.
receive
comment
.
to_diaspora_xml
,
@person
end
it
'should not send a comment a person made on a person post to anyone'
do
User
::
QUEUE
.
should_not_receive
(
:add_post_request
)
comment
=
Comment
.
new
(
:person_id
=>
@person2
.
id
,
:text
=>
"balls"
,
:post
=>
@person_status
)
user
.
receive
comment
.
to_diaspora_xml
,
@person
end
it
'should not clear the aspect post array on receiving a comment'
do
@
aspect
.
post_ids
.
include?
(
@
user_status
.
id
).
should
be
true
comment
=
Comment
.
new
(
:person_id
=>
@person
.
id
,
:text
=>
"balls"
,
:post
=>
@
user_status
)
it
'should not clear the aspect post array on receiving a comment'
do
aspect
.
post_ids
.
include?
(
user_status
.
id
).
should
be
true
comment
=
Comment
.
new
(
:person_id
=>
@person
.
id
,
:text
=>
"balls"
,
:post
=>
user_status
)
@
user
.
receive
comment
.
to_diaspora_xml
,
@person
user
.
receive
comment
.
to_diaspora_xml
,
@person
@aspect
.
reload
@aspect
.
post_ids
.
include?
(
@user_status
.
id
).
should
be
true
end
aspect
.
reload
aspect
.
post_ids
.
include?
(
user_status
.
id
).
should
be
true
end
describe
'serialization'
do
it
'should serialize the commenter
'
do
commenter
=
Factory
.
create
(
:user
)
commenter
_aspect
=
commenter
.
aspect
:name
=>
"brui
ser
s"
friend_users
(
@user
,
@aspect
,
commenter
,
commenter
_
aspect
)
post
=
@user
.
post
:status_message
,
:message
=>
"hello"
,
:to
=>
@
aspect
.
id
comment
=
commenter
.
comment
"Fool!
"
,
:o
n
=>
post
comment
.
person
.
should_not
==
@user
.
person
comment
.
to_diaspora_xml
.
include?
(
commenter
.
person
.
id
.
to_s
).
should
be
true
end
end
describe
'serialization
'
do
it
'should serialize the commenter'
do
commenter
=
Factory
.
create
(
:u
ser
)
commenter_aspect
=
commenter
.
aspect
:name
=>
"bruisers"
friend_users
(
user
,
aspect
,
commenter
,
commenter_
aspect
)
post
=
user
.
post
:status_message
,
:message
=>
"hello
"
,
:
t
o
=>
aspect
.
id
comment
=
commenter
.
comment
"Fool!"
,
:on
=>
post
comment
.
person
.
should_not
==
user
.
person
comment
.
to_diaspora_xml
.
include?
(
commenter
.
person
.
id
.
to_s
).
should
be
true
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment