Commit 2f038eedf7a1e98ac6884fe87c662055a4e89f4f
1 parent
444063e9
Fixes functional tests
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Showing
4 changed files
with
8 additions
and
7 deletions
Show diff stats
app/controllers/my_profile/followers_controller.rb
... | ... | @@ -4,11 +4,11 @@ class FollowersController < MyProfileController |
4 | 4 | before_action :accept_only_post, :only => [:update_category] |
5 | 5 | |
6 | 6 | def index |
7 | - @followed_people = profile.followed_profiles.order(:type) | |
7 | + @followed_people = profile.followed_profiles.sort_by(&:type) | |
8 | 8 | @profile_types = {_('All profiles') => nil}.merge(Circle.profile_types).to_a |
9 | 9 | |
10 | 10 | if params['filter'].present? |
11 | - @followed_people = @followed_people.where(:type => params['filter']) | |
11 | + @followed_people = @followed_people.select{|c| c.type == params['filter']} | |
12 | 12 | @active_filter = params['filter'] |
13 | 13 | end |
14 | 14 | ... | ... |
app/controllers/public/profile_controller.rb
... | ... | @@ -167,6 +167,7 @@ class ProfileController < PublicController |
167 | 167 | if profile.followed_by?(current_person) |
168 | 168 | render :text => _("You are already following %s.") % profile.name, :status => 400 |
169 | 169 | else |
170 | + params[:circles] ||= [] | |
170 | 171 | selected_circles = params[:circles].map{ |circle_name, circle_id| Circle.find_by(:id => circle_id) }.select{ |c| c.present? } |
171 | 172 | if selected_circles.present? |
172 | 173 | current_person.follow(profile, selected_circles) | ... | ... |
test/functional/followers_controller_test.rb
... | ... | @@ -10,7 +10,7 @@ class FollowersControllerTest < ActionController::TestCase |
10 | 10 | login_as(@profile.identifier) |
11 | 11 | person = fast_create(Person) |
12 | 12 | circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person') |
13 | - fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle.id) | |
13 | + ProfileFollower.create(:profile => person, :circle => circle) | |
14 | 14 | |
15 | 15 | get :index, :profile => @profile.identifier |
16 | 16 | assert_includes assigns(:followed_people), person |
... | ... | @@ -22,8 +22,8 @@ class FollowersControllerTest < ActionController::TestCase |
22 | 22 | community = fast_create(Community) |
23 | 23 | circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person') |
24 | 24 | circle2 = Circle.create!(:owner=> @profile, :name => "Teams", :profile_type => 'Community') |
25 | - fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle.id) | |
26 | - fast_create(ProfileFollower, :profile_id => community.id, :circle_id => circle2.id) | |
25 | + ProfileFollower.create(:profile => person, :circle => circle) | |
26 | + ProfileFollower.create(:profile => community, :circle => circle2) | |
27 | 27 | |
28 | 28 | get :index, :profile => @profile.identifier, :filter => "Community" |
29 | 29 | assert_equal assigns(:followed_people), [community] | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -2030,10 +2030,10 @@ class ProfileControllerTest < ActionController::TestCase |
2030 | 2030 | person = fast_create(Person) |
2031 | 2031 | |
2032 | 2032 | circle = Circle.create!(:owner=> @profile, :name => "Zombies", :profile_type => 'Person') |
2033 | - fast_create(ProfileFollower, :profile_id => person.id, :circle_id => circle.id) | |
2033 | + ProfileFollower.create(:profile => person, :circle => circle) | |
2034 | 2034 | |
2035 | 2035 | assert_no_difference 'ProfileFollower.count' do |
2036 | - post :follow, :profile => person.identifier, :follow => { :circles => {"Zombies" => circle.id} } | |
2036 | + post :follow, :profile => person.identifier, :circles => {"Zombies" => circle.id} | |
2037 | 2037 | end |
2038 | 2038 | assert_response 400 |
2039 | 2039 | end | ... | ... |