eliminate one source of dup pvs
This commit is contained in:
parent
2784f641ba
commit
ff0f37ceea
5 changed files with 19 additions and 11 deletions
|
|
@ -22,8 +22,8 @@ class StatusMessagesController < ApplicationController
|
||||||
aspects = current_user.aspects_from_ids(params[:aspect_ids])
|
aspects = current_user.aspects_from_ids(params[:aspect_ids])
|
||||||
|
|
||||||
if @status_message.save
|
if @status_message.save
|
||||||
current_user.add_to_streams(@status_message, aspects)
|
|
||||||
current_user.dispatch_post(@status_message, :url => post_url(@status_message))
|
current_user.dispatch_post(@status_message, :url => post_url(@status_message))
|
||||||
|
current_user.add_to_streams(@status_message, aspects)
|
||||||
if !photos.empty?
|
if !photos.empty?
|
||||||
@status_message.photos += photos
|
@status_message.photos += photos
|
||||||
for photo in photos
|
for photo in photos
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,6 @@ class Post < ActiveRecord::Base
|
||||||
def self.diaspora_initialize params
|
def self.diaspora_initialize params
|
||||||
new_post = self.new params.to_hash
|
new_post = self.new params.to_hash
|
||||||
new_post.person = params[:person]
|
new_post.person = params[:person]
|
||||||
params[:aspect_ids].each do |aspect_id|
|
|
||||||
new_post.aspects << Aspect.find_by_id(aspect_id)
|
|
||||||
end if params[:aspect_ids]
|
|
||||||
new_post.public = params[:public] if params[:public]
|
new_post.public = params[:public] if params[:public]
|
||||||
new_post.pending = params[:pending] if params[:pending]
|
new_post.pending = params[:pending] if params[:pending]
|
||||||
new_post.diaspora_handle = new_post.person.diaspora_handle
|
new_post.diaspora_handle = new_post.person.diaspora_handle
|
||||||
|
|
|
||||||
11
db/migrate/20110211001859_unique_post_visibilities.rb
Normal file
11
db/migrate/20110211001859_unique_post_visibilities.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
class UniquePostVisibilities < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
remove_index :post_visibilities, [:aspect_id, :post_id]
|
||||||
|
add_index :post_visibilities, [:aspect_id, :post_id], :unique => true
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_index :post_visibilities, [:aspect_id, :post_id]
|
||||||
|
add_index :post_visibilities, [:aspect_id, :post_id]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -351,7 +351,7 @@ ActiveRecord::Schema.define(:version => 20110211021926) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "post_visibilities", ["aspect_id", "post_id"], :name => "index_post_visibilities_on_aspect_id_and_post_id"
|
add_index "post_visibilities", ["aspect_id", "post_id"], :name => "index_post_visibilities_on_aspect_id_and_post_id", :unique => true
|
||||||
add_index "post_visibilities", ["aspect_id"], :name => "index_post_visibilities_on_aspect_id"
|
add_index "post_visibilities", ["aspect_id"], :name => "index_post_visibilities_on_aspect_id"
|
||||||
add_index "post_visibilities", ["post_id"], :name => "index_post_visibilities_on_post_id"
|
add_index "post_visibilities", ["post_id"], :name => "index_post_visibilities_on_post_id"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,14 +134,14 @@ describe 'a user receives a post' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not override userrefs on receive by another person' do
|
it 'should not override userrefs on receive by another person' do
|
||||||
new_user = Factory(:user)
|
new_user = Factory(:user_with_aspect)
|
||||||
@status_message.post_visibilities.reset
|
@status_message.post_visibilities.reset
|
||||||
@status_message.user_refs.should == 3
|
@status_message.user_refs.should == 3
|
||||||
|
|
||||||
new_user.activate_contact(@user2.person, @aspect3)
|
new_user.activate_contact(@user2.person, new_user.aspects.first)
|
||||||
xml = @status_message.to_diaspora_xml
|
xml = @status_message.to_diaspora_xml
|
||||||
|
|
||||||
receive_with_zord(new_user, @user2.person, xml)
|
receive_with_zord(new_user, @user2.person, xml)
|
||||||
|
|
||||||
@status_message.post_visibilities.reset
|
@status_message.post_visibilities.reset
|
||||||
@status_message.user_refs.should == 4
|
@status_message.user_refs.should == 4
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue