Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
diaspora
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Milan
diaspora
Commits
287d633c
Commit
287d633c
authored
14 years ago
by
danielvincent
Browse files
Options
Downloads
Patches
Plain Diff
user#post now handles posting to services.
parent
b2e8ebd0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/status_messages_controller.rb
+0
-7
0 additions, 7 deletions
app/controllers/status_messages_controller.rb
app/models/user.rb
+11
-8
11 additions, 8 deletions
app/models/user.rb
spec/models/user/posting_spec.rb
+20
-2
20 additions, 2 deletions
spec/models/user/posting_spec.rb
with
31 additions
and
17 deletions
app/controllers/status_messages_controller.rb
+
0
−
7
View file @
287d633c
...
...
@@ -11,14 +11,7 @@ class StatusMessagesController < ApplicationController
def
create
data
=
clean_hash
params
[
:status_message
]
message
=
params
[
:status_message
][
:message
]
if
params
[
:status_message
][
:public
]
==
'1'
current_user
.
post_to_twitter
(
message
)
current_user
.
post_to_facebook
(
message
)
end
@status_message
=
current_user
.
post
(
:status_message
,
data
)
render
:nothing
=>
true
end
...
...
This diff is collapsed.
Click to expand it.
app/models/user.rb
+
11
−
8
View file @
287d633c
...
...
@@ -151,7 +151,17 @@ class User
aspect_ids
=
validate_aspect_permissions
(
aspect_ids
)
intitial_post
(
class_name
,
aspect_ids
,
options
)
post
=
build_post
(
class_name
,
options
)
post
.
socket_to_uid
(
id
,
:aspect_ids
=>
aspect_ids
)
if
post
.
respond_to?
(
:socket_to_uid
)
push_to_aspects
(
post
,
aspect_ids
)
if
options
[
:public
]
self
.
services
.
each
do
|
service
|
self
.
send
(
"post_to_
#{
service
.
provider
}
"
.
to_sym
)
end
end
post
end
def
post_to_facebook
(
message
)
...
...
@@ -172,13 +182,6 @@ class User
end
end
def
intitial_post
(
class_name
,
aspect_ids
,
options
=
{})
post
=
build_post
(
class_name
,
options
)
post
.
socket_to_uid
(
id
,
:aspect_ids
=>
aspect_ids
)
if
post
.
respond_to?
(
:socket_to_uid
)
push_to_aspects
(
post
,
aspect_ids
)
post
end
def
update_post
(
post
,
post_hash
=
{})
if
self
.
owns?
post
post
.
update_attributes
(
post_hash
)
...
...
This diff is collapsed.
Click to expand it.
spec/models/user/posting_spec.rb
+
20
−
2
View file @
287d633c
...
...
@@ -7,12 +7,16 @@ require 'spec_helper'
describe
User
do
let!
(
:user
)
{
Factory
(
:user
)
}
let!
(
:user2
)
{
Factory
(
:user
)
}
let!
(
:aspect
)
{
user
.
aspect
(
:name
=>
'heroes'
)
}
let!
(
:aspect1
)
{
user
.
aspect
(
:name
=>
'other'
)
}
let!
(
:user2
)
{
Factory
(
:user
)
}
let!
(
:aspect2
)
{
user2
.
aspect
(
:name
=>
'losers'
)
}
let!
(
:service1
)
{
user
.
services
<<
Factory
(
:service
,
:provider
=>
'twitter'
)
}
let!
(
:service2
)
{
user
.
services
<<
Factory
(
:service
,
:provider
=>
'facebook'
)
}
describe
'#validate_aspect_permissions'
do
it
'requires an aspect'
do
proc
{
...
...
@@ -44,11 +48,25 @@ describe User do
aspect
.
reload
aspect
.
posts
.
should
include
album
end
it
"should add the post to that user's visible posts"
do
status_message
=
user
.
post
:status_message
,
:message
=>
"hi"
,
:to
=>
aspect
.
id
user
.
reload
user
.
raw_visible_posts
.
include?
(
status_message
).
should
be
true
end
it
"posts to services if post is public"
do
user
.
should_receive
(
:post_to_twitter
).
exactly
(
1
).
times
user
.
should_receive
(
:post_to_facebook
).
exactly
(
1
).
times
user
.
post
:status_message
,
:message
=>
"hi"
,
:to
=>
"all"
,
:public
=>
true
end
it
"does not post to services if post is not public"
do
user
.
should_receive
(
:post_to_twitter
).
exactly
(
0
).
times
user
.
should_receive
(
:post_to_facebook
).
exactly
(
0
).
times
user
.
post
:status_message
,
:message
=>
"hi"
,
:to
=>
"all"
end
end
describe
'#update_post'
do
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment