Skip to content
Extraits de code Groupes Projets
Valider 5a1b73dc rédigé par Daniel Grippi's avatar Daniel Grippi
Parcourir les fichiers

Merge pull request #2433 from geckoxx/2274-empty-tag

Fix Bug 2274, empty tag
parents b7412866 e16e28a7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -22,6 +22,9 @@ class PeopleController < ApplicationController ...@@ -22,6 +22,9 @@ class PeopleController < ApplicationController
if (params[:q][0] == 35 || params[:q][0] == '#') && params[:q].length > 1 if (params[:q][0] == 35 || params[:q][0] == '#') && params[:q].length > 1
redirect_to tag_path(:name => params[:q].gsub(/[#\.]/, ''), :q => params[:q]) redirect_to tag_path(:name => params[:q].gsub(/[#\.]/, ''), :q => params[:q])
return return
elsif (params[:q][0] == 35 || params[:q][0] == '#') && params[:q].length == 1
flash[:error] = I18n.t('tags.show.none', :name => params[:q])
redirect_to :back
end end
limit = params[:limit] ? params[:limit].to_i : 15 limit = params[:limit] ? params[:limit].to_i : 15
......
...@@ -15,13 +15,18 @@ class TagFollowingsController < ApplicationController ...@@ -15,13 +15,18 @@ class TagFollowingsController < ApplicationController
# POST /tag_followings.xml # POST /tag_followings.xml
def create def create
name_normalized = ActsAsTaggableOn::Tag.normalize(params['name']) name_normalized = ActsAsTaggableOn::Tag.normalize(params['name'])
@tag = ActsAsTaggableOn::Tag.find_or_create_by_name(name_normalized)
@tag_following = current_user.tag_followings.new(:tag_id => @tag.id) if name_normalized.nil? || name_normalized.empty?
flash[:error] = I18n.t('tag_followings.create.none')
if @tag_following.save
flash[:notice] = I18n.t('tag_followings.create.success', :name => name_normalized)
else else
flash[:error] = I18n.t('tag_followings.create.failure', :name => name_normalized) @tag = ActsAsTaggableOn::Tag.find_or_create_by_name(name_normalized)
@tag_following = current_user.tag_followings.new(:tag_id => @tag.id)
if @tag_following.save
flash[:notice] = I18n.t('tag_followings.create.success', :name => name_normalized)
else
flash[:error] = I18n.t('tag_followings.create.failure', :name => name_normalized)
end
end end
redirect_to :back redirect_to :back
......
...@@ -848,10 +848,12 @@ en: ...@@ -848,10 +848,12 @@ en:
following: "Following #%{tag}" following: "Following #%{tag}"
stop_following: "Stop Following #%{tag}" stop_following: "Stop Following #%{tag}"
followed_by: 'followed by' followed_by: 'followed by'
none: "The empty tag does not exist!"
tag_followings: tag_followings:
create: create:
success: "Hooray! You're now following #%{name}." success: "Hooray! You're now following #%{name}."
failure: "Failed to follow #%{name}. Are you already following it?" failure: "Failed to follow #%{name}. Are you already following it?"
none: "You cannot follow a blank tag!"
destroy: destroy:
success: "Alas! You aren't following #%{name} anymore." success: "Alas! You aren't following #%{name} anymore."
failure: "Failed to stop following #%{name}. Maybe you already stopped following it?" failure: "Failed to stop following #%{name}. Maybe you already stopped following it?"
......
...@@ -91,6 +91,11 @@ describe PeopleController do ...@@ -91,6 +91,11 @@ describe PeopleController do
get :index, :q => '#babi.es' get :index, :q => '#babi.es'
response.should redirect_to(tag_path('babies', :q => '#babi.es')) response.should redirect_to(tag_path('babies', :q => '#babi.es'))
end end
it 'stay on the page if you search for the empty hash' do
get :index, :q => '#'
flash[:error].should be_present
end
end end
describe '#tag_index' do describe '#tag_index' do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter