From 562c0d40acec2aa1b82efde91b2ea1631157d674 Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 17 Mar 2011 16:27:59 -0700 Subject: [PATCH] profile tags now federate --- app/models/profile.rb | 7 ++++++- app/models/user.rb | 5 ----- app/views/profiles/_edit_public.html.haml | 2 +- features/accepts_invitation.feature | 4 ++-- features/signs_up.feature | 2 +- public/stylesheets/sass/application.sass | 4 ---- spec/controllers/profiles_controller_spec.rb | 2 +- spec/models/profile_spec.rb | 8 ++++++++ 8 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index 82a51edd4..0ad621fd4 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -24,6 +24,7 @@ class Profile < ActiveRecord::Base xml_attr :gender xml_attr :bio xml_attr :searchable + xml_attr :tag_string before_save :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 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 + before_save do + self.build_tags + end + def subscribers(user) Person.joins(:contacts).where(:contacts => {:user_id => user.id}) end diff --git a/app/models/user.rb b/app/models/user.rb index eaacca3ae..cc9ec2609 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -204,11 +204,6 @@ class User < ActiveRecord::Base params[:image_url_medium] = photo.url(:thumb_medium) params[:image_url_small] = photo.url(:thumb_small) 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) Postzord::Dispatch.new(self, profile).post true diff --git a/app/views/profiles/_edit_public.html.haml b/app/views/profiles/_edit_public.html.haml index e92cff709..30820f0fa 100644 --- a/app/views/profiles/_edit_public.html.haml +++ b/app/views/profiles/_edit_public.html.haml @@ -14,7 +14,7 @@ %h4 = 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 = t('profiles.edit.your_photo') diff --git a/features/accepts_invitation.feature b/features/accepts_invitation.feature index feea31cb6..6bc449742 100644 --- a/features/accepts_invitation.feature +++ b/features/accepts_invitation.feature @@ -12,7 +12,7 @@ Feature: invitation acceptance And I should see "getting_started_logo" When I fill in "profile_first_name" with "O" 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" Then I should see "Profile updated" 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" When I fill in "profile_first_name" with "O" 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" Then I should see "Profile updated" diff --git a/features/signs_up.feature b/features/signs_up.feature index bd925dc67..ed5ee378a 100644 --- a/features/signs_up.feature +++ b/features/signs_up.feature @@ -14,7 +14,7 @@ Feature: new user registration Scenario: new user goes through the setup wizard When I fill in "profile_first_name" with "O" 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 wait for "step 2" to load Then I should see "Profile updated" diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index c372e6397..b8ee6de5a 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -2812,10 +2812,6 @@ h1.tag .info - :overflow hidden - :white-space nowrap - :text-overflow ellipsis - .tag :background :color #efefef diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index 241170215..a75f04bf2 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -47,7 +47,7 @@ describe ProfilesController do it 'sets tags' do params = { :id => @user.person.id, :profile => - { :tags => '#apples #oranges'}} + { :tag_string => '#apples #oranges'}} put :update, params @user.person(true).profile.tag_list.to_set.should == ['apples', 'oranges'].to_set diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index 9684a18e7..3e74c921c 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -80,6 +80,14 @@ describe Profile do xml = person.profile.to_diaspora_xml xml.should include "foobar" 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 describe '#image_url' do