diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2018-10-04 02:16:05 +0300 |
---|---|---|
committer | Dennis Schubert <mail@dennis-schubert.de> | 2018-10-08 03:50:25 +0300 |
commit | fc6893d4fc6ec8ba7f3efa45d39b1ff40dfc832a (patch) | |
tree | d7afefd9e00a51df53fdd1fe0412bec044891949 /spec | |
parent | d0c6495bba26103e67994c35634e5bfdfc030fdb (diff) |
Remove facebook integration
Facebook removed the API and facebook integration is broken now, so lets
remove it.
closes #7874
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/jasmine_fixtures/aspects_spec.rb | 4 | ||||
-rw-r--r-- | spec/controllers/services_controller_spec.rb | 44 | ||||
-rw-r--r-- | spec/controllers/status_messages_controller_spec.rb | 13 | ||||
-rw-r--r-- | spec/javascripts/app/models/user_spec.js | 4 | ||||
-rw-r--r-- | spec/lib/configuration_methods_spec.rb | 9 | ||||
-rw-r--r-- | spec/lib/diaspora/federated/retraction_spec.rb | 3 | ||||
-rw-r--r-- | spec/models/service_spec.rb | 53 | ||||
-rw-r--r-- | spec/models/services/facebook_spec.rb | 103 | ||||
-rw-r--r-- | spec/presenters/node_info_presenter_spec.rb | 10 | ||||
-rw-r--r-- | spec/services/status_message_creation_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/workers/delete_post_from_service_spec.rb | 2 |
11 files changed, 53 insertions, 196 deletions
diff --git a/spec/controllers/jasmine_fixtures/aspects_spec.rb b/spec/controllers/jasmine_fixtures/aspects_spec.rb index cd2c39c6c..47e5ec8ca 100644 --- a/spec/controllers/jasmine_fixtures/aspects_spec.rb +++ b/spec/controllers/jasmine_fixtures/aspects_spec.rb @@ -29,8 +29,8 @@ describe StreamsController, :type => :controller do end 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"} save_fixture(html_for("body"), "aspects_index_services") end diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index a1c333915..38ee497c4 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -5,12 +5,14 @@ # the COPYRIGHT file. describe ServicesController, :type => :controller do - let(:omniauth_auth) do - { 'provider' => 'facebook', - 'uid' => '2', - 'info' => { 'nickname' => 'grimmin', 'image' => 'http://graph.facebook.com/2/picture' }, - 'credentials' => { 'token' => 'tokin', 'secret' =>"not_so_much" }} - end + let(:omniauth_auth) { + { + "provider" => "tumblr", + "uid" => "2", + "info" => {"nickname" => "grimmin"}, + "credentials" => {"token" => "token", "secret" => "not_so_much"} + } + } let(:user) { alice } before do @@ -37,22 +39,13 @@ describe ServicesController, :type => :controller do it 'creates a new service and associates it with the current user' do expect { - post :create, params: {provider: "facebook"} + post :create, params: {provider: "twitter"} }.to change(user.services, :count).by(1) end it 'saves the provider' do - post :create, params: {provider: "facebook"} - expect(user.reload.services.first.class.name).to eq("Services::Facebook") - 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 + post :create, params: {provider: "twitter"} + expect(user.reload.services.first.class.name).to eq("Services::Tumblr") end context 'when service exists with the same uid' do @@ -97,23 +90,10 @@ describe ServicesController, :type => :controller do 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 before do 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 end diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb index d38c12289..14e6999ab 100644 --- a/spec/controllers/status_messages_controller_spec.rb +++ b/spec/controllers/status_messages_controller_spec.rb @@ -141,20 +141,17 @@ describe StatusMessagesController, :type => :controller do end it "dispatches the post to the specified services" do - s1 = Services::Facebook.new - alice.services << s1 alice.services << Services::Twitter.new - status_message_hash[:services] = ['facebook'] + status_message_hash[:services] = ["twitter"] 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 end it "works if services is a string" do - s1 = Services::Facebook.new - alice.services << s1 - status_message_hash[:services] = "facebook" - expect(alice).to receive(:dispatch_post).with(anything(), hash_including(:service_types => ["Services::Facebook"])) + alice.services << Services::Twitter.new + status_message_hash[:services] = "twitter" + expect(alice).to receive(:dispatch_post).with(anything, hash_including(service_types: ["Services::Twitter"])) post :create, params: status_message_hash end diff --git a/spec/javascripts/app/models/user_spec.js b/spec/javascripts/app/models/user_spec.js index 621b35a36..4d80b0873 100644 --- a/spec/javascripts/app/models/user_spec.js +++ b/spec/javascripts/app/models/user_spec.js @@ -16,8 +16,8 @@ describe("app.models.User", function(){ describe("isServiceConnected", function(){ it("checks to see if the sent provider name is a configured service", function(){ - this.user.set({configured_services : ["facebook"]}); - expect(this.user.isServiceConfigured("facebook")).toBeTruthy(); + this.user.set({configured_services: ["twitter"]}); // eslint-disable-line camelcase + expect(this.user.isServiceConfigured("twitter")).toBeTruthy(); expect(this.user.isServiceConfigured("tumblr")).toBeFalsy(); }); }); diff --git a/spec/lib/configuration_methods_spec.rb b/spec/lib/configuration_methods_spec.rb index eeb963185..ae812578c 100644 --- a/spec/lib/configuration_methods_spec.rb +++ b/spec/lib/configuration_methods_spec.rb @@ -94,22 +94,17 @@ describe Configuration::Methods do allow(disabled).to receive(:enable?).and_return(false) allow(services).to receive(:twitter).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(@settings).to receive(:services).and_return(services) expect(@settings.configured_services).to include :twitter expect(@settings.configured_services).to include :tumblr - expect(@settings.configured_services).not_to include :facebook expect(@settings.configured_services).not_to include :wordpress end end describe "#show_service" do before do - AppConfig.services.twitter.authorized = true AppConfig.services.twitter.enable = true - AppConfig.services.facebook.authorized = true - AppConfig.services.facebook.enable = true AppConfig.services.wordpress.authorized = false AppConfig.services.wordpress.enable = true AppConfig.services.tumblr.authorized = "alice" @@ -120,10 +115,6 @@ describe Configuration::Methods do expect(AppConfig.show_service?("twitter", bob)).to be_truthy 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 expect(AppConfig.show_service?("wordpress", bob)).to be_falsey end diff --git a/spec/lib/diaspora/federated/retraction_spec.rb b/spec/lib/diaspora/federated/retraction_spec.rb index 1fe6b9d56..ff1149064 100644 --- a/spec/lib/diaspora/federated/retraction_spec.rb +++ b/spec/lib/diaspora/federated/retraction_spec.rb @@ -79,8 +79,7 @@ describe Retraction do it "adds service metadata to queued job for deletion" do post.tweet_id = "123" twitter = Services::Twitter.new(access_token: "twitter") - facebook = Services::Facebook.new(access_token: "facebook") - alice.services << twitter << facebook + alice.services << twitter retraction = Retraction.for(post) federation_retraction = Diaspora::Federation::Entities.retraction(retraction) diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index 57223b981..7c00889b8 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -1,58 +1,59 @@ # frozen_string_literal: true -describe Service, :type => :model do +describe Service, type: :model do before do - @post = alice.post(:status_message, :text => "hello", :to => alice.aspects.first.id) - @service = Services::Facebook.new(:access_token => "yeah", :uid => 1) + @post = alice.post(:status_message, text: "hello", to: alice.aspects.first.id) + @service = Services::Twitter.new(access_token: "yeah", uid: 1) alice.services << @service 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 - 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.last.save expect(alice.services.last).to be_invalid end - it 'by default has no profile photo url' do - expect( described_class.new.profile_photo_url ).to be_nil + it "by default has no profile photo url" do + expect(described_class.new.profile_photo_url).to be_nil end - describe '.titles' do + describe ".titles" 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 - describe '.first_from_omniauth' do - let(:omniauth) { { 'provider' => 'facebook', 'uid' => '1', 'credentials' => {}, 'info' => {} } } - it 'first service by provider and uid' do - expect( described_class.first_from_omniauth( omniauth ) ).to eql @service + describe ".first_from_omniauth" do + let(:omniauth) { {"provider" => "twitter", "uid" => "1", "credentials" => {}, "info" => {}} } + it "first service by provider and uid" do + expect(described_class.first_from_omniauth(omniauth)).to eql @service end end - describe '.initialize_from_omniauth' do + describe ".initialize_from_omniauth" do let(:omniauth) do - { 'provider' => 'facebook', - 'uid' => '2', - 'info' => { 'nickname' => 'grimmin' }, - 'credentials' => { 'token' => 'tokin', 'secret' =>"not_so_much" } + { + "provider" => "twitter", + "uid" => "2", + "info" => {"nickname" => "grimmin"}, + "credentials" => {"token" => "token", "secret" => "not_so_much"} } 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 - expect( subject.type ).to eql "Services::Facebook" + it "new service obj of type Services::Twitter" do + expect(subject.type).to eql "Services::Twitter" end - it 'new service obj with oauth options populated' do - expect( subject.uid ).to eql "2" - expect( subject.nickname ).to eql "grimmin" - expect( subject.access_token ).to eql "tokin" - expect( subject.access_secret ).to eql "not_so_much" + it "new service obj with oauth options populated" do + expect(subject.uid).to eql "2" + expect(subject.nickname).to eql "grimmin" + expect(subject.access_token).to eql "token" + expect(subject.access_secret).to eql "not_so_much" end end end diff --git a/spec/models/services/facebook_spec.rb b/spec/models/services/facebook_spec.rb deleted file mode 100644 index 6df24fe10..000000000 --- a/spec/models/services/facebook_spec.rb +++ /dev/null @@ -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 diff --git a/spec/presenters/node_info_presenter_spec.rb b/spec/presenters/node_info_presenter_spec.rb index 8dcc0894b..8929213b0 100644 --- a/spec/presenters/node_info_presenter_spec.rb +++ b/spec/presenters/node_info_presenter_spec.rb @@ -52,10 +52,6 @@ describe NodeInfoPresenter do context "when services are enabled" do before do AppConfig.services = { - "facebook" => { - "enable" => true, - "authorized" => true - }, "twitter" => {"enable" => true}, "wordpress" => {"enable" => false}, "tumblr" => { @@ -66,17 +62,13 @@ describe NodeInfoPresenter do end it "provides services" do - expect(hash).to include "services" => include("outbound" => %w(twitter facebook)) + expect(hash).to include "services" => include("outbound" => ["twitter"]) end end context "when some services are set to username authorized" do before do AppConfig.services = { - "facebook" => { - "enable" => true, - "authorized" => "bob" - }, "twitter" => {"enable" => true}, "wordpress" => { "enable" => true, diff --git a/spec/services/status_message_creation_service_spec.rb b/spec/services/status_message_creation_service_spec.rb index aaca06da3..cc4a35d85 100644 --- a/spec/services/status_message_creation_service_spec.rb +++ b/spec/services/status_message_creation_service_spec.rb @@ -169,8 +169,8 @@ describe StatusMessageCreationService do it "dispatches the StatusMessage to services" do expect(alice).to receive(:dispatch_post) .with(instance_of(StatusMessage), - hash_including(service_types: array_including(%w(Services::Facebook Services::Twitter)))) - StatusMessageCreationService.new(alice).create(params.merge(services: %w(twitter facebook))) + hash_including(service_types: array_including(%w[Services::Tumblr Services::Twitter]))) + StatusMessageCreationService.new(alice).create(params.merge(services: %w[twitter tumblr])) end context "with mention" do diff --git a/spec/workers/delete_post_from_service_spec.rb b/spec/workers/delete_post_from_service_spec.rb index 48a9b85c1..bea4da827 100644 --- a/spec/workers/delete_post_from_service_spec.rb +++ b/spec/workers/delete_post_from_service_spec.rb @@ -3,7 +3,7 @@ describe Workers::DeletePostFromService do it "calls service#delete_from_service with given opts" do service = double - opts = {facebook_id: "23456"} + opts = {twitter_id: "23456"} expect(service).to receive(:delete_from_service).with(opts) allow(Service).to receive(:find_by_id).with("123").and_return(service) |