creating multiple tag_followings
This commit is contained in:
parent
511bd3ab03
commit
c7838debcf
4 changed files with 39 additions and 7 deletions
|
|
@ -51,4 +51,16 @@ class TagFollowingsController < ApplicationController
|
||||||
redirect_to tag_path(:name => params[:name])
|
redirect_to tag_path(:name => params[:name])
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -78,15 +78,12 @@
|
||||||
= form_for current_user.person.profile do |profile|
|
= form_for current_user.person.profile do |profile|
|
||||||
.span-5
|
.span-5
|
||||||
= profile.text_field :first_name, :placeholder => t('profiles.edit.first_name')
|
= profile.text_field :first_name, :placeholder => t('profiles.edit.first_name')
|
||||||
|
%br
|
||||||
|
= profile.submit "Save"
|
||||||
|
|
||||||
.span-7.last
|
.span-7.last
|
||||||
= render 'photos/new_profile_photo', :aspect => :getting_started, :person => current_user.person
|
= 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
|
%li.follow_interests
|
||||||
.getting_started_number
|
.getting_started_number
|
||||||
%h3
|
%h3
|
||||||
|
|
@ -99,7 +96,7 @@
|
||||||
= t('.hashtag_explanation')
|
= t('.hashtag_explanation')
|
||||||
|
|
||||||
.span-9
|
.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
|
= text_field_tag 'follow_tags', nil
|
||||||
|
|
||||||
.clearfix
|
.clearfix
|
||||||
|
|
@ -107,5 +104,5 @@
|
||||||
|
|
||||||
%li{:style => 'text-align:center;'}
|
%li{:style => 'text-align:center;'}
|
||||||
%p
|
%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();"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ Diaspora::Application.routes.draw do
|
||||||
delete "tag_followings" => "tag_followings#destroy"
|
delete "tag_followings" => "tag_followings#destroy"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
post "multiple_tag_followings" => "tag_followings#create_multiple", :as => 'multiple_tag_followings'
|
||||||
|
|
||||||
get "tag_followings" => "tag_followings#index", :as => 'tag_followings'
|
get "tag_followings" => "tag_followings#index", :as => 'tag_followings'
|
||||||
resources :mentions, :only => [:index]
|
resources :mentions, :only => [:index]
|
||||||
|
|
|
||||||
|
|
@ -102,4 +102,26 @@ describe TagFollowingsController do
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue