Commit eaf0515d69580fc794a431d778fc456549fdd885

Authored by Leandro Santos
2 parents 1d792a6d 975a0387
Exists in production

Merge branch 'staging' into production

app/controllers/my_profile/profile_editor_controller.rb
... ... @@ -12,7 +12,7 @@ class ProfileEditorController < MyProfileController
12 12 include CategoriesHelper
13 13  
14 14 def index
15   - @pending_tasks = Task.to(profile).pending.without_spam.select{|i| user.has_permission?(i.permission, profile)}
  15 + @pending_tasks = Task.to(profile).pending.without_spam
16 16 @show_appearance_option = user.is_admin?(environment) || environment.enabled?('enable_appearance')
17 17 @show_header_footer_option = user.is_admin?(environment) || (!profile.enterprise? && !environment.enabled?('disable_header_and_footer'))
18 18 end
... ...
app/controllers/public/invite_controller.rb
... ... @@ -98,6 +98,8 @@ class InviteController < PublicController
98 98 scope = profile.invite_friends_only ? user.friends : environment.people
99 99 scope = scope.not_members_of(profile) if profile.organization?
100 100 scope = scope.not_friends_of(profile) if profile.person?
  101 + scope = scope.distinct(false).group("profiles.id")
  102 +
101 103 results = find_by_contents(:people, environment, scope, params['q'], {:page => 1}, {:joins => :user})[:results]
102 104 render :text => prepare_to_token_input(results).to_json
103 105 end
... ...
app/helpers/application_helper.rb
... ... @@ -1185,10 +1185,10 @@ module ApplicationHelper
1185 1185 end
1186 1186  
1187 1187 controller_target = suggestion.suggestion_type == 'Person' ? :friends : :memberships
1188   - profiles << link_to("<big> +#{suggestion.profile_connections.count - 4}</big>", :controller => controller_target, :action => :connections, :id => suggestion.suggestion_id) if suggestion.profile_connections.count > 4
  1188 + profiles << link_to("<big> +#{suggestion.profile_connections.count - 4}</big>".html_safe, :controller => controller_target, :action => :connections, :id => suggestion.suggestion_id) if suggestion.profile_connections.count > 4
1189 1189  
1190 1190 if profiles.present?
1191   - content_tag(:div, profiles.join , :class => 'profile-connections')
  1191 + content_tag(:div, profiles.safe_join , :class => 'profile-connections')
1192 1192 else
1193 1193 ''
1194 1194 end
... ...
app/views/home/terms.html.erb
1 1 <h1><%= _('Terms of use - %s') % environment.name %></h1>
2   -<%= environment.terms_of_use %>
  2 +<%= environment.terms_of_use.html_safe %>
... ...
app/views/profile_editor/_pending_tasks.html.erb
... ... @@ -2,9 +2,9 @@
2 2  
3 3 <% unless @pending_tasks.empty? %>
4 4 <div class='pending-tasks'>
5   - <h2><%= _('You have pending requests') %></h2>
  5 + <h2><%= _('You have %s pending requests' % @pending_tasks.count) %></h2>
6 6 <ul>
7   - <%= safe_join(@pending_tasks.map {|task| content_tag('li', task_information(task).html_safe)}) %>
  7 + <%= safe_join(@pending_tasks.limit(5).map {|task| content_tag('li', task_information(task).html_safe)}) %>
8 8 </ul>
9 9 <%= button(:todo, _('Process requests'), :controller => 'tasks', :action => 'index') %>
10 10 </div>
... ...
app/views/shared/_profile_connections.html.erb
... ... @@ -4,7 +4,7 @@
4 4 <ul class="profile-list">
5 5 <% profiles.each do |profile| %>
6 6 <li>
7   - <%= link_to_profile profile_image(profile) + '<br/>' + profile.short_name,
  7 + <%= link_to_profile profile_image(profile) + '<br/>'.html_safe + profile.short_name,
8 8 profile.identifier, :class => 'profile-link' %>
9 9 </li>
10 10 <% end %>
... ...
plugins/pg_search/test/functional/invite_controller_test.rb 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +require "test_helper"
  2 +
  3 +class InviteControllerTest < ActionController::TestCase
  4 +
  5 + should 'list people available to invite' do
  6 + env = Environment.default
  7 + env.enable_plugin(PgSearchPlugin)
  8 + profile = create_user('profile').person
  9 + login_as(profile.identifier)
  10 +
  11 + community = fast_create(Community, :name => 'Testing community 1', :identifier => 'testcommunity1', :environment_id => env)
  12 + community.add_admin profile
  13 +
  14 + p1 = fast_create(Person, :identifier => 'someone')
  15 + p2 = fast_create(Person, :identifier => 'someother')
  16 +
  17 + assert_nothing_raised do
  18 + get :search, :profile => community.identifier, :q => 'some'
  19 + end
  20 + end
  21 +
  22 +end
... ...
test/functional/profile_editor_controller_test.rb
... ... @@ -391,8 +391,6 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
391 391 user2 = create_user('usertwo').person
392 392 AddFriend.create!(:person => user1, :friend => user2)
393 393 @controller.stubs(:user).returns(user2)
394   - user2.stubs(:has_permission?).with('edit_profile', anything).returns(true)
395   - user2.expects(:has_permission?).with(:manage_friends, anything).returns(true)
396 394 login_as('usertwo')
397 395 get :index, :profile => 'usertwo'
398 396 assert_tag :tag => 'div', :attributes => { :class => 'pending-tasks' }
... ... @@ -400,16 +398,34 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
400 398  
401 399 should 'not show task if user has no permission' do
402 400 user1 = profile
  401 + community = fast_create(Community)
403 402 user2 = create_user('usertwo').person
404   - task = AddFriend.create!(:person => user1, :friend => user2)
  403 + task = AddMember.create!(person: user1, organization: community)
405 404 @controller.stubs(:user).returns(user2)
406   - user2.stubs(:has_permission?).with('edit_profile', anything).returns(true)
407   - user2.expects(:has_permission?).with(:manage_friends, anything).returns(false)
  405 + give_permission(user2, 'invite_members', community)
408 406 login_as('usertwo')
409 407 get :index, :profile => 'usertwo'
410 408 assert_no_tag :tag => 'div', :attributes => { :class => 'pending-tasks' }
411 409 end
412 410  
  411 + should 'limit task list' do
  412 + user2 = create_user('usertwo').person
  413 + 6.times { AddFriend.create!(:person => create_user.person, :friend => user2) }
  414 + login_as('usertwo')
  415 + get :index, :profile => 'usertwo'
  416 + assert_select '.pending-tasks > ul > li', 5
  417 + end
  418 +
  419 + should 'display task count in task list' do
  420 + user2 = create_user('usertwo').person
  421 + 6.times { AddFriend.create!(:person => create_user.person, :friend => user2) }
  422 + login_as('usertwo')
  423 + get :index, :profile => 'usertwo'
  424 + assert_select '.pending-tasks h2' do |elements|
  425 + assert_match /6/, elements.first.content
  426 + end
  427 + end
  428 +
413 429 should 'show favorite enterprises button for person' do
414 430 get :index, :profile => profile.identifier
415 431 assert_tag :tag => 'a', :content => 'Favorite Enterprises'
... ...