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
144e9ed4
Valider
144e9ed4
rédigé
il y a 14 ans
par
Raphael
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Bookmarks now clean link in instantiate, posting them should work right again
parent
683bb0db
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
app/controllers/bookmarks_controller.rb
+0
-5
0 ajout, 5 suppressions
app/controllers/bookmarks_controller.rb
app/models/bookmark.rb
+10
-6
10 ajouts, 6 suppressions
app/models/bookmark.rb
spec/models/bookmark_spec.rb
+34
-28
34 ajouts, 28 suppressions
spec/models/bookmark_spec.rb
avec
44 ajouts
et
39 suppressions
app/controllers/bookmarks_controller.rb
+
0
−
5
Voir le fichier @
144e9ed4
...
...
@@ -4,11 +4,6 @@ class BookmarksController < ApplicationController
def
index
@bookmark
=
Bookmark
.
new
@bookmarks
=
Bookmark
.
paginate
:page
=>
params
[
:page
],
:order
=>
'created_at DESC'
respond_to
do
|
format
|
format
.
html
end
end
def
edit
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
app/models/bookmark.rb
+
10
−
6
Voir le fichier @
144e9ed4
...
...
@@ -12,8 +12,6 @@ class Bookmark < Post
validates_format_of
:link
,
:with
=>
/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
before_validation
:clean_link
def
to_activity
<<-
XML
<entry>
...
...
@@ -27,12 +25,18 @@ class Bookmark < Post
</entry>
XML
end
def
self
.
instantiate
params
params
[
:link
]
=
clean_link
(
params
[
:link
])
create
params
end
protected
def
clean_link
if
self
.
link
self
.
link
=
'http://'
+
self
.
link
unless
self
.
link
.
match
(
'https?://'
)
self
.
link
=
self
.
link
+
'/'
if
self
.
link
[
-
1
,
1
]
!=
'/'
def
self
.
clean_link
link
if
link
link
=
'http://'
+
link
unless
link
.
match
(
'https?://'
)
link
=
link
+
'/'
if
link
[
-
1
,
1
]
!=
'/'
link
end
end
end
Ce diff est replié.
Cliquez pour l'agrandir.
spec/models/bookmark_spec.rb
+
34
−
28
Voir le fichier @
144e9ed4
...
...
@@ -10,34 +10,6 @@ describe Bookmark do
it
'should validate its link'
do
bookmark
=
Factory
.
build
(
:bookmark
)
#links changed valid
bookmark
.
link
=
"google.com"
bookmark
.
valid?
.
should
==
true
bookmark
.
link
.
should
==
"http://google.com/"
bookmark
.
link
=
"www.google.com"
bookmark
.
valid?
.
should
==
true
bookmark
.
link
.
should
==
"http://www.google.com/"
bookmark
.
link
=
"google.com/"
bookmark
.
valid?
.
should
==
true
bookmark
.
link
.
should
==
"http://google.com/"
bookmark
.
link
=
"www.google.com/"
bookmark
.
valid?
.
should
==
true
bookmark
.
link
.
should
==
"http://www.google.com/"
bookmark
.
link
=
"http://google.com"
bookmark
.
valid?
.
should
==
true
bookmark
.
link
.
should
==
"http://google.com/"
bookmark
.
link
=
"http://www.google.com"
bookmark
.
valid?
.
should
==
true
#bookmark.link = "http://babycakes.sofaer.net:3000"
#bookmark.valid?.should == true
#invalid links
bookmark
.
link
=
"zsdvzxdg"
bookmark
.
valid?
.
should
==
false
...
...
@@ -54,6 +26,24 @@ describe Bookmark do
bookmark
.
link
=
"http:///www.asodij.com/"
bookmark
.
valid?
.
should
==
false
end
it
'should clean links'
do
bad_links
=
[
"google.com"
,
"www.google.com"
,
"google.com/"
,
"www.google.com/"
,
"http://google.com"
,
"http://www.google.com"
]
bad_links
.
each
{
|
link
|
Bookmark
.
clean_link
(
link
).
should
satisfy
{
|
link
|
/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
.
match
(
link
)
}
}
end
describe
"XML"
do
it
'should serialize to XML'
do
...
...
@@ -71,4 +61,20 @@ describe Bookmark do
parsed
.
valid?
.
should
be_true
end
end
describe
'with encryption'
do
before
do
unstub_mocha_stubs
@user
=
Factory
.
create
(
:user
)
end
after
do
stub_signature_verification
end
it
'should save a signed bookmark'
do
bookmark
=
@user
.
post
(
:bookmark
,
:title
=>
"I love cryptography"
,
:link
=>
"http://pgp.mit.edu/"
)
bookmark
.
created_at
.
should_not
be
nil
end
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