58 failures with mysql
This commit is contained in:
parent
319452537e
commit
cbda6b8c58
12 changed files with 40 additions and 21 deletions
|
|
@ -10,11 +10,11 @@ class Comment < ActiveRecord::Base
|
|||
include Diaspora::Webhooks
|
||||
include Encryptable
|
||||
include Diaspora::Socketable
|
||||
include Diaspora::Guid
|
||||
|
||||
xml_attr :text
|
||||
xml_accessor :diaspora_handle
|
||||
xml_accessor :post_guid
|
||||
xml_attr :guid
|
||||
|
||||
belongs_to :post
|
||||
belongs_to :person
|
||||
|
|
@ -34,7 +34,7 @@ class Comment < ActiveRecord::Base
|
|||
post.guid
|
||||
end
|
||||
def post_guid= new_post_guid
|
||||
post = Post.where(:guid => new_post_guid).first
|
||||
self.post = Post.where(:guid => new_post_guid).first
|
||||
end
|
||||
|
||||
def notification_type(user, person)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class Contact < ActiveRecord::Base
|
|||
has_many :aspects, :through => :aspect_memberships
|
||||
validate :not_contact_for_self
|
||||
validates_uniqueness_of :person_id, :scope => :user_id
|
||||
|
||||
|
||||
def dispatch_request
|
||||
request = self.generate_request
|
||||
self.user.push_to_people(request, [self.person])
|
||||
|
|
@ -21,7 +21,9 @@ class Contact < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def generate_request
|
||||
Request.new(:sender => self.user.person, :recipient => self.person)
|
||||
Request.new(:sender => self.user.person,
|
||||
:recipient => self.person,
|
||||
:aspect => aspects.first)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ class Person < ActiveRecord::Base
|
|||
include Encryptor::Public
|
||||
require File.join(Rails.root, 'lib/diaspora/web_socket')
|
||||
include Diaspora::Socketable
|
||||
include Diaspora::Guid
|
||||
|
||||
xml_attr :guid
|
||||
xml_attr :diaspora_handle
|
||||
xml_attr :url
|
||||
xml_attr :profile, :as => Profile
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ class Post < ActiveRecord::Base
|
|||
include ApplicationHelper
|
||||
include ROXML
|
||||
include Diaspora::Webhooks
|
||||
include Diaspora::Guid
|
||||
|
||||
xml_attr :guid
|
||||
xml_attr :diaspora_handle
|
||||
xml_attr :public
|
||||
xml_attr :created_at
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ class Request < ActiveRecord::Base
|
|||
include Diaspora::Webhooks
|
||||
include ROXML
|
||||
|
||||
xml_attr :sender_handle
|
||||
xml_attr :recipient_handle
|
||||
xml_accessor :sender_handle
|
||||
xml_accessor :recipient_handle
|
||||
|
||||
belongs_to :sender, :class_name => 'Person'
|
||||
belongs_to :recipient, :class_name => 'Person'
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ ActiveRecord::Schema.define(:version => 0) do
|
|||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "posts", ["guid"], :name => "index_posts_on_guid"
|
||||
add_index "posts", ["person_id"], :name => "index_posts_on_person_id"
|
||||
add_index "posts", ["type"], :name => "index_posts_on_type"
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ module Diaspora
|
|||
xml.export {
|
||||
xml.user {
|
||||
xml.username user.username
|
||||
xml.serialized_private_key user.serialized_private_key
|
||||
|
||||
xml.serialized_private_key user.serialized_private_key
|
||||
|
||||
xml.parent << user.person.to_xml
|
||||
}
|
||||
|
||||
|
|
@ -27,9 +27,9 @@ module Diaspora
|
|||
|
||||
xml.aspects {
|
||||
user.aspects.each do |aspect|
|
||||
xml.aspect {
|
||||
xml.aspect {
|
||||
xml.name aspect.name
|
||||
|
||||
|
||||
# xml.person_ids {
|
||||
#aspect.person_ids.each do |id|
|
||||
#xml.person_id id
|
||||
|
|
@ -47,9 +47,10 @@ module Diaspora
|
|||
|
||||
xml.contacts {
|
||||
user.contacts.each do |contact|
|
||||
xml.contact {
|
||||
xml.contact {
|
||||
xml.user_id contact.user_id
|
||||
xml.person_id contact.person_id
|
||||
xml.person_guid contact.person.guid
|
||||
|
||||
xml.aspects {
|
||||
contact.aspects.each do |aspect|
|
||||
|
|
@ -71,7 +72,7 @@ module Diaspora
|
|||
xml.parent << post.to_xml
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
xml.people {
|
||||
user.contacts.each do |contact|
|
||||
person = contact.person
|
||||
|
|
|
|||
11
lib/diaspora/guid.rb
Normal file
11
lib/diaspora/guid.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
module Diaspora::Guid
|
||||
def self.included(model)
|
||||
model.class_eval do
|
||||
before_create :set_guid
|
||||
xml_attr :guid
|
||||
end
|
||||
end
|
||||
def set_guid
|
||||
self.guid ||= ActiveSupport::SecureRandom.hex(8)
|
||||
end
|
||||
end
|
||||
|
|
@ -103,7 +103,8 @@ describe Diaspora::Exporter do
|
|||
|
||||
it 'should include post created at time' do
|
||||
doc = Nokogiri::XML::parse(posts_xml)
|
||||
Time.parse(doc.xpath('//posts/status_message/created_at').first.text).should == @status_message1.created_at
|
||||
xml_time = Time.zone.parse(doc.xpath('//posts/status_message/created_at').first.text)
|
||||
xml_time.to_i.should == @status_message1.created_at.to_i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,12 +30,13 @@ describe Diaspora::Parser do
|
|||
retraction = Retraction.for(message)
|
||||
xml = retraction.to_diaspora_xml
|
||||
|
||||
proc { user.receive xml, user2.person }.should change(StatusMessage, :count).by(-1)
|
||||
lambda {
|
||||
user.receive xml, user2.person
|
||||
}.should change(StatusMessage, :count).by(-1)
|
||||
end
|
||||
|
||||
context "connecting" do
|
||||
|
||||
let(:good_request) { FakeHttpRequest.new(:success)}
|
||||
let(:good_request) { FakeHttpRequest.new(:success)}
|
||||
it "should create a new person upon getting a person request" do
|
||||
remote_user = Factory.create(:user)
|
||||
new_person = remote_user.person
|
||||
|
|
@ -53,8 +54,6 @@ describe Diaspora::Parser do
|
|||
user.receive_salmon xml
|
||||
}.should change(Person, :count).by(1)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
it "should activate the Person if I initiated a request to that url" do
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ describe Invitation do
|
|||
let!(:aspect) {user.aspects.create(:name => "Invitees")}
|
||||
let(:user2) {Factory.create(:user)}
|
||||
before do
|
||||
user.invites = 20
|
||||
user.save
|
||||
@email = 'maggie@example.com'
|
||||
Devise.mailer.deliveries = []
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ describe User do
|
|||
|
||||
context "creating invites" do
|
||||
it 'requires your aspect' do
|
||||
inviter.invite_user("maggie@example.com", wrong_aspect.id).should raise_error ActiveRecord::RecordNotFound
|
||||
lambda {
|
||||
inviter.invite_user("maggie@example.com", wrong_aspect.id)
|
||||
}.should raise_error ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
it 'calls Invitation.invite' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue