diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb
index f5d0a9e..3649942 100644
--- a/app/controllers/public/profile_controller.rb
+++ b/app/controllers/public/profile_controller.rb
@@ -69,6 +69,8 @@ class ProfileController < PublicController
def following
@followed_people = profile.followed_profiles.paginate(:per_page => per_page, :page => params[:npage], :total_entries => profile.followed_profiles.count)
+ puts "FOLLOWED_PEOPLE: #{@followed_people.map(&:name)}"
+ return @followed_people
end
def followed
diff --git a/app/models/circle.rb b/app/models/circle.rb
index 861ccf3..4a7372f 100644
--- a/app/models/circle.rb
+++ b/app/models/circle.rb
@@ -1,6 +1,6 @@
class Circle < ApplicationRecord
#TODO -> n:m with profile, item in the circle
- has_many :profile, :through => :profile_follower
+ has_many :profile_followers
#TODO -> owner
belongs_to :owner, polymorphic: true
diff --git a/app/models/concerns/follower.rb b/app/models/concerns/follower.rb
index 81eadee..9ff397b 100644
--- a/app/models/concerns/follower.rb
+++ b/app/models/concerns/follower.rb
@@ -11,7 +11,7 @@ module Follower
def follows?(profile)
return false if profile.nil?
- profile.followed_by?(self)
+ p profile.followed_by?(self)
end
def unfollow(profile)
diff --git a/app/models/external_person.rb b/app/models/external_person.rb
index 7b4daf1..519689b 100644
--- a/app/models/external_person.rb
+++ b/app/models/external_person.rb
@@ -261,7 +261,7 @@ class ExternalPerson < ActiveRecord::Base
{}, followed_by?: false, display_private_info_to?: true, can_view_field?:
true, remove_from_suggestion_list: nil, layout_template: 'default',
is_admin?: false, add_friend: false, is_a_friend?: false,
- already_request_friendship?: false
+ already_request_friendship?: false, tracked_actions: ActionTracker::Record.none
}
derivated_methods = generate_derivated_methods(methods_and_responses)
diff --git a/app/models/profile_follower.rb b/app/models/profile_follower.rb
index ccc8636..9790a44 100644
--- a/app/models/profile_follower.rb
+++ b/app/models/profile_follower.rb
@@ -32,5 +32,4 @@ class ProfileFollower < ApplicationRecord
where(:circle => circle)
}
-
end
diff --git a/app/views/followers/_profile_list.html.erb b/app/views/followers/_profile_list.html.erb
index c33f43a..e67279f 100644
--- a/app/views/followers/_profile_list.html.erb
+++ b/app/views/followers/_profile_list.html.erb
@@ -1,4 +1,5 @@
+ Aqui
<% profiles.each do |followed_profile| %>
-
<%= link_to_profile profile_image(followed_profile) + tag('br') + followed_profile.short_name,
diff --git a/test/functional/circles_controller_test.rb b/test/functional/circles_controller_test.rb
index 7115275..f7fece2 100644
--- a/test/functional/circles_controller_test.rb
+++ b/test/functional/circles_controller_test.rb
@@ -10,8 +10,8 @@ class CirclesControllerTest < ActionController::TestCase
end
should 'return all circles of a profile' do
- circle1 = Circle.create!(:name => "circle1", :person => @person, :profile_type => 'Person')
- circle2 = Circle.create!(:name => "circle2", :person => @person, :profile_type => 'Person')
+ circle1 = Circle.create!(:name => "circle1", :owner => @person, :profile_type => 'Person')
+ circle2 = Circle.create!(:name => "circle2", :owner => @person, :profile_type => 'Person')
get :index, :profile => @person.identifier
assert_equivalent [circle1, circle2], assigns[:circles]
@@ -24,7 +24,7 @@ class CirclesControllerTest < ActionController::TestCase
end
should 'create a new circle' do
- assert_difference '@person.circles.count' do
+ assert_difference '@person.owned_circles.count' do
post :create, :profile => @person.identifier,
:circle => { :name => 'circle' , :profile_type => Person.name}
end
@@ -32,14 +32,14 @@ class CirclesControllerTest < ActionController::TestCase
end
should 'not create a circle without a name' do
- assert_no_difference '@person.circles.count' do
+ assert_no_difference '@person.owned_circles.count' do
post :create, :profile => @person.identifier, :circle => { :name => nil }
end
assert_template :new
end
should 'retrieve an existing circle when editing' do
- circle = Circle.create!(:name => "circle", :person => @person, :profile_type => 'Person')
+ circle = Circle.create!(:name => "circle", :owner => @person, :profile_type => 'Person')
get :edit, :profile => @person.identifier, :id => circle.id
assert_equal circle.name, assigns[:circle].name
end
@@ -50,7 +50,7 @@ class CirclesControllerTest < ActionController::TestCase
end
should 'update an existing circle' do
- circle = Circle.create!(:name => "circle", :person => @person, :profile_type => 'Person')
+ circle = Circle.create!(:name => "circle", :owner => @person, :profile_type => 'Person')
post :update, :profile => @person.identifier, :id => circle.id,
:circle => { :name => "new name" }
@@ -60,7 +60,7 @@ class CirclesControllerTest < ActionController::TestCase
end
should 'not update an existing circle without a name' do
- circle = Circle.create!(:name => "circle", :person => @person, :profile_type => 'Person')
+ circle = Circle.create!(:name => "circle", :owner => @person, :profile_type => 'Person')
post :update, :profile => @person.identifier, :id => circle.id,
:circle => { :name => nil }
@@ -75,18 +75,18 @@ class CirclesControllerTest < ActionController::TestCase
end
should 'destroy an existing circle and remove related profiles' do
- circle = Circle.create!(:name => "circle", :person => @person, :profile_type => 'Person')
+ circle = Circle.create!(:name => "circle", :owner => @person, :profile_type => 'Person')
fast_create(ProfileFollower, :profile_id => fast_create(Person).id, :circle_id => circle.id)
- assert_difference ["@person.circles.count", 'ProfileFollower.count'], -1 do
+ assert_difference ["@person.owned_circles.count", 'ProfileFollower.count'], -1 do
post :destroy, :profile => @person.identifier, :id => circle.id
end
end
should 'not destroy an existing circle if action is not post' do
- circle = Circle.create!(:name => "circle", :person => @person, :profile_type => 'Person')
+ circle = Circle.create!(:name => "circle", :owner => @person, :profile_type => 'Person')
- assert_no_difference "@person.circles.count" do
+ assert_no_difference "@person.owned_circles.count" do
get :destroy, :profile => @person.identifier, :id => circle.id
end
assert_response 404
diff --git a/test/functional/followers_controller_test.rb b/test/functional/followers_controller_test.rb
index fbe0278..f53d3b7 100644
--- a/test/functional/followers_controller_test.rb
+++ b/test/functional/followers_controller_test.rb
@@ -9,7 +9,7 @@ class FollowersControllerTest < ActionController::TestCase
should 'return followed people list' do
login_as(@profile.identifier)
person = fast_create(Person)
- circle = Circle.create!(:person=> @profile, :name => "Zombies", :profile_type => 'Person')
+ circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person')
fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle.id)
get :index, :profile => @profile.identifier
@@ -20,8 +20,8 @@ class FollowersControllerTest < ActionController::TestCase
login_as(@profile.identifier)
person = fast_create(Person)
community = fast_create(Community)
- circle = Circle.create!(:person=> @profile, :name => "Zombies", :profile_type => 'Person')
- circle2 = Circle.create!(:person=> @profile, :name => "Teams", :profile_type => 'Community')
+ circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person')
+ circle2 = Circle.create!(:owner=> @profile, :name => "Teams", :profile_type => 'Community')
fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle.id)
fast_create(ProfileFollower, :profile_id => community.id, :circle_id => circle2.id)
@@ -47,8 +47,8 @@ class FollowersControllerTest < ActionController::TestCase
should 'update followed person category' do
login_as(@profile.identifier)
person = fast_create(Person)
- circle = Circle.create!(:person=> @profile, :name => "Zombies", :profile_type => 'Person')
- circle2 = Circle.create!(:person=> @profile, :name => "DotA", :profile_type => 'Person')
+ circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person')
+ circle2 = Circle.create!(:owner=> @profile, :name => "DotA", :profile_type => 'Person')
fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle.id)
post :update_category, :profile => @profile.identifier, :circles => {"DotA"=> circle2.id}, :followed_profile_id => person.id
diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb
index 7fdd68f..73bcadf 100644
--- a/test/functional/profile_controller_test.rb
+++ b/test/functional/profile_controller_test.rb
@@ -772,7 +772,7 @@ class ProfileControllerTest < ActionController::TestCase
end
should 'not see the followers activities in the current profile' do
- circle = Circle.create!(:person=> profile, :name => "Zombies", :profile_type => 'Person')
+ circle = Circle.create!(:owner=> profile, :name => "Zombies", :profile_type => 'Person')
p2 = create_user.person
refute profile.follows?(p2)
@@ -968,7 +968,7 @@ class ProfileControllerTest < ActionController::TestCase
login_as(profile.identifier)
p1= fast_create(Person)
- circle = Circle.create!(:person=> profile, :name => "Zombies", :profile_type => 'Person')
+ circle = Circle.create!(:owner=> profile, :name => "Zombies", :profile_type => 'Person')
profile.follow(p1, circle)
@@ -1992,7 +1992,7 @@ class ProfileControllerTest < ActionController::TestCase
login_as(@profile.identifier)
person = fast_create(Person)
- circle = Circle.create!(:person=> @profile, :name => "Zombies", :profile_type => 'Person')
+ circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person')
assert_difference 'ProfileFollower.count' do
post :follow, :profile => person.identifier, :circles => {"Zombies" => circle.id}
@@ -2003,8 +2003,8 @@ class ProfileControllerTest < ActionController::TestCase
login_as(@profile.identifier)
person = fast_create(Person)
- circle = Circle.create!(:person=> @profile, :name => "Zombies", :profile_type => 'Person')
- circle2 = Circle.create!(:person=> @profile, :name => "Brainsss", :profile_type => 'Person')
+ circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person')
+ circle2 = Circle.create!(:owner=> @profile, :name => "Brainsss", :profile_type => 'Person')
assert_difference 'ProfileFollower.count', 2 do
post :follow, :profile => person.identifier, :circles => {"Zombies" => circle.id, "Brainsss"=> circle2.id}
@@ -2015,8 +2015,8 @@ class ProfileControllerTest < ActionController::TestCase
login_as(@profile.identifier)
person = fast_create(Person)
- circle = Circle.create!(:person=> @profile, :name => "Zombies", :profile_type => 'Person')
- circle2 = Circle.create!(:person=> @profile, :name => "Brainsss", :profile_type => 'Person')
+ circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person')
+ circle2 = Circle.create!(:owner=> @profile, :name => "Brainsss", :profile_type => 'Person')
assert_no_difference 'ProfileFollower.count' do
post :follow, :profile => person.identifier, :circles => {"Zombies" => "0", "Brainsss" => "0"}
@@ -2029,7 +2029,7 @@ class ProfileControllerTest < ActionController::TestCase
login_as(@profile.identifier)
person = fast_create(Person)
- circle = Circle.create!(:person=> @profile, :name => "Zombies", :profile_type => 'Person')
+ circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person')
fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle.id)
assert_no_difference 'ProfileFollower.count' do
@@ -2049,8 +2049,8 @@ class ProfileControllerTest < ActionController::TestCase
login_as(@profile.identifier)
person = fast_create(Person)
- circle = Circle.create!(:person=> @profile, :name => "Zombies", :profile_type => 'Person')
- follower = fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle.id)
+ circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person')
+ follower = ProfileFollower.create!(:profile => person, circle: circle)
assert_not_nil follower
@@ -2072,7 +2072,7 @@ class ProfileControllerTest < ActionController::TestCase
login_as(@profile.identifier)
person = fast_create(Person)
- circle = Circle.create!(:person=> @profile, :name => "Zombies", :profile_type => 'Person')
+ circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person')
fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle.id)
post :unfollow, :profile => person.identifier, :redirect_to => "/some/url"
diff --git a/test/unit/follower_test.rb b/test/unit/follower_test.rb
index a1b8e49..d49fff1 100644
--- a/test/unit/follower_test.rb
+++ b/test/unit/follower_test.rb
@@ -149,4 +149,15 @@ class FollowerTest < ActiveSupport::TestCase
person3.remove_profile_from_circle(@person2, @circle2)
assert_equivalent [@circle1, @circle2], @person2.circles
end
+
+ should 'external person be followable' do
+ person = fast_create(Person, :environment_id => Environment.default.id)
+ circle = Circle.create(owner: @external_person, profile_type: "Person", name: "FRIENDSSS")
+ pf = ProfileFollower.create(profile: @external_person, circle: circle)
+ assert person.follows? @external_person
+
+ # assert_difference 'ProfileFollower.all.count' do
+ # person.follow(@external_person, circle)
+ # end
+ end
end
--
libgit2 0.21.2