diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb index 9262c9c87..ec9c761b8 100644 --- a/app/controllers/tag_followings_controller.rb +++ b/app/controllers/tag_followings_controller.rb @@ -51,4 +51,16 @@ class TagFollowingsController < ApplicationController redirect_to tag_path(:name => params[:name]) end end + + def create_multiple + tags = params[:tags].split(",") + tags.each do |tag| + tag_name = tag.gsub(/^#/,"") + + @tag = ActsAsTaggableOn::Tag.find_or_create_by_name(tag_name) + @tag_following = current_user.tag_followings.create(:tag_id => @tag.id) + end + + redirect_to aspects_path + end end diff --git a/app/views/users/getting_started.haml b/app/views/users/getting_started.haml index 66d2d5b42..689b31e3b 100644 --- a/app/views/users/getting_started.haml +++ b/app/views/users/getting_started.haml @@ -78,15 +78,12 @@ = form_for current_user.person.profile do |profile| .span-5 = profile.text_field :first_name, :placeholder => t('profiles.edit.first_name') + %br + = profile.submit "Save" .span-7.last = render 'photos/new_profile_photo', :aspect => :getting_started, :person => current_user.person - %br - .span-6.prepend-6.last - .right - = profile.submit "Save" - %li.follow_interests .getting_started_number %h3 @@ -99,7 +96,7 @@ = t('.hashtag_explanation') .span-9 - = form_tag(tags_path, :method => 'get', :class => "tag_input search_form") do + = form_tag(multiple_tag_followings_path, :method => 'post', :class => "tag_input search_form") do = text_field_tag 'follow_tags', nil .clearfix @@ -107,5 +104,5 @@ %li{:style => 'text-align:center;'} %p - = link_to t('.awesome_take_me_to_diaspora'), getting_started_completed_path, :class => "button" + = link_to t('.awesome_take_me_to_diaspora'), "#", :class => "button", :onClick => "$('.tag_input').submit();" diff --git a/config/routes.rb b/config/routes.rb index b99f16108..2b32fd6e6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -53,6 +53,7 @@ Diaspora::Application.routes.draw do delete "tag_followings" => "tag_followings#destroy" end + post "multiple_tag_followings" => "tag_followings#create_multiple", :as => 'multiple_tag_followings' get "tag_followings" => "tag_followings#index", :as => 'tag_followings' resources :mentions, :only => [:index] diff --git a/spec/controllers/tag_followings_controller_spec.rb b/spec/controllers/tag_followings_controller_spec.rb index 040bef8e3..f3a9609f3 100644 --- a/spec/controllers/tag_followings_controller_spec.rb +++ b/spec/controllers/tag_followings_controller_spec.rb @@ -102,4 +102,26 @@ describe TagFollowingsController do end end + describe "#create_multiple" do + it "adds multiple tags" do + lambda{ + post :create_multiple, :tags => "#tags,#cats,#bats," + }.should change{ + bob.followed_tags.count + }.by(3) + end + + it "adds non-followed tags" do + TagFollowing.create!(:tag => @tag, :user => bob ) + + lambda{ + post :create_multiple, :tags => "#partytimeexcellent,#cats,#bats," + }.should change{ + bob.followed_tags.count + }.by(2) + + response.should be_redirect + end + end + end