Loading Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ ## Features * Support fetching StatusMessage by Poll GUID [#7815](https://github.com/diaspora/diaspora/pull/7815) * Always include link to diaspora in facebook cross-posts [#7774](https://github.com/diaspora/diaspora/pull/7774) # 0.7.5.0 Loading app/models/services/facebook.rb +12 −8 Original line number Diff line number Diff line Loading @@ -24,12 +24,16 @@ class Services::Facebook < Service def create_post_params(post) message = post.message.plain_text_without_markdown if post.photos.any? message += " " + short_post_url(post, protocol: AppConfig.pod_uri.scheme, host: AppConfig.pod_uri.authority) post_url = short_post_url(post, protocol: AppConfig.pod_uri.scheme, host: AppConfig.pod_uri.authority) message = if message.empty? post_url else "#{message} (via #{post_url})" end {message: message, { message: message, access_token: access_token, link: post.message.urls.first } Loading spec/models/services/facebook_spec.rb +22 −12 Original line number Diff line number Diff line Loading @@ -22,39 +22,49 @@ describe Services::Facebook, :type => :model do post_params = @service.create_post_params(post) end it 'does not add post link when no photos' do it "adds '(via <post URL>)'" do message = "Some text." post = double(message: double(plain_text_without_markdown: message, urls: []), photos: []) post_params = @service.create_post_params(post) expect(post_params[:message]).not_to include "http" expect(post_params[:message]).to include "(via http:" end it 'sets facebook id on post' do stub_request(:post, "https://graph.facebook.com/me/feed"). to_return(:status => 200, :body => '{"id": "12345"}', :headers => {}) it "sets facebook id on post" do stub_request(:post, "https://graph.facebook.com/me/feed") .to_return(status: 200, body: '{"id": "12345"}', headers: {}) @service.post(@post) expect(@post.facebook_id).to match "12345" end 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 = [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!) end @status_message = alice.build_post(:status_message, :text => "the best pebble.") it "should include post url in message with photos as (via... " do @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) post_params = @service.create_post_params(@status_message) expect(post_params[:message]).to include "(via http:" end it "should include post url in message with photos" do it "should include post url in message with photos when no text message" do @status_message = alice.build_post(:status_message, text: "") @status_message.photos << @photos @status_message.save! alice.add_to_streams(@status_message, alice.aspects) post_params = @service.create_post_params(@status_message) expect(post_params[:message]).to include 'http' expect(post_params[:message]).to include "http:" end end Loading Loading
Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ ## Features * Support fetching StatusMessage by Poll GUID [#7815](https://github.com/diaspora/diaspora/pull/7815) * Always include link to diaspora in facebook cross-posts [#7774](https://github.com/diaspora/diaspora/pull/7774) # 0.7.5.0 Loading
app/models/services/facebook.rb +12 −8 Original line number Diff line number Diff line Loading @@ -24,12 +24,16 @@ class Services::Facebook < Service def create_post_params(post) message = post.message.plain_text_without_markdown if post.photos.any? message += " " + short_post_url(post, protocol: AppConfig.pod_uri.scheme, host: AppConfig.pod_uri.authority) post_url = short_post_url(post, protocol: AppConfig.pod_uri.scheme, host: AppConfig.pod_uri.authority) message = if message.empty? post_url else "#{message} (via #{post_url})" end {message: message, { message: message, access_token: access_token, link: post.message.urls.first } Loading
spec/models/services/facebook_spec.rb +22 −12 Original line number Diff line number Diff line Loading @@ -22,39 +22,49 @@ describe Services::Facebook, :type => :model do post_params = @service.create_post_params(post) end it 'does not add post link when no photos' do it "adds '(via <post URL>)'" do message = "Some text." post = double(message: double(plain_text_without_markdown: message, urls: []), photos: []) post_params = @service.create_post_params(post) expect(post_params[:message]).not_to include "http" expect(post_params[:message]).to include "(via http:" end it 'sets facebook id on post' do stub_request(:post, "https://graph.facebook.com/me/feed"). to_return(:status => 200, :body => '{"id": "12345"}', :headers => {}) it "sets facebook id on post" do stub_request(:post, "https://graph.facebook.com/me/feed") .to_return(status: 200, body: '{"id": "12345"}', headers: {}) @service.post(@post) expect(@post.facebook_id).to match "12345" end 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 = [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!) end @status_message = alice.build_post(:status_message, :text => "the best pebble.") it "should include post url in message with photos as (via... " do @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) post_params = @service.create_post_params(@status_message) expect(post_params[:message]).to include "(via http:" end it "should include post url in message with photos" do it "should include post url in message with photos when no text message" do @status_message = alice.build_post(:status_message, text: "") @status_message.photos << @photos @status_message.save! alice.add_to_streams(@status_message, alice.aspects) post_params = @service.create_post_params(@status_message) expect(post_params[:message]).to include 'http' expect(post_params[:message]).to include "http:" end end Loading