fixed every spec but the activity stream photos controller spec
This commit is contained in:
parent
74a7c3ab00
commit
d46f3a8d1f
8 changed files with 39 additions and 26 deletions
2
Gemfile
2
Gemfile
|
|
@ -97,5 +97,5 @@ group :test do
|
|||
gem 'fuubar'
|
||||
|
||||
gem 'diaspora-client', #:git => 'git@github.com:diaspora/diaspora-client.git'
|
||||
:path => "~/work/diaspora-client"
|
||||
:path => "~/workspace/diaspora-client"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ GIT
|
|||
json (>= 1.2.4)
|
||||
|
||||
PATH
|
||||
remote: ~/work/diaspora-client
|
||||
remote: ~/workspace/diaspora-client
|
||||
specs:
|
||||
diaspora-client (0.0.0)
|
||||
activerecord
|
||||
|
|
|
|||
|
|
@ -5,11 +5,14 @@ require 'uri'
|
|||
|
||||
class AppConfig < Settingslogic
|
||||
|
||||
if Rails.env == 'test'
|
||||
source File.join(Rails.root, "config", "application.yml.example")
|
||||
else
|
||||
source File.join(Rails.root, "config", "application.yml")
|
||||
def self.source_file
|
||||
if Rails.env == 'test'
|
||||
File.join(Rails.root, "config", "application.yml.example")
|
||||
else
|
||||
File.join(Rails.root, "config", "application.yml")
|
||||
end
|
||||
end
|
||||
source source_file
|
||||
namespace Rails.env
|
||||
|
||||
def self.load!
|
||||
|
|
|
|||
|
|
@ -31,11 +31,10 @@ describe ActivityStreams::PhotosController do
|
|||
}
|
||||
JSON
|
||||
end
|
||||
it 'allows token authentication' do
|
||||
bob.reset_authentication_token!
|
||||
get :create, @json.merge!(:auth_token => bob.authentication_token)
|
||||
it 'allows oauth authentication' do
|
||||
token = Factory(:oauth_access_token)
|
||||
get :create, @json.merge!(:oauth_token => token.access_token)
|
||||
response.should be_success
|
||||
warden.should be_authenticated
|
||||
end
|
||||
|
||||
# It is unclear why this test fails. An equivalent cucumber feature passes in features/logs_in_and_out.feature.
|
||||
|
|
|
|||
|
|
@ -118,4 +118,15 @@ Factory.define(:app, :class => OAuth2::Provider.client_class) do |a|
|
|||
|
||||
a.description "The best way to chub on the net."
|
||||
a.icon_url "/images/chubbies48.png"
|
||||
a.permissions_overview "I will use the permissions this way!"
|
||||
a.sequence(:public_key) {|n| OpenSSL::PKey::RSA.new(2048) }
|
||||
end
|
||||
|
||||
Factory.define(:oauth_authorization, :class => OAuth2::Provider.authorization_class) do |a|
|
||||
a.association(:client, :factory => :app)
|
||||
a.association(:resource_owner, :factory => :user)
|
||||
end
|
||||
|
||||
Factory.define(:oauth_access_token, :class => OAuth2::Provider.access_token_class) do |a|
|
||||
a.association(:authorization, :factory => :oauth_authorization)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ require 'spec_helper'
|
|||
require File.join(Rails.root, 'lib/webfinger')
|
||||
|
||||
describe Webfinger do
|
||||
let(:host_with_port) { "#{AppConfig.pod_uri.host}:#{AppConfig.pod_uri.port}" }
|
||||
let(:user1) { alice }
|
||||
let(:user2) { eve }
|
||||
|
||||
|
|
@ -40,19 +41,14 @@ describe Webfinger do
|
|||
|
||||
context 'webfinger query chain processing' do
|
||||
describe '#webfinger_profile_url' do
|
||||
it 'should parse out the webfinger template' do
|
||||
it 'parses out the webfinger template' do
|
||||
finger.send(:webfinger_profile_url, diaspora_xrd).should ==
|
||||
"http://example.org/webfinger?q=foo@tom.joindiaspora.com"
|
||||
"http://#{host_with_port}/webfinger?q=foo@tom.joindiaspora.com"
|
||||
end
|
||||
|
||||
it 'should return nil if not an xrd' do
|
||||
finger.send(:webfinger_profile_url, '<html></html>').should be nil
|
||||
end
|
||||
|
||||
it 'should return the template for xrd' do
|
||||
finger.send(:webfinger_profile_url, diaspora_xrd).should ==
|
||||
'http://example.org/webfinger?q=foo@tom.joindiaspora.com'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#xrd_url' do
|
||||
|
|
@ -75,14 +71,17 @@ describe Webfinger do
|
|||
end
|
||||
end
|
||||
it 'should fetch a diaspora webfinger and make a person for them' do
|
||||
diaspora_xrd.stub!(:body).and_return(diaspora_xrd)
|
||||
hcard_xml.stub!(:body).and_return(hcard_xml)
|
||||
diaspora_finger.stub!(:body).and_return(diaspora_finger)
|
||||
RestClient.stub!(:get).and_return(diaspora_xrd, diaspora_finger, hcard_xml)
|
||||
User.delete_all; Person.delete_all; Profile.delete_all;
|
||||
diaspora_xrd.should_receive(:body).and_return(diaspora_xrd)
|
||||
hcard_xml.should_receive(:body).and_return(hcard_xml)
|
||||
diaspora_finger.should_receive(:body).and_return(diaspora_finger)
|
||||
RestClient.should_receive(:get).exactly(3).times.and_return(diaspora_xrd, diaspora_finger, hcard_xml)
|
||||
#new_person = Factory.build(:person, :diaspora_handle => "tom@tom.joindiaspora.com")
|
||||
# http://tom.joindiaspora.com/.well-known/host-meta
|
||||
f = Webfinger.new("alice@example.org").fetch
|
||||
f = Webfinger.new("alice@#{host_with_port}").fetch
|
||||
|
||||
f.valid?
|
||||
pp f.errors.full_messages
|
||||
f.should be_valid
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -40,13 +40,14 @@ describe AppConfig do
|
|||
|
||||
context "when source config file (i.e. config/application.yml) does not exist" do
|
||||
before do
|
||||
application_yml = File.join(Rails.root, "config", "application.yml")
|
||||
application_yml = File.join(Rails.root, "config", "application.yml.example")
|
||||
@app_yml = File.join(Rails.root, "config", "app.yml")
|
||||
@app_config_yml = File.join(Rails.root, "config", "app_config.yml")
|
||||
File.should_receive(:exists?).with(application_yml).at_least(:once).and_return(false)
|
||||
end
|
||||
after do
|
||||
File.instance_eval { alias :exists? :obfuscated_by_rspec_mocks__exists? } # unmock exists? so that the AppConfig.reload! in the top-level after block can run
|
||||
AppConfig.source(AppConfig.source_file)
|
||||
end
|
||||
context "and there are no old-style config files around" do
|
||||
it "prints an error message with instructions for setting up application.yml and exits" do
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ describe Profile do
|
|||
let(:profile) { Factory.build(:profile) }
|
||||
|
||||
it 'accepts form data' do
|
||||
profile.birthday.should == nil
|
||||
profile.birthday = nil
|
||||
profile.date = { 'year' => '2000', 'month' => '01', 'day' => '01' }
|
||||
profile.birthday.year.should == 2000
|
||||
profile.birthday.month.should == 1
|
||||
|
|
@ -166,8 +166,8 @@ describe Profile do
|
|||
profile.birthday.day.should == 1
|
||||
end
|
||||
|
||||
it 'accepts blank initial vallues' do
|
||||
profile.birthday.should == nil
|
||||
it 'does not accept blank initial values' do
|
||||
profile.birthday = nil
|
||||
profile.date = { 'year' => '2001', 'month' => '', 'day' => ''}
|
||||
profile.birthday.should == nil
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue