Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
diaspora
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
diasporg
diaspora
Commits
d3edbfd8
Commit
d3edbfd8
authored
Aug 04, 2016
by
Benjamin Neff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove pending flag from posts
parent
83db0a8f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
34 additions
and
39 deletions
+34
-39
app/models/photo.rb
app/models/photo.rb
+1
-1
app/models/post.rb
app/models/post.rb
+1
-0
app/models/user/querying.rb
app/models/user/querying.rb
+2
-2
db/migrate/20160802212635_cleanup_posts_table.rb
db/migrate/20160802212635_cleanup_posts_table.rb
+4
-0
db/schema.rb
db/schema.rb
+1
-2
lib/diaspora/shareable.rb
lib/diaspora/shareable.rb
+1
-3
spec/lib/diaspora/shareable_spec.rb
spec/lib/diaspora/shareable_spec.rb
+0
-16
spec/models/photo_spec.rb
spec/models/photo_spec.rb
+5
-0
spec/models/post_spec.rb
spec/models/post_spec.rb
+15
-0
spec/models/user/querying_spec.rb
spec/models/user/querying_spec.rb
+4
-15
No files found.
app/models/photo.rb
View file @
d3edbfd8
...
...
@@ -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
app/models/post.rb
View file @
d3edbfd8
...
...
@@ -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.*'
)
...
...
app/models/user/querying.rb
View file @
d3edbfd8
...
...
@@ -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
)
...
...
db/migrate/20160802212635_cleanup_posts_table.rb
View file @
d3edbfd8
...
...
@@ -3,8 +3,10 @@ class CleanupPostsTable < ActiveRecord::Migration
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
...
...
@@ -22,5 +24,7 @@ class CleanupPostsTable < ActiveRecord::Migration
# 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
db/schema.rb
View file @
d3edbfd8
...
...
@@ -450,7 +450,6 @@ ActiveRecord::Schema.define(version: 20160802212635) 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
.
datetime
"created_at"
,
null:
false
...
...
@@ -472,9 +471,9 @@ ActiveRecord::Schema.define(version: 20160802212635) 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"
,
[
"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
...
...
lib/diaspora/shareable.rb
View file @
d3edbfd8
...
...
@@ -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
...
...
spec/lib/diaspora/shareable_spec.rb
View file @
d3edbfd8
...
...
@@ -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
...
...
spec/models/photo_spec.rb
View file @
d3edbfd8
...
...
@@ -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
...
...
spec/models/post_spec.rb
View file @
d3edbfd8
...
...
@@ -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
...
...
spec/models/user/querying_spec.rb
View file @
d3edbfd8
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment