Merge remote branch 'drummondj/1049-unconfimed-tags'

This commit is contained in:
Raphael Sofaer 2011-06-26 23:24:03 -07:00
commit c7b4e2b4f4
2 changed files with 18 additions and 1 deletions

View file

@ -20,7 +20,15 @@ class ProfilesController < ApplicationController
def update def update
# upload and set new profile photo # upload and set new profile photo
params[:profile] ||= {} params[:profile] ||= {}
params[:tags] << params[:profile][:tag_string] unless params[:profile][:tag_string].nil? unless params[:profile][:tag_string].nil?
params[:profile][:tag_string].split( " " ).each do |extra_tag|
extra_tag.strip!
unless extra_tag == ""
extra_tag = "##{extra_tag}" unless extra_tag.start_with?( "#" )
params[:tags] += " #{extra_tag}"
end
end
end
params[:profile][:tag_string] = (params[:tags]) ? params[:tags].gsub(',',' ') : "" params[:profile][:tag_string] = (params[:tags]) ? params[:tags].gsub(',',' ') : ""
params[:profile][:searchable] ||= false params[:profile][:searchable] ||= false
params[:profile][:photo] = Photo.where(:author_id => current_user.person.id, params[:profile][:photo] = Photo.where(:author_id => current_user.person.id,

View file

@ -59,6 +59,15 @@ describe ProfilesController do
@user.person(true).profile.tag_list.to_set.should == ['apples', 'oranges', 'pears'].to_set @user.person(true).profile.tag_list.to_set.should == ['apples', 'oranges', 'pears'].to_set
end end
it 'sets plaintext tags without #' do
params = { :id => @user.person.id,
:tags => ',#apples,#oranges,',
:profile => {:tag_string => 'bananas'} }
put :update, params
@user.person(true).profile.tag_list.to_set.should == ['apples', 'oranges', 'bananas'].to_set
end
context 'with a profile photo set' do context 'with a profile photo set' do
before do before do
@params = { :id => @user.person.id, @params = { :id => @user.person.id,