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 if user_signed_in? && current_user.person.id != author.id
link_to image_tag('deletelabel.png'), blocks_path(:block => {:person_id => author.id}), link_to image_tag('deletelabel.png'), blocks_path(:block => {:person_id => author.id}),
:class => 'block_user delete', :class => 'block_user delete',
:confirm => t('are_you_sure'), :confirm => t('.ignore_user_description'),
:title => t('.block_user', :name => author.first_name), :title => t('.ignore_user', :name => author.first_name),
:method => :post :method => :post
end end
end end

View file

@ -10,15 +10,15 @@ module StreamHelper
"/apps/1?#{{:max_time => @posts.last.created_at.to_i}.to_param}" "/apps/1?#{{:max_time => @posts.last.created_at.to_i}.to_param}"
elsif controller.instance_of?(PeopleController) elsif controller.instance_of?(PeopleController)
person_path(@person, :max_time => time_for_scroll(opts[:ajax_stream], @stream)) person_path(@person, :max_time => time_for_scroll(opts[:ajax_stream], @stream))
elsif controller.instance_of?(TagFollowingsController) elsif controller.instance_of?(TagFollowingsController)
tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
elsif controller.instance_of?(CommunitySpotlightController) elsif controller.instance_of?(CommunitySpotlightController)
spotlight_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) spotlight_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
elsif controller.instance_of?(MentionsController) elsif controller.instance_of?(MentionsController)
mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
elsif controller.instance_of?(MultisController) elsif controller.instance_of?(MultisController)
multi_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) multi_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
elsif controller.instance_of?(PostsController) elsif controller.instance_of?(PostsController)
public_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) public_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
elsif controller.instance_of?(AspectsController) elsif controller.instance_of?(AspectsController)
aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids, :sort_order => session[:sort_order]) aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids, :sort_order => session[:sort_order])

View file

@ -19,7 +19,8 @@ class Contact < ActiveRecord::Base
validates_uniqueness_of :person_id, :scope => :user_id 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 # contact.sharing is true when contact.person is sharing with contact.user
scope :sharing, lambda { scope :sharing, lambda {
@ -39,7 +40,14 @@ class Contact < ActiveRecord::Base
Notification.where(:target_type => "Person", Notification.where(:target_type => "Person",
:target_id => person_id, :target_id => person_id,
:recipient_id => user_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 end
def dispatch_request def dispatch_request

View file

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

View file

@ -725,11 +725,11 @@ en:
blocks: blocks:
create: create:
success: "Alright, you won't see them again. #niceblock!" success: "Alright, you won't see that user in your stream again. #silencio!"
failure: "I couldn't block that user. #evasion" failure: "I couldn't ignore that user. #evasion"
destroy: destroy:
success: "User unblocked! #combobreaker" success: "Let's see what they have to say! #sayhello"
failure: "I couldn't unblock that user. #evasion" failure: "I couldn't stop ignoring that user. #evasion"
shared: shared:
aspect_dropdown: aspect_dropdown:
@ -793,7 +793,8 @@ en:
connect_to_comment: "Connect to this user to comment on their post" connect_to_comment: "Connect to this user to comment on their post"
currently_unavailable: 'commenting currently unavailable' currently_unavailable: 'commenting currently unavailable'
via: "via %{link}" 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" hide_and_mute: "Hide and mute post"
like: "Like" like: "Like"
unlike: "Unlike" unlike: "Unlike"
@ -932,8 +933,8 @@ en:
privacy_settings: privacy_settings:
title: "Privacy Settings" title: "Privacy Settings"
blocked_users: "Blocked Users" ignored_users: "Ignored Users"
unblock: "Unblock" 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." 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: getting_started:

View file

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

View file

@ -141,7 +141,7 @@ module Diaspora
end end
def shareables_from(klass, person) 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 con = Contact.arel_table
p = klass.arel_table p = klass.arel_table
shareable_ids = [] shareable_ids = []

View file

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

View file

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

View file

@ -174,4 +174,29 @@ describe Contact do
end end
end 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 end

View file

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