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
872a96dc
Valider
872a96dc
rédigé
13 years ago
par
Sarah Mei
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Refactor services controller spec
parent
ebfc3de8
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/services_controller.rb
+4
-3
4 ajouts, 3 suppressions
app/controllers/services_controller.rb
spec/controllers/services_controller_spec.rb
+35
-37
35 ajouts, 37 suppressions
spec/controllers/services_controller_spec.rb
avec
39 ajouts
et
40 suppressions
app/controllers/services_controller.rb
+
4
−
3
Voir le fichier @
872a96dc
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file.
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class
ServicesController
<
ApplicationController
class
ServicesController
<
ApplicationController
before_filter
:authenticate_user!
before_filter
:authenticate_user!
...
@@ -38,8 +39,8 @@ class ServicesController < ApplicationController
...
@@ -38,8 +39,8 @@ class ServicesController < ApplicationController
if
existing_service
=
Service
.
where
(
:type
=>
service
.
type
.
to_s
,
:uid
=>
service
.
uid
).
first
if
existing_service
=
Service
.
where
(
:type
=>
service
.
type
.
to_s
,
:uid
=>
service
.
uid
).
first
flash
[
:error
]
<<
I18n
.
t
(
'services.create.already_authorized'
,
flash
[
:error
]
<<
I18n
.
t
(
'services.create.already_authorized'
,
:diaspora_id
=>
existing_service
.
user
.
person
.
profile
.
diaspora_handle
,
:diaspora_id
=>
existing_service
.
user
.
person
.
profile
.
diaspora_handle
,
:service_name
=>
provider
.
camelize
)
:service_name
=>
provider
.
camelize
)
end
end
end
end
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
spec/controllers/services_controller_spec.rb
+
35
−
37
Voir le fichier @
872a96dc
...
@@ -36,50 +36,48 @@ describe ServicesController do
...
@@ -36,50 +36,48 @@ describe ServicesController do
end
end
describe
'#create'
do
describe
'#create'
do
it
'creates a new OmniauthService'
do
context
'when not fetching a photo'
do
request
.
env
[
'omniauth.auth'
]
=
omniauth_auth
before
do
lambda
{
request
.
env
[
'omniauth.auth'
]
=
omniauth_auth
post
:create
,
:provider
=>
'twitter'
end
}.
should
change
(
@user
.
services
,
:count
).
by
(
1
)
end
it
'redirects to getting started if the user is getting started'
do
@user
.
getting_started
=
true
request
.
env
[
'omniauth.auth'
]
=
omniauth_auth
post
:create
,
:provider
=>
'twitter'
response
.
should
redirect_to
getting_started_path
end
it
'redirects to services url'
do
@user
.
getting_started
=
false
request
.
env
[
'omniauth.auth'
]
=
omniauth_auth
post
:create
,
:provider
=>
'twitter'
response
.
should
redirect_to
services_url
end
it
'creates a twitter service'
do
it
'creates a new OmniauthService'
do
Service
.
delete_all
expect
{
@user
.
getting_started
=
false
post
:create
,
:provider
=>
'twitter'
request
.
env
[
'omniauth.auth'
]
=
omniauth_auth
}.
to
change
(
@user
.
services
,
:count
).
by
(
1
)
post
:create
,
:provider
=>
'twitter'
end
@user
.
reload
.
services
.
first
.
class
.
name
.
should
==
"Services::Twitter"
end
it
'returns error if the service is connected with that uid'
do
it
'redirects to getting started if the user is getting started'
do
request
.
env
[
'omniauth.auth'
]
=
omniauth_auth
@user
.
getting_started
=
true
post
:create
,
:provider
=>
'twitter'
response
.
should
redirect_to
getting_started_path
end
Services
::
Twitter
.
create!
(
:nickname
=>
omniauth_auth
[
"info"
][
'nickname'
],
it
'redirects to services url if user is not getting started'
do
:access_token
=>
omniauth_auth
[
'credentials'
][
'token'
],
@user
.
getting_started
=
false
:access_secret
=>
omniauth_auth
[
'credentials'
][
'secret'
],
post
:create
,
:provider
=>
'twitter'
:uid
=>
omniauth_auth
[
'uid'
],
response
.
should
redirect_to
services_url
:user
=>
bob
)
end
post
:create
,
:provider
=>
'twitter'
it
'creates a twitter service'
do
Service
.
delete_all
@user
.
getting_started
=
false
post
:create
,
:provider
=>
'twitter'
@user
.
reload
.
services
.
first
.
class
.
name
.
should
==
"Services::Twitter"
end
flash
[
:error
].
include?
(
bob
.
person
.
profile
.
diaspora_handle
).
should
be_true
it
'returns error if the user already a service with that uid'
do
Services
::
Twitter
.
create!
(
:nickname
=>
omniauth_auth
[
"info"
][
'nickname'
],
:access_token
=>
omniauth_auth
[
'credentials'
][
'token'
],
:access_secret
=>
omniauth_auth
[
'credentials'
][
'secret'
],
:uid
=>
omniauth_auth
[
'uid'
],
:user
=>
bob
)
post
:create
,
:provider
=>
'twitter'
flash
[
:error
].
include?
(
bob
.
person
.
profile
.
diaspora_handle
).
should
be_true
end
end
end
context
"photo
fetching
"
do
context
'when
fetching
a photo'
do
before
do
before
do
omniauth_auth
omniauth_auth
omniauth_auth
[
"info"
].
merge!
({
"image"
=>
"https://service.com/fallback_lowres.jpg"
})
omniauth_auth
[
"info"
].
merge!
({
"image"
=>
"https://service.com/fallback_lowres.jpg"
})
...
...
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