diff --git a/app/controllers/my_profile/follow_categories_controller.rb b/app/controllers/my_profile/follow_categories_controller.rb index a27eb5c..468859a 100644 --- a/app/controllers/my_profile/follow_categories_controller.rb +++ b/app/controllers/my_profile/follow_categories_controller.rb @@ -5,11 +5,11 @@ class FollowCategoriesController < MyProfileController end def new - @follow_category = FollowCategory.new + @follow_category = Circle.new end def create - @follow_category = FollowCategory.new(:name => params[:follow_category][:name], + @follow_category = Circle.new(:name => params[:follow_category][:name], :person => current_person) if @follow_category.save redirect_to :action => 'index' @@ -19,12 +19,13 @@ class FollowCategoriesController < MyProfileController end def edit - @follow_category = FollowCategory.find_by_id(params[:id]) + @follow_category = Circle.find_by_id(params[:id]) render_not_found if @follow_category.nil? end + #TODO FIX METHOD def update - @follow_category = FollowCategory.find_by_id(params[:id]) + @follow_category = Circle.find_by_id(params[:id]) return render_not_found if @follow_category.nil? if @follow_category.update(params[:follow_category]) @@ -35,7 +36,7 @@ class FollowCategoriesController < MyProfileController end def destroy - @follow_category = FollowCategory.find_by_id(params[:id]) + @follow_category = Circle.find_by_id(params[:id]) return render_not_found if @follow_category.nil? if !@follow_category.destroy diff --git a/app/controllers/my_profile/followers_controller.rb b/app/controllers/my_profile/followers_controller.rb index 75d13fa..4c695a9 100644 --- a/app/controllers/my_profile/followers_controller.rb +++ b/app/controllers/my_profile/followers_controller.rb @@ -3,27 +3,21 @@ class FollowersController < MyProfileController before_filter :only_for_person, :only => :index def index - @followed_people = current_person.following_profiles.order(:type).paginate(:per_page => 15, :page => params[:npage]) + @followed_people = current_person.followed_profiles.order(:type).paginate(:per_page => 15, :page => params[:npage]) end def set_category_modal - categories = FollowCategory.where(:person => current_person).map(&:name) + categories = Circle.where(:person => current_person).map(&:name) profile = Profile.find(params[:followed_profile_id]) render :partial => 'blocks/profile_info_actions/follow_categories', :locals => { :categories => categories, :profile => profile } end + #TODO fix def update_category params["followed_profile_id"] ||= profile.id - follower = ProfileFollower.find_by(follower_id: current_person.id, profile_id: params[:followed_profile_id]) if params[:category_name] - category = FollowCategory.find_or_create_by(:name => params[:category_name], :person => current_person) - else - category = nil - end - - if follower - follower.follow_category = category - follower.save + category = Circle.find_or_create_by(:name => params[:category_name], :person => current_person) + follower = ProfileFollower.find_or_create_by(circle: category, profile: Profile.find_by(:id => params[:followed_profile_id])) end redirect_url = params["redirect_to"] ? params["redirect_to"] : url_for(:controller => "followers", :action => "index", :profile => current_person.identifier) diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index 92291c8..ab1730f 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -4,7 +4,7 @@ class ProfileController < PublicController before_filter :check_access_to_profile, :except => [:join, :join_not_logged, :index, :add] before_filter :store_location, :only => [:join, :join_not_logged, :report_abuse, :send_mail] before_filter :login_required, :only => [:add, :join, :leave, :unblock, :leave_scrap, :remove_scrap, :remove_activity, :view_more_activities, :view_more_network_activities, :report_abuse, :register_report, :leave_comment_on_activity, :send_mail, :follow, :unfollow] - before_filter :allow_following?, :only => [:follow, :unfollow] + before_filter :allow_followers?, :only => [:follow, :unfollow] helper TagsHelper helper ActionTrackerHelper @@ -158,10 +158,10 @@ class ProfileController < PublicController def follow if !current_person.follows?(profile) - group = params['follow'] ? params['follow']['category'] : '' - current_person.follow(profile, group) + #group = params['follow'] ? params['follow']['category'] : '' + #current_person.follow(profile, group) - categories = FollowCategory.where(:person => current_person).map(&:name) + categories = Circle.where(:person => current_person).map(&:name) render :partial => 'blocks/profile_info_actions/follow_categories', :locals => { :categories => categories } else render :text => _("It was not possible to follow %s") % profile.name, :status => 400 @@ -462,8 +462,8 @@ class ProfileController < PublicController [:image, :domains, :preferred_domain, :environment] end - def allow_following? - render_not_found unless profile.allow_following? + def allow_followers? + render_not_found unless profile.allow_followers? end end diff --git a/app/models/add_member.rb b/app/models/add_member.rb index ffa2374..cbb5f35 100644 --- a/app/models/add_member.rb +++ b/app/models/add_member.rb @@ -22,7 +22,7 @@ class AddMember < Task self.roles = [Profile::Roles.member(organization.environment.id).id] end target.affiliate(requestor, self.roles.select{|r| !r.to_i.zero? }.map{|i| Role.find(i)}) - person.follow(organization, _('memberships')) + person.follow(organization, Circle.find_or_create_by(:person => person, :name =>_('memberships'))) end def title diff --git a/app/models/circle.rb b/app/models/circle.rb new file mode 100644 index 0000000..73106d7 --- /dev/null +++ b/app/models/circle.rb @@ -0,0 +1,20 @@ +class Circle < ApplicationRecord + has_many :profile_followers + belongs_to :person + + attr_accessible :name, :person, :profile_type + + validates :name, presence: true + validates :person_id, presence: true + + validates :person_id, :uniqueness => {:scope => :name, :message => "can't add two circles with the same name"} + + scope :by_owner, -> person{ + where(:person => person) + } + + scope :with_name, -> name{ + where(:name => name) + } + +end diff --git a/app/models/favorite_enterprise_person.rb b/app/models/favorite_enterprise_person.rb index deb6562..b432d87 100644 --- a/app/models/favorite_enterprise_person.rb +++ b/app/models/favorite_enterprise_person.rb @@ -8,7 +8,7 @@ class FavoriteEnterprisePerson < ApplicationRecord belongs_to :person after_create do |favorite| - favorite.person.follow(favorite.enterprise, _('favorites')) + favorite.person.follow(favotire.enterprise, Circle.find_or_create_by(:person => favorite.person, :name =>_('favorites'))) end protected diff --git a/app/models/follow_category.rb b/app/models/follow_category.rb deleted file mode 100644 index b4dca5d..0000000 --- a/app/models/follow_category.rb +++ /dev/null @@ -1,8 +0,0 @@ -class FollowCategory < ApplicationRecord - belongs_to :environment - has_many :profile_followers - belongs_to :person - - attr_accessible :name, :person - validates :name, presence: true -end diff --git a/app/models/friendship.rb b/app/models/friendship.rb index d3ff315..76ded0a 100644 --- a/app/models/friendship.rb +++ b/app/models/friendship.rb @@ -9,13 +9,15 @@ class Friendship < ApplicationRecord after_create do |friendship| Friendship.update_cache_counter(:friends_count, friendship.person, 1) Friendship.update_cache_counter(:friends_count, friendship.friend, 1) - friendship.person.follow(friendship.friend, friendship.group) + friendship.person.follow(friendship.friend, Circle.find_or_create_by(:person => friendship.person, :name => friendship.group)) end after_destroy do |friendship| Friendship.update_cache_counter(:friends_count, friendship.person, -1) Friendship.update_cache_counter(:friends_count, friendship.friend, -1) - friendship.person.unfollow(friendship.friend) + + circle=Circle.find_by(:person => friendship.person, :name => friendship.group) + friendship.person.remove_profile_from_circle(friendship.friend, circle) if circle end def self.remove_friendship(person1, person2) diff --git a/app/models/person.rb b/app/models/person.rb index 3c83e4c..f5ff215 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -92,7 +92,7 @@ class Person < Profile has_many :following_articles, :class_name => 'Article', :through => :article_followers, :source => :article has_many :friendships, :dependent => :destroy has_many :friends, :class_name => 'Person', :through => :friendships - has_many :follow_categories + has_many :circles scope :online, -> { joins(:user).where("users.chat_status != '' AND users.chat_status_at >= ?", DateTime.now - User.expires_chat_status_every.minutes) @@ -200,17 +200,33 @@ class Person < Profile end end - def follow(profile, category_name = "") - unless self.following_profiles.include?(profile) - profile_follower = ProfileFollower.new - profile_follower.profile = profile - profile_follower.follower = self - category = FollowCategory.find_or_create_by(:name => category_name, :person => self) - profile_follower.follow_category = category - profile_follower.save + def follow (profile, circles) + circles = [circles] unless circles.is_a?(Array) + circles.each do |new_circle| + ProfileFollower.create(profile: profile, circle: new_circle) end end + def update_profile_circles (profile, new_circles) + circles_to_add = new_circles - self.circles + circles_to_remove = self.circles - new_circles + + circles_to_add.each do |new_circle| + ProfileFollower.create(profile: profile, circle: new_circle) + end + + ProfileFollower.where('circle_id IN (?) AND profile_id = ?', + circles_to_remove.map(&:id), profile.id).destroy_all + end + + def unfollow(profile) + ProfileFollower.with_follower(self).with_profile(profile).destroy_all + end + + def remove_profile_from_circle(profile, circle) + ProfileFollower.with_profile(profile).with_circle(circle).destroy_all + end + def already_request_friendship?(person) person.tasks.where(requestor_id: self.id, type: 'AddFriend', status: Task::Status::ACTIVE).first end @@ -219,11 +235,6 @@ class Person < Profile Friendship.where(friend_id: friend, person_id: id).first.destroy end - def unfollow(profile) - follower = ProfileFollower.where(follower_id: id, profile_id: profile.id) if profile - follower.first.destroy if follower.present? - end - FIELDS = %w[ description image @@ -596,8 +607,8 @@ class Person < Profile person.has_permission?(:manage_friends, self) end - def following_profiles - Profile.following_profiles self + def followed_profiles + Profile.followed_by self end def in_social_circle?(person) diff --git a/app/models/profile.rb b/app/models/profile.rb index 2da0d77..33e13cf 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -5,7 +5,7 @@ class Profile < ApplicationRecord attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time, :redirection_after_login, :custom_url_redirection, - :email_suggestions, :allow_members_to_invite, :invite_friends_only, :secret, :profile_admin_mail_notification, :allow_following + :email_suggestions, :allow_members_to_invite, :invite_friends_only, :secret, :profile_admin_mail_notification, :allow_followers # use for internationalizable human type names in search facets # reimplement on subclasses @@ -203,15 +203,22 @@ class Profile < ApplicationRecord scope :more_active, -> { order 'activities_count DESC' } scope :more_recent, -> { order "created_at DESC" } - scope :following_profiles, -> person { - distinct.select('profiles.*, follow_categories.name AS category'). - joins('left join profile_followers ON profile_followers.profile_id = profiles.id'). - joins('left join follow_categories ON follow_categories.id = profile_followers.follow_category_id'). - where('profile_followers.follower_id = ?', person.id) + scope :followed_by, -> person{ + distinct.select('profiles.*, circles.name as category'). #TODO remove category from here + joins('left join profiles_circles ON profiles_circles.profile_id = profiles.id'). + joins('left join circles ON circles.id = profiles_circles.circle_id'). + where('circles.person_id = ?', person.id) } - settings_items :allow_following, :type => :boolean, :default => true - alias_method :allow_following?, :allow_following + scope :in_circle, -> circle{ + distinct.select('profiles.*'). + joins('left join profiles_circles ON profiles_circles.profile_id = profiles.id'). + joins('left join circles ON circles.id = profiles_circles.circle_id'). + where('circles.id = ?', circle.id) + } + + settings_items :allow_followers, :type => :boolean, :default => true + alias_method :allow_followers?, :allow_followers acts_as_trackable :dependent => :destroy @@ -226,7 +233,7 @@ class Profile < ApplicationRecord has_many :email_templates, :foreign_key => :owner_id has_many :profile_followers - has_many :followers, :class_name => 'Person', :through => :profile_followers + has_many :followers, :class_name => 'Person', :through => :profile_followers, :source => :person # Although this should be a has_one relation, there are no non-silly names for # a foreign key on article to reference the template to which it is @@ -777,7 +784,7 @@ private :generate_url, :url_options else self.affiliate(person, Profile::Roles.admin(environment.id), attributes) if members.count == 0 self.affiliate(person, Profile::Roles.member(environment.id), attributes) - person.follow(self, _('memberships')) + person.follow(self, Circle.find_or_create_by(:person => person, :name =>_('memberships'))) end person.tasks.pending.of("InviteMember").select { |t| t.data[:community_id] == self.id }.each { |invite| invite.cancel } remove_from_suggestion_list person diff --git a/app/models/profile_follower.rb b/app/models/profile_follower.rb index c35b199..4bf1698 100644 --- a/app/models/profile_follower.rb +++ b/app/models/profile_follower.rb @@ -1,13 +1,28 @@ class ProfileFollower < ApplicationRecord + self.table_name = :profiles_circles track_actions :new_follower, :after_create, :keep_params => ["follower.name", "follower.url", "follower.profile_custom_icon"], :custom_user => :profile - attr_accessible :profile, :follower, :follow_category + attr_accessible :profile, :circle - belongs_to :profile, :foreign_key => :profile_id - belongs_to :follower, :class_name => 'Person', :foreign_key => :follower_id - belongs_to :follow_category, :foreign_key => :follow_category_id + belongs_to :profile + belongs_to :circle - validates_presence_of :profile_id, :follower_id - validates :profile_id, :uniqueness => {:scope => :follower_id, :message => "can't follow the same profile twice"} + has_one :person, through: :circle + alias follower person + + validates_presence_of :profile_id, :circle_id + validates :profile_id, :uniqueness => {:scope => :circle_id, :message => "can't put a profile in the same circle twice"} + + scope :with_follower, -> person{ + joins(:circle).where('circles.person_id = ?', person.id) + } + + scope :with_profile, -> profile{ + where(:profile => profile) + } + + scope :with_circle, -> circle{ + where(:circle => circle) + } end diff --git a/app/views/blocks/profile_info_actions/_common.html.erb b/app/views/blocks/profile_info_actions/_common.html.erb index 49baca6..d080c98 100644 --- a/app/views/blocks/profile_info_actions/_common.html.erb +++ b/app/views/blocks/profile_info_actions/_common.html.erb @@ -1,5 +1,5 @@
  • <%= report_abuse(profile, :button) %>
  • -<%if logged_in? && (user != profile) && profile.allow_following?%> +<%if logged_in? && (user != profile) && profile.allow_followers?%>
  • <% if user.follows?(profile) %> <%= button(:unfollow, content_tag('span', _('Unfollow')), {:profile => profile.identifier, :controller => 'profile', :action => 'unfollow'}) %> diff --git a/app/views/followers/_profile_list.html.erb b/app/views/followers/_profile_list.html.erb index fe1d7a3..846d12b 100644 --- a/app/views/followers/_profile_list.html.erb +++ b/app/views/followers/_profile_list.html.erb @@ -4,7 +4,7 @@ <%= link_to_profile profile_image(profile) + tag('br') + profile.short_name, profile.identifier, :class => 'profile-link' %>

    - <%= profile.category %> + <%= profile.category #TODO get categories through scope%>

    <%= button_without_text :remove, content_tag('span',_('unfollow')), diff --git a/app/views/profile_editor/edit.html.erb b/app/views/profile_editor/edit.html.erb index 7c262be..99db5b8 100644 --- a/app/views/profile_editor/edit.html.erb +++ b/app/views/profile_editor/edit.html.erb @@ -24,7 +24,7 @@

    <%= _('Privacy options') %>

    - <%= labelled_check_box _("Allow other users to follow me"), 'profile_data[allow_following]', true, @profile.allow_following?, :class => "person-can-be-followed" %> + <%= labelled_check_box _("Allow other users to follow me"), 'profile_data[allow_followers]', true, @profile.allow_followers?, :class => "person-can-be-followed" %>
    <% if profile.person? %>
    diff --git a/db/migrate/20160608123748_create_profile_followers_table.rb b/db/migrate/20160608123748_create_profile_followers_table.rb index 3e8a853..fb8ca81 100644 --- a/db/migrate/20160608123748_create_profile_followers_table.rb +++ b/db/migrate/20160608123748_create_profile_followers_table.rb @@ -1,41 +1,42 @@ class CreateProfileFollowersTable < ActiveRecord::Migration def up - create_table :profile_followers do |t| + create_table :profiles_circles do |t| t.column :profile_id, :integer - t.column :follower_id, :integer - t.column :follow_category_id, :integer + t.column :circle_id, :integer t.timestamps end - create_table :follow_categories do |t| + create_table :circles do |t| t.column :name, :string t.belongs_to :person + t.column :profile_type, :string end - add_foreign_key :profile_followers, :follow_categories, :on_delete => :nullify + add_foreign_key :profiles_circles, :circles, :on_delete => :nullify - add_index :profile_followers, [:profile_id, :follower_id], :name => "profile_followers_composite_key_index", :unique => true + add_index :profiles_circles, [:profile_id, :circle_id], :name => "profiles_circles_composite_key_index", :unique => true + add_index :circles, [:person_id, :name], :name => "circles_composite_key_index", :unique => true #insert one category for each friend group a person has - execute("INSERT INTO follow_categories(name, person_id) SELECT DISTINCT (CASE WHEN (f.group IS NULL OR f.group = '') THEN 'friendships' ELSE f.group END), f.person_id FROM friendships as f") + execute("INSERT INTO circles(name, person_id, profile_type) SELECT DISTINCT (CASE WHEN (f.group IS NULL OR f.group = '') THEN 'friendships' ELSE f.group END), f.person_id, 'Person' FROM friendships as f") #insert 'memberships' category if a person is in a community as a member, moderator or profile admin - execute("INSERT INTO follow_categories(name, person_id) SELECT DISTINCT 'memberships', ra.accessor_id FROM role_assignments as ra JOIN roles ON ra.role_id = roles.id WHERE roles.name IN ('Member','Moderator','Profile Administrator')") + execute("INSERT INTO circles(name, person_id, profile_type) SELECT DISTINCT 'memberships', ra.accessor_id, 'Community' FROM role_assignments as ra JOIN roles ON ra.role_id = roles.id WHERE roles.name IN ('Member','Moderator','Profile Administrator')") #insert 'favorites' category if a person has any favorited enterprise - execute("INSERT INTO follow_categories(name, person_id) SELECT DISTINCT 'favorites', person_id FROM favorite_enterprise_people") + execute("INSERT INTO circles(name, person_id, profile_type) SELECT DISTINCT 'favorites', person_id, 'Enterprise' FROM favorite_enterprise_people") #insert a follower entry for each friend, with the category the same as the friendship group or equals 'friendships' - execute("INSERT INTO profile_followers(follower_id, profile_id, follow_category_id) SELECT DISTINCT f.person_id, f.friend_id, c.id FROM friendships as f JOIN follow_categories as c ON f.person_id = c.person_id WHERE c.name = f.group OR c.name = 'friendships'") + execute("INSERT INTO profiles_circles(profile_id, circle_id) SELECT DISTINCT f.friend_id, c.id FROM friendships as f JOIN circles as c ON f.person_id = c.person_id WHERE c.name = f.group OR c.name = 'friendships'") #insert a follower entry for each favorited enterprise, with the category 'favorites' - execute("INSERT INTO profile_followers(follower_id, profile_id, follow_category_id) SELECT DISTINCT f.person_id, f.enterprise_id, c.id FROM favorite_enterprise_people AS f JOIN follow_categories as c ON f.person_id = c.person_id WHERE c.name = 'favorites' ") + execute("INSERT INTO profiles_circles(profile_id, circle_id) SELECT DISTINCT f.enterprise_id, c.id FROM favorite_enterprise_people AS f JOIN circles as c ON f.person_id = c.person_id WHERE c.name = 'favorites' ") #insert a follower entry for each community a person participates as a member, moderator or admininstrator - execute("INSERT INTO profile_followers(follower_id, profile_id, follow_category_id) SELECT DISTINCT ra.accessor_id, ra.resource_id, c.id FROM role_assignments as ra JOIN roles ON ra.role_id = roles.id JOIN follow_categories as c ON ra.accessor_id = c.person_id WHERE roles.name IN ('Member','Moderator','Profile Administrator') AND c.name = 'memberships'") - + execute("INSERT INTO profiles_circles(profile_id, circle_id) SELECT DISTINCT ra.resource_id, c.id FROM role_assignments as ra JOIN roles ON ra.role_id = roles.id JOIN circles as c ON ra.accessor_id = c.person_id WHERE roles.name IN ('Member','Moderator','Profile Administrator') AND c.name = 'memberships'") end def down - remove_foreign_key :profile_followers, :follow_categories - drop_table :follow_categories - remove_index :profile_followers, :name => "profile_followers_composite_key_index" - drop_table :profile_followers + remove_foreign_key :profiles_circles, :circles + remove_index :profiles_circles, :name => "profiles_circles_composite_key_index" + remove_index :circles, :name => "circles_composite_key_index" + drop_table :circles + drop_table :profiles_circles end end diff --git a/features/step_definitions/followers_steps.rb b/features/step_definitions/followers_steps.rb index 3e24929..f27e976 100644 --- a/features/step_definitions/followers_steps.rb +++ b/features/step_definitions/followers_steps.rb @@ -1,7 +1,7 @@ Given /^the user "(.+)" has the following categories to follow$/ do |user_name,table| person = User.find_by(:login => user_name).person table.hashes.each do |category| - FollowCategory.create!(:person => person, :name => category[:name]) + Circle.create!(:person => person, :name => category[:name]) end end @@ -10,7 +10,7 @@ Then /^"(.+)" should be a follower of "(.+)" (?:with no category|with category " followers = profile.followers person = Person.find_by(identifier: person) followers.should include(person) - + # TODO fix profile follower follower if category ProfileFollower.find_by(:follower => person, :profile => profile).follow_category.name.should == category else @@ -30,8 +30,9 @@ Given /^"(.+)" is a follower of "(.+)" (?:with no category|with category "(.+)") person = Person.find_by(identifier: person) params = {:follower => person, :profile => profile} + # TODO fix profile follower follower if category - category = FollowCategory.find_by(:name => category, :person => person) + category = Circle.find_by(:name => category, :person => person) params.merge!({:follow_category => category}) end ProfileFollower.create!(params) diff --git a/test/functional/follow_categories_controller_tests.rb b/test/functional/follow_categories_controller_tests.rb index 32848d3..f9f244c 100644 --- a/test/functional/follow_categories_controller_tests.rb +++ b/test/functional/follow_categories_controller_tests.rb @@ -10,8 +10,8 @@ class FollowCategoriesControllerTest < ActionController::TestCase end should 'return all categories of a profile' do - category1 = FollowCategory.create(:name => "category1", :person => @person) - category2 = FollowCategory.create(:name => "category2", :person => @person) + category1 = Circle.create(:name => "category1", :person => @person) + category2 = Circle.create(:name => "category2", :person => @person) get :index, :profile => @person.identifier assert_equivalent [category1, category2], assigns[:categories] @@ -39,7 +39,7 @@ class FollowCategoriesControllerTest < ActionController::TestCase end should 'retrieve an existing category when editing' do - category = FollowCategory.create(:name => "category", :person => @person) + category = Circle.create(:name => "category", :person => @person) get :edit, :profile => @person.identifier, :id => category.id assert_equal category.name, assigns[:follow_category].name end @@ -50,7 +50,7 @@ class FollowCategoriesControllerTest < ActionController::TestCase end should 'update an existing category' do - category = FollowCategory.create(:name => "category", :person => @person) + category = Circle.create(:name => "category", :person => @person) get :update, :profile => @person.identifier, :id => category.id, :follow_category => { :name => "new name" } @@ -60,7 +60,7 @@ class FollowCategoriesControllerTest < ActionController::TestCase end should 'not update an existing category without a name' do - category = FollowCategory.create(:name => "category", :person => @person) + category = Circle.create(:name => "category", :person => @person) get :update, :profile => @person.identifier, :id => category.id, :follow_category => { :name => nil } @@ -75,7 +75,7 @@ class FollowCategoriesControllerTest < ActionController::TestCase end should 'destroy an existing category and update related profiles' do - category = FollowCategory.create(:name => "category", :person => @person) + category = Circle.create(:name => "category", :person => @person) follower = fast_create(ProfileFollower, :profile_id => fast_create(Person).id, :follower_id => @person.id, :follow_category_id => category.id) @@ -93,8 +93,8 @@ class FollowCategoriesControllerTest < ActionController::TestCase end should 'display notice when ' do - category = FollowCategory.create(:name => "category", :person => @person) - FollowCategory.any_instance.stubs(:destroy).returns(false) + category = Circle.create(:name => "category", :person => @person) + Circle.any_instance.stubs(:destroy).returns(false) get :destroy, :profile => @person.identifier, :id => category.id assert_not_nil session[:notice] -- libgit2 0.21.2