End the require mess

* Rename and reorganize post fetcher to fix autoloading, also let it use
  Faradays default connection so we get nice redirects
* Add initializer to load libs at a central place
* added lib dir to autoload_once paths to increase thread safety
* Moved lib/exceptions.rb to lib/diaspora/ to conform namespacing
This commit is contained in:
Jonne Haß 2013-02-19 05:37:58 +01:00
parent 13ee6129e5
commit 3fc3b249e7
61 changed files with 115 additions and 154 deletions

View file

@ -1,5 +1,3 @@
require Rails.root.join('lib', 'statistics')
class AdminsController < ApplicationController class AdminsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :redirect_unless_admin before_filter :redirect_unless_admin

View file

@ -2,8 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join('lib', 'email_inviter')
class InvitationsController < ApplicationController class InvitationsController < ApplicationController
before_filter :authenticate_user!, :only => [:new, :create] before_filter :authenticate_user!, :only => [:new, :create]

View file

@ -2,8 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join("app", "presenters", "post_presenter")
class LikesController < ApplicationController class LikesController < ApplicationController
include ApplicationHelper include ApplicationHelper
before_filter :authenticate_user! before_filter :authenticate_user!

View file

@ -2,8 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join("lib", 'stream', "person")
class PeopleController < ApplicationController class PeopleController < ApplicationController
before_filter :authenticate_user!, :except => [:show, :last_post] before_filter :authenticate_user!, :except => [:show, :last_post]
before_filter :redirect_if_tag_search, :only => [:index] before_filter :redirect_if_tag_search, :only => [:index]

View file

@ -2,8 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join("app", "presenters", "post_presenter")
class PostsController < ApplicationController class PostsController < ApplicationController
include PostsHelper include PostsHelper

View file

@ -2,11 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join('lib', 'stream', 'public')
class PublicsController < ApplicationController class PublicsController < ApplicationController
require Rails.root.join('lib', 'diaspora', 'parser')
require Rails.root.join('lib', 'postzord', 'receiver', 'public')
require Rails.root.join('lib', 'postzord', 'receiver', 'private')
include Diaspora::Parser include Diaspora::Parser
skip_before_filter :set_header_data skip_before_filter :set_header_data

View file

@ -2,15 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join("lib", "stream", "aspect")
require Rails.root.join("lib", "stream", "multi")
require Rails.root.join("lib", "stream", "comments")
require Rails.root.join("lib", "stream", "likes")
require Rails.root.join("lib", "stream", "mention")
require Rails.root.join("lib", "stream", "followed_tag")
require Rails.root.join("lib", "stream", "activity")
class StreamsController < ApplicationController class StreamsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :save_selected_aspects, :only => :aspects before_filter :save_selected_aspects, :only => :aspects

View file

@ -1,8 +1,6 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is # Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join('app', 'models', 'acts_as_taggable_on', 'tag')
require Rails.root.join('lib', 'stream', 'tag')
class TagsController < ApplicationController class TagsController < ApplicationController
skip_before_filter :set_grammatical_gender skip_before_filter :set_grammatical_gender

View file

@ -3,9 +3,6 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class UsersController < ApplicationController class UsersController < ApplicationController
require Rails.root.join('lib', 'diaspora', 'exporter')
require Rails.root.join('lib', 'collect_user_photos')
before_filter :authenticate_user!, :except => [:new, :create, :public, :user_photo] before_filter :authenticate_user!, :except => [:new, :create, :public, :user_photo]
respond_to :html respond_to :html

View file

@ -2,9 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join('lib', 'diaspora', 'markdownify')
require 'redcarpet/render_strip'
module MarkdownifyHelper module MarkdownifyHelper
def markdownify(target, render_options={}) def markdownify(target, render_options={})

View file

@ -17,7 +17,7 @@ module Jobs
people = Person.where(:id => person_ids) people = Person.where(:id => person_ids)
dispatcher = dispatcher_class_as_string.constantize dispatcher = dispatcher_class_as_string.constantize
hydra = HydraWrapper.new(user, people, encoded_object_xml, dispatcher) hydra = ::HydraWrapper.new(user, people, encoded_object_xml, dispatcher)
hydra.enqueue_batch hydra.enqueue_batch
hydra.run hydra.run

View file

@ -2,9 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require 'uri'
require Rails.root.join('lib', 'hcard')
class Person < ActiveRecord::Base class Person < ActiveRecord::Base
include ROXML include ROXML
include Encryptor::Public include Encryptor::Public

View file

@ -3,8 +3,6 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class Photo < ActiveRecord::Base class Photo < ActiveRecord::Base
require 'carrierwave/orm/activerecord'
include Diaspora::Federated::Shareable include Diaspora::Federated::Shareable
include Diaspora::Commentable include Diaspora::Commentable
include Diaspora::Shareable include Diaspora::Shareable

View file

@ -4,7 +4,6 @@
class Service < ActiveRecord::Base class Service < ActiveRecord::Base
include ActionView::Helpers::TextHelper include ActionView::Helpers::TextHelper
require Rails.root.join('app', 'helpers', 'markdownify_helper')
include MarkdownifyHelper include MarkdownifyHelper
belongs_to :user belongs_to :user
@ -39,5 +38,5 @@ class Service < ActiveRecord::Base
end end
end end
require Rails.root.join('app', 'models', 'services', 'facebook') require 'services/facebook'
require Rails.root.join('app', 'models', 'services', 'twitter') require 'services/twitter'

View file

@ -1,7 +1,5 @@
require 'uri'
class Services::Facebook < Service class Services::Facebook < Service
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers
require Rails.root.join('app', 'helpers', 'markdownify_helper')
include MarkdownifyHelper include MarkdownifyHelper
OVERRIDE_FIELDS_ON_FB_UPDATE = [:contact_id, :person_id, :request_id, :invitation_id, :photo_url, :name, :username] OVERRIDE_FIELDS_ON_FB_UPDATE = [:contact_id, :person_id, :request_id, :invitation_id, :photo_url, :name, :username]

View file

@ -1,5 +1,3 @@
require 'uri'
class Services::Twitter < Service class Services::Twitter < Service
MAX_CHARACTERS = 140 MAX_CHARACTERS = 140
SHORTENED_URL_LENGTH = 21 SHORTENED_URL_LENGTH = 21

View file

@ -159,7 +159,6 @@ class StatusMessage < Post
end end
def contains_oembed_url_in_text? def contains_oembed_url_in_text?
require 'uri'
urls = URI.extract(self.raw_message, ['http', 'https']) urls = URI.extract(self.raw_message, ['http', 'https'])
self.oembed_url = urls.find{ |url| !TRUSTED_OEMBED_PROVIDERS.find(url).nil? } self.oembed_url = urls.find{ |url| !TRUSTED_OEMBED_PROVIDERS.find(url).nil? }
end end

View file

@ -2,9 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join('lib', 'salmon', 'salmon')
require Rails.root.join('lib', 'postzord', 'dispatcher')
class User < ActiveRecord::Base class User < ActiveRecord::Base
include Encryptor::Private include Encryptor::Private
include Connecting include Connecting

View file

@ -2,9 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join('lib', 'evil_query')
#TODO: THIS FILE SHOULD NOT EXIST, EVIL SQL SHOULD BE ENCAPSULATED IN EvilQueries, #TODO: THIS FILE SHOULD NOT EXIST, EVIL SQL SHOULD BE ENCAPSULATED IN EvilQueries,
#throwing all of this stuff in user violates demeter like WHOA #throwing all of this stuff in user violates demeter like WHOA
module User::Querying module User::Querying

View file

@ -1,4 +1,3 @@
require 'uri'
class OEmbedPresenter class OEmbedPresenter
include PostsHelper include PostsHelper
include ActionView::Helpers::TextHelper include ActionView::Helpers::TextHelper

View file

@ -1,5 +1,3 @@
require Rails.root.join('lib', 'template_picker')
class PostPresenter class PostPresenter
attr_accessor :post, :current_user attr_accessor :post, :current_user

View file

@ -32,8 +32,8 @@ module Diaspora
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.
# Add additional load paths for your own custom dirs # Add additional load paths for your own custom dirs
config.autoload_paths += %W(#{config.root}/app/presenters) config.autoload_paths += %W{#{config.root}/app/presenters}
config.autoload_paths += %W(#{config.root}/lib) config.autoload_once_paths += %W{#{config.root}/lib}
# Only load the plugins named here, in the order given (default is alphabetical). # Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named # :all can be used as a placeholder for all plugins not explicitly named

View file

@ -13,7 +13,6 @@ end
# Load the rails application # Load the rails application
require Pathname.new(__FILE__).dirname.expand_path.join('application') require Pathname.new(__FILE__).dirname.expand_path.join('application')
require Rails.root.join("lib", "exceptions")
# Load configuration system early # Load configuration system early
require Rails.root.join('config', 'load_config') require Rails.root.join('config', 'load_config')
@ -27,7 +26,6 @@ USERNAME_BLACKLIST = ['admin', 'administrator', 'hostmaster', 'info', 'postmaste
# Initialize the rails application # Initialize the rails application
Diaspora::Application.initialize! Diaspora::Application.initialize!
require Rails.root.join('lib', 'federation_logger')
# allow token auth only for posting activitystream photos # allow token auth only for posting activitystream photos
module Devise module Devise

View file

@ -1,3 +1,2 @@
ActsAsTaggableOn.force_lowercase = true ActsAsTaggableOn.force_lowercase = true
require Rails.root.join("app", "models", "acts_as_taggable_on", "tag")

View file

@ -0,0 +1,36 @@
# Stdlib
require 'cgi'
require 'uri'
# Not auto required gems
require 'active_support/base64'
require 'builder/xchar'
require 'carrierwave/orm/activerecord'
require 'erb'
require 'redcarpet/render_strip'
require 'typhoeus'
# Presenters
require 'post_presenter'
# Helpers
require 'markdownify_helper'
# Our libs
require 'collect_user_photos'
require 'diaspora'
require 'email_inviter'
require 'evil_query'
require 'federation_logger'
require 'h_card'
require 'hydra_wrapper'
require 'postzord'
require 'publisher'
require 'pubsubhubbub'
require 'salmon'
require 'statistics'
require 'stream'
require 'template_picker'
require 'webfinger'
require 'webfinger_profile'

View file

@ -1,6 +1,6 @@
module DebuggingCukeHelpers module DebuggingCukeHelpers
def start_debugging def start_debugging
require 'ruby-debug' require 'debug'
debugger debugger
true true
end end

View file

@ -4,8 +4,6 @@
# instead of editing this one. Cucumber will automatically load all features/**/*.rb # instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files. # files.
require 'uri'
require 'cgi'
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
module WithinHelpers module WithinHelpers

View file

@ -3,5 +3,9 @@
# the COPYRIGHT file. # the COPYRIGHT file.
module Diaspora module Diaspora
autoload :Parser require 'diaspora/exceptions'
require 'diaspora/parser'
require 'diaspora/fetcher'
require 'diaspora/markdownify'
require 'diaspora/exporter'
end end

View file

@ -9,8 +9,6 @@
#including this module lets you federate an object at the most basic of level #including this module lets you federate an object at the most basic of level
require 'builder/xchar'
module Diaspora module Diaspora
module Federated module Federated
module Base module Base

5
lib/diaspora/fetcher.rb Normal file
View file

@ -0,0 +1,5 @@
module Diaspora
module Fetcher
require 'diaspora/fetcher/public'
end
end

View file

@ -1,8 +1,7 @@
# Copyright (c) 2010-2012, Diaspora Inc. This file is # Copyright (c) 2010-2012, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
module Diaspora; module Fetcher; class Public
class PublicFetcher
# various states that can be assigned to a person to describe where # various states that can be assigned to a person to describe where
# in the process of fetching their public posts we're currently at # in the process of fetching their public posts we're currently at
@ -23,11 +22,11 @@ class PublicFetcher
begin begin
retrieve_and_process_posts retrieve_and_process_posts
rescue => e rescue => e
set_fetch_status PublicFetcher::Status_Failed set_fetch_status Public::Status_Failed
raise e raise e
end end
set_fetch_status PublicFetcher::Status_Done set_fetch_status Public::Status_Done
end end
private private
@ -35,20 +34,20 @@ class PublicFetcher
# if it is reasonable to do so, and that they have not been fetched already # if it is reasonable to do so, and that they have not been fetched already
def qualifies_for_fetching? def qualifies_for_fetching?
raise ActiveRecord::RecordNotFound unless @person.present? raise ActiveRecord::RecordNotFound unless @person.present?
return false if @person.fetch_status == PublicFetcher::Status_Unfetchable return false if @person.fetch_status == Public::Status_Unfetchable
# local users don't need to be fetched # local users don't need to be fetched
if @person.local? if @person.local?
set_fetch_status PublicFetcher::Status_Unfetchable set_fetch_status Public::Status_Unfetchable
return false return false
end end
# this record is already being worked on # this record is already being worked on
return false if @person.fetch_status > PublicFetcher::Status_Initial return false if @person.fetch_status > Public::Status_Initial
# ok, let's go # ok, let's go
@person.remote? && @person.remote? &&
@person.fetch_status == PublicFetcher::Status_Initial @person.fetch_status == Public::Status_Initial
end end
# call the methods to fetch and process the public posts for the person # call the methods to fetch and process the public posts for the person
@ -72,24 +71,19 @@ class PublicFetcher
# fetch the public posts of the person from their server and save the # fetch the public posts of the person from their server and save the
# JSON response to `@data` # JSON response to `@data`
def retrieve_posts def retrieve_posts
set_fetch_status PublicFetcher::Status_Running set_fetch_status Public::Status_Running
FEDERATION_LOGGER.info "fetching public posts for #{@person.diaspora_handle}" FEDERATION_LOGGER.info "fetching public posts for #{@person.diaspora_handle}"
conn = Faraday.new(:url => @person.url) do |c| resp = Faraday.get("#{@person.url}/people/#{@person.guid}") do |req|
c.request :json req.headers[:accept] = 'application/json'
c.response :json req.headers[:user_agent] = 'diaspora-fetcher'
c.adapter :net_http
end end
conn.headers[:user_agent] = 'diaspora-fetcher'
conn.headers[:accept] = 'application/json'
resp = conn.get "/people/#{@person.guid}"
FEDERATION_LOGGER.debug resp.body.to_s[0..250] FEDERATION_LOGGER.debug resp.body.to_s[0..250]
@data = resp.body @data = JSON.parse resp.body
set_fetch_status PublicFetcher::Status_Fetched set_fetch_status Public::Status_Fetched
end end
# process the public posts that were previously fetched with `retrieve_posts` # process the public posts that were previously fetched with `retrieve_posts`
@ -124,7 +118,7 @@ class PublicFetcher
StatusMessage.set_callback :create, :set_guid StatusMessage.set_callback :create, :set_guid
end end
set_fetch_status PublicFetcher::Status_Processed set_fetch_status Public::Status_Processed
end end
# set and save the fetch status for the current person # set and save the fetch status for the current person
@ -182,4 +176,4 @@ class PublicFetcher
type_ok type_ok
end end
end end; end; end

View file

@ -1,5 +1,3 @@
require 'erb'
module Diaspora module Diaspora
module Markdownify module Markdownify
class HTML < Redcarpet::Render::HTML class HTML < Redcarpet::Render::HTML

View file

@ -1,5 +1,3 @@
require Rails.root.join("app", "models", "acts_as_taggable_on", "tag")
module Diaspora module Diaspora
module Markdownify module Markdownify
class Email < Redcarpet::Render::HTML class Email < Redcarpet::Render::HTML
@ -26,4 +24,4 @@ module Diaspora
end end
end end
end end
end end

View file

@ -2,8 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join("app", "models", "acts_as_taggable_on", "tag")
module Diaspora module Diaspora
module Taggable module Taggable
def self.included(model) def self.included(model)

View file

@ -2,9 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require 'typhoeus'
require 'active_support/base64'
class HydraWrapper class HydraWrapper
OPTS = {:max_redirects => 3, :timeout => 25000, :method => :post, OPTS = {:max_redirects => 3, :timeout => 25000, :method => :post,

View file

@ -3,5 +3,6 @@
# the COPYRIGHT file. # the COPYRIGHT file.
module Postzord module Postzord
require 'postzord/receiver'
require 'postzord/dispatcher'
end end

View file

@ -4,8 +4,8 @@
class Postzord::Dispatcher class Postzord::Dispatcher
require Rails.root.join('lib', 'postzord', 'dispatcher', 'private') require 'postzord/dispatcher/private'
require Rails.root.join('lib', 'postzord', 'dispatcher', 'public') require 'postzord/dispatcher/public'
attr_reader :sender, :object, :xml, :subscribers, :opts attr_reader :sender, :object, :xml, :subscribers, :opts

View file

@ -4,8 +4,9 @@
class Postzord::Receiver class Postzord::Receiver
require Rails.root.join('lib', 'postzord', 'receiver', 'private') require 'postzord/receiver/private'
require Rails.root.join('lib', 'postzord', 'receiver', 'public') require 'postzord/receiver/public'
require 'postzord/receiver/local_batch'
def perform! def perform!
self.receive! self.receive!

View file

@ -2,9 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join('lib', 'webfinger')
require Rails.root.join('lib', 'diaspora', 'parser')
class Postzord::Receiver::Private < Postzord::Receiver class Postzord::Receiver::Private < Postzord::Receiver
def initialize(user, opts={}) def initialize(user, opts={})

View file

@ -24,7 +24,7 @@ end
# Verify documents secured with Magic Signatures # Verify documents secured with Magic Signatures
module Salmon module Salmon
autoload :Slap, File.join(Rails.root, "lib", "salmon", "slap").to_s require "salmon/slap"
autoload :EncryptedSlap, File.join(Rails.root, "lib", "salmon", "encrypted_slap").to_s require "salmon/encrypted_slap"
autoload :MagicSigEnvelope, File.join(Rails.root, "lib", "salmon", "magic_sig_envelope").to_s require "salmon/magic_sig_envelope"
end end

View file

@ -1,3 +1,12 @@
module Stream module Stream
require 'stream/activity'
require 'stream/aspect'
require 'stream/comments'
require 'stream/followed_tag'
require 'stream/likes'
require 'stream/mention'
require 'stream/multi'
require 'stream/person'
require 'stream/public'
require 'stream/tag'
end end

View file

@ -1,4 +1,3 @@
require Rails.root.join("lib", "publisher")
class Stream::Base class Stream::Base
TYPES_OF_POST_IN_STREAM = ['StatusMessage', 'Reshare', 'ActivityStreams::Photo'] TYPES_OF_POST_IN_STREAM = ['StatusMessage', 'Reshare', 'ActivityStreams::Photo']

View file

@ -2,9 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require Rails.root.join('lib', 'hcard')
require Rails.root.join('lib', 'webfinger_profile')
class Webfinger class Webfinger
attr_accessor :host_meta_xrd, :webfinger_profile_xrd, attr_accessor :host_meta_xrd, :webfinger_profile_xrd,
:webfinger_profile, :hcard, :hcard_xrd, :person, :webfinger_profile, :hcard, :hcard_xrd, :person,

View file

@ -3,24 +3,26 @@
# the COPYRIGHT file. # the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib','diaspora','fetcher','public')
# Tests fetching public posts of a person on a remote server # Tests fetching public posts of a person on a remote server
describe PublicFetcher do describe Diaspora::Fetcher::Public do
before do before do
# the fixture is taken from an actual json request. # the fixture is taken from an actual json request.
# it contains 10 StatusMessages and 5 Reshares, all of them public # it contains 10 StatusMessages and 5 Reshares, all of them public
# the guid of the person is "7445f9a0a6c28ebb" # the guid of the person is "7445f9a0a6c28ebb"
@fixture = File.open(Rails.root.join('spec', 'fixtures', 'public_posts.json')).read @fixture = File.open(Rails.root.join('spec', 'fixtures', 'public_posts.json')).read
@fetcher = PublicFetcher.new @fetcher = Diaspora::Fetcher::Public.new
@person = FactoryGirl.create(:person, {:guid => "7445f9a0a6c28ebb", @person = FactoryGirl.create(:person, {:guid => "7445f9a0a6c28ebb",
:url => "https://remote-testpod.net", :url => "https://remote-testpod.net",
:diaspora_handle => "testuser@remote-testpod.net"}) :diaspora_handle => "testuser@remote-testpod.net"})
stub_request(:get, /remote-testpod.net\/people\/.*/) stub_request(:get, /remote-testpod.net\/people\/.*/)
.with(:headers => {'Accept'=>'application/json'}) .with(headers: {
.to_return(:body => @fixture) 'Accept'=>'application/json',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'User-Agent'=>'diaspora-fetcher'
}).to_return(:body => @fixture)
end end
describe "#retrieve_posts" do describe "#retrieve_posts" do
@ -34,8 +36,8 @@ describe PublicFetcher do
it "sets the operation status on the person" do it "sets the operation status on the person" do
@person.reload @person.reload
@person.fetch_status.should_not eql(PublicFetcher::Status_Initial) @person.fetch_status.should_not eql(Diaspora::Fetcher::Public::Status_Initial)
@person.fetch_status.should eql(PublicFetcher::Status_Fetched) @person.fetch_status.should eql(Diaspora::Fetcher::Public::Status_Fetched)
end end
it "sets the @data variable to the parsed JSON data" do it "sets the @data variable to the parsed JSON data" do
@ -73,8 +75,8 @@ describe PublicFetcher do
} }
@person.reload @person.reload
@person.fetch_status.should_not eql(PublicFetcher::Status_Initial) @person.fetch_status.should_not eql(Diaspora::Fetcher::Public::Status_Initial)
@person.fetch_status.should eql(PublicFetcher::Status_Processed) @person.fetch_status.should eql(Diaspora::Fetcher::Public::Status_Processed)
end end
context 'created post' do context 'created post' do
@ -121,7 +123,7 @@ describe PublicFetcher do
end end
context "private methods" do context "private methods" do
let(:public_fetcher) { PublicFetcher.new } let(:public_fetcher) { Diaspora::Fetcher::Public.new }
describe '#qualifies_for_fetching?' do describe '#qualifies_for_fetching?' do
it "raises an error if the person doesn't exist" do it "raises an error if the person doesn't exist" do
@ -135,7 +137,7 @@ describe PublicFetcher do
it 'returns false if the person is unfetchable' do it 'returns false if the person is unfetchable' do
public_fetcher.instance_eval { public_fetcher.instance_eval {
@person = FactoryGirl.create(:person, {:fetch_status => PublicFetcher::Status_Unfetchable}) @person = FactoryGirl.create(:person, {:fetch_status => Diaspora::Fetcher::Public::Status_Unfetchable})
qualifies_for_fetching? qualifies_for_fetching?
}.should be_false }.should be_false
end end
@ -146,12 +148,12 @@ describe PublicFetcher do
@person = user.person @person = user.person
qualifies_for_fetching? qualifies_for_fetching?
}.should be_false }.should be_false
user.person.fetch_status.should eql PublicFetcher::Status_Unfetchable user.person.fetch_status.should eql Diaspora::Fetcher::Public::Status_Unfetchable
end end
it 'returns false if the person is processing already (or has been processed)' do it 'returns false if the person is processing already (or has been processed)' do
person = FactoryGirl.create(:person) person = FactoryGirl.create(:person)
person.fetch_status = PublicFetcher::Status_Fetched person.fetch_status = Diaspora::Fetcher::Public::Status_Fetched
person.save person.save
public_fetcher.instance_eval { public_fetcher.instance_eval {
@person = person @person = person
@ -173,14 +175,14 @@ describe PublicFetcher do
person = @person person = @person
public_fetcher.instance_eval { public_fetcher.instance_eval {
@person = person @person = person
set_fetch_status PublicFetcher::Status_Unfetchable set_fetch_status Diaspora::Fetcher::Public::Status_Unfetchable
} }
@person.fetch_status.should eql PublicFetcher::Status_Unfetchable @person.fetch_status.should eql Diaspora::Fetcher::Public::Status_Unfetchable
public_fetcher.instance_eval { public_fetcher.instance_eval {
set_fetch_status PublicFetcher::Status_Initial set_fetch_status Diaspora::Fetcher::Public::Status_Initial
} }
@person.fetch_status.should eql PublicFetcher::Status_Initial @person.fetch_status.should eql Diaspora::Fetcher::Public::Status_Initial
end end
end end

View file

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'email_inviter') require 'spec_helper'
describe EmailInviter do describe EmailInviter do
before do before do
@ -53,4 +53,4 @@ describe EmailInviter do
inviter.invitation_code.should == @user.invitation_code inviter.invitation_code.should == @user.invitation_code
end end
end end
end end

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file. # the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib', 'hcard')
describe HCard do describe HCard do
it 'should parse an hcard' do it 'should parse an hcard' do

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file. # the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib', 'postzord', 'dispatcher', 'private')
describe Postzord::Dispatcher::Private do describe Postzord::Dispatcher::Private do

View file

@ -4,8 +4,6 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib', 'postzord', 'dispatcher')
describe Postzord::Dispatcher do describe Postzord::Dispatcher do
before do before do
@sm = FactoryGirl.create(:status_message, :public => true, :author => alice.person) @sm = FactoryGirl.create(:status_message, :public => true, :author => alice.person)

View file

@ -1,5 +1,4 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib', 'postzord', 'receiver', 'local_batch')
describe Postzord::Receiver::LocalBatch do describe Postzord::Receiver::LocalBatch do
before do before do

View file

@ -4,9 +4,6 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib', 'postzord')
require Rails.root.join('lib', 'postzord', 'receiver', 'private')
describe Postzord::Receiver::Private do describe Postzord::Receiver::Private do
before do before do

View file

@ -4,9 +4,6 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib', 'postzord')
require Rails.root.join('lib', 'postzord', 'receiver', 'public')
describe Postzord::Receiver::Public do describe Postzord::Receiver::Public do
before do before do
@post = FactoryGirl.build(:status_message, :author => alice.person, :public => true) @post = FactoryGirl.build(:status_message, :author => alice.person, :public => true)

View file

@ -4,8 +4,6 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib', 'postzord', 'receiver')
describe Postzord::Receiver do describe Postzord::Receiver do
before do before do
@receiver = Postzord::Receiver.new @receiver = Postzord::Receiver.new

View file

@ -1,9 +1,6 @@
require 'spec_helper' require 'spec_helper'
#NOTE;why is it not auto loadeded?
require Rails.root.join('lib', 'publisher')
describe Publisher do describe Publisher do
before do before do
@publisher = Publisher.new(alice) @publisher = Publisher.new(alice)

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file. # the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib', 'pubsubhubbub')
describe Pubsubhubbub do describe Pubsubhubbub do
describe '#publish' do describe '#publish' do
@ -16,4 +15,4 @@ describe Pubsubhubbub do
Pubsubhubbub.new(hub).publish(feed).should be_success Pubsubhubbub.new(hub).publish(feed).should be_success
end end
end end
end end

View file

@ -3,7 +3,8 @@
# the COPYRIGHT file. # the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib', 'rake_helpers') require 'rake_helpers'
include RakeHelpers include RakeHelpers
describe RakeHelpers do describe RakeHelpers do
before do before do

View file

@ -1,5 +1,4 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib', 'statistics')
describe Statistics do describe Statistics do

View file

@ -1,5 +1,6 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('spec', 'shared_behaviors', 'stream') require Rails.root.join('spec', 'shared_behaviors', 'stream')
describe Stream::Base do describe Stream::Base do
before do before do
@stream = Stream::Base.new(alice) @stream = Stream::Base.new(alice)

View file

@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'template_picker')
require 'spec_helper' require 'spec_helper'
describe TemplatePicker do describe TemplatePicker do
before do before do
@post_stubs = {:type => 'StatusMessage', :photos => stub(:size => 2), @post_stubs = {:type => 'StatusMessage', :photos => stub(:size => 2),

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file. # the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
require Rails.root.join('lib', 'pubsubhubbub')
describe Jobs::PublishToHub do describe Jobs::PublishToHub do
describe '.perform' do describe '.perform' do