Commit c4bef2114e2da7a44dfac36c0924c31dc9b98201

Authored by Marcos Pereira
1 parent 3c449838

fixes some tests and add migration TODO finisht it

app/controllers/public/content_viewer_controller.rb
... ... @@ -128,9 +128,9 @@ class ContentViewerController < ApplicationController
128 128 end
129 129  
130 130 unless @page.display_to?(user)
131   - if !profile.visible? || profile.secret? || (user && user.follows?(profile)) || user.blank?
  131 + if !profile.visible? || profile.secret? || (user && profile.in_social_circle?(user)) || user.blank?
132 132 render_access_denied
133   - else #!profile.public?
  133 + else
134 134 private_profile_partial_parameters
135 135 render :template => 'profile/_private_profile', :status => 403, :formats => [:html]
136 136 end
... ...
app/models/person.rb
... ... @@ -603,10 +603,4 @@ class Person < Profile
603 603 self.is_a_friend?(person) || super
604 604 end
605 605  
606   - #protected
607   -
608   - #def followed_by?(profile)
609   - # self == profile || self.followers.include?(profile)
610   - #end
611   -
612 606 end
... ...
db/migrate/20160616143830_create_followers_for_social_circles.rb 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +class CreateFollowersForSocialCircles < ActiveRecord::Migration
  2 + def up
  3 + #OK amizades
  4 + #membros de comunidade
  5 + #OK fans de empreendimento
  6 +
  7 + execute("INSERT INTO profile_followers(follower_id, profile_id, group) SELECT friend_id, person_id, group FROM friendships")
  8 + execute("INSERT INTO profile_followers(follower_id, profile_id, group) SELECT f.person_id, f.enterprise_id, 'favorites' FROM favorite_enterprise_people AS f")
  9 +
  10 + end
  11 +end
... ...
db/schema.rb
... ... @@ -375,9 +375,6 @@ ActiveRecord::Schema.define(version: 20160422163123) do
375 375 t.integer "external_environment_id"
376 376 end
377 377  
378   - add_index "environment_external_environments", ["environment_id"], name: "index_environment_external_environments_on_environment_id", using: :btree
379   - add_index "environment_external_environments", ["external_environment_id"], name: "index_environment_external_environments_on_external_environment_id", using: :btree
380   -
381 378 create_table "environments", force: :cascade do |t|
382 379 t.string "name"
383 380 t.string "contact_email"
... ...
test/functional/profile_controller_test.rb
... ... @@ -771,12 +771,13 @@ class ProfileControllerTest &lt; ActionController::TestCase
771 771 assert_equal 15, assigns(:activities).size
772 772 end
773 773  
774   - should 'not see the friends activities in the current profile' do
  774 + should 'not see the followers activities in the current profile' do
775 775 p2 = create_user.person
776   - refute profile.is_a_friend?(p2)
  776 + refute profile.follows?(p2)
777 777 p3 = create_user.person
778   - p3.add_friend(profile)
779   - assert p3.is_a_friend?(profile)
  778 + profile.follow(p3)
  779 + assert profile.follows?(p3)
  780 +
780 781 ActionTracker::Record.destroy_all
781 782  
782 783 scrap1 = create(Scrap, defaults_for_scrap(:sender => p2, :receiver => p3))
... ... @@ -964,7 +965,9 @@ class ProfileControllerTest &lt; ActionController::TestCase
964 965 should 'have activities defined if logged in and is following profile' do
965 966 login_as(profile.identifier)
966 967 p1= fast_create(Person)
967   - p1.add_friend(profile)
  968 +
  969 + profile.follow(p1)
  970 +
968 971 ActionTracker::Record.destroy_all
969 972 get :index, :profile => p1.identifier
970 973 assert_equal [], assigns(:activities)
... ...
test/unit/person_test.rb
... ... @@ -1035,12 +1035,13 @@ class PersonTest &lt; ActiveSupport::TestCase
1035 1035 p2 = create_user('p2').person
1036 1036 p3 = create_user('p3').person
1037 1037 c = fast_create(Community, :name => "Foo")
  1038 +
1038 1039 c.add_member(p1)
1039 1040 process_delayed_job_queue
1040 1041 c.add_member(p3)
1041 1042 process_delayed_job_queue
1042 1043  
1043   - assert_equal 4, ActionTracker::Record.count
  1044 + assert_equal 5, ActionTracker::Record.count
1044 1045 assert_equal 5, ActionTrackerNotification.count
1045 1046 has_add_member_notification = false
1046 1047 ActionTrackerNotification.all.map do |notification|
... ...