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
c3b9da8d
Valider
c3b9da8d
rédigé
il y a 14 ans
par
Sarah Mei
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Add specs to conversations#new. Unpending spec for create.
parent
8d7aa182
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/conversations_controller.rb
+10
-10
10 ajouts, 10 suppressions
app/controllers/conversations_controller.rb
spec/controllers/conversations_controller_spec.rb
+28
-22
28 ajouts, 22 suppressions
spec/controllers/conversations_controller_spec.rb
avec
38 ajouts
et
32 suppressions
app/controllers/conversations_controller.rb
+
10
−
10
Voir le fichier @
c3b9da8d
...
@@ -5,20 +5,20 @@ class ConversationsController < ApplicationController
...
@@ -5,20 +5,20 @@ class ConversationsController < ApplicationController
def
index
def
index
@conversations
=
Conversation
.
joins
(
:conversation_visibilities
).
where
(
@conversations
=
Conversation
.
joins
(
:conversation_visibilities
).
where
(
:conversation_visibilities
=>
{
:person_id
=>
current_user
.
person
.
id
}).
paginate
(
:conversation_visibilities
=>
{
:person_id
=>
current_user
.
person
.
id
}).
paginate
(
:page
=>
params
[
:page
],
:per_page
=>
15
,
:order
=>
'updated_at DESC'
)
:page
=>
params
[
:page
],
:per_page
=>
15
,
:order
=>
'updated_at DESC'
)
@visibilities
=
ConversationVisibility
.
where
(
:person_id
=>
current_user
.
person
.
id
).
paginate
(
@visibilities
=
ConversationVisibility
.
where
(
:person_id
=>
current_user
.
person
.
id
).
paginate
(
:page
=>
params
[
:page
],
:per_page
=>
15
,
:order
=>
'updated_at DESC'
)
:page
=>
params
[
:page
],
:per_page
=>
15
,
:order
=>
'updated_at DESC'
)
@unread_counts
=
{}
@unread_counts
=
{}
@visibilities
.
each
{
|
v
|
@unread_counts
[
v
.
conversation_id
]
=
v
.
unread
}
@visibilities
.
each
{
|
v
|
@unread_counts
[
v
.
conversation_id
]
=
v
.
unread
}
@authors
=
{}
@authors
=
{}
@conversations
.
each
{
|
c
|
@authors
[
c
.
id
]
=
c
.
last_author
}
@conversations
.
each
{
|
c
|
@authors
[
c
.
id
]
=
c
.
last_author
}
@conversation
=
Conversation
.
joins
(
:conversation_visibilities
).
where
(
@conversation
=
Conversation
.
joins
(
:conversation_visibilities
).
where
(
:conversation_visibilities
=>
{
:person_id
=>
current_user
.
person
.
id
,
:conversation_id
=>
params
[
:conversation_id
]}).
first
:conversation_visibilities
=>
{
:person_id
=>
current_user
.
person
.
id
,
:conversation_id
=>
params
[
:conversation_id
]}).
first
end
end
def
create
def
create
...
@@ -43,7 +43,7 @@ class ConversationsController < ApplicationController
...
@@ -43,7 +43,7 @@ class ConversationsController < ApplicationController
def
show
def
show
@conversation
=
Conversation
.
joins
(
:conversation_visibilities
).
where
(
:id
=>
params
[
:id
],
@conversation
=
Conversation
.
joins
(
:conversation_visibilities
).
where
(
:id
=>
params
[
:id
],
:conversation_visibilities
=>
{
:person_id
=>
current_user
.
person
.
id
}).
first
:conversation_visibilities
=>
{
:person_id
=>
current_user
.
person
.
id
}).
first
if
@visibility
=
ConversationVisibility
.
where
(
:conversation_id
=>
params
[
:id
],
:person_id
=>
current_user
.
person
.
id
).
first
if
@visibility
=
ConversationVisibility
.
where
(
:conversation_id
=>
params
[
:id
],
:person_id
=>
current_user
.
person
.
id
).
first
@visibility
.
unread
=
0
@visibility
.
unread
=
0
...
@@ -58,7 +58,7 @@ class ConversationsController < ApplicationController
...
@@ -58,7 +58,7 @@ class ConversationsController < ApplicationController
end
end
def
new
def
new
@all_contacts_and_ids
=
current_user
.
contacts
.
map
{
|
c
|
{
:value
=>
c
.
id
,
:name
=>
c
.
person
.
name
}}
@all_contacts_and_ids
=
current_user
.
contacts
.
map
{
|
c
|
{
:value
=>
c
.
id
,
:name
=>
c
.
person
.
name
}
}
@contact
=
current_user
.
contacts
.
find
(
params
[
:contact_id
])
if
params
[
:contact_id
]
@contact
=
current_user
.
contacts
.
find
(
params
[
:contact_id
])
if
params
[
:contact_id
]
render
:layout
=>
false
render
:layout
=>
false
end
end
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
spec/controllers/conversations_controller_spec.rb
+
28
−
22
Voir le fichier @
c3b9da8d
...
@@ -4,15 +4,24 @@ describe ConversationsController do
...
@@ -4,15 +4,24 @@ describe ConversationsController do
render_views
render_views
before
do
before
do
@
user1
=
alice
@
alice
=
alice
sign_in
:user
,
@
user1
sign_in
:user
,
@
alice
end
end
describe
'#new'
do
describe
'#new'
do
it
'succeeds'
do
before
do
get
:new
get
:new
end
it
'succeeds'
do
response
.
should
be_success
response
.
should
be_success
end
end
it
"assigns a list of the user's contacts"
do
assigns
(
:all_contacts_and_ids
).
should
==
@alice
.
contacts
.
collect
{
|
c
|
{
"value"
=>
c
.
id
,
"name"
=>
c
.
person
.
name
}}
end
it
"assigns a contact if passed a contact id"
do
get
:new
,
:contact_id
=>
@alice
.
contacts
.
first
.
id
assigns
(
:contact
).
should
==
@alice
.
contacts
.
first
end
end
end
describe
'#index'
do
describe
'#index'
do
...
@@ -22,12 +31,9 @@ describe ConversationsController do
...
@@ -22,12 +31,9 @@ describe ConversationsController do
end
end
it
'retrieves all conversations for a user'
do
it
'retrieves all conversations for a user'
do
hash
=
{
:author
=>
@user1
.
person
,
:participant_ids
=>
[
@user1
.
contacts
.
first
.
person
.
id
,
@user1
.
person
.
id
],
hash
=
{
:author
=>
@alice
.
person
,
:participant_ids
=>
[
@alice
.
contacts
.
first
.
person
.
id
,
@alice
.
person
.
id
],
:subject
=>
'not spam'
,
:text
=>
'cool stuff'
}
:subject
=>
'not spam'
,
:text
=>
'cool stuff'
}
3
.
times
{
Conversation
.
create
(
hash
)
}
3
.
times
do
cnv
=
Conversation
.
create
(
hash
)
end
get
:index
get
:index
assigns
[
:conversations
].
count
.
should
==
3
assigns
[
:conversations
].
count
.
should
==
3
...
@@ -36,10 +42,12 @@ describe ConversationsController do
...
@@ -36,10 +42,12 @@ describe ConversationsController do
describe
'#create'
do
describe
'#create'
do
before
do
before
do
@hash
=
{
:conversation
=>
{
@hash
=
{
:subject
=>
"secret stuff"
,
:conversation
=>
{
:text
=>
'text'
},
:subject
=>
"secret stuff"
,
:contact_ids
=>
'@user1.contacts.first.id'
}
:text
=>
'text'
},
:contact_ids
=>
[
@alice
.
contacts
.
first
.
id
]
}
end
end
it
'creates a conversation'
do
it
'creates a conversation'
do
...
@@ -55,19 +63,17 @@ describe ConversationsController do
...
@@ -55,19 +63,17 @@ describe ConversationsController do
end
end
it
'sets the author to the current_user'
do
it
'sets the author to the current_user'
do
pending
@hash
[
:author
]
=
Factory
.
create
(
:user
)
@hash
[
:author
]
=
Factory
.
create
(
:user
)
post
:create
,
@hash
post
:create
,
@hash
Message
.
first
.
author
.
should
==
@
user1
.
person
Message
.
first
.
author
.
should
==
@
alice
.
person
Conversation
.
first
.
author
.
should
==
@
user1
.
person
Conversation
.
first
.
author
.
should
==
@
alice
.
person
end
end
it
'dispatches the conversation'
do
it
'dispatches the conversation'
do
cnv
=
Conversation
.
create
(
@hash
[
:conversation
].
merge
({
cnv
=
Conversation
.
create
(
:author
=>
@user1
.
person
,
@hash
[
:conversation
].
merge
({
:author
=>
@alice
.
person
,
:participant_ids
=>
[
@alice
.
contacts
.
first
.
person
.
id
]}))
:participant_ids
=>
[
@user1
.
contacts
.
first
.
person
.
id
]}))
p
=
Postzord
::
Dispatch
.
new
(
@
user1
,
cnv
)
p
=
Postzord
::
Dispatch
.
new
(
@
alice
,
cnv
)
Postzord
::
Dispatch
.
stub!
(
:new
).
and_return
(
p
)
Postzord
::
Dispatch
.
stub!
(
:new
).
and_return
(
p
)
p
.
should_receive
(
:post
)
p
.
should_receive
(
:post
)
post
:create
,
@hash
post
:create
,
@hash
...
@@ -76,8 +82,8 @@ describe ConversationsController do
...
@@ -76,8 +82,8 @@ describe ConversationsController do
describe
'#show'
do
describe
'#show'
do
before
do
before
do
hash
=
{
:author
=>
@
user1
.
person
,
:participant_ids
=>
[
@
user1
.
contacts
.
first
.
person
.
id
,
@
user1
.
person
.
id
],
hash
=
{
:author
=>
@
alice
.
person
,
:participant_ids
=>
[
@
alice
.
contacts
.
first
.
person
.
id
,
@
alice
.
person
.
id
],
:subject
=>
'not spam'
,
:text
=>
'cool stuff'
}
:subject
=>
'not spam'
,
:text
=>
'cool stuff'
}
@conversation
=
Conversation
.
create
(
hash
)
@conversation
=
Conversation
.
create
(
hash
)
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