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
ff1cb665
Valider
ff1cb665
rédigé
il y a 13 ans
par
Ilya Zhitomirskiy
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
not passing in by members of if it wasn't passed into the stream
parent
2e96f012
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
lib/aspect_stream.rb
+5
-4
5 ajouts, 4 suppressions
lib/aspect_stream.rb
spec/lib/aspect_stream_spec.rb
+47
-30
47 ajouts, 30 suppressions
spec/lib/aspect_stream_spec.rb
avec
52 ajouts
et
34 suppressions
lib/aspect_stream.rb
+
5
−
4
Voir le fichier @
ff1cb665
...
...
@@ -42,10 +42,11 @@ class AspectStream
# @return [ActiveRecord::Association<Post>] AR association of posts
def
posts
# NOTE(this should be something like Post.all_for_stream(@user, aspect_ids, {}) that calls visible_posts
@posts
||=
@user
.
visible_posts
(
:by_members_of
=>
aspect_ids
,
:type
=>
[
'StatusMessage'
,
'Reshare'
,
'ActivityStreams::Photo'
],
:order
=>
"
#{
@order
}
DESC"
,
:max_time
=>
@max_time
opts
=
{
:type
=>
[
'StatusMessage'
,
'Reshare'
,
'ActivityStreams::Photo'
],
:order
=>
"
#{
@order
}
DESC"
,
:max_time
=>
@max_time
}
opts
[
:by_members_of
]
=
aspect_ids
unless
(
@inputted_aspect_ids
==
[])
@posts
||=
@user
.
visible_posts
(
opts
).
includes
(
:mentions
=>
{
:person
=>
:profile
},
:author
=>
:profile
)
end
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
spec/lib/aspect_stream_spec.rb
+
47
−
30
Voir le fichier @
ff1cb665
...
...
@@ -5,50 +5,67 @@
require
'aspect_stream'
describe
AspectStream
do
describe
'#aspects'
do
it
'queries the user given initialized aspect ids'
do
alice
=
stub
.
as_null_object
stream
=
AspectStream
.
new
(
alice
,
[
1
,
2
,
3
])
#
describe '#aspects' do
#
it 'queries the user given initialized aspect ids' do
#
alice = stub.as_null_object
#
stream = AspectStream.new(alice, [1,2,3])
alice
.
aspects
.
should_receive
(
:where
)
stream
.
aspects
end
#
alice.aspects.should_receive(:where)
#
stream.aspects
#
end
it
"returns all the user's aspects if no aspect ids are specified"
do
alice
=
stub
.
as_null_object
stream
=
AspectStream
.
new
(
alice
,
[])
#
it "returns all the user's aspects if no aspect ids are specified" do
#
alice = stub.as_null_object
#
stream = AspectStream.new(alice, [])
alice
.
aspects
.
should_not_receive
(
:where
)
stream
.
aspects
end
#
alice.aspects.should_not_receive(:where)
#
stream.aspects
#
end
it
'filters aspects given a user'
do
alice
=
stub
(
:aspects
=>
[
stub
(
:id
=>
1
)])
alice
.
aspects
.
stub
(
:where
).
and_return
(
alice
.
aspects
)
stream
=
AspectStream
.
new
(
alice
,
[
1
,
2
,
3
])
#
it 'filters aspects given a user' do
#
alice = stub(:aspects => [stub(:id => 1)])
#
alice.aspects.stub(:where).and_return(alice.aspects)
#
stream = AspectStream.new(alice, [1,2,3])
stream
.
aspects
.
should
==
alice
.
aspects
end
end
#
stream.aspects.should == alice.aspects
#
end
#
end
describe
'#aspect_ids'
do
it
'maps ids from aspects'
do
alice
=
stub
.
as_null_object
aspects
=
stub
.
as_null_object
#
describe '#aspect_ids' do
#
it 'maps ids from aspects' do
#
alice = stub.as_null_object
#
aspects = stub.as_null_object
stream
=
AspectStream
.
new
(
alice
,
[
1
,
2
])
#
stream = AspectStream.new(alice, [1,2])
stream
.
should_receive
(
:aspects
).
and_return
(
aspects
)
aspects
.
should_receive
(
:map
)
stream
.
aspect_ids
end
end
#
stream.should_receive(:aspects).and_return(aspects)
#
aspects.should_receive(:map)
#
stream.aspect_ids
#
end
#
end
describe
'#posts'
do
before
do
@alice
=
stub
.
as_null_object
end
it
'calls visible posts with blank by_members_of if called with all aspects'
do
stream
=
AspectStream
.
new
(
@alice
,
[])
stream
.
stub
(
:aspect_ids
).
and_return
([
1
,
2
])
@alice
.
stub
(
:visible_posts
).
and_return
(
stub
.
as_null_object
)
@alice
.
should_not_receive
(
:visible_posts
).
with
(
hash_including
(
:by_members_of
=>
anything
)).
and_return
(
stub
.
as_null_object
)
stream
.
posts
end
it
'calls visible posts with by_members_of if with aspects are filtered'
do
stream
=
AspectStream
.
new
(
@alice
,
[
1
,
2
])
stream
.
stub
(
:aspect_ids
).
and_return
([
1
])
@alice
.
should_receive
(
:visible_posts
).
with
(
hash_including
(
:by_members_of
=>
[
1
])).
and_return
(
stub
.
as_null_object
)
stream
.
posts
end
it
'calls visible posts for the given user'
do
stream
=
AspectStream
.
new
(
@alice
,
[
1
,
2
])
...
...
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