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
7e4529f2
Commit
7e4529f2
authored
14 years ago
by
Sarah Mei
Browse files
Options
Downloads
Patches
Plain Diff
im in ur test stubbin ur mailers
parent
6620f33a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spec/controllers/publics_controller_spec.rb
+11
-8
11 additions, 8 deletions
spec/controllers/publics_controller_spec.rb
spec/lib/diaspora_parser_spec.rb
+45
-37
45 additions, 37 deletions
spec/lib/diaspora_parser_spec.rb
with
56 additions
and
45 deletions
spec/controllers/publics_controller_spec.rb
+
11
−
8
View file @
7e4529f2
...
...
@@ -6,10 +6,10 @@ require 'spec_helper'
describe
PublicsController
do
render_views
let
(
:user
)
{
Factory
.
create
:user
}
let
(
:user2
)
{
Factory
.
create
:user
}
let
(
:aspect1
)
{
user
.
aspect
(
:name
=>
"foo"
)}
let
(
:aspect2
)
{
user2
.
aspect
(
:name
=>
"far"
)}
let
(
:user
)
{
Factory
.
create
:user
}
let
(
:user2
)
{
Factory
.
create
:user
}
let
(
:aspect1
)
{
user
.
aspect
(
:name
=>
"foo"
)
}
let
(
:aspect2
)
{
user2
.
aspect
(
:name
=>
"far"
)
}
before
do
sign_in
:user
,
user
end
...
...
@@ -23,7 +23,7 @@ describe PublicsController do
it
'should accept a post from another node and save the information'
do
message
=
user2
.
build_post
(
:status_message
,
:message
=>
"hi"
)
friend_users
(
user
,
aspect1
,
user2
,
aspect2
)
user
.
reload
user
.
visible_post_ids
.
include?
(
message
.
id
).
should
be
false
...
...
@@ -77,10 +77,13 @@ describe PublicsController do
end
describe
'friend requests'
do
let
(
:aspect2
)
{
user2
.
aspect
(
:name
=>
'disciples'
)}
let!
(
:req
)
{
user2
.
send_friend_request_to
(
user
.
person
,
aspect2
)}
let!
(
:xml
)
{
user2
.
salmon
(
req
).
xml_for
(
user
.
person
)}
let
(
:aspect2
)
{
user2
.
aspect
(
:name
=>
'disciples'
)
}
let!
(
:req
)
{
user2
.
send_friend_request_to
(
user
.
person
,
aspect2
)
}
let!
(
:xml
)
{
user2
.
salmon
(
req
).
xml_for
(
user
.
person
)
}
before
do
deliverable
=
Object
.
new
deliverable
.
stub!
(
:deliver
)
Notifier
.
stub!
(
:new_request
).
and_return
(
deliverable
)
req
.
delete
user2
.
reload
user2
.
pending_requests
.
count
.
should
be
1
...
...
This diff is collapsed.
Click to expand it.
spec/lib/diaspora_parser_spec.rb
+
45
−
37
View file @
7e4529f2
...
...
@@ -5,15 +5,15 @@
require
'spec_helper'
describe
Diaspora
::
Parser
do
let
(
:user
)
{
Factory
.
create
(
:user
)}
let
(
:aspect
)
{
user
.
aspect
(
:name
=>
'spies'
)}
let
(
:user2
)
{
Factory
.
create
(
:user
)}
let
(
:aspect2
)
{
user2
.
aspect
(
:name
=>
"pandas"
)}
let
(
:user3
)
{
Factory
.
create
:user
}
let
(
:person
)
{
user3
.
person
}
let
(
:user
)
{
Factory
.
create
(
:user
)
}
let
(
:aspect
)
{
user
.
aspect
(
:name
=>
'spies'
)
}
let
(
:user2
)
{
Factory
.
create
(
:user
)
}
let
(
:aspect2
)
{
user2
.
aspect
(
:name
=>
"pandas"
)
}
let
(
:user3
)
{
Factory
.
create
:user
}
let
(
:person
)
{
user3
.
person
}
describe
"parsing compliant XML object"
do
it
'should be able to correctly handle comments with person in db'
do
it
'should be able to correctly handle comments with person in db'
do
post
=
user
.
post
:status_message
,
:message
=>
"hello"
,
:to
=>
aspect
.
id
comment
=
Factory
.
build
(
:comment
,
:post
=>
post
,
:person
=>
@person
,
:text
=>
"Freedom!"
)
xml
=
comment
.
to_diaspora_xml
...
...
@@ -25,7 +25,7 @@ describe Diaspora::Parser do
end
it
'should be able to correctly handle person on a comment with person not in db'
do
friend_users
(
user
,
aspect
,
user2
,
aspect2
)
friend_users
(
user
,
aspect
,
user2
,
aspect2
)
post
=
user
.
post
:status_message
,
:message
=>
"hello"
,
:to
=>
aspect
.
id
comment
=
user2
.
comment
"Fool!"
,
:on
=>
post
...
...
@@ -40,42 +40,50 @@ describe Diaspora::Parser do
end
it
'should accept retractions'
do
friend_users
(
user
,
aspect
,
user2
,
aspect2
)
friend_users
(
user
,
aspect
,
user2
,
aspect2
)
message
=
Factory
.
create
(
:status_message
,
:person
=>
user2
.
person
)
retraction
=
Retraction
.
for
(
message
)
xml
=
retraction
.
to_diaspora_xml
proc
{
user
.
receive
xml
,
user2
.
person
}.
should
change
(
StatusMessage
,
:count
).
by
(
-
1
)
proc
{
user
.
receive
xml
,
user2
.
person
}.
should
change
(
StatusMessage
,
:count
).
by
(
-
1
)
end
it
"should create a new person upon getting a person request"
do
request
=
Request
.
instantiate
(
:to
=>
"http://www.google.com/"
,
:from
=>
person
)
context
"friending"
do
before
do
deliverable
=
Object
.
new
deliverable
.
stub!
(
:deliver
)
Notifier
.
stub!
(
:new_request
).
and_return
(
deliverable
)
end
xml
=
request
.
to_diaspora_xml
it
"should create a new person upon getting a person request"
do
request
=
Request
.
instantiate
(
:to
=>
"http://www.google.com/"
,
:from
=>
person
)
user3
.
destroy
person
.
destroy
user
lambda
{
user
.
receive
xml
,
person
}.
should
change
(
Person
,
:count
).
by
(
1
)
end
xml
=
request
.
to_diaspora_xml
it
"should not create a new person if the person is already here"
do
request
=
Request
.
instantiate
(
:to
=>
"http://www.google.com/"
,
:from
=>
user2
.
person
)
original_person_id
=
user2
.
person
.
id
xml
=
request
.
to_diaspora_xml
user
lambda
{
user
.
receive
xml
,
user2
.
person
}.
should_not
change
(
Person
,
:count
)
user3
.
destroy
person
.
destroy
user
lambda
{
user
.
receive
xml
,
person
}.
should
change
(
Person
,
:count
).
by
(
1
)
end
it
"should not create a new person if the person is already here"
do
request
=
Request
.
instantiate
(
:to
=>
"http://www.google.com/"
,
:from
=>
user2
.
person
)
original_person_id
=
user2
.
person
.
id
xml
=
request
.
to_diaspora_xml
user
lambda
{
user
.
receive
xml
,
user2
.
person
}.
should_not
change
(
Person
,
:count
)
user2
.
reload
user2
.
person
.
reload
user2
.
serialized_private_key
.
include?
(
"PRIVATE"
).
should
be
true
user2
.
reload
user2
.
person
.
reload
user2
.
serialized_private_key
.
include?
(
"PRIVATE"
).
should
be
true
url
=
"http://"
+
request
.
callback_url
.
split
(
"/"
)[
2
]
+
"/"
Person
.
where
(
:url
=>
url
).
first
.
id
.
should
==
original_person_id
url
=
"http://"
+
request
.
callback_url
.
split
(
"/"
)[
2
]
+
"/"
Person
.
where
(
:url
=>
url
).
first
.
id
.
should
==
original_person_id
end
end
it
"should activate the Person if I initiated a request to that url"
do
request
=
user
.
send_friend_request_to
(
user3
.
person
,
aspect
)
request
=
user
.
send_friend_request_to
(
user3
.
person
,
aspect
)
user
.
reload
request
.
reverse_for
user3
...
...
@@ -95,16 +103,16 @@ describe Diaspora::Parser do
end
it
'should process retraction for a person'
do
friend_users
(
user
,
aspect
,
user2
,
aspect2
)
friend_users
(
user
,
aspect
,
user2
,
aspect2
)
retraction
=
Retraction
.
for
(
user2
)
retraction_xml
=
retraction
.
to_diaspora_xml
lambda
{
user
.
receive
retraction_xml
,
user2
.
person
}.
should
change
{
aspect
.
reload
.
people
.
size
}.
by
(
-
1
)
lambda
{
user
.
receive
retraction_xml
,
user2
.
person
}.
should
change
{
aspect
.
reload
.
people
.
size
}.
by
(
-
1
)
end
it
'should marshal a profile for a person'
do
friend_users
(
user
,
aspect
,
user2
,
aspect2
)
friend_users
(
user
,
aspect
,
user2
,
aspect2
)
#Create person
person
=
user2
.
person
id
=
person
.
id
...
...
@@ -132,9 +140,9 @@ describe Diaspora::Parser do
person
=
Person
.
first
(
:id
=>
person
.
id
)
person
.
profile
.
should_not
be
nil
person
.
profile
.
first_name
.
should
==
old_profile
.
first_name
person
.
profile
.
last_name
.
should
==
old_profile
.
last_name
person
.
profile
.
image_url
.
should
==
old_profile
.
image_url
end
person
.
profile
.
last_name
.
should
==
old_profile
.
last_name
person
.
profile
.
image_url
.
should
==
old_profile
.
image_url
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