Skip to content
Extraits de code Groupes Projets
Valider cbda6b8c rédigé par Raphael's avatar Raphael
Parcourir les fichiers

58 failures with mysql

parent 31945253
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -10,11 +10,11 @@ class Comment < ActiveRecord::Base ...@@ -10,11 +10,11 @@ class Comment < ActiveRecord::Base
include Diaspora::Webhooks include Diaspora::Webhooks
include Encryptable include Encryptable
include Diaspora::Socketable include Diaspora::Socketable
include Diaspora::Guid
xml_attr :text xml_attr :text
xml_accessor :diaspora_handle xml_accessor :diaspora_handle
xml_accessor :post_guid xml_accessor :post_guid
xml_attr :guid
belongs_to :post belongs_to :post
belongs_to :person belongs_to :person
...@@ -34,7 +34,7 @@ class Comment < ActiveRecord::Base ...@@ -34,7 +34,7 @@ class Comment < ActiveRecord::Base
post.guid post.guid
end end
def post_guid= new_post_guid def post_guid= new_post_guid
post = Post.where(:guid => new_post_guid).first self.post = Post.where(:guid => new_post_guid).first
end end
def notification_type(user, person) def notification_type(user, person)
......
...@@ -13,7 +13,7 @@ class Contact < ActiveRecord::Base ...@@ -13,7 +13,7 @@ class Contact < ActiveRecord::Base
has_many :aspects, :through => :aspect_memberships has_many :aspects, :through => :aspect_memberships
validate :not_contact_for_self validate :not_contact_for_self
validates_uniqueness_of :person_id, :scope => :user_id validates_uniqueness_of :person_id, :scope => :user_id
def dispatch_request def dispatch_request
request = self.generate_request request = self.generate_request
self.user.push_to_people(request, [self.person]) self.user.push_to_people(request, [self.person])
...@@ -21,7 +21,9 @@ class Contact < ActiveRecord::Base ...@@ -21,7 +21,9 @@ class Contact < ActiveRecord::Base
end end
def generate_request 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 end
private private
......
...@@ -9,8 +9,8 @@ class Person < ActiveRecord::Base ...@@ -9,8 +9,8 @@ class Person < ActiveRecord::Base
include Encryptor::Public include Encryptor::Public
require File.join(Rails.root, 'lib/diaspora/web_socket') require File.join(Rails.root, 'lib/diaspora/web_socket')
include Diaspora::Socketable include Diaspora::Socketable
include Diaspora::Guid
xml_attr :guid
xml_attr :diaspora_handle xml_attr :diaspora_handle
xml_attr :url xml_attr :url
xml_attr :profile, :as => Profile xml_attr :profile, :as => Profile
......
...@@ -8,8 +8,8 @@ class Post < ActiveRecord::Base ...@@ -8,8 +8,8 @@ class Post < ActiveRecord::Base
include ApplicationHelper include ApplicationHelper
include ROXML include ROXML
include Diaspora::Webhooks include Diaspora::Webhooks
include Diaspora::Guid
xml_attr :guid
xml_attr :diaspora_handle xml_attr :diaspora_handle
xml_attr :public xml_attr :public
xml_attr :created_at xml_attr :created_at
......
...@@ -8,8 +8,8 @@ class Request < ActiveRecord::Base ...@@ -8,8 +8,8 @@ class Request < ActiveRecord::Base
include Diaspora::Webhooks include Diaspora::Webhooks
include ROXML include ROXML
xml_attr :sender_handle xml_accessor :sender_handle
xml_attr :recipient_handle xml_accessor :recipient_handle
belongs_to :sender, :class_name => 'Person' belongs_to :sender, :class_name => 'Person'
belongs_to :recipient, :class_name => 'Person' belongs_to :recipient, :class_name => 'Person'
......
...@@ -124,6 +124,7 @@ ActiveRecord::Schema.define(:version => 0) do ...@@ -124,6 +124,7 @@ ActiveRecord::Schema.define(:version => 0) do
t.datetime "updated_at" t.datetime "updated_at"
end end
add_index "posts", ["guid"], :name => "index_posts_on_guid"
add_index "posts", ["person_id"], :name => "index_posts_on_person_id" add_index "posts", ["person_id"], :name => "index_posts_on_person_id"
add_index "posts", ["type"], :name => "index_posts_on_type" add_index "posts", ["type"], :name => "index_posts_on_type"
......
...@@ -18,8 +18,8 @@ module Diaspora ...@@ -18,8 +18,8 @@ module Diaspora
xml.export { xml.export {
xml.user { xml.user {
xml.username user.username 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 xml.parent << user.person.to_xml
} }
...@@ -27,9 +27,9 @@ module Diaspora ...@@ -27,9 +27,9 @@ module Diaspora
xml.aspects { xml.aspects {
user.aspects.each do |aspect| user.aspects.each do |aspect|
xml.aspect { xml.aspect {
xml.name aspect.name xml.name aspect.name
# xml.person_ids { # xml.person_ids {
#aspect.person_ids.each do |id| #aspect.person_ids.each do |id|
#xml.person_id id #xml.person_id id
...@@ -47,9 +47,10 @@ module Diaspora ...@@ -47,9 +47,10 @@ module Diaspora
xml.contacts { xml.contacts {
user.contacts.each do |contact| user.contacts.each do |contact|
xml.contact { xml.contact {
xml.user_id contact.user_id xml.user_id contact.user_id
xml.person_id contact.person_id xml.person_id contact.person_id
xml.person_guid contact.person.guid
xml.aspects { xml.aspects {
contact.aspects.each do |aspect| contact.aspects.each do |aspect|
...@@ -71,7 +72,7 @@ module Diaspora ...@@ -71,7 +72,7 @@ module Diaspora
xml.parent << post.to_xml xml.parent << post.to_xml
end end
} }
xml.people { xml.people {
user.contacts.each do |contact| user.contacts.each do |contact|
person = contact.person person = contact.person
......
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 ...@@ -103,7 +103,8 @@ describe Diaspora::Exporter do
it 'should include post created at time' do it 'should include post created at time' do
doc = Nokogiri::XML::parse(posts_xml) 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 end
end end
...@@ -30,12 +30,13 @@ describe Diaspora::Parser do ...@@ -30,12 +30,13 @@ describe Diaspora::Parser do
retraction = Retraction.for(message) retraction = Retraction.for(message)
xml = retraction.to_diaspora_xml 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 end
context "connecting" do 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 it "should create a new person upon getting a person request" do
remote_user = Factory.create(:user) remote_user = Factory.create(:user)
new_person = remote_user.person new_person = remote_user.person
...@@ -53,8 +54,6 @@ describe Diaspora::Parser do ...@@ -53,8 +54,6 @@ describe Diaspora::Parser do
user.receive_salmon xml user.receive_salmon xml
}.should change(Person, :count).by(1) }.should change(Person, :count).by(1)
end end
end end
it "should activate the Person if I initiated a request to that url" do it "should activate the Person if I initiated a request to that url" do
......
...@@ -9,6 +9,8 @@ describe Invitation do ...@@ -9,6 +9,8 @@ describe Invitation do
let!(:aspect) {user.aspects.create(:name => "Invitees")} let!(:aspect) {user.aspects.create(:name => "Invitees")}
let(:user2) {Factory.create(:user)} let(:user2) {Factory.create(:user)}
before do before do
user.invites = 20
user.save
@email = 'maggie@example.com' @email = 'maggie@example.com'
Devise.mailer.deliveries = [] Devise.mailer.deliveries = []
end end
......
...@@ -14,7 +14,9 @@ describe User do ...@@ -14,7 +14,9 @@ describe User do
context "creating invites" do context "creating invites" do
it 'requires your aspect' 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 end
it 'calls Invitation.invite' do it 'calls Invitation.invite' do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter