Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
parlote-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
parlote-facil
Validations
199eb894
Valider
199eb894
rédigé
14 years ago
par
Raphael
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
clean up posting spec, move socket_to_uid into add_to_streams
parent
836b5685
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
app/models/user.rb
+6
-16
6 ajouts, 16 suppressions
app/models/user.rb
spec/models/user/posting_spec.rb
+24
-31
24 ajouts, 31 suppressions
spec/models/user/posting_spec.rb
avec
30 ajouts
et
47 suppressions
app/models/user.rb
+
6
−
16
Voir le fichier @
199eb894
...
@@ -166,8 +166,7 @@ class User
...
@@ -166,8 +166,7 @@ class User
#socket post
#socket post
Rails
.
logger
.
info
(
"event=dispatch user=
#{
diaspora_handle
}
post=
#{
post
.
id
.
to_s
}
"
)
Rails
.
logger
.
info
(
"event=dispatch user=
#{
diaspora_handle
}
post=
#{
post
.
id
.
to_s
}
"
)
push_to_aspects
(
post
,
aspect_ids
)
push_to_aspects
(
post
,
aspects_from_ids
(
aspect_ids
))
post
.
socket_to_uid
(
id
,
:aspect_ids
=>
aspect_ids
)
if
post
.
respond_to?
(
:socket_to_uid
)
&&
!
post
.
pending
if
post
.
public
if
post
.
public
self
.
services
.
each
do
|
service
|
self
.
services
.
each
do
|
service
|
...
@@ -200,6 +199,7 @@ class User
...
@@ -200,6 +199,7 @@ class User
self
.
raw_visible_posts
<<
post
self
.
raw_visible_posts
<<
post
self
.
save
self
.
save
post
.
socket_to_uid
(
id
,
:aspect_ids
=>
aspect_ids
)
if
post
.
respond_to?
:socket_to_uid
target_aspects
=
aspects_from_ids
(
aspect_ids
)
target_aspects
=
aspects_from_ids
(
aspect_ids
)
target_aspects
.
each
do
|
aspect
|
target_aspects
.
each
do
|
aspect
|
aspect
.
posts
<<
post
aspect
.
posts
<<
post
...
@@ -219,23 +219,13 @@ class User
...
@@ -219,23 +219,13 @@ class User
end
end
end
end
def
push_to_aspects
(
post
,
aspect_ids
)
def
push_to_aspects
(
post
,
aspects
)
if
aspect_ids
==
:all
||
aspect_ids
==
"all"
aspects
=
self
.
aspects
elsif
aspect_ids
.
is_a?
(
Array
)
&&
aspect_ids
.
first
.
class
==
Aspect
aspects
=
aspect_ids
else
aspects
=
self
.
aspects
.
find_all_by_id
(
aspect_ids
)
end
#send to the aspects
#send to the aspects
target_contacts
=
[]
target_contacts
=
aspects
.
inject
([])
{
|
contacts
,
aspect
|
contacts
=
contacts
|
aspect
.
contacts
aspects
.
each
{
|
aspect
|
target_contacts
=
target_contacts
|
aspect
.
contacts
}
}
push_to_hub
(
post
)
if
post
.
respond_to?
(
:public
)
&&
post
.
public
push_to_hub
(
post
)
if
post
.
respond_to?
(
:public
)
&&
post
.
public
push_to_people
(
post
,
self
.
person_objects
(
target_contacts
))
push_to_people
(
post
,
self
.
person_objects
(
target_contacts
))
end
end
...
@@ -250,7 +240,7 @@ class User
...
@@ -250,7 +240,7 @@ class User
person
.
reload
# Sadly, we need this for Ruby 1.9.
person
.
reload
# Sadly, we need this for Ruby 1.9.
# person.owner will always return a ProxyObject.
# person.owner will always return a ProxyObject.
# calling nil? performs a necessary evaluation.
# calling nil? performs a necessary evaluation.
unless
person
.
owner
.
nil?
if
person
.
owner
_id
Rails
.
logger
.
info
(
"event=push_to_person route=local sender=
#{
self
.
diaspora_handle
}
recipient=
#{
person
.
diaspora_handle
}
payload_type=
#{
post
.
class
}
"
)
Rails
.
logger
.
info
(
"event=push_to_person route=local sender=
#{
self
.
diaspora_handle
}
recipient=
#{
person
.
diaspora_handle
}
payload_type=
#{
post
.
class
}
"
)
person
.
owner
.
receive
(
post
.
to_diaspora_xml
,
self
.
person
)
person
.
owner
.
receive
(
post
.
to_diaspora_xml
,
self
.
person
)
else
else
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
spec/models/user/posting_spec.rb
+
24
−
31
Voir le fichier @
199eb894
...
@@ -37,6 +37,10 @@ describe User do
...
@@ -37,6 +37,10 @@ describe User do
aspect1
.
reload
.
post_ids
.
should
include
@post
.
id
aspect1
.
reload
.
post_ids
.
should
include
@post
.
id
end
end
it
'sockets the post to the poster'
do
@post
.
should_receive
(
:socket_to_uid
).
with
(
user
.
id
,
anything
)
user
.
add_to_streams
(
@post
,
@aspect_ids
)
end
end
end
describe
'#aspects_from_ids'
do
describe
'#aspects_from_ids'
do
...
@@ -67,45 +71,34 @@ describe User do
...
@@ -67,45 +71,34 @@ describe User do
end
end
describe
'#dispatch_post'
do
describe
'#dispatch_post'
do
it
'should put the post in the aspect post array'
do
let
(
:status
)
{
user
.
build_post
(
:status_message
,
@status_opts
)}
post
=
user
.
post
(
:status_message
,
:message
=>
"hey"
,
:to
=>
aspect
.
id
)
before
do
aspect
.
reload
@message
=
"hello, world!"
aspect
.
posts
.
should
include
post
@status_opts
=
{
:to
=>
"all"
,
:message
=>
@message
}
end
it
"should add the post to that user's visible posts"
do
status_message
=
user
.
post
:status_message
,
:message
=>
"hi"
,
:to
=>
aspect
.
id
user
.
reload
user
.
raw_visible_posts
.
include?
(
status_message
).
should
be
true
end
end
it
"posts to services if post is public"
do
it
"posts to services if post is public"
do
message
=
"hello, world!"
@status_opts
[
:public
]
=
true
user
.
should_receive
(
:post_to_twitter
).
with
(
service1
,
message
).
exactly
(
1
).
times
status
.
save
user
.
should_receive
(
:post_to_facebook
).
with
(
service2
,
message
).
exactly
(
1
).
times
user
.
should_receive
(
:post_to_twitter
).
with
(
service1
,
@message
).
once
user
.
post
:status_message
,
:message
=>
message
,
:to
=>
"all"
,
:public
=>
true
user
.
should_receive
(
:post_to_facebook
).
with
(
service2
,
@message
).
once
user
.
dispatch_post
(
status
,
:to
=>
"all"
)
end
end
it
"does not post to services if post is not public"
do
it
"does not post to services if post is not public"
do
user
.
should_receive
(
:post_to_twitter
).
exactly
(
0
).
times
@status_opts
[
:public
]
=
false
user
.
should_receive
(
:post_to_facebook
).
exactly
(
0
).
times
status
.
save
user
.
post
:status_message
,
:message
=>
"hi"
,
:to
=>
"all"
user
.
should_not_receive
(
:post_to_twitter
)
end
user
.
should_not_receive
(
:post_to_facebook
)
user
.
dispatch_post
(
status
,
:to
=>
"all"
)
it
'should not socket a pending post'
do
sm
=
user
.
build_post
(
:status_message
,
:message
=>
"your mom"
,
:to
=>
aspect
.
id
,
:pending
=>
true
)
sm
.
should_not_receive
(
:socket_to_uid
)
user
.
dispatch_post
(
sm
,
:to
=>
aspect
.
id
)
end
end
end
end
describe
'#post'
do
describe
'#post'
do
it
'should not create a post with invalid aspect'
do
it
'should not create a post with invalid aspect'
do
pending
"this would just cause
s
db polution"
pending
"this would just cause db polution"
p
ost_count
=
Post
.
count
p
roc
{
proc
{
user
.
post
(
:status_message
,
:message
=>
"hey"
,
:to
=>
aspect2
.
id
)
}.
should
raise_error
/Cannot post to an aspect you do not own./
user
.
post
(
:status_message
,
:message
=>
"hey"
,
:to
=>
aspect2
.
id
)
Post
.
count
.
should
==
post_
count
}.
should_not
change
(
Post
,
:
count
)
end
end
end
end
...
@@ -139,12 +132,12 @@ describe User do
...
@@ -139,12 +132,12 @@ describe User do
describe
'#push_to_aspects'
do
describe
'#push_to_aspects'
do
it
'should push a post to a aspect'
do
it
'should push a post to a aspect'
do
user
.
should_receive
(
:push_to_person
).
twice
user
.
should_receive
(
:push_to_person
).
twice
user
.
push_to_aspects
(
post
,
aspect
.
id
)
user
.
push_to_aspects
(
post
,
[
aspect
]
)
end
end
it
'should push a post to contacts in all aspects'
do
it
'should push a post to contacts in all aspects'
do
user
.
should_receive
(
:push_to_person
).
exactly
(
3
).
times
user
.
should_receive
(
:push_to_person
).
exactly
(
3
).
times
user
.
push_to_aspects
(
post
,
:all
)
user
.
push_to_aspects
(
post
,
user
.
aspects
)
end
end
end
end
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter