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
5df6bc1a
Valider
5df6bc1a
rédigé
il y a 13 ans
par
danielgrippi
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
block user now removes a contact if user is blocking a contact
parent
ee5bc25f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
app/controllers/blocks_controller.rb
+9
-0
9 ajouts, 0 suppression
app/controllers/blocks_controller.rb
lib/diaspora/user/connecting.rb
+2
-2
2 ajouts, 2 suppressions
lib/diaspora/user/connecting.rb
spec/controllers/blocks_controller_spec.rb
+24
-1
24 ajouts, 1 suppression
spec/controllers/blocks_controller_spec.rb
avec
35 ajouts
et
3 suppressions
app/controllers/blocks_controller.rb
+
9
−
0
Voir le fichier @
5df6bc1a
...
@@ -5,6 +5,7 @@ class BlocksController < ApplicationController
...
@@ -5,6 +5,7 @@ class BlocksController < ApplicationController
block
=
current_user
.
blocks
.
new
(
params
[
:block
])
block
=
current_user
.
blocks
.
new
(
params
[
:block
])
if
block
.
save
if
block
.
save
disconnect_if_contact
(
block
.
person
)
notice
=
{
:notice
=>
t
(
'blocks.create.success'
)}
notice
=
{
:notice
=>
t
(
'blocks.create.success'
)}
else
else
notice
=
{
:error
=>
t
(
'blocks.create.failure'
)}
notice
=
{
:error
=>
t
(
'blocks.create.failure'
)}
...
@@ -20,4 +21,12 @@ class BlocksController < ApplicationController
...
@@ -20,4 +21,12 @@ class BlocksController < ApplicationController
end
end
redirect_to
:back
,
notice
redirect_to
:back
,
notice
end
end
protected
def
disconnect_if_contact
(
person
)
if
contact
=
current_user
.
contact_for
(
person
)
current_user
.
disconnect
(
contact
,
:force
=>
true
)
end
end
end
end
Ce diff est replié.
Cliquez pour l'agrandir.
lib/diaspora/user/connecting.rb
+
2
−
2
Voir le fichier @
5df6bc1a
...
@@ -56,7 +56,7 @@ module Diaspora
...
@@ -56,7 +56,7 @@ module Diaspora
end
end
end
end
def
disconnect
(
bad_contact
)
def
disconnect
(
bad_contact
,
opts
=
{}
)
person
=
bad_contact
.
person
person
=
bad_contact
.
person
Rails
.
logger
.
info
(
"event=disconnect user=
#{
diaspora_handle
}
target=
#{
person
.
diaspora_handle
}
"
)
Rails
.
logger
.
info
(
"event=disconnect user=
#{
diaspora_handle
}
target=
#{
person
.
diaspora_handle
}
"
)
retraction
=
Retraction
.
for
(
self
)
retraction
=
Retraction
.
for
(
self
)
...
@@ -64,7 +64,7 @@ module Diaspora
...
@@ -64,7 +64,7 @@ module Diaspora
Postzord
::
Dispatcher
.
build
(
self
,
retraction
).
post
Postzord
::
Dispatcher
.
build
(
self
,
retraction
).
post
AspectMembership
.
where
(
:contact_id
=>
bad_contact
.
id
).
delete_all
AspectMembership
.
where
(
:contact_id
=>
bad_contact
.
id
).
delete_all
remove_contact
(
bad_contact
)
remove_contact
(
bad_contact
,
opts
)
end
end
def
disconnected_by
(
person
)
def
disconnected_by
(
person
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
spec/controllers/blocks_controller_spec.rb
+
24
−
1
Voir le fichier @
5df6bc1a
...
@@ -8,7 +8,7 @@ describe BlocksController do
...
@@ -8,7 +8,7 @@ describe BlocksController do
describe
"#create"
do
describe
"#create"
do
it
"creates a block"
do
it
"creates a block"
do
expect
{
expect
{
post
:create
,
:block
=>
{
:person_id
=>
2
}
post
:create
,
:block
=>
{
:person_id
=>
eve
.
person
.
id
}
}.
should
change
{
alice
.
blocks
.
count
}.
by
(
1
)
}.
should
change
{
alice
.
blocks
.
count
}.
by
(
1
)
end
end
...
@@ -23,6 +23,11 @@ describe BlocksController do
...
@@ -23,6 +23,11 @@ describe BlocksController do
flash
.
should_not
be_empty
flash
.
should_not
be_empty
end
end
it
"calls #disconnect_if_contact"
do
@controller
.
should_receive
(
:disconnect_if_contact
).
with
(
bob
.
person
)
post
:create
,
:block
=>
{
:person_id
=>
bob
.
person
.
id
}
end
end
end
describe
"#destroy"
do
describe
"#destroy"
do
...
@@ -41,4 +46,22 @@ describe BlocksController do
...
@@ -41,4 +46,22 @@ describe BlocksController do
}.
should
change
{
alice
.
blocks
.
count
}.
by
(
-
1
)
}.
should
change
{
alice
.
blocks
.
count
}.
by
(
-
1
)
end
end
end
end
describe
"#disconnect_if_contact"
do
before
do
@controller
.
stub
(
:current_user
).
and_return
(
alice
)
end
it
"calls disconnect with the force option if there is a contact for a given user"
do
contact
=
alice
.
contact_for
(
bob
.
person
)
alice
.
stub
(
:contact_for
).
and_return
(
contact
)
alice
.
should_receive
(
:disconnect
).
with
(
contact
,
hash_including
(
:force
=>
true
))
@controller
.
send
(
:disconnect_if_contact
,
bob
.
person
)
end
it
"doesn't call disconnect if there is a contact for a given user"
do
alice
.
should_not_receive
(
:disconnect
)
@controller
.
send
(
:disconnect_if_contact
,
eve
.
person
)
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