Merge branch 'release/0.7.7.0' into next-minor

This commit is contained in:
Dennis Schubert 2018-10-08 02:50:29 +02:00
commit 89d9a865b6
No known key found for this signature in database
GPG key ID: 5A0304BEA7966D7E
27 changed files with 72 additions and 306 deletions

View file

@ -11,6 +11,7 @@
## Refactor ## Refactor
* Remove mention of deprecated `statistic.json` [#7867](https://github.com/diaspora/diaspora/pull/7867) * Remove mention of deprecated `statistic.json` [#7867](https://github.com/diaspora/diaspora/pull/7867)
* Add quotes in `database.yml.example` to fields that may contain special characters [#7875](https://github.com/diaspora/diaspora/pull/7875) * Add quotes in `database.yml.example` to fields that may contain special characters [#7875](https://github.com/diaspora/diaspora/pull/7875)
* Removed broken, and thus deprecated, Facebook integration [#7874](https://github.com/diaspora/diaspora/pull/7874)
## Bug fixes ## Bug fixes
* Add compatibility with macOS to `script/configure_bundler` [#7830](https://github.com/diaspora/diaspora/pull/7830) * Add compatibility with macOS to `script/configure_bundler` [#7830](https://github.com/diaspora/diaspora/pull/7830)

View file

@ -157,7 +157,6 @@ gem "secure_headers", "5.0.5"
# Services # Services
gem "omniauth", "1.8.1" gem "omniauth", "1.8.1"
gem "omniauth-facebook", "4.0.0"
gem "omniauth-tumblr", "1.2" gem "omniauth-tumblr", "1.2"
gem "omniauth-twitter", "1.4.0" gem "omniauth-twitter", "1.4.0"
gem "omniauth-wordpress", "0.2.2" gem "omniauth-wordpress", "0.2.2"

View file

@ -408,8 +408,6 @@ GEM
omniauth (1.8.1) omniauth (1.8.1)
hashie (>= 3.4.6, < 3.6.0) hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3) rack (>= 1.6.2, < 3)
omniauth-facebook (4.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth (1.1.0) omniauth-oauth (1.1.0)
oauth oauth
omniauth (~> 1.0) omniauth (~> 1.0)
@ -820,7 +818,6 @@ DEPENDENCIES
mysql2 (= 0.5.0) mysql2 (= 0.5.0)
nokogiri (= 1.8.2) nokogiri (= 1.8.2)
omniauth (= 1.8.1) omniauth (= 1.8.1)
omniauth-facebook (= 4.0.0)
omniauth-tumblr (= 1.2) omniauth-tumblr (= 1.2)
omniauth-twitter (= 1.4.0) omniauth-twitter (= 1.4.0)
omniauth-wordpress (= 0.2.2) omniauth-wordpress (= 0.2.2)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 814 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -199,7 +199,6 @@
} }
text-align: center; text-align: center;
.social-media-logos-facebook-24x24,
.social-media-logos-twitter-24x24, .social-media-logos-twitter-24x24,
.social-media-logos-tumblr-24x24, .social-media-logos-tumblr-24x24,
.social-media-logos-wordpress-24x24 { .social-media-logos-wordpress-24x24 {

View file

@ -1,58 +0,0 @@
# frozen_string_literal: true
class Services::Facebook < Service
include Rails.application.routes.url_helpers
OVERRIDE_FIELDS_ON_FB_UPDATE = [:contact_id, :person_id, :request_id, :invitation_id, :photo_url, :name, :username]
MAX_CHARACTERS = 63206
def provider
"facebook"
end
def post(post, url='')
logger.debug "event=post_to_service type=facebook sender_id=#{user_id} post=#{post.guid}"
response = post_to_facebook("https://graph.facebook.com/me/feed", create_post_params(post).to_param)
response = JSON.parse response.body
post.facebook_id = response["id"]
post.save
end
def post_to_facebook(url, body)
Faraday.post(url, body)
end
def create_post_params(post)
message = post.message.plain_text_without_markdown
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,
access_token: access_token,
link: post.message.urls.first
}
end
def profile_photo_url
"https://graph.facebook.com/#{self.uid}/picture?type=large&access_token=#{URI.escape(self.access_token)}"
end
def post_opts(post)
{facebook_id: post.facebook_id} if post.facebook_id.present?
end
def delete_from_service(opts)
logger.debug "event=delete_from_service type=facebook sender_id=#{user_id} facebook_id=#{opts[:facebook_id]}"
delete_from_facebook("https://graph.facebook.com/#{opts[:facebook_id]}/", access_token: access_token)
end
def delete_from_facebook(url, body)
Faraday.delete(url, body)
end
end

View file

@ -14,10 +14,6 @@
%h3 %h3
= t(".who_are_you") = t(".who_are_you")
- if AppConfig.configured_services.include? :facebook
%p
!= t('.connect_to_facebook', link: link_to(t('.connect_to_facebook_link'), "auth/facebook?callback_url=#{getting_started_url}"))
= form_tag profile_path, method: :put, remote: true, id: 'edit_profile' do = form_tag profile_path, method: :put, remote: true, id: 'edit_profile' do
%fieldset %fieldset
.form-group .form-group

View file

@ -19,10 +19,6 @@
%h2 %h2
= t(".who_are_you") = t(".who_are_you")
- if AppConfig.configured_services.include? :facebook
%p
!= t('.connect_to_facebook', link: link_to(t('.connect_to_facebook_link'), "auth/facebook?callback_url=#{getting_started_url}"))
= form_tag profile_path, method: :put, remote: true, id: "edit_profile" do = form_tag profile_path, method: :put, remote: true, id: "edit_profile" do
%fieldset %fieldset
.form-group .form-group

View file

@ -153,12 +153,6 @@ defaults:
report_only: true report_only: true
report_uri: report_uri:
services: services:
facebook:
enable: false
app_id:
secret:
open_graph_namespace: 'joindiaspora'
authorized: false
twitter: twitter:
enable: false enable: false
key: key:
@ -234,11 +228,10 @@ test:
invitations: invitations:
open: true open: true
services: services:
facebook: twitter:
enable: true enable: true
app_id: 'fake' key: 'fake'
secret: 'sdoigjosdfijg' secret: 'sdoigjosdfijg'
authorized: true
mail: mail:
enable: true enable: true
integration1: integration1:

View file

@ -21,7 +21,7 @@
## - Specify lists/arrays as comma-separated values ## - Specify lists/arrays as comma-separated values
## ##
## - For example, on Heroku: ## - For example, on Heroku:
## heroku config:set SERVICES_FACEBOOK_APP_ID=yourappid SERVICES_FACEBOOK_SECRET=yourappsecret ## heroku config:set SERVICES_TWITTER_KEY=yourkey SERVICES_TWITTER_SECRET=yoursecret
configuration: ## Section configuration: ## Section
@ -583,20 +583,6 @@ configuration: ## Section
## Posting from Diaspora to external services (all are disabled by default). ## Posting from Diaspora to external services (all are disabled by default).
services: ## Section services: ## Section
## OAuth credentials for Facebook
facebook: ## Section
#enable: true
#app_id: 'abcdef'
#secret: 'change_me'
## This setting is required to define whether the Facebook app has permissions to post
## false == No permissions (default)
## true == Permissions for all users to post. App MUST have 'publish_actions' approved by Facebook!
## "username" == Set to local username to allow a single user to cross-post. The person who has created
## the Facebook app will always be able to cross-post, even without 'publish_actions'.
#authorized: false
## OAuth credentials for Twitter ## OAuth credentials for Twitter
twitter: ## Section twitter: ## Section

View file

@ -13,17 +13,6 @@ Rails.application.config.middleware.use OmniAuth::Builder do
provider :tumblr, AppConfig.services.tumblr.key, AppConfig.services.tumblr.secret provider :tumblr, AppConfig.services.tumblr.key, AppConfig.services.tumblr.secret
end end
if AppConfig.services.facebook.enable?
provider :facebook, AppConfig.services.facebook.app_id, AppConfig.services.facebook.secret, {
scope: "public_profile,publish_actions",
client_options: {
ssl: {
ca_file: AppConfig.environment.certificate_authorities
}
}
}
end
if AppConfig.services.wordpress.enable? if AppConfig.services.wordpress.enable?
provider :wordpress, AppConfig.services.wordpress.client_id, AppConfig.services.wordpress.secret provider :wordpress, AppConfig.services.wordpress.client_id, AppConfig.services.wordpress.secret
end end

View file

@ -1043,7 +1043,6 @@ en:
comment_email_subject: "%{resharer}s reshare of %{author}s post" comment_email_subject: "%{resharer}s reshare of %{author}s post"
services: services:
provider: provider:
facebook: "Facebook"
tumblr: "Tumblr" tumblr: "Tumblr"
twitter: "Twitter" twitter: "Twitter"
wordpress: "WordPress" wordpress: "WordPress"
@ -1264,8 +1263,6 @@ en:
community_welcome: "diaspora*s community is happy to have you aboard!" community_welcome: "diaspora*s community is happy to have you aboard!"
awesome_take_me_to_diaspora: "Awesome! Take me to diaspora*" awesome_take_me_to_diaspora: "Awesome! Take me to diaspora*"
who_are_you: "Who are you?" who_are_you: "Who are you?"
connect_to_facebook: "We can speed things up a bit by %{link} to diaspora*. This will pull your name and photo, and enable cross-posting."
connect_to_facebook_link: "Hooking up your Facebook account"
what_are_you_in_to: "What are you into?" what_are_you_in_to: "What are you into?"
hashtag_explanation: "Hashtags allow you to talk about and follow your interests. Theyre also a great way to find new people on diaspora*." hashtag_explanation: "Hashtags allow you to talk about and follow your interests. Theyre also a great way to find new people on diaspora*."
hashtag_suggestions: "Try following tags like #art, #movies, #gif, etc." hashtag_suggestions: "Try following tags like #art, #movies, #gif, etc."

View file

@ -0,0 +1,14 @@
# frozen_string_literal: true
class RemoveFacebook < ActiveRecord::Migration[5.1]
class Service < ApplicationRecord
end
def change
remove_column :posts, :facebook_id, :string
reversible do |change|
change.up { Service.where(type: "Services::Facebook").delete_all }
end
end
end

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
module Configuration module Configuration
KNOWN_SERVICES = [:twitter, :tumblr, :facebook, :wordpress].freeze KNOWN_SERVICES = %i[twitter tumblr wordpress].freeze
module Methods module Methods
def pod_uri def pod_uri

View file

@ -29,8 +29,8 @@ describe StreamsController, :type => :controller do
end end
it 'generates a jasmine fixture with services', :fixture => true do it 'generates a jasmine fixture with services', :fixture => true do
alice.services << Services::Facebook.create(:user_id => alice.id) alice.services << Services::Twitter.create(user_id: alice.id)
alice.services << Services::Twitter.create(:user_id => alice.id) alice.services << Services::Tumblr.create(user_id: alice.id)
get :aspects, params: {prefill: "reshare things"} get :aspects, params: {prefill: "reshare things"}
save_fixture(html_for("body"), "aspects_index_services") save_fixture(html_for("body"), "aspects_index_services")
end end

View file

@ -5,12 +5,14 @@
# the COPYRIGHT file. # the COPYRIGHT file.
describe ServicesController, :type => :controller do describe ServicesController, :type => :controller do
let(:omniauth_auth) do let(:omniauth_auth) {
{ 'provider' => 'facebook', {
'uid' => '2', "provider" => "tumblr",
'info' => { 'nickname' => 'grimmin', 'image' => 'http://graph.facebook.com/2/picture' }, "uid" => "2",
'credentials' => { 'token' => 'tokin', 'secret' =>"not_so_much" }} "info" => {"nickname" => "grimmin"},
end "credentials" => {"token" => "token", "secret" => "not_so_much"}
}
}
let(:user) { alice } let(:user) { alice }
before do before do
@ -37,22 +39,13 @@ describe ServicesController, :type => :controller do
it 'creates a new service and associates it with the current user' do it 'creates a new service and associates it with the current user' do
expect { expect {
post :create, params: {provider: "facebook"} post :create, params: {provider: "twitter"}
}.to change(user.services, :count).by(1) }.to change(user.services, :count).by(1)
end end
it 'saves the provider' do it 'saves the provider' do
post :create, params: {provider: "facebook"} post :create, params: {provider: "twitter"}
expect(user.reload.services.first.class.name).to eq("Services::Facebook") expect(user.reload.services.first.class.name).to eq("Services::Tumblr")
end
context "when the user hasn't got a profile photo on Diaspora" do
before { user.person.profile.update_attribute :image_url, nil }
it "imports the profile photo from the service" do
expect(Workers::FetchProfilePhoto).to receive(:perform_async)
post :create, params: {provider: "facebook"}
end
end end
context 'when service exists with the same uid' do context 'when service exists with the same uid' do
@ -97,23 +90,10 @@ describe ServicesController, :type => :controller do
end end
end end
context 'Facebook' do
before do
facebook_auth_without_twitter_extras = { 'provider' => 'facebook', 'extras' => { 'someotherkey' => 'lorem'}}
request.env['omniauth.auth'] = omniauth_auth.merge!( facebook_auth_without_twitter_extras )
end
it "doesn't break when twitter-specific extras aren't available in omniauth hash" do
expect {
post :create, params: {provider: "facebook"}
}.to change(user.services, :count).by(1)
end
end
context 'when fetching a photo' do context 'when fetching a photo' do
before do before do
omniauth_auth omniauth_auth
omniauth_auth["info"].merge!({"image" => "https://service.com/fallback_lowres.jpg"}) omniauth_auth["info"]["image"] = "https://service.com/fallback_lowres.jpg"
request.env['omniauth.auth'] = omniauth_auth request.env['omniauth.auth'] = omniauth_auth
end end

View file

@ -141,20 +141,17 @@ describe StatusMessagesController, :type => :controller do
end end
it "dispatches the post to the specified services" do it "dispatches the post to the specified services" do
s1 = Services::Facebook.new
alice.services << s1
alice.services << Services::Twitter.new alice.services << Services::Twitter.new
status_message_hash[:services] = ['facebook'] status_message_hash[:services] = ["twitter"]
service_types = Service.titles(status_message_hash[:services]) service_types = Service.titles(status_message_hash[:services])
expect(alice).to receive(:dispatch_post).with(anything(), hash_including(:service_types => service_types)) expect(alice).to receive(:dispatch_post).with(anything, hash_including(service_types: service_types))
post :create, params: status_message_hash post :create, params: status_message_hash
end end
it "works if services is a string" do it "works if services is a string" do
s1 = Services::Facebook.new alice.services << Services::Twitter.new
alice.services << s1 status_message_hash[:services] = "twitter"
status_message_hash[:services] = "facebook" expect(alice).to receive(:dispatch_post).with(anything, hash_including(service_types: ["Services::Twitter"]))
expect(alice).to receive(:dispatch_post).with(anything(), hash_including(:service_types => ["Services::Facebook"]))
post :create, params: status_message_hash post :create, params: status_message_hash
end end

View file

@ -16,8 +16,8 @@ describe("app.models.User", function(){
describe("isServiceConnected", function(){ describe("isServiceConnected", function(){
it("checks to see if the sent provider name is a configured service", function(){ it("checks to see if the sent provider name is a configured service", function(){
this.user.set({configured_services : ["facebook"]}); this.user.set({configured_services: ["twitter"]}); // eslint-disable-line camelcase
expect(this.user.isServiceConfigured("facebook")).toBeTruthy(); expect(this.user.isServiceConfigured("twitter")).toBeTruthy();
expect(this.user.isServiceConfigured("tumblr")).toBeFalsy(); expect(this.user.isServiceConfigured("tumblr")).toBeFalsy();
}); });
}); });

View file

@ -94,22 +94,17 @@ describe Configuration::Methods do
allow(disabled).to receive(:enable?).and_return(false) allow(disabled).to receive(:enable?).and_return(false)
allow(services).to receive(:twitter).and_return(enabled) allow(services).to receive(:twitter).and_return(enabled)
allow(services).to receive(:tumblr).and_return(enabled) allow(services).to receive(:tumblr).and_return(enabled)
allow(services).to receive(:facebook).and_return(disabled)
allow(services).to receive(:wordpress).and_return(disabled) allow(services).to receive(:wordpress).and_return(disabled)
allow(@settings).to receive(:services).and_return(services) allow(@settings).to receive(:services).and_return(services)
expect(@settings.configured_services).to include :twitter expect(@settings.configured_services).to include :twitter
expect(@settings.configured_services).to include :tumblr expect(@settings.configured_services).to include :tumblr
expect(@settings.configured_services).not_to include :facebook
expect(@settings.configured_services).not_to include :wordpress expect(@settings.configured_services).not_to include :wordpress
end end
end end
describe "#show_service" do describe "#show_service" do
before do before do
AppConfig.services.twitter.authorized = true
AppConfig.services.twitter.enable = true AppConfig.services.twitter.enable = true
AppConfig.services.facebook.authorized = true
AppConfig.services.facebook.enable = true
AppConfig.services.wordpress.authorized = false AppConfig.services.wordpress.authorized = false
AppConfig.services.wordpress.enable = true AppConfig.services.wordpress.enable = true
AppConfig.services.tumblr.authorized = "alice" AppConfig.services.tumblr.authorized = "alice"
@ -120,10 +115,6 @@ describe Configuration::Methods do
expect(AppConfig.show_service?("twitter", bob)).to be_truthy expect(AppConfig.show_service?("twitter", bob)).to be_truthy
end end
it "shows service with authorized key true" do
expect(AppConfig.show_service?("facebook", bob)).to be_truthy
end
it "doesn't show service with authorized key false" do it "doesn't show service with authorized key false" do
expect(AppConfig.show_service?("wordpress", bob)).to be_falsey expect(AppConfig.show_service?("wordpress", bob)).to be_falsey
end end

View file

@ -79,8 +79,7 @@ describe Retraction do
it "adds service metadata to queued job for deletion" do it "adds service metadata to queued job for deletion" do
post.tweet_id = "123" post.tweet_id = "123"
twitter = Services::Twitter.new(access_token: "twitter") twitter = Services::Twitter.new(access_token: "twitter")
facebook = Services::Facebook.new(access_token: "facebook") alice.services << twitter
alice.services << twitter << facebook
retraction = Retraction.for(post) retraction = Retraction.for(post)
federation_retraction = Diaspora::Federation::Entities.retraction(retraction) federation_retraction = Diaspora::Federation::Entities.retraction(retraction)

View file

@ -1,58 +1,59 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Service, :type => :model do describe Service, type: :model do
before do before do
@post = alice.post(:status_message, :text => "hello", :to => alice.aspects.first.id) @post = alice.post(:status_message, text: "hello", to: alice.aspects.first.id)
@service = Services::Facebook.new(:access_token => "yeah", :uid => 1) @service = Services::Twitter.new(access_token: "yeah", uid: 1)
alice.services << @service alice.services << @service
end end
it 'is unique to a user by service type and uid' do it "is unique to a user by service type and uid" do
@service.save @service.save
second_service = Services::Facebook.new(:access_token => "yeah", :uid => 1) second_service = Services::Twitter.new(access_token: "yeah", uid: 1)
alice.services << second_service alice.services << second_service
alice.services.last.save alice.services.last.save
expect(alice.services.last).to be_invalid expect(alice.services.last).to be_invalid
end end
it 'by default has no profile photo url' do it "by default has no profile photo url" do
expect( described_class.new.profile_photo_url ).to be_nil expect(described_class.new.profile_photo_url).to be_nil
end end
describe '.titles' do describe ".titles" do
it "converts passed service titles into service constants" do it "converts passed service titles into service constants" do
expect( described_class.titles( ['twitter'] ) ).to eql ['Services::Twitter'] expect(described_class.titles(["twitter"])).to eql ["Services::Twitter"]
end end
end end
describe '.first_from_omniauth' do describe ".first_from_omniauth" do
let(:omniauth) { { 'provider' => 'facebook', 'uid' => '1', 'credentials' => {}, 'info' => {} } } let(:omniauth) { {"provider" => "twitter", "uid" => "1", "credentials" => {}, "info" => {}} }
it 'first service by provider and uid' do it "first service by provider and uid" do
expect( described_class.first_from_omniauth( omniauth ) ).to eql @service expect(described_class.first_from_omniauth(omniauth)).to eql @service
end end
end end
describe '.initialize_from_omniauth' do describe ".initialize_from_omniauth" do
let(:omniauth) do let(:omniauth) do
{ 'provider' => 'facebook', {
'uid' => '2', "provider" => "twitter",
'info' => { 'nickname' => 'grimmin' }, "uid" => "2",
'credentials' => { 'token' => 'tokin', 'secret' =>"not_so_much" } "info" => {"nickname" => "grimmin"},
"credentials" => {"token" => "token", "secret" => "not_so_much"}
} }
end end
let(:subject) { described_class.initialize_from_omniauth( omniauth ) } let(:subject) { described_class.initialize_from_omniauth(omniauth) }
it 'new service obj of type Services::Facebook' do it "new service obj of type Services::Twitter" do
expect( subject.type ).to eql "Services::Facebook" expect(subject.type).to eql "Services::Twitter"
end end
it 'new service obj with oauth options populated' do it "new service obj with oauth options populated" do
expect( subject.uid ).to eql "2" expect(subject.uid).to eql "2"
expect( subject.nickname ).to eql "grimmin" expect(subject.nickname).to eql "grimmin"
expect( subject.access_token ).to eql "tokin" expect(subject.access_token).to eql "token"
expect( subject.access_secret ).to eql "not_so_much" expect(subject.access_secret).to eql "not_so_much"
end end
end end
end end

View file

@ -1,103 +0,0 @@
# frozen_string_literal: true
describe Services::Facebook, :type => :model do
before do
@user = alice
@post = @user.post(:status_message, :text => "hello", :to =>@user.aspects.first.id, :public =>true, :photos => [])
@service = Services::Facebook.new(:access_token => "yeah")
@user.services << @service
end
describe '#post' do
it 'posts a status message to facebook' do
stub_request(:post, "https://graph.facebook.com/me/feed").
to_return(:status => 200, :body => '{"id": "12345"}', :headers => {})
@service.post(@post)
end
it 'removes text formatting markdown from post text' do
message = double(urls: [])
expect(message).to receive(:plain_text_without_markdown).and_return("")
post = double(message: message, photos: [])
post_params = @service.create_post_params(post)
end
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]).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: {})
@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.each(&:save!)
end
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 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:"
end
end
describe "#profile_photo_url" do
it 'returns a large profile photo url' do
@service.uid = "abc123"
@service.access_token = "token123"
expect(@service.profile_photo_url).to eq(
"https://graph.facebook.com/abc123/picture?type=large&access_token=token123"
)
end
end
describe "#post_opts" do
it "returns the facebook_id of the post" do
@post.facebook_id = "2345"
expect(@service.post_opts(@post)).to eq(facebook_id: "2345")
end
it "returns nil when the post has no facebook_id" do
expect(@service.post_opts(@post)).to be_nil
end
end
describe "#delete_from_service" do
it "removes a post from facebook" do
facebook_id = "2345"
url = "https://graph.facebook.com/#{facebook_id}/"
stub_request(:delete, "#{url}?access_token=#{@service.access_token}").to_return(status: 200)
expect(@service).to receive(:delete_from_facebook).with(url, access_token: @service.access_token)
@service.delete_from_service(facebook_id: facebook_id)
end
end
end

View file

@ -52,10 +52,6 @@ describe NodeInfoPresenter do
context "when services are enabled" do context "when services are enabled" do
before do before do
AppConfig.services = { AppConfig.services = {
"facebook" => {
"enable" => true,
"authorized" => true
},
"twitter" => {"enable" => true}, "twitter" => {"enable" => true},
"wordpress" => {"enable" => false}, "wordpress" => {"enable" => false},
"tumblr" => { "tumblr" => {
@ -66,17 +62,13 @@ describe NodeInfoPresenter do
end end
it "provides services" do it "provides services" do
expect(hash).to include "services" => include("outbound" => %w(twitter facebook)) expect(hash).to include "services" => include("outbound" => ["twitter"])
end end
end end
context "when some services are set to username authorized" do context "when some services are set to username authorized" do
before do before do
AppConfig.services = { AppConfig.services = {
"facebook" => {
"enable" => true,
"authorized" => "bob"
},
"twitter" => {"enable" => true}, "twitter" => {"enable" => true},
"wordpress" => { "wordpress" => {
"enable" => true, "enable" => true,

View file

@ -169,8 +169,8 @@ describe StatusMessageCreationService do
it "dispatches the StatusMessage to services" do it "dispatches the StatusMessage to services" do
expect(alice).to receive(:dispatch_post) expect(alice).to receive(:dispatch_post)
.with(instance_of(StatusMessage), .with(instance_of(StatusMessage),
hash_including(service_types: array_including(%w(Services::Facebook Services::Twitter)))) hash_including(service_types: array_including(%w[Services::Tumblr Services::Twitter])))
StatusMessageCreationService.new(alice).create(params.merge(services: %w(twitter facebook))) StatusMessageCreationService.new(alice).create(params.merge(services: %w[twitter tumblr]))
end end
context "with mention" do context "with mention" do

View file

@ -3,7 +3,7 @@
describe Workers::DeletePostFromService do describe Workers::DeletePostFromService do
it "calls service#delete_from_service with given opts" do it "calls service#delete_from_service with given opts" do
service = double service = double
opts = {facebook_id: "23456"} opts = {twitter_id: "23456"}
expect(service).to receive(:delete_from_service).with(opts) expect(service).to receive(:delete_from_service).with(opts)
allow(Service).to receive(:find_by_id).with("123").and_return(service) allow(Service).to receive(:find_by_id).with("123").and_return(service)