create temporary fixture tests and remove old tests
This commit is contained in:
parent
f875be8d5b
commit
8bf54e32ae
2 changed files with 36 additions and 70 deletions
36
spec/controllers/diaspora_federation_controller_spec.rb
Normal file
36
spec/controllers/diaspora_federation_controller_spec.rb
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
# this is temporarily needed for fixture generation
|
||||||
|
# TODO: remove this after the parsing is also in the diaspora_federation gem
|
||||||
|
describe DiasporaFederation do
|
||||||
|
routes { DiasporaFederation::Engine.routes }
|
||||||
|
|
||||||
|
let(:fixture_path) { Rails.root.join("spec", "fixtures") }
|
||||||
|
|
||||||
|
describe DiasporaFederation::WebfingerController, type: :controller do
|
||||||
|
it "generates the host_meta fixture", fixture: true do
|
||||||
|
get :host_meta
|
||||||
|
expect(response).to be_success
|
||||||
|
expect(response.body).to match(/webfinger/)
|
||||||
|
save_fixture(response.body, "host-meta", fixture_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "generates the webfinger fixture", fixture: true do
|
||||||
|
post :legacy_webfinger, "q" => alice.person.diaspora_handle
|
||||||
|
expect(response).to be_success
|
||||||
|
save_fixture(response.body, "webfinger", fixture_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe DiasporaFederation::HCardController, type: :controller do
|
||||||
|
it "generates the hCard fixture", fixture: true do
|
||||||
|
post :hcard, "guid" => alice.person.guid.to_s
|
||||||
|
expect(response).to be_success
|
||||||
|
save_fixture(response.body, "hcard", fixture_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -11,15 +11,6 @@ describe PublicsController, :type => :controller do
|
||||||
@person = FactoryGirl.create(:person)
|
@person = FactoryGirl.create(:person)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#host_meta' do
|
|
||||||
it 'succeeds', :fixture => true do
|
|
||||||
get :host_meta
|
|
||||||
expect(response).to be_success
|
|
||||||
expect(response.body).to match(/webfinger/)
|
|
||||||
save_fixture(response.body, "host-meta", fixture_path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#receive_public' do
|
describe '#receive_public' do
|
||||||
it 'succeeds' do
|
it 'succeeds' do
|
||||||
post :receive_public, :xml => "<stuff/>"
|
post :receive_public, :xml => "<stuff/>"
|
||||||
|
|
@ -79,67 +70,6 @@ describe PublicsController, :type => :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#hcard' do
|
|
||||||
it "succeeds", :fixture => true do
|
|
||||||
post :hcard, "guid" => @user.person.guid.to_s
|
|
||||||
expect(response).to be_success
|
|
||||||
save_fixture(response.body, "hcard", fixture_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets the person' do
|
|
||||||
post :hcard, "guid" => @user.person.guid.to_s
|
|
||||||
expect(assigns[:person]).to eq(@user.person)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not query by user id' do
|
|
||||||
post :hcard, "guid" => 90348257609247856.to_s
|
|
||||||
expect(assigns[:person]).to be_nil
|
|
||||||
expect(response).to be_not_found
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'finds nothing for closed accounts' do
|
|
||||||
@user.person.update_attributes(:closed_account => true)
|
|
||||||
get :hcard, :guid => @user.person.guid.to_s
|
|
||||||
expect(response).to be_not_found
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#webfinger' do
|
|
||||||
it "succeeds when the person and user exist locally", :fixture => true do
|
|
||||||
post :webfinger, 'q' => @user.person.diaspora_handle
|
|
||||||
expect(response).to be_success
|
|
||||||
save_fixture(response.body, "webfinger", fixture_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "404s when the person exists remotely because it is local only" do
|
|
||||||
stub_success('me@mydiaspora.pod.com')
|
|
||||||
post :webfinger, 'q' => 'me@mydiaspora.pod.com'
|
|
||||||
expect(response).to be_not_found
|
|
||||||
end
|
|
||||||
|
|
||||||
it "404s when the person is local but doesn't have an owner" do
|
|
||||||
post :webfinger, 'q' => @person.diaspora_handle
|
|
||||||
expect(response).to be_not_found
|
|
||||||
end
|
|
||||||
|
|
||||||
it "404s when the person does not exist locally or remotely" do
|
|
||||||
stub_failure('me@mydiaspora.pod.com')
|
|
||||||
post :webfinger, 'q' => 'me@mydiaspora.pod.com'
|
|
||||||
expect(response).to be_not_found
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has the users profile href' do
|
|
||||||
get :webfinger, :q => @user.diaspora_handle
|
|
||||||
expect(response.body).to include "http://webfinger.net/rel/profile-page"
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'finds nothing for closed accounts' do
|
|
||||||
@user.person.update_attributes(:closed_account => true)
|
|
||||||
get :webfinger, :q => @user.diaspora_handle
|
|
||||||
expect(response).to be_not_found
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#hub' do
|
describe '#hub' do
|
||||||
it 'succeeds' do
|
it 'succeeds' do
|
||||||
get :hub
|
get :hub
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue