Commit 0d6d7158 authored by azul's avatar azul

Merge branch 'fix-slow-member-removal' into 'staging'

Fix slow member removal

See merge request !286
parents 1065ac29 9ecd2a71
......@@ -159,14 +159,6 @@ module Group::Users
I18n.t(:no_such_membership_error, group: self.name, user: user.name)
end
# removing all participations (makes the stars disappear - not sure
# if we want this)
pages = membership.group.pages_owned
pages.each do |page|
page.users.delete user if page.users.include? user
page.save!
end
user.clear_peer_cache_of_my_peers
membership.destroy
Notice::UserRemovedNotice.create! group: self, user: user
......
......@@ -152,7 +152,7 @@ class Page < ApplicationRecord
before_save :clear_tag_cache
def clear_tag_cache
User.clear_tag_cache(user_ids) if @tags_changed
User.clear_tag_cache(user_participations.map(&:user_id)) if @tags_changed
end
#
......
......@@ -99,15 +99,14 @@ module Page::Users
# used for sphinx index
# e: why not just use the normal user_ids()? i guess the assumption is that
# user_participations will always be already loaded if we are saving the page.
# Plus it may be the first time we save the page. So
# user_participations may not exist in the database yet.
# We also only want user participations that actually grant access.
#
def user_ids
user_participations.collect(&:user_id)
user_participations.to_a.select(&:access).map(&:user_id)
end
# like users.with_access, but uses already included data
# def users_with_access
# user_participations.collect{|part| part.user if part.access }.compact
# end
# A contributor has actually modified the page in some way. A participant
# simply has a user_participation record, maybe they have never even seen
# the page.
......
......@@ -126,7 +126,7 @@ class GroupExpellTest < IntegrationTest
Time.stub(:now, 2.weeks.from_now) do
@user = users(:blue)
page = create_page(owner: groups(:animals), title: 'animals secrets')
page.add(users(:kangaroo), star: true, access: :admin)
page.add(users(:kangaroo), star: true)
page.save!
login
visit '/animals'
......@@ -152,7 +152,7 @@ class GroupExpellTest < IntegrationTest
def test_do_not_list_committee_pages_after_expel
page = create_page(owner: groups(:cold), title: 'cold colors secrets')
page.add(users(:penguin), star: true, access: :admin)
page.add(users(:penguin), star: true)
page.save!
@user = users(:penguin)
login
......
......@@ -37,7 +37,7 @@ class TagSuggestionTest < JavascriptIntegrationTest
def test_tag_suggested_via_group_participations
tag_source_page = create_user_page tag_list: ['sharedtag']
tag_source_page.add [users(:dolphin), groups(:rainbow)]
tag_source_page.add [users(:dolphin), groups(:rainbow)], access: :edit
tag_source_page.save!
tag_me = create_user_page
tag_me.add [users(:dolphin), groups(:rainbow)], access: :edit
......
......@@ -5,12 +5,19 @@ require 'test_helper'
class Page::TermsTest < ActiveSupport::TestCase
def test_create
user = users(:blue)
page = DiscussionPage.create! title: 'hi', user: user
assert_equal Page.access_ids_for(user_ids: [user.id]).first,
page = DiscussionPage.create! title: 'hi', user: user, owner: user
assert_equal Page.access_ids_for(user_ids: [user.id]).join(' '),
page.page_terms.access_ids
assert page.page_terms.delta
end
def test_star_does_not_grant_access
page = DiscussionPage.create! title: 'hi', user: users(:blue), owner: groups(:rainbow)
page.add(users(:red), star: true)
assert_equal Page.access_ids_for(group_ids: [groups(:rainbow).id]).join(' '),
page.page_terms.access_ids
end
def test_destroy
user = users(:blue)
page = DiscussionPage.create! title: 'hi', user: user
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment