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
65c22020
Valider
65c22020
rédigé
il y a 14 ans
par
maxwell
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
fixing photo controllers spec
parent
2c09c354
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Étiquettes contenant la validation
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/photos_controller.rb
+17
-13
17 ajouts, 13 suppressions
app/controllers/photos_controller.rb
app/models/photo.rb
+3
-1
3 ajouts, 1 suppression
app/models/photo.rb
spec/models/photo_spec.rb
+3
-0
3 ajouts, 0 suppression
spec/models/photo_spec.rb
avec
23 ajouts
et
14 suppressions
app/controllers/photos_controller.rb
+
17
−
13
Voir le fichier @
65c22020
...
@@ -104,7 +104,8 @@ class PhotosController < ApplicationController
...
@@ -104,7 +104,8 @@ class PhotosController < ApplicationController
photo
.
destroy
photo
.
destroy
flash
[
:notice
]
=
I18n
.
t
'photos.destroy.notice'
flash
[
:notice
]
=
I18n
.
t
'photos.destroy.notice'
if
photo
.
status_message_id
if
photo
.
status_message
respond_with
:location
=>
photo
.
status_message
respond_with
:location
=>
photo
.
status_message
else
else
respond_with
:location
=>
person_photos_path
(
current_user
.
person
)
respond_with
:location
=>
person_photos_path
(
current_user
.
person
)
...
@@ -117,21 +118,24 @@ class PhotosController < ApplicationController
...
@@ -117,21 +118,24 @@ class PhotosController < ApplicationController
def
show
def
show
@photo
=
current_user
.
find_visible_post_by_id
params
[
:id
]
@photo
=
current_user
.
find_visible_post_by_id
params
[
:id
]
@parent
=
@photo
.
status_message
if
@photo
@parent
=
@photo
.
status_message
#if photo is not an attachment, fetch comments for self
#if photo is not an attachment, fetch comments for self
unless
@parent
unless
@parent
@parent
=
@photo
@parent
=
@photo
end
end
comments_hash
=
Comment
.
hash_from_post_ids
[
@parent
.
id
]
person_hash
=
Person
.
from_post_comment_hash
comments_hash
@comment_hashes
=
comments_hash
[
@parent
.
id
].
map
do
|
comment
|
{
:comment
=>
comment
,
:person
=>
person_hash
[
comment
.
person_id
]
}
end
@ownership
=
current_user
.
owns?
@photo
comments_hash
=
Comment
.
hash_from_post_ids
[
@parent
.
id
]
person_hash
=
Person
.
from_post_comment_hash
comments_hash
@comment_hashes
=
comments_hash
[
@parent
.
id
].
map
do
|
comment
|
{
:comment
=>
comment
,
:person
=>
person_hash
[
comment
.
person_id
]
}
end
end
@ownership
=
current_user
.
owns?
@photo
respond_with
@photo
respond_with
@photo
end
end
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
app/models/photo.rb
+
3
−
1
Voir le fichier @
65c22020
...
@@ -27,7 +27,7 @@ class Photo < Post
...
@@ -27,7 +27,7 @@ class Photo < Post
before_destroy
:ensure_user_picture
before_destroy
:ensure_user_picture
before_destroy
:delete_parent_if_no_photos_or_message
#
before_destroy :delete_parent_if_no_photos_or_message
def
ownership_of_status_message
def
ownership_of_status_message
message
=
StatusMessage
.
find_by_id
(
self
.
status_message_id
)
message
=
StatusMessage
.
find_by_id
(
self
.
status_message_id
)
if
status_message_id
&&
message
if
status_message_id
&&
message
...
@@ -119,6 +119,7 @@ class Photo < Post
...
@@ -119,6 +119,7 @@ class Photo < Post
where
(
:status_message_id
.
in
=>
post_ids
)
where
(
:status_message_id
.
in
=>
post_ids
)
}
}
=begin
private
private
def delete_parent_if_no_photos_or_message
def delete_parent_if_no_photos_or_message
parent = self.status_message
parent = self.status_message
...
@@ -127,6 +128,7 @@ class Photo < Post
...
@@ -127,6 +128,7 @@ class Photo < Post
parent.delete
parent.delete
end
end
end
end
=end
end
end
Ce diff est replié.
Cliquez pour l'agrandir.
spec/models/photo_spec.rb
+
3
−
0
Voir le fichier @
65c22020
...
@@ -172,12 +172,14 @@ describe Photo do
...
@@ -172,12 +172,14 @@ describe Photo do
end
end
it
'deletes the parent object if there are no other photos or message'
do
it
'deletes the parent object if there are no other photos or message'
do
pending
proc
{
proc
{
@photo2
.
destroy
@photo2
.
destroy
}.
should
change
(
StatusMessage
,
:count
).
by
(
-
1
)
}.
should
change
(
StatusMessage
,
:count
).
by
(
-
1
)
end
end
it
'does not delete the parent if the parent has other photos'
do
it
'does not delete the parent if the parent has other photos'
do
pending
@status_message
.
photos
<<
@photo
@status_message
.
photos
<<
@photo
@status_message
.
save
@status_message
.
save
...
@@ -187,6 +189,7 @@ describe Photo do
...
@@ -187,6 +189,7 @@ describe Photo do
end
end
it
'does not delete the parent if the parent has a message'
do
it
'does not delete the parent if the parent has a message'
do
pending
@status_message
.
message
=
"hello there kids"
@status_message
.
message
=
"hello there kids"
@status_message
.
save
@status_message
.
save
...
...
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