diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2015-08-09 02:53:31 +0300 |
---|---|---|
committer | Jonne Haß <me@jhass.eu> | 2015-08-21 15:21:43 +0300 |
commit | d28e03f053ae47d215b0d87b7a452e92c07cb167 (patch) | |
tree | 7f7867be5d5da407d121dd8a24cfd8738ecf8dbb /spec | |
parent | 21e5bd869748f667f00771487e64dd835b061316 (diff) |
use discovery from diaspora_federation gem
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/registrations_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/integration/receiving_spec.rb | 5 | ||||
-rw-r--r-- | spec/lib/postzord/receiver/private_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/reshare_spec.rb | 9 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 8 | ||||
-rw-r--r-- | spec/workers/fetch_webfinger_spec.rb | 4 |
6 files changed, 12 insertions, 22 deletions
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 32ee54b4f..6866b712e 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -16,7 +16,7 @@ describe RegistrationsController, :type => :controller do :password_confirmation => "password" } } - allow(Webfinger).to receive_message_chain(:new, :fetch).and_return(FactoryGirl.create(:person)) + allow(Person).to receive(:find_or_fetch_by_identifier).and_return(FactoryGirl.create(:person)) end describe '#check_registrations_open!' do diff --git a/spec/integration/receiving_spec.rb b/spec/integration/receiving_spec.rb index 1d31116e9..c62241cf7 100644 --- a/spec/integration/receiving_spec.rb +++ b/spec/integration/receiving_spec.rb @@ -225,11 +225,10 @@ describe 'a user receives a post', :type => :request do Profile.where(:person_id => remote_person.id).delete_all remote_person.attributes.delete(:id) # leaving a nil id causes it to try to save with id set to NULL in postgres - m = double() - expect(Webfinger).to receive(:new).twice.with(eve.person.diaspora_handle).and_return(m) remote_person.save(:validate => false) remote_person.profile = FactoryGirl.create(:profile, :person => remote_person) - expect(m).to receive(:fetch).twice.and_return(remote_person) + expect(Person).to receive(:find_or_fetch_by_identifier).twice.with(eve.person.diaspora_handle) + .and_return(remote_person) expect(bob.reload.visible_shareables(Post).size).to eq(1) post_in_db = StatusMessage.find(@post.id) diff --git a/spec/lib/postzord/receiver/private_spec.rb b/spec/lib/postzord/receiver/private_spec.rb index 717dbe8c1..088df5ecf 100644 --- a/spec/lib/postzord/receiver/private_spec.rb +++ b/spec/lib/postzord/receiver/private_spec.rb @@ -13,7 +13,7 @@ describe Postzord::Receiver::Private do describe '.initialize' do it 'valid for local' do - expect(Webfinger).not_to receive(:new) + expect(Person).not_to receive(:find_or_fetch_by_identifier) expect(Salmon::EncryptedSlap).not_to receive(:from_xml) zord = Postzord::Receiver::Private.new(bob, :person => alice.person, :object => @alices_post) @@ -24,11 +24,9 @@ describe Postzord::Receiver::Private do it 'valid for remote' do salmon_double = double() - web_double = double() - expect(web_double).to receive(:fetch).and_return true expect(salmon_double).to receive(:author_id).and_return(true) expect(Salmon::EncryptedSlap).to receive(:from_xml).with(@salmon_xml, bob).and_return(salmon_double) - expect(Webfinger).to receive(:new).and_return(web_double) + expect(Person).to receive(:find_or_fetch_by_identifier).and_return(true) zord = Postzord::Receiver::Private.new(bob, :salmon_xml => @salmon_xml) expect(zord.instance_variable_get(:@user)).not_to be_nil diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb index ff1781b9a..e235c4066 100644 --- a/spec/models/reshare_spec.rb +++ b/spec/models/reshare_spec.rb @@ -212,9 +212,7 @@ describe Reshare, :type => :model do @original_author.profile = @original_profile - wf_prof_double = double - expect(wf_prof_double).to receive(:fetch).and_return(@original_author) - expect(Webfinger).to receive(:new).and_return(wf_prof_double) + expect(Person).to receive(:find_or_fetch_by_identifier).and_return(@original_author) allow(@response).to receive(:body).and_return(@root_object.to_diaspora_xml) @@ -287,10 +285,7 @@ describe Reshare, :type => :model do @xml = @reshare.to_xml.to_s different_person = FactoryGirl.build(:person) - - wf_prof_double = double - expect(wf_prof_double).to receive(:fetch).and_return(different_person) - expect(Webfinger).to receive(:new).and_return(wf_prof_double) + expect(Person).to receive(:find_or_fetch_by_identifier).and_return(different_person) allow(different_person).to receive(:url).and_return(@original_author.url) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 5c001abe1..489c1ac45 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -905,11 +905,9 @@ describe User, :type => :model do context "with autofollow sharing enabled" do it "should start sharing with autofollow account" do AppConfig.settings.autofollow_on_join = true - AppConfig.settings.autofollow_on_join_user = 'one' + AppConfig.settings.autofollow_on_join_user = "one" - wf_double = double - expect(wf_double).to receive(:fetch) - expect(Webfinger).to receive(:new).with('one').and_return(wf_double) + expect(Person).to receive(:find_or_fetch_by_identifier).with("one") user.seed_aspects end @@ -919,7 +917,7 @@ describe User, :type => :model do it "should not start sharing with the diasporahq account" do AppConfig.settings.autofollow_on_join = false - expect(Webfinger).not_to receive(:new) + expect(Person).not_to receive(:find_or_fetch_by_identifier) user.seed_aspects end diff --git a/spec/workers/fetch_webfinger_spec.rb b/spec/workers/fetch_webfinger_spec.rb index cfa83b24a..0a9469c75 100644 --- a/spec/workers/fetch_webfinger_spec.rb +++ b/spec/workers/fetch_webfinger_spec.rb @@ -3,7 +3,7 @@ require "spec_helper" describe Workers::FetchWebfinger do it "should webfinger and queue a job to fetch public posts" do @person = FactoryGirl.create(:person) - allow(Webfinger).to receive(:new).and_return(double(fetch: @person)) + allow(Person).to receive(:find_or_fetch_by_identifier).and_return(@person) expect(Diaspora::Fetcher::Public).to receive(:queue_for).exactly(1).times @@ -11,7 +11,7 @@ describe Workers::FetchWebfinger do end it "should webfinger and queue no job to fetch public posts if the person is not found" do - allow(Webfinger).to receive(:new).and_return(double(fetch: nil)) + allow(Person).to receive(:find_or_fetch_by_identifier).and_return(nil) expect(Diaspora::Fetcher::Public).not_to receive(:queue_for) |