If post has photos, always include url in post to Facebook to stay consistant with other servies, fixes #3706

This commit is contained in:
Jason Robinson 2013-03-10 00:26:38 +02:00
parent 3c29007c39
commit affa713616
3 changed files with 34 additions and 2 deletions

View file

@ -21,6 +21,7 @@
* Include reshares in a users public atom feed [#1781](https://github.com/diaspora/diaspora/issues/1781)
* Add the ability to upload photos from the mobile site. [#4004](https://github.com/diaspora/diaspora/issues/4004)
* Show timestamp when hovering on comment time-ago string. [#4042](https://github.com/diaspora/diaspora/issues/4042)
* If sharing a post with photos to Facebook, always include URL to post [#3706](https://github.com/diaspora/diaspora/issues/3706)
# 0.0.3.2

View file

@ -25,6 +25,9 @@ class Services::Facebook < Service
def create_post_params(post)
message = strip_markdown(post.text(:plain_text => true))
if post.photos.any?
message += " " + Rails.application.routes.url_helpers.short_post_url(post, :protocol => AppConfig.pod_uri.scheme, :host => AppConfig.pod_uri.authority)
end
{:message => message, :access_token => self.access_token, :link => URI.extract(message, ['https', 'http']).first}
end

View file

@ -4,7 +4,7 @@ describe Services::Facebook do
before do
@user = alice
@post = @user.post(:status_message, :text => "hello", :to =>@user.aspects.first.id, :public =>true, :facebook_id => "23456" )
@post = @user.post(:status_message, :text => "hello", :to =>@user.aspects.first.id, :public =>true, :facebook_id => "23456", :photos => [])
@service = Services::Facebook.new(:access_token => "yeah")
@user.services << @service
end
@ -34,7 +34,14 @@ describe Services::Facebook do
it 'removes text formatting markdown from post text' do
message = "Text with some **bolded** and _italic_ parts."
post = stub(:text => message)
post = stub(:text => message, :photos => [])
post_params = @service.create_post_params(post)
post_params[:message].should match "Text with some bolded and italic parts."
end
it 'does not add post link when no photos' do
message = "Text with some **bolded** and _italic_ parts."
post = stub(:text => message, :photos => [])
post_params = @service.create_post_params(post)
post_params[:message].should match "Text with some bolded and italic parts."
end
@ -48,6 +55,27 @@ describe Services::Facebook do
end
describe "with photo" do
before do
@photos = [alice.build_post(:photo, :pending => true, :user_file=> File.open(photo_fixture_name)),
alice.build_post(:photo, :pending => true, :user_file=> File.open(photo_fixture_name))]
@photos.each(&:save!)
@status_message = alice.build_post(:status_message, :text => "the best pebble.")
@status_message.photos << @photos
@status_message.save!
alice.add_to_streams(@status_message, alice.aspects)
end
it "should include post url in message with photos" do
post_params = @service.create_post_params(@status_message)
post_params[:message].should include 'http'
end
end
describe "#profile_photo_url" do
it 'returns a large profile photo url' do
@service.uid = "abc123"