Unverified Commit ca2dd532 authored by Jonne Haß's avatar Jonne Haß

Merge pull request #6940 from SuperTux88/cleanup-posts-table

Cleanup posts table
parents e738f40d d3edbfd8
......@@ -116,6 +116,7 @@ before.
* Extract photo export into a service class [#6922](https://github.com/diaspora/diaspora/pull/6922)
* Use handlebars template for aspect membership dropdown [#6864](https://github.com/diaspora/diaspora/pull/6864)
* Extract relayable signatures into their own tables [#6932](https://github.com/diaspora/diaspora/pull/6932)
* Remove outdated columns from posts table [#6940](https://github.com/diaspora/diaspora/pull/6940)
## Bug fixes
* Destroy Participation when removing interactions with a post [#5852](https://github.com/diaspora/diaspora/pull/5852)
......
......@@ -334,7 +334,6 @@ app.views.Publisher = Backbone.View.extend({
"author" : app.currentUser ? app.currentUser.attributes : {},
"mentioned_people" : mentionedPeople,
"photos" : photos,
"frame_name" : "status",
"title" : serializedForm["status_message[text]"],
"location" : location,
"interactions" : {"likes":[],"reshares":[],"comments_count":0,"likes_count":0,"reshares_count":0},
......
......@@ -141,6 +141,6 @@ class Photo < ActiveRecord::Base
else
Photo.where(author_id: person.id, public: true)
end
photos.order("created_at desc")
photos.where(pending: false).order("created_at DESC")
end
end
......@@ -43,6 +43,7 @@ class Post < ActiveRecord::Base
) #note should include root and photos, but i think those are both on status_message
}
scope :all_public, -> { where(public: true) }
scope :commented_by, ->(person) {
select('DISTINCT posts.*')
......@@ -129,10 +130,6 @@ class Post < ActiveRecord::Base
new(params.to_hash.stringify_keys.slice(*column_names, "author"))
end
def activity_streams?
false
end
def comment_email_subject
I18n.t('notifier.a_post_you_shared')
end
......
......@@ -117,7 +117,7 @@ module User::Querying
end
def visible_shareables_query(query, opts)
query.with_visibility.where(pending: false).where(
query.with_visibility.where(
visible_private_shareables(opts).or(opts[:klass].arel_table[:public].eq(true))
)
end
......@@ -129,7 +129,7 @@ module User::Querying
end
def construct_shareable_from_self_query(opts)
conditions = {pending: false, author_id: person_id}
conditions = {author_id: person_id}
conditions[:type] = opts[:type] if opts.has_key?(:type)
query = opts[:klass].where(conditions)
......
......@@ -15,7 +15,7 @@ class PostPresenter < BasePresenter
private
def directly_retrieved_attributes
%i(id guid public created_at interacted_at provider_display_name image_url object_url)
%i(id guid public created_at interacted_at provider_display_name)
end
def non_directly_retrieved_attributes
......
......@@ -5,9 +5,6 @@ module Export
:public,
:diaspora_handle,
:type,
:image_url,
:image_height,
:image_width,
:likes_count,
:comments_count,
:reshares_count,
......
......@@ -13,9 +13,8 @@
- unless post.is_a?(Reshare)
= render "shared/nsfw_shield", post: post
- if !post.activity_streams?
.nsfw-hidden
= render "status_messages/status_message", post: post, photos: post.photos
.nsfw-hidden
= render "status_messages/status_message", post: post, photos: post.photos
- else
.content
= t(".deleted")
......
......@@ -11,6 +11,3 @@
.additional_photo_count
= "+ #{post.photos.size-1}"
= image_tag post.photos.first.url(:thumb_large), class: "stream-photo big-stream-photo"
- elsif post.activity_streams?
= image_tag post.image_url
......@@ -20,9 +20,7 @@
= link_to(post_path(post)) do
= timeago(post.created_at)
%span.via
- if post.activity_streams?
= t('shared.stream_element.via', link: link_to("#{post.provider_display_name}", post.actor_url)).html_safe
- elsif post.provider_display_name == 'mobile'
- if post.provider_display_name == "mobile"
= t('shared.stream_element.via_mobile', link: nil)
&ndash;
%span.scope_scope
......
......@@ -11,8 +11,6 @@
.additional_photo_count
= "+ #{post.photos.size-1}"
= image_tag post.first_photo_url(:thumb_large), :class => "stream-photo big-stream-photo"
- elsif post.activity_streams?
= image_tag post.image_url
%div{:class => direction_for(post.text)}
!= post.message.markdownified
......
class CleanupPostsTable < ActiveRecord::Migration
def change
remove_index :posts, column: %i(status_message_guid pending),
name: :index_posts_on_status_message_guid_and_pending, length: {status_message_guid: 190}
remove_index :posts, column: :status_message_guid, name: :index_posts_on_status_message_guid, length: 191
remove_index :posts, column: %i(type pending id), name: :index_posts_on_type_and_pending_and_id
# from photos?
remove_column :posts, :pending, :boolean, default: false, null: false
remove_column :posts, :remote_photo_path, :text
remove_column :posts, :remote_photo_name, :string
remove_column :posts, :random_string, :string
remove_column :posts, :processed_image, :string
remove_column :posts, :unprocessed_image, :string
remove_column :posts, :status_message_guid, :string
# old cubbi.es stuff
remove_column :posts, :object_url, :string
remove_column :posts, :image_url, :string
remove_column :posts, :image_height, :integer
remove_column :posts, :image_width, :integer
remove_column :posts, :actor_url, :string
remove_column :posts, :objectId, :string
# old single post view templates
remove_column :posts, :frame_name, :string
add_index :posts, %i(id type), name: :index_posts_on_id_and_type
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160720212620) do
ActiveRecord::Schema.define(version: 20160802212635) do
create_table "account_deletions", force: :cascade do |t|
t.string "diaspora_handle", limit: 255
......@@ -450,31 +450,17 @@ ActiveRecord::Schema.define(version: 20160720212620) do
t.integer "author_id", limit: 4, null: false
t.boolean "public", default: false, null: false
t.string "guid", limit: 255, null: false
t.boolean "pending", default: false, null: false
t.string "type", limit: 40, null: false
t.text "text", limit: 65535
t.text "remote_photo_path", limit: 65535
t.string "remote_photo_name", limit: 255
t.string "random_string", limit: 255
t.string "processed_image", limit: 255
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "unprocessed_image", limit: 255
t.string "object_url", limit: 255
t.string "image_url", limit: 255
t.integer "image_height", limit: 4
t.integer "image_width", limit: 4
t.string "provider_display_name", limit: 255
t.string "actor_url", limit: 255
t.string "objectId", limit: 255
t.string "root_guid", limit: 255
t.string "status_message_guid", limit: 255
t.integer "likes_count", limit: 4, default: 0
t.integer "comments_count", limit: 4, default: 0
t.integer "o_embed_cache_id", limit: 4
t.integer "reshares_count", limit: 4, default: 0
t.datetime "interacted_at"
t.string "frame_name", limit: 255
t.string "facebook_id", limit: 255
t.string "tweet_id", limit: 255
t.integer "open_graph_cache_id", limit: 4
......@@ -485,11 +471,9 @@ ActiveRecord::Schema.define(version: 20160720212620) do
add_index "posts", ["author_id"], name: "index_posts_on_person_id", using: :btree
add_index "posts", ["guid"], name: "index_posts_on_guid", unique: true, length: {"guid"=>191}, using: :btree
add_index "posts", ["id", "type", "created_at"], name: "index_posts_on_id_and_type_and_created_at", using: :btree
add_index "posts", ["id", "type"], name: "index_posts_on_id_and_type", using: :btree
add_index "posts", ["root_guid"], name: "index_posts_on_root_guid", length: {"root_guid"=>191}, using: :btree
add_index "posts", ["status_message_guid", "pending"], name: "index_posts_on_status_message_guid_and_pending", length: {"status_message_guid"=>190, "pending"=>nil}, using: :btree
add_index "posts", ["status_message_guid"], name: "index_posts_on_status_message_guid", length: {"status_message_guid"=>191}, using: :btree
add_index "posts", ["tweet_id"], name: "index_posts_on_tweet_id", length: {"tweet_id"=>191}, using: :btree
add_index "posts", ["type", "pending", "id"], name: "index_posts_on_type_and_pending_and_id", using: :btree
create_table "ppid", force: :cascade do |t|
t.integer "o_auth_application_id", limit: 4
......
......@@ -109,14 +109,13 @@ module Diaspora; module Fetcher; class Public
:author => @person,
:public => true
)
entry.assign_attributes({
:guid => post['guid'],
:text => post['text'],
:provider_display_name => post['provider_display_name'],
:created_at => ActiveSupport::TimeZone.new('UTC').parse(post['created_at']).to_datetime,
:interacted_at => ActiveSupport::TimeZone.new('UTC').parse(post['interacted_at']).to_datetime,
:frame_name => post['frame_name']
})
entry.assign_attributes(
guid: post["guid"],
text: post["text"],
provider_display_name: post["provider_display_name"],
created_at: ActiveSupport::TimeZone.new("UTC").parse(post["created_at"]).to_datetime,
interacted_at: ActiveSupport::TimeZone.new("UTC").parse(post["interacted_at"]).to_datetime
)
entry.save
# re-enable everything we disabled before
......
......@@ -19,8 +19,6 @@ module Diaspora
delegate :id, :name, :first_name, to: :author, prefix: true
# scopes
scope :all_public, -> { where(public: true, pending: false) }
scope :with_visibility, -> {
joins("LEFT OUTER JOIN share_visibilities ON share_visibilities.shareable_id = #{table_name}.id AND "\
"share_visibilities.shareable_type = '#{base_class}'")
......@@ -77,7 +75,7 @@ module Diaspora
end
def owned_by_user(user)
user.person.public_send(table_name).where(pending: false)
user.person.public_send(table_name)
end
private
......
contact_mongo_id,aspect_mongo_id
4d2b6eb7cc8cb43cc200000f,4d2b6eb6cc8cb43cc2000008
4d2b6eb7cc8cb43cc2000010,4d2b6eb7cc8cb43cc200000c
4d2b6eb7cc8cb43cc2000013,4d2b6eb7cc8cb43cc200000c
4d2b6eb7cc8cb43cc200001c,4d2b6eb7cc8cb43cc2000015
4d2b6eb8cc8cb43cc2000022,4d2b6eb7cc8cb43cc2000015
4d2b6ec2cc8cb43cc2000035,4d2b6eb7cc8cb43cc2000019
mongo_id,name,user_mongo_id,created_at,updated_at
4d2b6eb6cc8cb43cc2000008,generic,4d2b6eb6cc8cb43cc2000007,1294692022000,1294692033000
4d2b6eb7cc8cb43cc200000c,generic,4d2b6eb6cc8cb43cc200000b,1294692023000,1294692033000
4d2b6eb7cc8cb43cc2000015,generic,4d2b6eb7cc8cb43cc2000014,1294692023000,1294692034000
4d2b6eb7cc8cb43cc2000019,generic,4d2b6eb7cc8cb43cc2000018,1294692023000,1294692036000
mongo_id,post_mongo_id,person_mongo_id,diaspora_handle,text,youtube_titles
4d2b6ebfcc8cb43cc200002b,4d2b6ebecc8cb43cc2000029,4d2b6eb7cc8cb43cc2000017,bob3c6c46f@localhost,Hey me!,""
4d2b6ebfcc8cb43cc200002c,4d2b6ebecc8cb43cc2000027,4d2b6eb7cc8cb43cc200000e,bob2f66ee4@localhost,Hey you!,""
mongo_id,user_mongo_id,person_mongo_id,pending,created_at,updated_at
4d2b6eb7cc8cb43cc200000f,4d2b6eb6cc8cb43cc2000007,4d2b6eb7cc8cb43cc200000e,false,,
4d2b6eb7cc8cb43cc2000010,4d2b6eb6cc8cb43cc200000b,4d2b6eb6cc8cb43cc200000a,false,,
4d2b6eb7cc8cb43cc2000013,4d2b6eb6cc8cb43cc200000b,4d2b6eb7cc8cb43cc2000011,false,,
4d2b6eb7cc8cb43cc200001c,4d2b6eb7cc8cb43cc2000014,4d2b6eb7cc8cb43cc200001b,true,,
4d2b6eb8cc8cb43cc2000022,4d2b6eb7cc8cb43cc2000014,4d2b6eb8cc8cb43cc2000020,true,,
4d2b6ec2cc8cb43cc2000035,4d2b6eb7cc8cb43cc2000018,4d2b6ec2cc8cb43cc2000034,false,,
mongo_id,recipient_mongo_id,sender_mongo_id,aspect_mongo_id,message
4d2b6ebecc8cb43cc2000026,4d2b6ebccc8cb43cc2000025,4d2b6eb6cc8cb43cc2000007,4d2b6eb6cc8cb43cc2000008,Hello!
mongo_id,target_mongo_id,recipient_mongo_id,actor_mongo_id,action,target_type,unread
4d2b6eb8cc8cb43cc200001f,4d2b6eb8cc8cb43cc200001e,4d2b6eb7cc8cb43cc2000018,4d2b6eb7cc8cb43cc2000017,,new_request,true
4d2b6ec4cc8cb43cc200003b,4d2b6ec4cc8cb43cc200003a,4d2b6eb6cc8cb43cc200000b,4d2b6ec2cc8cb43cc2000034,,new_request,true
created_at,updated_at,serialized_public_key,url,mongo_id,owner_mongo_id,diaspora_handle
1294692022000,1294692022000,"-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAKuK2doYFmBhcymlxKTII8fmFUXQtgk+NxSoJqCRWds/Uhsg/S/97Kzp
DJjzYWWDKNRfHXnrKsQ5wgcis+rIuvVrB6uVVe2pWjVRZoDxC/4qy5TghwnBsf5O
9/mfN1YhZLRzHCbGL5GBDwk5+emP7Re6l4hqNZRxZB5bpssoTShdAgMBAAE=
-----END RSA PUBLIC KEY-----
",http://google-1b05052.com/,4d2b6eb6cc8cb43cc2000001,,bob-person-1fe12fb@aol.com
1294692022000,1294692022000,"-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAKuK2doYFmBhcymlxKTII8fmFUXQtgk+NxSoJqCRWds/Uhsg/S/97Kzp
DJjzYWWDKNRfHXnrKsQ5wgcis+rIuvVrB6uVVe2pWjVRZoDxC/4qy5TghwnBsf5O
9/mfN1YhZLRzHCbGL5GBDwk5+emP7Re6l4hqNZRxZB5bpssoTShdAgMBAAE=
-----END RSA PUBLIC KEY-----
",http://google-287b15e.com/,4d2b6eb6cc8cb43cc2000003,,bob-person-2281475@aol.com
1294692022000,1294692022000,"-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAKuK2doYFmBhcymlxKTII8fmFUXQtgk+NxSoJqCRWds/Uhsg/S/97Kzp
DJjzYWWDKNRfHXnrKsQ5wgcis+rIuvVrB6uVVe2pWjVRZoDxC/4qy5TghwnBsf5O
9/mfN1YhZLRzHCbGL5GBDwk5+emP7Re6l4hqNZRxZB5bpssoTShdAgMBAAE=
-----END RSA PUBLIC KEY-----
",http://google-37bb582.com/,4d2b6eb6cc8cb43cc2000005,,bob-person-34e6e33@aol.com
1294692022000,1294692033000,"-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANLXsDZWFFy/SyjfTcykyCZVd5raI7G+EF+2kM3yF8UAAHf3FdinP0xv
mB9LsL86PZMiVfKSYU/pwPaIDO/XccnMspd6KxHORX+SbB9F3HC5auiYeekqNxPu
GqmsgBGFLjz8FZ3pbJbuu44XLf0cP1qfBqxKaDSOpwRH8bxvaUXLAgMBAAE=
-----END RSA PUBLIC KEY-----
",http://google-4e2e53f.com/,4d2b6eb6cc8cb43cc200000a,4d2b6eb6cc8cb43cc2000007,bob1d2f837@localhost
1294692023000,1294692032000,"-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANLXsDZWFFy/SyjfTcykyCZVd5raI7G+EF+2kM3yF8UAAHf3FdinP0xv
mB9LsL86PZMiVfKSYU/pwPaIDO/XccnMspd6KxHORX+SbB9F3HC5auiYeekqNxPu
GqmsgBGFLjz8FZ3pbJbuu44XLf0cP1qfBqxKaDSOpwRH8bxvaUXLAgMBAAE=
-----END RSA PUBLIC KEY-----
",http://google-57834ac.com/,4d2b6eb7cc8cb43cc200000e,4d2b6eb6cc8cb43cc200000b,bob2f66ee4@localhost
1294692023000,1294692023000,"-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAKuK2doYFmBhcymlxKTII8fmFUXQtgk+NxSoJqCRWds/Uhsg/S/97Kzp
DJjzYWWDKNRfHXnrKsQ5wgcis+rIuvVrB6uVVe2pWjVRZoDxC/4qy5TghwnBsf5O
9/mfN1YhZLRzHCbGL5GBDwk5+emP7Re6l4hqNZRxZB5bpssoTShdAgMBAAE=
-----END RSA PUBLIC KEY-----
",http://google-6be752e.com/,4d2b6eb7cc8cb43cc2000011,,bob-person-46c7362@aol.com
1294692023000,1294692034000,"-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANLXsDZWFFy/SyjfTcykyCZVd5raI7G+EF+2kM3yF8UAAHf3FdinP0xv
mB9LsL86PZMiVfKSYU/pwPaIDO/XccnMspd6KxHORX+SbB9F3HC5auiYeekqNxPu
GqmsgBGFLjz8FZ3pbJbuu44XLf0cP1qfBqxKaDSOpwRH8bxvaUXLAgMBAAE=
-----END RSA PUBLIC KEY-----
",http://google-732b7c0.com/,4d2b6eb7cc8cb43cc2000017,4d2b6eb7cc8cb43cc2000014,bob3c6c46f@localhost
1294692023000,1294692036000,"-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANLXsDZWFFy/SyjfTcykyCZVd5raI7G+EF+2kM3yF8UAAHf3FdinP0xv
mB9LsL86PZMiVfKSYU/pwPaIDO/XccnMspd6KxHORX+SbB9F3HC5auiYeekqNxPu
GqmsgBGFLjz8FZ3pbJbuu44XLf0cP1qfBqxKaDSOpwRH8bxvaUXLAgMBAAE=
-----END RSA PUBLIC KEY-----
",http://google-8b1c74b.com/,4d2b6eb7cc8cb43cc200001b,4d2b6eb7cc8cb43cc2000018,bob457b189@localhost
1294692024000,1294692024000,"-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAKuK2doYFmBhcymlxKTII8fmFUXQtgk+NxSoJqCRWds/Uhsg/S/97Kzp
DJjzYWWDKNRfHXnrKsQ5wgcis+rIuvVrB6uVVe2pWjVRZoDxC/4qy5TghwnBsf5O
9/mfN1YhZLRzHCbGL5GBDwk5+emP7Re6l4hqNZRxZB5bpssoTShdAgMBAAE=
-----END RSA PUBLIC KEY-----
",http://google-934e10b.com/,4d2b6eb8cc8cb43cc2000020,,bob-person-5e2a1d1@aol.com
1294692034000,1294692036000,"-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANLXsDZWFFy/SyjfTcykyCZVd5raI7G+EF+2kM3yF8UAAHf3FdinP0xv
mB9LsL86PZMiVfKSYU/pwPaIDO/XccnMspd6KxHORX+SbB9F3HC5auiYeekqNxPu
GqmsgBGFLjz8FZ3pbJbuu44XLf0cP1qfBqxKaDSOpwRH8bxvaUXLAgMBAAE=
-----END RSA PUBLIC KEY-----
",http://google-105a8ed8.com/,4d2b6ec2cc8cb43cc2000034,,bob5aa0fd5@localhost
aspect_mongo_id,post_mongo_id
4d2b6eb6cc8cb43cc2000008,4d2b6ebecc8cb43cc2000027
4d2b6eb6cc8cb43cc2000008,4d2b6ebfcc8cb43cc200002d
4d2b6eb7cc8cb43cc200000c,4d2b6ebecc8cb43cc2000027
4d2b6eb7cc8cb43cc200000c,4d2b6ebfcc8cb43cc200002d
4d2b6eb7cc8cb43cc2000015,4d2b6ebecc8cb43cc2000029
4d2b6eb7cc8cb43cc2000015,4d2b6ec1cc8cb43cc200002f
4d2b6eb7cc8cb43cc2000019,4d2b6ec2cc8cb43cc2000036
4d2b6eb7cc8cb43cc2000019,4d2b6ec4cc8cb43cc2000037
youtube_titles,pending,created_at,public,updated_at,status_message_mongo_id,caption,remote_photo_path,remote_photo_name,random_string,image,mongo_id,type,diaspora_handle,person_mongo_id,message
"",false,1294692030000,false,1294692030000,,,,,,,4d2b6ebecc8cb43cc2000027,StatusMessage,bob1d2f837@localhost,4d2b6eb6cc8cb43cc200000a,User2 can see this
"",false,1294692030000,false,1294692030000,,,,,,,4d2b6ebecc8cb43cc2000029,StatusMessage,bob3c6c46f@localhost,4d2b6eb7cc8cb43cc2000017,User3 can see this
,false,1294692030000,false,1294692030000,4d2b6ebecc8cb43cc2000027,,,,mUKUIxkYlV,mUKUIxkYlV4d2b6ebfcc8cb43cc200002d.png,4d2b6ebfcc8cb43cc200002d,Photo,bob2f66ee4@localhost,4d2b6eb7cc8cb43cc200000e,
,false,1294692034000,false,1294692034000,,,,,AtwSOhcrt0,AtwSOhcrt04d2b6ec1cc8cb43cc200002f.png,4d2b6ec1cc8cb43cc200002f,Photo,bob3c6c46f@localhost,4d2b6eb7cc8cb43cc2000017,
,false,1294692036000,false,1294692036000,,,/uploads/images,3jcOyI5M444d2b6ec2cc8cb43cc2000036.png,,,4d2b6ec2cc8cb43cc2000036,Photo,bob5aa0fd5@localhost,4d2b6ec2cc8cb43cc2000034,
"",false,1294692036000,false,1294692036000,,,,,,,4d2b6ec4cc8cb43cc2000037,StatusMessage,bob5aa0fd5@localhost,4d2b6ec2cc8cb43cc2000034,from another server!
image_url_medium,searchable,image_url,person_mongo_id,gender,diaspora_handle,birthday,last_name,bio,image_url_small,first_name
,true,,4d2b6eb6cc8cb43cc2000001,,,,weinstien,,,eugene
,true,,4d2b6eb6cc8cb43cc2000003,,,,weinstien,,,eugene
,true,,4d2b6eb6cc8cb43cc2000005,,,,weinstien,,,eugene
,true,,4d2b6eb6cc8cb43cc200000a,,,,Grimm12dfa3a,,,Robert1742367
,true,,4d2b6eb7cc8cb43cc200000e,,,,Grimm2527144,,,Robert27d6c2c
,true,,4d2b6eb7cc8cb43cc2000011,,,,weinstien,,,eugene
,true,,4d2b6eb7cc8cb43cc2000017,,,,Grimm3089db2,,,Robert39365a5
,true,,4d2b6eb7cc8cb43cc200001b,,,,Grimm49fb290,,,Robert405fcf8
,true,,4d2b6eb8cc8cb43cc2000020,,,,weinstien,,,eugene
,true,,4d2b6ec2cc8cb43cc2000034,,,,Grimm50990f2,,,Robert5501643
mongo_id,recipient_mongo_id,sender_mongo_id,aspect_mongo_id
4d2b6eb8cc8cb43cc200001e,4d2b6eb7cc8cb43cc200001b,4d2b6eb7cc8cb43cc2000017,
4d2b6ec4cc8cb43cc200003a,4d2b6eb7cc8cb43cc200000e,4d2b6ec2cc8cb43cc2000034,
mongo_id,type,user_mongo_id,provider,uid,access_token,access_secret,nickname
4d2b6ec4cc8cb43cc200003e,Services::Facebook,4d2b6eb7cc8cb43cc2000014,,,yeah,,
4d2b6ec4cc8cb43cc200003f,Services::Twitter,4d2b6eb6cc8cb43cc200000b,,,yeah,foobar,
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -81,13 +81,11 @@ var factory = {
"interacted_at" : '2012-01-03T19:53:13Z',
"public" : false,
"guid" : this.guid(),
"image_url" : null,
"o_embed_cache" : null,
"open_graph_cache": null,
"photos" : [],
"text" : "jasmine is bomb",
"id" : this.id.next(),
"object_url" : null,
"root" : null,
"post_type" : "StatusMessage",
"interactions" : {
......
......@@ -2,22 +2,6 @@ require "spec_helper"
describe Diaspora::Shareable do
describe "scopes" do
describe ".all_public" do
it "includes all public posts" do
post1 = FactoryGirl.create(:status_message, author: alice.person, public: true)
post2 = FactoryGirl.create(:status_message, author: bob.person, public: true)
post3 = FactoryGirl.create(:status_message, author: eve.person, public: true)
expect(Post.all_public.map(&:id)).to match_array([post1.id, post2.id, post3.id])
end
it "doesn't include any private posts" do
FactoryGirl.create(:status_message, author: alice.person, public: false)
FactoryGirl.create(:status_message, author: bob.person, public: false)
FactoryGirl.create(:status_message, author: eve.person, public: false)
expect(Post.all_public.map(&:id)).to eq([])
end
end
context "having multiple objects with equal db IDs" do
before do
# Determine the next database key ID, free on both Photo and StatusMessage
......
......@@ -256,6 +256,11 @@ describe Photo, :type => :model do
expect(@user).to receive(:photos_from).with(@user.person, limit: :all, max_time: nil).and_call_original
Photo.visible(@user, @user.person)
end
it "does not contain pending photos" do
pending_photo = @user.post(:photo, pending: true, user_file: File.open(photo_fixture_name), to: @aspect)
expect(Photo.visible(@user, @user.person).ids).not_to include(pending_photo.id)
end
end
context "without a current user" do
......
......@@ -42,6 +42,21 @@ describe Post, :type => :model do
end
end
describe ".all_public" do
it "includes all public posts" do
post1 = FactoryGirl.create(:status_message, author: alice.person, public: true)
post2 = FactoryGirl.create(:status_message, author: bob.person, public: true)
post3 = FactoryGirl.create(:status_message, author: eve.person, public: true)
expect(Post.all_public.ids).to match_array([post1.id, post2.id, post3.id])
end
it "doesn't include any private posts" do
FactoryGirl.create(:status_message, author: alice.person, public: false)
FactoryGirl.create(:status_message, author: bob.person, public: false)
FactoryGirl.create(:status_message, author: eve.person, public: false)
expect(Post.all_public.ids).to eq([])
end
end
describe '.for_a_stream' do
it 'calls #for_visible_shareable_sql' do
......
......@@ -45,22 +45,11 @@ describe User::Querying, :type => :model do
expect(alice.visible_shareable_ids(Post)).not_to include(invisible_post.id)
end
it "does not contain pending posts" do
pending_post = bob.post(:status_message, :text => "hey", :public => true, :to => @bobs_aspect.id, :pending => true)
expect(pending_post).to be_pending
expect(alice.visible_shareable_ids(Post)).not_to include pending_post.id
end
it "does not contain pending photos" do
pending_photo = bob.post(:photo, :pending => true, :user_file=> File.open(photo_fixture_name), :to => @bobs_aspect)
expect(alice.visible_shareable_ids(Photo)).not_to include pending_photo.id
end
it "respects the :type option" do
post = bob.post(:status_message, :text => "hey", :public => true, :to => @bobs_aspect.id, :pending => false)
reshare = bob.post(:reshare, :pending => false, :root_guid => post.guid, :to => @bobs_aspect)
expect(alice.visible_shareable_ids(Post, :type => "Reshare")).to include(reshare.id)
expect(alice.visible_shareable_ids(Post, :type => 'StatusMessage')).not_to include(reshare.id)
post = bob.post(:status_message, text: "hey", public: true, to: @bobs_aspect.id)
reshare = bob.post(:reshare, root_guid: post.guid, to: @bobs_aspect)
expect(alice.visible_shareable_ids(Post, type: "Reshare")).to include(reshare.id)
expect(alice.visible_shareable_ids(Post, type: "StatusMessage")).not_to include(reshare.id)
end
it "does not contain duplicate posts" do
......
......@@ -9,9 +9,6 @@ describe Export::PostSerializer do
it { is_expected.to include %("public":#{post.public}) }
it { is_expected.to include %("diaspora_handle":"#{post.diaspora_handle}") }
it { is_expected.to include %("type":"#{post.type}") }
it { is_expected.to include %("image_url":#{post.image_url}) }
it { is_expected.to include %("image_height":#{post.image_height}) }
it { is_expected.to include %("image_width":#{post.image_width}) }
it { is_expected.to include %("likes_count":#{post.likes_count}) }
it { is_expected.to include %("comments_count":#{post.comments_count}) }
it { is_expected.to include %("reshares_count":#{post.reshares_count}) }
......
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