diff --git a/app/controllers/subscription_controller.rb b/app/controllers/subscription_controller.rb index 5a5e7fe611..40b77ab479 100644 --- a/app/controllers/subscription_controller.rb +++ b/app/controllers/subscription_controller.rb @@ -119,15 +119,15 @@ def digest end def multiple_add - if !params[:names] || params[:names] == '' + if !params[:tagnames] || params[:tagnames] == '' 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(',') + if params[:tagnames].is_a? String + tag_list = params[:tagnames].split(',') else - tag_list = params[:names] + tag_list = params[:tagnames] end # should be logged in to subscribe if current_user @@ -136,7 +136,7 @@ def multiple_add tag_list.each do |t| if t.length.positive? tag = Tag.find_by(name: t) - # t should be not nil consider params[:names] = balloon,,mapping,,kites,oil + # t should be not nil consider params[:tagnames] = balloon,,mapping,,kites,oil if tag.nil? # if the tag doesn't exist, we should create it! # this could fail validations; error out if so... @@ -166,7 +166,7 @@ def multiple_add if request.xhr? render :json => true else - flash[:notice] = "You are now following '#{params[:names]}'." + flash[:notice] = "You are now following '#{params[:tagnames]}'." redirect_to "/subscriptions" + "?_=" + Time.now.to_i.to_s end end diff --git a/config/routes.rb b/config/routes.rb index e0b2099089..c4ed497a6b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,8 +86,8 @@ get 'subscribe/:type/:name' => 'subscription#add' get 'subscriptions' => 'subscription#index' get 'subscriptions/digest' => 'subscription#digest' - get 'subscribe/multiple/:type/:names' => 'subscription#multiple_add' - post 'subscribe/multiple/:type/:names' => 'subscription#multiple_add' + get 'subscribe/multiple/:type/:tagnames' => 'subscription#multiple_add' + post 'subscribe/multiple/:type/:tagnames' => 'subscription#multiple_add' get 'subscribe/multiple/:type' => 'subscription#multiple_add' post 'subscribe/multiple/:type' => 'subscription#multiple_add' get 'wiki/stale' => 'wiki#stale' diff --git a/test/functional/subscription_controller_test.rb b/test/functional/subscription_controller_test.rb index a316eaa2da..bcf4d7dba7 100644 --- a/test/functional/subscription_controller_test.rb +++ b/test/functional/subscription_controller_test.rb @@ -30,7 +30,7 @@ def setup test 'should subscribe to multiple tags' do UserSession.create(users(:bob)) assert users(:bob).following(:awesome) - get :multiple_add, params: { type: 'tag', names: 'blog,kites,,balloon,awesome' } + get :multiple_add, params: { type: 'tag', tagnames: 'blog,kites,,balloon,awesome' } assert_response :redirect assert users(:bob).following(:blog) assert users(:bob).following(:awesome) @@ -41,13 +41,13 @@ def setup 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: '' } + get :multiple_add, params: { type: 'tag', tagnames: '' } 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' } + get :multiple_add, params: { type: 'tag', tagnames: '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