change 'mute' to 'ignore' for now; fix specs; repopulate cache upon

contact removal
This commit is contained in:
danielgrippi 2011-11-02 21:24:13 -07:00
parent 5df6bc1adf
commit 07f713f46c
11 changed files with 60 additions and 25 deletions

View file

@ -3,8 +3,8 @@ module StreamElementHelper
if user_signed_in? && current_user.person.id != author.id
link_to image_tag('deletelabel.png'), blocks_path(:block => {:person_id => author.id}),
:class => 'block_user delete',
:confirm => t('are_you_sure'),
:title => t('.block_user', :name => author.first_name),
:confirm => t('.ignore_user_description'),
:title => t('.ignore_user', :name => author.first_name),
:method => :post
end
end

View file

@ -19,7 +19,8 @@ class Contact < ActiveRecord::Base
validates_uniqueness_of :person_id, :scope => :user_id
before_destroy :destroy_notifications
before_destroy :destroy_notifications,
:repopulate_cache!
# contact.sharing is true when contact.person is sharing with contact.user
scope :sharing, lambda {
@ -39,7 +40,14 @@ class Contact < ActiveRecord::Base
Notification.where(:target_type => "Person",
:target_id => person_id,
:recipient_id => user_id,
:type => "Notifications::StartedSharing").delete_all
:type => "Notifications::StartedSharing").delete_all
end
def repopulate_cache!
if RedisCache.configured?
cache = RedisCache.new(self.user)
cache.repopulate!
end
end
def dispatch_request

View file

@ -12,13 +12,12 @@
.span-12.prepend-5.last
%h3
= t('.blocked_users')
= t('.ignored_users')
- @blocks.each do |block|
= block.person.name
\-
= link_to t('.unblock'), block_path(block),
:confirm => t('are_you_sure'),
= link_to t('.stop_ignoring'), block_path(block),
:method => :delete
%br

View file

@ -725,11 +725,11 @@ en:
blocks:
create:
success: "Alright, you won't see them again. #niceblock!"
failure: "I couldn't block that user. #evasion"
success: "Alright, you won't see that user in your stream again. #silencio!"
failure: "I couldn't ignore that user. #evasion"
destroy:
success: "User unblocked! #combobreaker"
failure: "I couldn't unblock that user. #evasion"
success: "Let's see what they have to say! #sayhello"
failure: "I couldn't stop ignoring that user. #evasion"
shared:
aspect_dropdown:
@ -793,7 +793,8 @@ en:
connect_to_comment: "Connect to this user to comment on their post"
currently_unavailable: 'commenting currently unavailable'
via: "via %{link}"
block_user: "Block %{name}"
ignore_user: "Ignore %{name}"
ignore_user_description: "Ignore and remove user from all aspects?"
hide_and_mute: "Hide and mute post"
like: "Like"
unlike: "Unlike"
@ -932,8 +933,8 @@ en:
privacy_settings:
title: "Privacy Settings"
blocked_users: "Blocked Users"
unblock: "Unblock"
ignored_users: "Ignored Users"
stop_ignoring: "Stop ignoring"
destroy: "Your account has been locked. It may take 20 minutes for us to finish closing your account. Thank you for trying Diaspora."
getting_started:

View file

@ -4,10 +4,10 @@
class RedisCache
SUPPORTED_CACHES = [:created_at] #['updated_at',
SUPPORTED_CACHES = [:created_at]
CACHE_LIMIT = 100
def initialize(user, order_field)
def initialize(user, order_field=:created_at)
@user = user
@order_field = order_field.to_s
end

View file

@ -141,7 +141,7 @@ module Diaspora
end
def shareables_from(klass, person)
return self.person.send(klass.table_name).where(:pending => false).order("created_at DESC") if person == self.person
return self.person.send(klass.table_name).where(:pending => false).order("#{klass.table_name}.created_at DESC") if person == self.person
con = Contact.arel_table
p = klass.arel_table
shareable_ids = []

View file

@ -96,6 +96,8 @@ form
:padding
:top 45px
:bottom 8px
:left 12px
:right 12px
#flash_notice
.message

View file

@ -3,7 +3,7 @@ require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
describe Stream::Public do
before do
@stream = Stream::Public.new(stub)
@stream = Stream::Public.new(alice)
end
describe 'shared behaviors' do

View file

@ -174,4 +174,29 @@ describe Contact do
end
end
end
describe "#repopulate_cache" do
before do
@contact = bob.contact_for(alice.person)
end
it "repopulates the cache if the cache exists" do
cache = stub(:repopulate!)
RedisCache.stub(:configured? => true, :new => cache)
cache.should_receive(:repopulate!)
@contact.repopulate_cache!
end
it "does not touch the cache if it is not configured" do
RedisCache.stub(:configured?).and_return(false)
RedisCache.should_not_receive(:new)
@contact.repopulate_cache!
end
it "gets called on destroy" do
@contact.should_receive(:repopulate_cache!)
@contact.destroy
end
end
end

View file

@ -52,8 +52,8 @@ describe Diaspora::UserModules::Connecting do
it 'calls remove contact' do
contact = bob.contact_for(alice.person)
bob.should_receive(:remove_contact).with(contact)
bob.disconnect contact
bob.should_receive(:remove_contact).with(contact, {})
bob.disconnect(contact)
end
it 'dispatches a retraction' do