Put in a lot of non nullable fields, edit the specs to match, drop a couple superfluous columns
This commit is contained in:
parent
a037575ebc
commit
b67aca0ffc
29 changed files with 294 additions and 134 deletions
|
|
@ -20,7 +20,6 @@ class ServicesController < ApplicationController
|
|||
service = "Services::#{provider.camelize}".constantize.new(:nickname => user['nickname'],
|
||||
:access_token => toke,
|
||||
:access_secret => secret,
|
||||
:provider => provider,
|
||||
:uid => auth['uid'])
|
||||
current_user.services << service
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ class AspectMembership < ActiveRecord::Base
|
|||
|
||||
belongs_to :aspect
|
||||
belongs_to :contact
|
||||
validates_presence_of :contact
|
||||
validates_presence_of :aspect
|
||||
has_one :user, :through => :contact
|
||||
has_one :person, :through => :contact
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
class Services::Facebook < Service
|
||||
MAX_CHARACTERS = 420
|
||||
|
||||
def provider
|
||||
"facebook"
|
||||
end
|
||||
|
||||
def post(post, url='')
|
||||
Rails.logger.debug("event=post_to_service type=facebook sender_id=#{self.user_id}")
|
||||
message = public_message(post, url)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
class Services::Twitter < Service
|
||||
MAX_CHARACTERS = 140
|
||||
|
||||
def provider
|
||||
"twitter"
|
||||
end
|
||||
|
||||
def post(post, url='')
|
||||
Rails.logger.debug("event=post_to_service type=twitter sender_id=#{self.user_id}")
|
||||
message = public_message(post, url)
|
||||
|
|
|
|||
|
|
@ -44,11 +44,12 @@ class Statistic < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.generate(time=Time.now, post_range=(0..50))
|
||||
stat = Statistic.new(:type => "posts_per_day", :time => time)
|
||||
stat = Statistic.new(:time => time)
|
||||
stat.save
|
||||
post_range.each do |n|
|
||||
data_point = DataPoint.users_with_posts_on_day(time,n)
|
||||
data_point.statistic = stat
|
||||
data_point.save
|
||||
stat.data_points << data_point
|
||||
end
|
||||
stat.compute_average
|
||||
stat.save
|
||||
|
|
|
|||
10
db/migrate/20110127000931_drop_extra_columns.rb
Normal file
10
db/migrate/20110127000931_drop_extra_columns.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
class DropExtraColumns < ActiveRecord::Migration
|
||||
def self.up
|
||||
remove_column :services, :provider
|
||||
remove_column :statistics, :type
|
||||
end
|
||||
|
||||
def self.down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
37
db/migrate/20110127000953_make_fields_not_null.rb
Normal file
37
db/migrate/20110127000953_make_fields_not_null.rb
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
class MakeFieldsNotNull < ActiveRecord::Migration
|
||||
def self.non_nullable_fields
|
||||
fields = {
|
||||
:aspect_memberships => [:aspect_id, :contact_id],
|
||||
:aspects => [:user_id, :name],
|
||||
:comments => [:text, :post_id, :person_id, :guid],
|
||||
:contacts => [:user_id, :person_id, :pending],
|
||||
:data_points => [:key, :value, :statistic_id],
|
||||
:invitations => [:recipient_id, :sender_id],
|
||||
:notifications => [:recipient_id, :actor_id, :action, :unread],
|
||||
:people => [:guid, :url, :diaspora_handle, :serialized_public_key],
|
||||
:post_visibilities => [:aspect_id, :post_id],
|
||||
:posts => [:person_id, :public, :guid, :pending, :type],
|
||||
:profiles => [:person_id, :searchable],
|
||||
:requests => [:sender_id, :recipient_id],
|
||||
:services => [:type, :user_id],
|
||||
:statistics => [:time],
|
||||
:users => [:getting_started, :invites, :disable_mail]
|
||||
}
|
||||
end
|
||||
|
||||
def self.up
|
||||
non_nullable_fields.each_pair do |table, columns|
|
||||
columns.each do |column|
|
||||
change_column_null(table, column, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
non_nullable_fields.each_pair do |table, columns|
|
||||
columns.each do |column|
|
||||
change_column_null(table, column, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
86
db/schema.rb
86
db/schema.rb
|
|
@ -10,11 +10,11 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20110126232040) do
|
||||
ActiveRecord::Schema.define(:version => 20110127000953) do
|
||||
|
||||
create_table "aspect_memberships", :force => true do |t|
|
||||
t.integer "aspect_id"
|
||||
t.integer "contact_id"
|
||||
t.integer "aspect_id", :null => false
|
||||
t.integer "contact_id", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
|
@ -24,8 +24,8 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
add_index "aspect_memberships", ["contact_id"], :name => "index_aspect_memberships_on_contact_id"
|
||||
|
||||
create_table "aspects", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "user_id"
|
||||
t.string "name", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "mongo_id"
|
||||
|
|
@ -36,10 +36,10 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
add_index "aspects", ["user_id"], :name => "index_aspects_on_user_id"
|
||||
|
||||
create_table "comments", :force => true do |t|
|
||||
t.text "text"
|
||||
t.integer "post_id"
|
||||
t.integer "person_id"
|
||||
t.string "guid"
|
||||
t.text "text", :null => false
|
||||
t.integer "post_id", :null => false
|
||||
t.integer "person_id", :null => false
|
||||
t.string "guid", :null => false
|
||||
t.text "creator_signature"
|
||||
t.text "post_creator_signature"
|
||||
t.text "youtube_titles"
|
||||
|
|
@ -54,9 +54,9 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
add_index "comments", ["post_id"], :name => "index_comments_on_post_id"
|
||||
|
||||
create_table "contacts", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "person_id"
|
||||
t.boolean "pending", :default => true
|
||||
t.integer "user_id", :null => false
|
||||
t.integer "person_id", :null => false
|
||||
t.boolean "pending", :default => true, :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "mongo_id"
|
||||
|
|
@ -68,9 +68,9 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
add_index "contacts", ["user_id", "person_id"], :name => "index_contacts_on_user_id_and_person_id", :unique => true
|
||||
|
||||
create_table "data_points", :force => true do |t|
|
||||
t.string "key"
|
||||
t.integer "value"
|
||||
t.integer "statistic_id"
|
||||
t.string "key", :null => false
|
||||
t.integer "value", :null => false
|
||||
t.integer "statistic_id", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
|
@ -79,8 +79,8 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
|
||||
create_table "invitations", :force => true do |t|
|
||||
t.text "message"
|
||||
t.integer "sender_id"
|
||||
t.integer "recipient_id"
|
||||
t.integer "sender_id", :null => false
|
||||
t.integer "recipient_id", :null => false
|
||||
t.integer "aspect_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
|
|
@ -294,10 +294,10 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
create_table "notifications", :force => true do |t|
|
||||
t.string "target_type"
|
||||
t.integer "target_id"
|
||||
t.integer "recipient_id"
|
||||
t.integer "actor_id"
|
||||
t.string "action"
|
||||
t.boolean "unread", :default => true
|
||||
t.integer "recipient_id", :null => false
|
||||
t.integer "actor_id", :null => false
|
||||
t.string "action", :null => false
|
||||
t.boolean "unread", :default => true, :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "mongo_id"
|
||||
|
|
@ -309,10 +309,10 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
add_index "notifications", ["target_type", "target_id"], :name => "index_notifications_on_target_type_and_target_id"
|
||||
|
||||
create_table "people", :force => true do |t|
|
||||
t.string "guid"
|
||||
t.text "url"
|
||||
t.string "diaspora_handle"
|
||||
t.text "serialized_public_key"
|
||||
t.string "guid", :null => false
|
||||
t.text "url", :null => false
|
||||
t.string "diaspora_handle", :null => false
|
||||
t.text "serialized_public_key", :null => false
|
||||
t.integer "owner_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
|
|
@ -325,8 +325,8 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
add_index "people", ["owner_id"], :name => "index_people_on_owner_id", :unique => true
|
||||
|
||||
create_table "post_visibilities", :force => true do |t|
|
||||
t.integer "aspect_id"
|
||||
t.integer "post_id"
|
||||
t.integer "aspect_id", :null => false
|
||||
t.integer "post_id", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
|
@ -336,12 +336,12 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
add_index "post_visibilities", ["post_id"], :name => "index_post_visibilities_on_post_id"
|
||||
|
||||
create_table "posts", :force => true do |t|
|
||||
t.integer "person_id"
|
||||
t.boolean "public", :default => false
|
||||
t.integer "person_id", :null => false
|
||||
t.boolean "public", :default => false, :null => false
|
||||
t.string "diaspora_handle"
|
||||
t.string "guid"
|
||||
t.boolean "pending", :default => false
|
||||
t.string "type"
|
||||
t.string "guid", :null => false
|
||||
t.boolean "pending", :default => false, :null => false
|
||||
t.string "type", :null => false
|
||||
t.text "message"
|
||||
t.integer "status_message_id"
|
||||
t.text "caption"
|
||||
|
|
@ -373,8 +373,8 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
t.date "birthday"
|
||||
t.string "gender"
|
||||
t.text "bio"
|
||||
t.boolean "searchable", :default => true
|
||||
t.integer "person_id"
|
||||
t.boolean "searchable", :default => true, :null => false
|
||||
t.integer "person_id", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "mongo_id"
|
||||
|
|
@ -387,8 +387,8 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
add_index "profiles", ["person_id"], :name => "index_profiles_on_person_id", :unique => true
|
||||
|
||||
create_table "requests", :force => true do |t|
|
||||
t.integer "sender_id"
|
||||
t.integer "recipient_id"
|
||||
t.integer "sender_id", :null => false
|
||||
t.integer "recipient_id", :null => false
|
||||
t.integer "aspect_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
|
|
@ -401,9 +401,8 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
add_index "requests", ["sender_id"], :name => "index_requests_on_sender_id"
|
||||
|
||||
create_table "services", :force => true do |t|
|
||||
t.string "type"
|
||||
t.integer "user_id"
|
||||
t.string "provider"
|
||||
t.string "type", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
t.string "uid"
|
||||
t.string "access_token"
|
||||
t.string "access_secret"
|
||||
|
|
@ -419,8 +418,7 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
|
||||
create_table "statistics", :force => true do |t|
|
||||
t.integer "average"
|
||||
t.string "type"
|
||||
t.datetime "time"
|
||||
t.datetime "time", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
|
@ -428,9 +426,9 @@ ActiveRecord::Schema.define(:version => 20110126232040) do
|
|||
create_table "users", :force => true do |t|
|
||||
t.string "username"
|
||||
t.text "serialized_private_key"
|
||||
t.integer "invites", :default => 0
|
||||
t.boolean "getting_started", :default => true
|
||||
t.boolean "disable_mail", :default => false
|
||||
t.integer "invites", :default => 0, :null => false
|
||||
t.boolean "getting_started", :default => true, :null => false
|
||||
t.boolean "disable_mail", :default => false, :null => false
|
||||
t.string "language"
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
|
|
|
|||
|
|
@ -216,7 +216,6 @@ module DataConversion
|
|||
SELECT mongo_services.id,
|
||||
mongo_services.type,
|
||||
users.id,
|
||||
mongo_services.provider,
|
||||
mongo_services.uid,
|
||||
mongo_services.access_token,
|
||||
mongo_services.access_secret,
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ class Webfinger
|
|||
Rails.logger.info("event=webfinger status=failure route=remote target=#{@account}")
|
||||
raise WebfingerFailedError.new(@account)
|
||||
end
|
||||
rescue
|
||||
Rails.logger.info("event=receive status=abort recipient=#{@account} sender=#{salmon.author_email} reason='#{e.message}'")
|
||||
rescue Exception => e
|
||||
Rails.logger.info("event=receive status=abort recipient=#{@account} reason='#{e.message}'")
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ describe NotificationsController do
|
|||
|
||||
describe '#update' do
|
||||
it 'marks a notification as read' do
|
||||
note = Notification.create(:recipient_id => @user.id)
|
||||
note = Factory(:notification, :recipient => @user)
|
||||
put :update, :id => note.id
|
||||
Notification.first.unread.should == false
|
||||
end
|
||||
|
|
@ -23,8 +23,8 @@ describe NotificationsController do
|
|||
it 'only lets you read your own notifications' do
|
||||
user2 = bob
|
||||
|
||||
Notification.create(:recipient_id => @user.id)
|
||||
note = Notification.create(:recipient_id => user2.id)
|
||||
Factory(:notification, :recipient => @user)
|
||||
note = Factory(:notification, :recipient => user2)
|
||||
|
||||
put :update, :id => note.id
|
||||
|
||||
|
|
@ -35,8 +35,8 @@ describe NotificationsController do
|
|||
describe "#read_all" do
|
||||
it 'marks all notifications as read' do
|
||||
request.env["HTTP_REFERER"] = "I wish I were spelled right"
|
||||
Notification.create(:recipient_id => @user.id)
|
||||
Notification.create(:recipient_id => @user.id)
|
||||
Factory(:notification, :recipient => @user)
|
||||
Factory(:notification, :recipient => @user)
|
||||
|
||||
Notification.where(:unread => true).count.should == 2
|
||||
get :read_all
|
||||
|
|
@ -47,7 +47,7 @@ describe NotificationsController do
|
|||
describe '#index' do
|
||||
it 'paginates the notifications' do
|
||||
35.times do
|
||||
Notification.create(:recipient_id => @user.id)
|
||||
Factory(:notification, :recipient => @user)
|
||||
end
|
||||
|
||||
get :index
|
||||
|
|
|
|||
|
|
@ -78,16 +78,16 @@ describe PeopleController do
|
|||
describe '#index (search)' do
|
||||
before do
|
||||
@eugene = Factory.create(:person,
|
||||
:profile => Factory(:profile, :first_name => "Eugene",
|
||||
:profile => Factory.build(:profile, :first_name => "Eugene",
|
||||
:last_name => "w"))
|
||||
@korth = Factory.create(:person,
|
||||
:profile => Factory(:profile, :first_name => "Evan",
|
||||
:profile => Factory.build(:profile, :first_name => "Evan",
|
||||
:last_name => "Korth"))
|
||||
end
|
||||
|
||||
it "assigns people" do
|
||||
eugene2 = Factory.create(:person,
|
||||
:profile => Factory(:profile, :first_name => "Eugene",
|
||||
:profile => Factory.build(:profile, :first_name => "Eugene",
|
||||
:last_name => "w"))
|
||||
get :index, :q => "Eug"
|
||||
assigns[:people].should =~ [@eugene, eugene2]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ require 'spec_helper'
|
|||
|
||||
describe PublicsController do
|
||||
render_views
|
||||
|
||||
let(:fixture_path) { File.join(Rails.root, 'spec', 'fixtures')}
|
||||
before do
|
||||
@user = alice
|
||||
@person = Factory(:person)
|
||||
|
|
@ -17,6 +17,7 @@ describe PublicsController do
|
|||
get :host_meta
|
||||
response.should be_success
|
||||
response.body.should =~ /webfinger/
|
||||
save_fixture(response.body, "host-meta", fixture_path)
|
||||
end
|
||||
end
|
||||
describe '#receive' do
|
||||
|
|
@ -60,6 +61,7 @@ describe PublicsController do
|
|||
it "succeeds" do
|
||||
post :hcard, "guid" => @user.person.guid.to_s
|
||||
response.should be_success
|
||||
save_fixture(response.body, "hcard", fixture_path)
|
||||
end
|
||||
|
||||
it 'sets the person' do
|
||||
|
|
@ -78,6 +80,7 @@ describe PublicsController do
|
|||
it "succeeds when the person and user exist locally" do
|
||||
post :webfinger, 'q' => @user.person.diaspora_handle
|
||||
response.should be_success
|
||||
save_fixture(response.body, "webfinger", fixture_path)
|
||||
end
|
||||
|
||||
it "404s when the person exists remotely because it is local only" do
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ describe ServicesController do
|
|||
describe '#index' do
|
||||
it 'displays all connected serivices for a user' do
|
||||
4.times do
|
||||
@user.services << Factory(:service)
|
||||
Factory(:service, :user => @user)
|
||||
end
|
||||
|
||||
get :index
|
||||
|
|
@ -72,8 +72,7 @@ describe ServicesController do
|
|||
|
||||
describe '#destroy' do
|
||||
before do
|
||||
@service1 = Factory.create(:service)
|
||||
@user.services << @service1
|
||||
@service1 = Factory.create(:service, :user => @user)
|
||||
end
|
||||
it 'destroys a service selected by id' do
|
||||
lambda{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ describe StatisticsController do
|
|||
end
|
||||
|
||||
before do
|
||||
faker_stat = Statistic.generate
|
||||
@stat = Statistic.new
|
||||
5.times do |n|
|
||||
bob.post(:status_message, :message => 'hi', :to => bob.aspects.first)
|
||||
|
|
@ -16,6 +17,7 @@ describe StatisticsController do
|
|||
(0..10).each do |n|
|
||||
@stat.data_points << DataPoint.users_with_posts_on_day(Time.now, n)
|
||||
end
|
||||
@stat.time = faker_stat.time
|
||||
@stat.save
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,13 @@ end
|
|||
Factory.define :person do |p|
|
||||
p.sequence(:diaspora_handle) { |n| "bob-person-#{n}#{r_str}@aol.com" }
|
||||
p.sequence(:url) { |n| "http://google-#{n}#{r_str}.com/" }
|
||||
p.association :profile
|
||||
p.serialized_public_key OpenSSL::PKey::RSA.generate(1024).public_key.export
|
||||
p.after_build do |person|
|
||||
person.profile ||= Factory.build(:profile, :person => person)
|
||||
end
|
||||
p.after_create do |person|
|
||||
person.profile.save
|
||||
end
|
||||
end
|
||||
|
||||
Factory.define :searchable_person, :parent => :person do |p|
|
||||
|
|
@ -37,19 +42,24 @@ Factory.define :user do |u|
|
|||
u.password_confirmation { |u| u.password }
|
||||
u.serialized_private_key OpenSSL::PKey::RSA.generate(1024).export
|
||||
u.after_build do |user|
|
||||
user.person = Factory.build(:person, :profile => Factory.create(:profile),
|
||||
user.person = Factory.build(:person, :profile => Factory.build(:profile),
|
||||
:owner_id => user.id,
|
||||
:serialized_public_key => user.encryption_key.public_key.export,
|
||||
:diaspora_handle => "#{user.username}@#{AppConfig[:pod_url].gsub(/(https?:|www\.)\/\//, '').chop!}")
|
||||
end
|
||||
u.after_create do |user|
|
||||
user.person.save
|
||||
user.person.profile.save
|
||||
end
|
||||
end
|
||||
|
||||
Factory.define :user_with_aspect, :parent => :user do |u|
|
||||
u.after_build { |user| user.aspects << Factory(:aspect) }
|
||||
u.after_create { |user| Factory(:aspect, :user => user) }
|
||||
end
|
||||
|
||||
Factory.define :aspect do |aspect|
|
||||
aspect.name "generic"
|
||||
aspect.association :user
|
||||
end
|
||||
|
||||
Factory.define :status_message do |m|
|
||||
|
|
@ -66,18 +76,25 @@ end
|
|||
|
||||
Factory.define :service do |service|
|
||||
service.nickname "sirrobertking"
|
||||
service.provider "twitter"
|
||||
service.type "Services::Twitter"
|
||||
|
||||
service.sequence(:uid) { |token| "00000#{token}" }
|
||||
service.sequence(:access_token) { |token| "12345#{token}" }
|
||||
service.sequence(:access_secret) { |token| "98765#{token}" }
|
||||
service.after_build do |s|
|
||||
s.type = "Services::#{s.provider.camelize}"
|
||||
end
|
||||
end
|
||||
|
||||
Factory.define(:comment) do |comment|
|
||||
comment.sequence(:text) {|n| "#{n} cats"}
|
||||
comment.association(:person)
|
||||
comment.association :post, :factory => :status_message
|
||||
end
|
||||
|
||||
Factory.define(:notification) do |n|
|
||||
n.association :recipient, :factory => :user
|
||||
n.association :actor, :factory => :person
|
||||
n.association :target, :factory => :comment
|
||||
n.after_build do |note|
|
||||
note.action = note.target.notification_type(note.recipient, note.actor)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
62
spec/fixtures/hcard.fixture.html
vendored
Normal file
62
spec/fixtures/hcard.fixture.html
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<div id='content'>
|
||||
<h1>Robert12074e3 Grimm1009eba</h1>
|
||||
<div id='content_inner'>
|
||||
<div class='entity_profile vcard author' id='i'>
|
||||
<h2>User profile</h2>
|
||||
<dl class='entity_nickname'>
|
||||
<dt>Nickname</dt>
|
||||
<dd>
|
||||
<a class='nickname url uid' href='http://google-1266a2d.com/' rel='me'>Robert12074e3 Grimm1009eba</a>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class='entity_given_name'>
|
||||
<dt>First name</dt>
|
||||
<dd>
|
||||
<span class='given_name'>Robert12074e3</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class='entity_family_name'>
|
||||
<dt>Family name</dt>
|
||||
<dd>
|
||||
<span class='family_name'>Grimm1009eba</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class='entity_fn'>
|
||||
<dt>Full name</dt>
|
||||
<dd>
|
||||
<span class='fn'>Robert12074e3 Grimm1009eba</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class='entity_url'>
|
||||
<dt>URL</dt>
|
||||
<dd>
|
||||
<a class='url' href='http://google-1266a2d.com/' id='pod_location' rel='me'>http://google-1266a2d.com/</a>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class='entity_photo'>
|
||||
<dt>Photo</dt>
|
||||
<dd>
|
||||
<img class='photo avatar' height='300px' src='/images/user/default.png' width='300px'>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class='entity_photo_medium'>
|
||||
<dt>Photo</dt>
|
||||
<dd>
|
||||
<img class='photo avatar' height='100px' src='/images/user/default.png' width='100px'>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class='entity_photo_small'>
|
||||
<dt>Photo</dt>
|
||||
<dd>
|
||||
<img class='photo avatar' height='50px' src='/images/user/default.png' width='50px'>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class='entity_searchable'>
|
||||
<dt>Searchable</dt>
|
||||
<dd>
|
||||
<span class='searchable'>true</span>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
9
spec/fixtures/host-meta.fixture.html
vendored
Normal file
9
spec/fixtures/host-meta.fixture.html
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
|
||||
xmlns:hm='http://host-meta.net/xrd/1.0'>
|
||||
<hm:Host>example.org</hm:Host>
|
||||
<Link rel='lrdd'
|
||||
template='http://example.org/webfinger?q={uri}'>
|
||||
<Title>Resource Descriptor</Title>
|
||||
</Link>
|
||||
</XRD>
|
||||
18
spec/fixtures/webfinger.fixture.html
vendored
Normal file
18
spec/fixtures/webfinger.fixture.html
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Subject>acct:alice@example.org</Subject>
|
||||
<Alias>"http://google-1266a2d.com/"</Alias>
|
||||
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="http://google-1266a2d.com/hcard/users/677146a674670091"/>
|
||||
<Link rel="http://joindiaspora.com/seed_location" type = 'text/html' href="http://google-1266a2d.com/"/>
|
||||
<Link rel="http://joindiaspora.com/guid" type = 'text/html' href="677146a674670091"/>
|
||||
|
||||
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="http://google-1266a2d.com/public/alice.atom"/>
|
||||
|
||||
<Link rel="diaspora-public-key" type = 'RSA' href="LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1JR0pBb0dCQU0xWWlZ
|
||||
UDdkMzVqY0FwcUtTNU1BeWFPQkxjOUpNQkxzYkljeVFhNWU4WktXcGIxUDkz
|
||||
RnB4b1gKVmxuZ0t0L2dzMEZwUHp2eCtJdTFldWR0SGEwUUZxV0dHMmN6SExE
|
||||
cHJWajRNNjd2b1hTQVhrc1duUHUzOUs3RgpvaXFENnZGOXZpdkZ3aXJ6ZG9M
|
||||
YktmU2ovdjNDb0FEZWwzeXlVYksvL0FCNyt5MmRSYTAxQWdNQkFBRT0KLS0t
|
||||
LS1FTkQgUlNBIFBVQkxJQyBLRVktLS0tLQo=
|
||||
"/>
|
||||
</XRD>
|
||||
|
|
@ -184,16 +184,17 @@ describe 'a user receives a post' do
|
|||
remote_person = @user3.person.dup
|
||||
@user3.person.delete
|
||||
@user3.delete
|
||||
Person.where(:id => remote_person.id).delete_all
|
||||
Profile.where(:person_id => remote_person.id).delete_all
|
||||
remote_person.id = nil
|
||||
|
||||
#stubs async webfinger
|
||||
Person.should_receive(:by_account_identifier).twice.and_return{ |handle|
|
||||
if handle == @user1.person.diaspora_handle
|
||||
@user1.person.save
|
||||
@user1.person
|
||||
else
|
||||
remote_person.profile = Factory(:profile)
|
||||
remote_person.save!
|
||||
remote_person.save(:validate => false)
|
||||
remote_person.profile = Factory(:profile, :person => remote_person)
|
||||
remote_person
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ describe DataConversion::ImportToMysql do
|
|||
service = Service.where(:mongo_id => "4d2b6ec4cc8cb43cc200003e").first
|
||||
service.type_before_type_cast.should == "Services::Facebook"
|
||||
service.user_mongo_id.should == "4d2b6eb7cc8cb43cc2000014"
|
||||
service.provider.should be_nil
|
||||
service.uid.should be_nil
|
||||
service.access_token.should == "yeah"
|
||||
service.access_secret.should be_nil
|
||||
|
|
@ -739,7 +738,6 @@ describe DataConversion::ImportToMysql do
|
|||
service.mongo_id.should == "4d2b6ec4cc8cb43cc200003e"
|
||||
service.type_before_type_cast.should == "Services::Facebook"
|
||||
service.user_mongo_id.should == "4d2b6eb7cc8cb43cc2000014"
|
||||
service.provider.should be_nil
|
||||
service.uid.should be_nil
|
||||
service.access_token.should == "yeah"
|
||||
service.access_secret.should be_nil
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ describe Diaspora::Parser do
|
|||
#Build xml for profile, clear profile
|
||||
xml = person.profile.to_diaspora_xml
|
||||
reloaded_person = Person.find(id)
|
||||
reloaded_person.profile = nil
|
||||
reloaded_person.profile.delete
|
||||
reloaded_person.save(:validate => false)
|
||||
|
||||
#Make sure profile is cleared
|
||||
|
|
|
|||
|
|
@ -16,16 +16,15 @@ describe Webfinger do
|
|||
|
||||
let(:good_request) { FakeHttpRequest.new(:success)}
|
||||
|
||||
let(:diaspora_xrd) {File.open(File.join(Rails.root, 'spec/fixtures/host_xrd')).read}
|
||||
let(:diaspora_finger) {File.open(File.join(Rails.root, 'spec/fixtures/finger_xrd')).read}
|
||||
let(:hcard_xml) {File.open(File.join(Rails.root, 'spec/fixtures/hcard_response')).read}
|
||||
let(:diaspora_xrd) {File.open(File.join(Rails.root, 'spec/fixtures/host-meta.fixture.html')).read}
|
||||
let(:diaspora_finger) {File.open(File.join(Rails.root, 'spec/fixtures/webfinger.fixture.html')).read}
|
||||
let(:hcard_xml) {File.open(File.join(Rails.root, 'spec/fixtures/hcard.fixture.html')).read}
|
||||
|
||||
|
||||
let(:non_diaspora_xrd) {File.open(File.join(Rails.root, 'spec/fixtures/nonseed_finger_xrd')).read}
|
||||
let(:non_diaspora_hcard) {File.open(File.join(Rails.root, 'spec/fixtures/evan_hcard')).read}
|
||||
|
||||
context 'setup' do
|
||||
let(:action){ Proc.new{|person| person.inspect }}
|
||||
|
||||
describe '#intialize' do
|
||||
it 'sets account ' do
|
||||
|
|
@ -42,7 +41,8 @@ describe Webfinger do
|
|||
context 'webfinger query chain processing' do
|
||||
describe '#webfinger_profile_url' do
|
||||
it 'should parse out the webfinger template' do
|
||||
finger.send(:webfinger_profile_url, diaspora_xrd).should == "http://tom.joindiaspora.com/webfinger/?q=#{account}"
|
||||
finger.send(:webfinger_profile_url, diaspora_xrd).should ==
|
||||
"http://example.org/webfinger?q=foo@tom.joindiaspora.com"
|
||||
end
|
||||
|
||||
it 'should return nil if not an xrd' do
|
||||
|
|
@ -50,7 +50,8 @@ describe Webfinger do
|
|||
end
|
||||
|
||||
it 'should return the template for xrd' do
|
||||
finger.send(:webfinger_profile_url, diaspora_xrd).should == 'http://tom.joindiaspora.com/webfinger/?q=foo@tom.joindiaspora.com'
|
||||
finger.send(:webfinger_profile_url, diaspora_xrd).should ==
|
||||
'http://example.org/webfinger?q=foo@tom.joindiaspora.com'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -80,7 +81,7 @@ describe Webfinger do
|
|||
RestClient.stub!(:get).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("tom@tom.joindiaspora.com").fetch
|
||||
f = Webfinger.new("alice@example.org").fetch
|
||||
|
||||
f.should be_valid
|
||||
end
|
||||
|
|
@ -96,4 +97,4 @@ describe Webfinger do
|
|||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ describe Notification do
|
|||
@aspect = @user.aspects.create(:name => "dudes")
|
||||
@opts = {:target_id => @sm.id,
|
||||
:target_type => @sm.class.name,
|
||||
:action => "comment_on_post",
|
||||
:actor_id => @person.id,
|
||||
:recipient_id => @user.id}
|
||||
@note = Notification.new(@opts)
|
||||
|
|
@ -60,7 +61,8 @@ describe Notification do
|
|||
|
||||
it 'sockets to the recipient' do
|
||||
opts = {:target_id => @request.id,
|
||||
:target_type => @request.notification_type(@user, @person),
|
||||
:target_type => "Request",
|
||||
:action => @request.notification_type(@user, @person),
|
||||
:actor_id => @person.id,
|
||||
:recipient_id => @user.id}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ describe Person do
|
|||
end
|
||||
|
||||
it "deletes all notifications from a person's actions" do
|
||||
note = Notification.create(:actor_id => @deleter.id, :recipient_id => @user.id)
|
||||
note = Factory(:notification, :actor => @deleter, :recipient => @user)
|
||||
@deleter.destroy
|
||||
Notification.where(:id => note.id).first.should be_nil
|
||||
end
|
||||
|
|
@ -220,7 +220,7 @@ describe Person do
|
|||
end
|
||||
|
||||
it 'only displays searchable people' do
|
||||
invisible_person = Factory(:person, :profile => Factory(:profile,:searchable => false, :first_name => "johnson"))
|
||||
invisible_person = Factory(:person, :profile => Factory.build(:profile,:searchable => false, :first_name => "johnson"))
|
||||
Person.search("johnson", @user).should_not include invisible_person
|
||||
Person.search("", @user).should_not include invisible_person
|
||||
end
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ describe Profile do
|
|||
end
|
||||
|
||||
describe 'date=' do
|
||||
let(:profile) { Factory(:profile) }
|
||||
let(:profile) { Factory.build(:profile) }
|
||||
|
||||
it 'accepts form data' do
|
||||
profile.birthday.should == nil
|
||||
|
|
|
|||
|
|
@ -112,9 +112,7 @@ describe Diaspora::UserModules::Connecting do
|
|||
end
|
||||
|
||||
it "should mark the corresponding notification as 'read'" do
|
||||
notification = Notification.create(:target_id => @received_request.id,
|
||||
:target_type => 'new_request',
|
||||
:unread => true)
|
||||
notification = Factory.create(:notification, :target => @received_request)
|
||||
|
||||
Notification.where(:target_id=>@received_request.id).first.unread.should be_true
|
||||
user.accept_contact_request(@received_request, aspect)
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ describe User do
|
|||
let!(:aspect1) { user.aspects.create(:name => 'other') }
|
||||
let!(:aspect2) { user2.aspects.first }
|
||||
|
||||
let!(:service1) { s = Factory(:service, :provider => 'twitter'); user.services << s; s }
|
||||
let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s }
|
||||
let!(:service1) { Factory(:service, :type => 'Services::Twitter' , :user => user) }
|
||||
let!(:service2) { Factory(:service, :type => 'Services::Facebook', :user => user) }
|
||||
|
||||
describe '#add_to_streams' do
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
Rspec::Rails::ControllerExampleGroup.class_eval do
|
||||
|
||||
# Saves the markup to a fixture file using the given name
|
||||
def save_fixture(markup, name)
|
||||
fixture_path = File.join(Rails.root, 'tmp', 'js_dom_fixtures')
|
||||
def save_fixture(markup, name, fixture_path=nil )
|
||||
fixture_path = File.join(Rails.root, 'tmp', 'js_dom_fixtures') unless fixture_path
|
||||
Dir.mkdir(fixture_path) unless File.exists?(fixture_path)
|
||||
|
||||
fixture_file = File.join(fixture_path, "#{name}.fixture.html")
|
||||
|
|
|
|||
Loading…
Reference in a new issue