profile tags now federate

This commit is contained in:
maxwell 2011-03-17 16:27:59 -07:00
parent 1c14e2676b
commit 562c0d40ac
8 changed files with 19 additions and 15 deletions

View file

@ -24,6 +24,7 @@ class Profile < ActiveRecord::Base
xml_attr :gender xml_attr :gender
xml_attr :bio xml_attr :bio
xml_attr :searchable xml_attr :searchable
xml_attr :tag_string
before_save :strip_names before_save :strip_names
after_validation :strip_names after_validation :strip_names
@ -34,10 +35,14 @@ class Profile < ActiveRecord::Base
validates_format_of :last_name, :with => /\A[^;]+\z/, :allow_blank => true validates_format_of :last_name, :with => /\A[^;]+\z/, :allow_blank => true
attr_accessible :first_name, :last_name, :image_url, :image_url_medium, attr_accessible :first_name, :last_name, :image_url, :image_url_medium,
:image_url_small, :birthday, :gender, :bio, :searchable, :date :image_url_small, :birthday, :gender, :bio, :searchable, :date, :tag_string
belongs_to :person belongs_to :person
before_save do
self.build_tags
end
def subscribers(user) def subscribers(user)
Person.joins(:contacts).where(:contacts => {:user_id => user.id}) Person.joins(:contacts).where(:contacts => {:user_id => user.id})
end end

View file

@ -204,11 +204,6 @@ class User < ActiveRecord::Base
params[:image_url_medium] = photo.url(:thumb_medium) params[:image_url_medium] = photo.url(:thumb_medium)
params[:image_url_small] = photo.url(:thumb_small) params[:image_url_small] = photo.url(:thumb_small)
end end
if tag_string = params.delete(:tags)
self.person.profile.tag_string = tag_string
self.person.profile.build_tags
self.person.profile.save
end
if self.person.profile.update_attributes(params) if self.person.profile.update_attributes(params)
Postzord::Dispatch.new(self, profile).post Postzord::Dispatch.new(self, profile).post
true true

View file

@ -14,7 +14,7 @@
%h4 %h4
= t('profiles.edit.your_tags') = t('profiles.edit.your_tags')
= text_field_tag 'profile[tags]', profile.tag_string, :placeholder => t('profiles.edit.your_tags_placeholder') = text_field_tag 'profile[tag_string]', profile.tag_string, :placeholder => t('profiles.edit.your_tags_placeholder')
%h4 %h4
= t('profiles.edit.your_photo') = t('profiles.edit.your_photo')

View file

@ -12,7 +12,7 @@ Feature: invitation acceptance
And I should see "getting_started_logo" And I should see "getting_started_logo"
When I fill in "profile_first_name" with "O" When I fill in "profile_first_name" with "O"
And I fill in "profile_last_name" with "Hai" And I fill in "profile_last_name" with "Hai"
And I fill in "profile_tags" with "#beingawesome" And I fill in "profile_tag_string" with "#beingawesome"
And I press "Save and continue" And I press "Save and continue"
Then I should see "Profile updated" Then I should see "Profile updated"
And I should see "Would you like to find your Facebook friends on Diaspora?" And I should see "Would you like to find your Facebook friends on Diaspora?"
@ -30,7 +30,7 @@ Feature: invitation acceptance
And I should see "getting_started_logo" And I should see "getting_started_logo"
When I fill in "profile_first_name" with "O" When I fill in "profile_first_name" with "O"
And I fill in "profile_last_name" with "Hai" And I fill in "profile_last_name" with "Hai"
And I fill in "profile_tags" with "#tags" And I fill in "profile_tag_string" with "#tags"
And I press "Save and continue" And I press "Save and continue"
Then I should see "Profile updated" Then I should see "Profile updated"

View file

@ -14,7 +14,7 @@ Feature: new user registration
Scenario: new user goes through the setup wizard Scenario: new user goes through the setup wizard
When I fill in "profile_first_name" with "O" When I fill in "profile_first_name" with "O"
And I fill in "profile_last_name" with "Hai" And I fill in "profile_last_name" with "Hai"
And I fill in "profile_tags" with "#gender" And I fill in "profile_tag_string" with "#gender"
And I press "Save and continue" And I press "Save and continue"
And I wait for "step 2" to load And I wait for "step 2" to load
Then I should see "Profile updated" Then I should see "Profile updated"

View file

@ -2812,10 +2812,6 @@ h1.tag
.info .info
:overflow hidden
:white-space nowrap
:text-overflow ellipsis
.tag .tag
:background :background
:color #efefef :color #efefef

View file

@ -47,7 +47,7 @@ describe ProfilesController do
it 'sets tags' do it 'sets tags' do
params = { :id => @user.person.id, params = { :id => @user.person.id,
:profile => :profile =>
{ :tags => '#apples #oranges'}} { :tag_string => '#apples #oranges'}}
put :update, params put :update, params
@user.person(true).profile.tag_list.to_set.should == ['apples', 'oranges'].to_set @user.person(true).profile.tag_list.to_set.should == ['apples', 'oranges'].to_set

View file

@ -80,6 +80,14 @@ describe Profile do
xml = person.profile.to_diaspora_xml xml = person.profile.to_diaspora_xml
xml.should include "foobar" xml.should include "foobar"
end end
it 'includes tags' do
person.profile.tag_string = '#one'
person.profile.build_tags
person.profile.save
xml = person.profile.to_diaspora_xml
xml.should include "#one"
end
end end
describe '#image_url' do describe '#image_url' do