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
21463582
Valider
21463582
rédigé
il y a 13 ans
par
Raphael Sofaer
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Fix pagination on notifications page, it was getting all notifications for a user
parent
e22eee36
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/controllers/notifications_controller.rb
+14
-2
14 ajouts, 2 suppressions
app/controllers/notifications_controller.rb
spec/controllers/notifications_controller_spec.rb
+9
-2
9 ajouts, 2 suppressions
spec/controllers/notifications_controller_spec.rb
avec
23 ajouts
et
4 suppressions
app/controllers/notifications_controller.rb
+
14
−
2
Voir le fichier @
21463582
...
@@ -19,8 +19,20 @@ class NotificationsController < ApplicationController
...
@@ -19,8 +19,20 @@ class NotificationsController < ApplicationController
def
index
def
index
@aspect
=
:notification
@aspect
=
:notification
@notifications
=
Notification
.
find
(
:all
,
:conditions
=>
{
:recipient_id
=>
current_user
.
id
},
conditions
=
{
:recipient_id
=>
current_user
.
id
}
:order
=>
'created_at desc'
,
:include
=>
[
:target
,
{
:actors
=>
:profile
}]).
paginate
:page
=>
params
[
:page
],
:per_page
=>
25
page
=
params
[
:page
]
||
1
@notifications
=
WillPaginate
::
Collection
.
create
(
page
,
25
,
Notification
.
where
(
conditions
).
count
)
do
|
pager
|
result
=
Notification
.
find
(
:all
,
:conditions
=>
conditions
,
:order
=>
'created_at desc'
,
:include
=>
[
:target
,
{
:actors
=>
:profile
}],
:limit
=>
pager
.
per_page
,
:offset
=>
pager
.
offset
)
pager
.
replace
(
result
)
end
@group_days
=
@notifications
.
group_by
{
|
note
|
I18n
.
l
(
note
.
created_at
,
:format
=>
I18n
.
t
(
'date.formats.fullmonth_day'
))
}
@group_days
=
@notifications
.
group_by
{
|
note
|
I18n
.
l
(
note
.
created_at
,
:format
=>
I18n
.
t
(
'date.formats.fullmonth_day'
))
}
respond_with
@notifications
respond_with
@notifications
end
end
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
spec/controllers/notifications_controller_spec.rb
+
9
−
2
Voir le fichier @
21463582
...
@@ -43,16 +43,23 @@ describe NotificationsController do
...
@@ -43,16 +43,23 @@ describe NotificationsController do
end
end
describe
'#index'
do
describe
'#index'
do
it
'paginates the notifications'
do
before
do
26
.
times
do
26
.
times
do
Factory
(
:notification
,
:recipient
=>
@user
)
Factory
(
:notification
,
:recipient
=>
@user
)
end
end
end
it
'paginates the notifications'
do
get
:index
get
:index
assigns
[
:notifications
].
count
.
should
==
25
assigns
[
:notifications
].
count
.
should
==
25
get
:index
,
:page
=>
2
get
:index
,
:page
=>
2
assigns
[
:notifications
].
count
.
should
==
1
assigns
[
:notifications
].
count
.
should
==
1
end
end
it
'eager loads the target'
do
get
:index
assigns
[
:notifications
].
each
{
|
note
|
note
.
loaded_target?
.
should
be_true
}
end
end
end
end
end
\ No newline at end of file
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