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
4c7948c7
Non vérifiée
Valider
4c7948c7
rédigé
il y a 7 ans
par
Steffen van Bergerem
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Use id in stream comparator as fallback
parent
757a5fbd
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/assets/javascripts/app/models/stream.js
+10
-2
10 ajouts, 2 suppressions
app/assets/javascripts/app/models/stream.js
spec/javascripts/app/models/stream_spec.js
+32
-0
32 ajouts, 0 suppression
spec/javascripts/app/models/stream_spec.js
avec
42 ajouts
et
2 suppressions
app/assets/javascripts/app/models/stream.js
+
10
−
2
Voir le fichier @
4c7948c7
...
@@ -13,8 +13,16 @@ app.models.Stream = Backbone.Collection.extend({
...
@@ -13,8 +13,16 @@ app.models.Stream = Backbone.Collection.extend({
},
},
collectionOptions
:
function
(){
collectionOptions
:
function
(){
var
order
=
this
.
sortOrder
();
var
order
=
this
.
sortOrder
();
return
{
comparator
:
function
(
item
)
{
return
-
item
[
order
]();
}
};
return
{
comparator
:
function
(
item1
,
item2
)
{
if
(
item1
[
order
]()
<
item2
[
order
]())
{
return
1
;
}
if
(
item1
[
order
]()
>
item2
[
order
]())
{
return
-
1
;
}
if
(
item1
.
id
<
item2
.
id
)
{
return
1
;
}
if
(
item1
.
id
>
item2
.
id
)
{
return
-
1
;
}
return
0
;
}
};
},
},
url
:
function
(){
url
:
function
(){
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
spec/javascripts/app/models/stream_spec.js
+
32
−
0
Voir le fichier @
4c7948c7
...
@@ -7,6 +7,38 @@ describe("app.models.Stream", function() {
...
@@ -7,6 +7,38 @@ describe("app.models.Stream", function() {
expectedPath
=
document
.
location
.
pathname
;
expectedPath
=
document
.
location
.
pathname
;
});
});
describe
(
"
collectionOptions
"
,
function
()
{
beforeEach
(
function
()
{
this
.
post1
=
new
app
.
models
.
Post
({
"
id
"
:
1
,
"
created_at
"
:
12
,
"
interacted_at
"
:
123
});
this
.
post2
=
new
app
.
models
.
Post
({
"
id
"
:
2
,
"
created_at
"
:
13
,
"
interacted_at
"
:
123
});
this
.
post3
=
new
app
.
models
.
Post
({
"
id
"
:
3
,
"
created_at
"
:
13
,
"
interacted_at
"
:
122
});
this
.
post4
=
new
app
.
models
.
Post
({
"
id
"
:
4
,
"
created_at
"
:
10
,
"
interacted_at
"
:
100
});
});
it
(
"
returns a comparator for posts that compares created_at and ids by default
"
,
function
()
{
this
.
options
=
stream
.
collectionOptions
();
expect
(
this
.
options
.
comparator
(
this
.
post1
,
this
.
post2
)).
toBe
(
1
);
expect
(
this
.
options
.
comparator
(
this
.
post2
,
this
.
post1
)).
toBe
(
-
1
);
expect
(
this
.
options
.
comparator
(
this
.
post2
,
this
.
post3
)).
toBe
(
1
);
expect
(
this
.
options
.
comparator
(
this
.
post3
,
this
.
post2
)).
toBe
(
-
1
);
expect
(
this
.
options
.
comparator
(
this
.
post1
,
this
.
post4
)).
toBe
(
-
1
);
expect
(
this
.
options
.
comparator
(
this
.
post4
,
this
.
post1
)).
toBe
(
1
);
expect
(
this
.
options
.
comparator
(
this
.
post1
,
this
.
post1
)).
toBe
(
0
);
});
it
(
"
returns a comparator for posts that compares interacted_at and ids for the activity stream
"
,
function
()
{
spyOn
(
stream
,
"
basePath
"
).
and
.
returnValue
(
"
activity
"
);
this
.
options
=
stream
.
collectionOptions
();
expect
(
this
.
options
.
comparator
(
this
.
post1
,
this
.
post2
)).
toBe
(
1
);
expect
(
this
.
options
.
comparator
(
this
.
post2
,
this
.
post1
)).
toBe
(
-
1
);
expect
(
this
.
options
.
comparator
(
this
.
post2
,
this
.
post3
)).
toBe
(
-
1
);
expect
(
this
.
options
.
comparator
(
this
.
post3
,
this
.
post2
)).
toBe
(
1
);
expect
(
this
.
options
.
comparator
(
this
.
post1
,
this
.
post4
)).
toBe
(
-
1
);
expect
(
this
.
options
.
comparator
(
this
.
post4
,
this
.
post1
)).
toBe
(
1
);
expect
(
this
.
options
.
comparator
(
this
.
post1
,
this
.
post1
)).
toBe
(
0
);
});
});
describe
(
"
#_fetchOpts
"
,
function
()
{
describe
(
"
#_fetchOpts
"
,
function
()
{
it
(
"
it fetches posts from the window's url, and ads them to the collection
"
,
function
()
{
it
(
"
it fetches posts from the window's url, and ads them to the collection
"
,
function
()
{
expect
(
stream
.
_fetchOpts
()
).
toEqual
({
remove
:
false
,
url
:
expectedPath
});
expect
(
stream
.
_fetchOpts
()
).
toEqual
({
remove
:
false
,
url
:
expectedPath
});
...
...
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