fixed every spec but the activity stream photos controller spec

This commit is contained in:
Ilyaaaaaaaaaaaaa Zhitomirskiy 2011-06-23 15:17:12 -07:00
parent 74a7c3ab00
commit d46f3a8d1f
8 changed files with 39 additions and 26 deletions

View file

@ -97,5 +97,5 @@ group :test do
gem 'fuubar' gem 'fuubar'
gem 'diaspora-client', #:git => 'git@github.com:diaspora/diaspora-client.git' gem 'diaspora-client', #:git => 'git@github.com:diaspora/diaspora-client.git'
:path => "~/work/diaspora-client" :path => "~/workspace/diaspora-client"
end end

View file

@ -45,7 +45,7 @@ GIT
json (>= 1.2.4) json (>= 1.2.4)
PATH PATH
remote: ~/work/diaspora-client remote: ~/workspace/diaspora-client
specs: specs:
diaspora-client (0.0.0) diaspora-client (0.0.0)
activerecord activerecord

View file

@ -5,11 +5,14 @@ require 'uri'
class AppConfig < Settingslogic class AppConfig < Settingslogic
if Rails.env == 'test' def self.source_file
source File.join(Rails.root, "config", "application.yml.example") if Rails.env == 'test'
else File.join(Rails.root, "config", "application.yml.example")
source File.join(Rails.root, "config", "application.yml") else
File.join(Rails.root, "config", "application.yml")
end
end end
source source_file
namespace Rails.env namespace Rails.env
def self.load! def self.load!

View file

@ -31,11 +31,10 @@ describe ActivityStreams::PhotosController do
} }
JSON JSON
end end
it 'allows token authentication' do it 'allows oauth authentication' do
bob.reset_authentication_token! token = Factory(:oauth_access_token)
get :create, @json.merge!(:auth_token => bob.authentication_token) get :create, @json.merge!(:oauth_token => token.access_token)
response.should be_success response.should be_success
warden.should be_authenticated
end end
# It is unclear why this test fails. An equivalent cucumber feature passes in features/logs_in_and_out.feature. # It is unclear why this test fails. An equivalent cucumber feature passes in features/logs_in_and_out.feature.

View file

@ -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.description "The best way to chub on the net."
a.icon_url "/images/chubbies48.png" 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 end

View file

@ -7,6 +7,7 @@ require 'spec_helper'
require File.join(Rails.root, 'lib/webfinger') require File.join(Rails.root, 'lib/webfinger')
describe Webfinger do describe Webfinger do
let(:host_with_port) { "#{AppConfig.pod_uri.host}:#{AppConfig.pod_uri.port}" }
let(:user1) { alice } let(:user1) { alice }
let(:user2) { eve } let(:user2) { eve }
@ -40,19 +41,14 @@ describe Webfinger do
context 'webfinger query chain processing' do context 'webfinger query chain processing' do
describe '#webfinger_profile_url' 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 == 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 end
it 'should return nil if not an xrd' do it 'should return nil if not an xrd' do
finger.send(:webfinger_profile_url, '<html></html>').should be nil finger.send(:webfinger_profile_url, '<html></html>').should be nil
end 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 end
describe '#xrd_url' do describe '#xrd_url' do
@ -75,14 +71,17 @@ describe Webfinger do
end end
end end
it 'should fetch a diaspora webfinger and make a person for them' do it 'should fetch a diaspora webfinger and make a person for them' do
diaspora_xrd.stub!(:body).and_return(diaspora_xrd) User.delete_all; Person.delete_all; Profile.delete_all;
hcard_xml.stub!(:body).and_return(hcard_xml) diaspora_xrd.should_receive(:body).and_return(diaspora_xrd)
diaspora_finger.stub!(:body).and_return(diaspora_finger) hcard_xml.should_receive(:body).and_return(hcard_xml)
RestClient.stub!(:get).and_return(diaspora_xrd, diaspora_finger, 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") #new_person = Factory.build(:person, :diaspora_handle => "tom@tom.joindiaspora.com")
# http://tom.joindiaspora.com/.well-known/host-meta # 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 f.should be_valid
end end

View file

@ -40,13 +40,14 @@ describe AppConfig do
context "when source config file (i.e. config/application.yml) does not exist" do context "when source config file (i.e. config/application.yml) does not exist" do
before 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_yml = File.join(Rails.root, "config", "app.yml")
@app_config_yml = File.join(Rails.root, "config", "app_config.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) File.should_receive(:exists?).with(application_yml).at_least(:once).and_return(false)
end end
after do 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 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 end
context "and there are no old-style config files around" do 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 it "prints an error message with instructions for setting up application.yml and exits" do

View file

@ -145,7 +145,7 @@ describe Profile do
let(:profile) { Factory.build(:profile) } let(:profile) { Factory.build(:profile) }
it 'accepts form data' do it 'accepts form data' do
profile.birthday.should == nil profile.birthday = nil
profile.date = { 'year' => '2000', 'month' => '01', 'day' => '01' } profile.date = { 'year' => '2000', 'month' => '01', 'day' => '01' }
profile.birthday.year.should == 2000 profile.birthday.year.should == 2000
profile.birthday.month.should == 1 profile.birthday.month.should == 1
@ -166,8 +166,8 @@ describe Profile do
profile.birthday.day.should == 1 profile.birthday.day.should == 1
end end
it 'accepts blank initial vallues' do it 'does not accept blank initial values' do
profile.birthday.should == nil profile.birthday = nil
profile.date = { 'year' => '2001', 'month' => '', 'day' => ''} profile.date = { 'year' => '2001', 'month' => '', 'day' => ''}
profile.birthday.should == nil profile.birthday.should == nil
end end