diff --git a/app/controllers/subscription_controller.rb b/app/controllers/subscription_controller.rb
index 05c56aac7e..5a5e7fe611 100644
--- a/app/controllers/subscription_controller.rb
+++ b/app/controllers/subscription_controller.rb
@@ -119,11 +119,16 @@ def digest
end
def multiple_add
- unless params[:names]
+ if !params[:names] || params[:names] == ''
flash[:notice] = "Please enter tags for subscription in the url."
redirect_to "/subscriptions" + "?_=" + Time.now.to_i.to_s
+ return
+ end
+ if params[:names].is_a? String
+ tag_list = params[:names].split(',')
+ else
+ tag_list = params[:names]
end
- tag_list = params[:names].split(',')
# should be logged in to subscribe
if current_user
# assume tag, for now
@@ -170,8 +175,8 @@ def multiple_add
# user or node subscription
end
else
- flash[:warning] = "You must be logged in to subscribe for email updates."
- redirect_to "/login"
+ flash[:warning] = "You must be logged in to subscribe for email updates!"
+ redirect_to "/login?return_to=" + request.fullpath
end
end
diff --git a/app/views/tag/_tags.html.erb b/app/views/tag/_tags.html.erb
index 44c9ba2ce5..4aff9fdcdd 100644
--- a/app/views/tag/_tags.html.erb
+++ b/app/views/tag/_tags.html.erb
@@ -1,7 +1,6 @@
<% tags.each do |tag| %>
<% if tag.class == NodeTag %>
-
<% if power_tag ^ tag.name.include?(':') # XOR operator??? %>
-
<%= tag.name %>
diff --git a/config/routes.rb b/config/routes.rb
index b7d3d5cb23..e0b2099089 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -87,8 +87,9 @@
get 'subscriptions' => 'subscription#index'
get 'subscriptions/digest' => 'subscription#digest'
get 'subscribe/multiple/:type/:names' => 'subscription#multiple_add'
- put 'subscribe/multiple/:type/:names' => 'subscription#multiple_add'
-
+ post 'subscribe/multiple/:type/:names' => 'subscription#multiple_add'
+ get 'subscribe/multiple/:type' => 'subscription#multiple_add'
+ post 'subscribe/multiple/:type' => 'subscription#multiple_add'
get 'wiki/stale' => 'wiki#stale'
get 'wiki/new' => 'wiki#new'
get 'wiki/replace/:id' => 'wiki#replace'
diff --git a/test/functional/subscription_controller_test.rb b/test/functional/subscription_controller_test.rb
index 57c7148296..a316eaa2da 100644
--- a/test/functional/subscription_controller_test.rb
+++ b/test/functional/subscription_controller_test.rb
@@ -37,4 +37,18 @@ def setup
assert users(:bob).following(:kites)
assert users(:bob).following(:balloon)
end
+
+ test 'should not subscribe to multiple tags in case of empty string' do
+ UserSession.create(users(:bob))
+ assert users(:bob).following(:awesome)
+ get :multiple_add, params: { type: 'tag', names: '' }
+ assert_response :redirect
+ assert_equal "Please enter tags for subscription in the url.", flash[:notice]
+ end
+
+ test 'user is not logged in and tries to subscribe multiple tags' do
+ get :multiple_add, params: { type: 'tag', names: 'kites,balloon' }
+ assert_redirected_to '/login?return_to=/subscribe/multiple/tag/kites,balloon'
+ assert_equal "You must be logged in to subscribe for email updates!", flash[:warning]
+ end
end