drop requests table wip
This commit is contained in:
parent
2e5b5e1efe
commit
4f972a23f6
20 changed files with 63 additions and 148 deletions
|
|
@ -8,7 +8,6 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
before_filter :ensure_http_referer_is_set
|
before_filter :ensure_http_referer_is_set
|
||||||
before_filter :set_header_data, :except => [:create, :update]
|
before_filter :set_header_data, :except => [:create, :update]
|
||||||
before_filter :count_requests
|
|
||||||
before_filter :set_invites
|
before_filter :set_invites
|
||||||
before_filter :set_locale
|
before_filter :set_locale
|
||||||
before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision])
|
before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision])
|
||||||
|
|
@ -34,10 +33,6 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_requests
|
|
||||||
@request_count = Request.where(:recipient_id => current_user.person.id).count if current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_invites
|
def set_invites
|
||||||
if user_signed_in?
|
if user_signed_in?
|
||||||
@invites = current_user.invites
|
@invites = current_user.invites
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,6 @@ class PhotosController < ApplicationController
|
||||||
@person = Person.find_by_id(params[:person_id])
|
@person = Person.find_by_id(params[:person_id])
|
||||||
|
|
||||||
if @person
|
if @person
|
||||||
@incoming_request = Request.where(:recipient_id => current_user.person.id, :sender_id => @person.id).first
|
|
||||||
@outgoing_request = Request.where(:sender_id => current_user.person.id, :recipient_id => @person.id).first
|
|
||||||
|
|
||||||
@profile = @person.profile
|
@profile = @person.profile
|
||||||
@contact = current_user.contact_for(@person)
|
@contact = current_user.contact_for(@person)
|
||||||
@is_contact = @person != current_user.person && @contact
|
@is_contact = @person != current_user.person && @contact
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class PostsController < ApplicationController
|
class PostsController < ApplicationController
|
||||||
skip_before_filter :count_requests
|
|
||||||
skip_before_filter :set_invites
|
skip_before_filter :set_invites
|
||||||
skip_before_filter :which_action_and_user
|
skip_before_filter :which_action_and_user
|
||||||
skip_before_filter :set_grammatical_gender
|
skip_before_filter :set_grammatical_gender
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ class PublicsController < ApplicationController
|
||||||
include Diaspora::Parser
|
include Diaspora::Parser
|
||||||
|
|
||||||
skip_before_filter :set_header_data
|
skip_before_filter :set_header_data
|
||||||
skip_before_filter :count_requests
|
|
||||||
skip_before_filter :set_invites
|
skip_before_filter :set_invites
|
||||||
skip_before_filter :which_action_and_user
|
skip_before_filter :which_action_and_user
|
||||||
skip_before_filter :set_grammatical_gender
|
skip_before_filter :set_grammatical_gender
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class TagsController < ApplicationController
|
class TagsController < ApplicationController
|
||||||
skip_before_filter :count_requests
|
|
||||||
skip_before_filter :set_invites
|
skip_before_filter :set_invites
|
||||||
skip_before_filter :which_action_and_user
|
skip_before_filter :which_action_and_user
|
||||||
skip_before_filter :set_grammatical_gender
|
skip_before_filter :set_grammatical_gender
|
||||||
|
|
|
||||||
|
|
@ -106,10 +106,8 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if @step == 3
|
if @step == 3
|
||||||
@requests = Request.where(:recipient_id => @person.id).includes(:sender => :profile).all
|
|
||||||
@friends = service ? service.finder(:local => true) : []
|
@friends = service ? service.finder(:local => true) : []
|
||||||
@friends ||= []
|
@friends ||= []
|
||||||
@friends.delete_if{|f| @requests.any?{ |r| r.sender_id == f.person.id} }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ class Contact < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_request
|
def generate_request
|
||||||
Request.new(:sender => self.user.person,
|
Request.diaspora_initialize(:from => self.user.person,
|
||||||
:recipient => self.person,
|
:to => self.person,
|
||||||
:aspect => aspects.first)
|
:into => aspects.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive_post(post)
|
def receive_post(post)
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,15 @@ class Notifications::StartedSharing < Notification
|
||||||
def translation_key
|
def translation_key
|
||||||
'started_sharing'
|
'started_sharing'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def email_the_user(target, actor)
|
||||||
|
super(target.sender, actor)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def self.make_notification(recipient, target, actor, notification_type)
|
||||||
|
super(recipient, target.sender, actor, notification_type)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,8 @@ class Person < ActiveRecord::Base
|
||||||
sql, tokens = self.search_query_string(query)
|
sql, tokens = self.search_query_string(query)
|
||||||
Person.searchable.where(sql, *tokens).joins(
|
Person.searchable.where(sql, *tokens).joins(
|
||||||
"LEFT OUTER JOIN `contacts` ON `contacts`.user_id = #{user.id} AND `contacts`.person_id = `people`.id"
|
"LEFT OUTER JOIN `contacts` ON `contacts`.user_id = #{user.id} AND `contacts`.person_id = `people`.id"
|
||||||
).joins("LEFT OUTER JOIN `requests` ON `requests`.recipient_id = #{user.person.id} AND `requests`.sender_id = `people`.id"
|
|
||||||
).includes(:profile
|
).includes(:profile
|
||||||
).order("contacts.user_id DESC", "requests.recipient_id DESC", "profiles.last_name ASC", "profiles.first_name ASC")
|
).order("contacts.user_id DESC", "profiles.last_name ASC", "profiles.first_name ASC")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,29 +2,26 @@
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class Request < ActiveRecord::Base
|
class Request
|
||||||
require File.join(Rails.root, 'lib/diaspora/webhooks')
|
|
||||||
require File.join(Rails.root, 'lib/postzord/dispatch')
|
|
||||||
|
|
||||||
include Diaspora::Webhooks
|
|
||||||
include ROXML
|
include ROXML
|
||||||
|
include Diaspora::Webhooks
|
||||||
|
include ActiveModel::Validations
|
||||||
|
|
||||||
|
attr_accessor :sender, :recipient, :aspect
|
||||||
|
|
||||||
xml_accessor :sender_handle
|
xml_accessor :sender_handle
|
||||||
xml_accessor :recipient_handle
|
xml_accessor :recipient_handle
|
||||||
|
|
||||||
belongs_to :sender, :class_name => 'Person'
|
|
||||||
belongs_to :recipient, :class_name => 'Person'
|
|
||||||
belongs_to :aspect
|
|
||||||
|
|
||||||
validates_uniqueness_of :sender_id, :scope => :recipient_id
|
|
||||||
validates_presence_of :sender, :recipient
|
validates_presence_of :sender, :recipient
|
||||||
validate :not_already_connected
|
validate :not_already_connected
|
||||||
validate :not_friending_yourself
|
validate :not_friending_yourself
|
||||||
|
|
||||||
def self.diaspora_initialize(opts = {})
|
def self.diaspora_initialize(opts = {})
|
||||||
self.new(:sender => opts[:from],
|
req = self.new
|
||||||
:recipient => opts[:to],
|
req.sender = opts[:from]
|
||||||
:aspect => opts[:into])
|
req.recipient = opts[:to]
|
||||||
|
req.aspect = opts[:into]
|
||||||
|
req
|
||||||
end
|
end
|
||||||
|
|
||||||
def reverse_for accepting_user
|
def reverse_for accepting_user
|
||||||
|
|
@ -63,7 +60,6 @@ class Request < ActiveRecord::Base
|
||||||
def receive(user, person)
|
def receive(user, person)
|
||||||
Rails.logger.info("event=receive payload_type=request sender=#{self.sender} to=#{self.recipient}")
|
Rails.logger.info("event=receive payload_type=request sender=#{self.sender} to=#{self.recipient}")
|
||||||
user.contacts.create(:person_id => person.id)
|
user.contacts.create(:person_id => person.id)
|
||||||
self.save
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,6 @@
|
||||||
.description
|
.description
|
||||||
= link_to current_user.diaspora_handle, person_path(current_user.person)
|
= link_to current_user.diaspora_handle, person_path(current_user.person)
|
||||||
|
|
||||||
- if @notification_count > 0 || @request_count > 0
|
|
||||||
#new_requests
|
|
||||||
- if @request_count > 0
|
|
||||||
%h4
|
|
||||||
= new_request_link(@request_count)
|
|
||||||
%h4.section.invite_friends
|
%h4.section.invite_friends
|
||||||
!= t('bookmarklet.explanation', :link => link_to(t('bookmarklet.explanation_link_text'), bookmarklet))
|
!= t('bookmarklet.explanation', :link => link_to(t('bookmarklet.explanation_link_text'), bookmarklet))
|
||||||
- if @invites > 0
|
- if @invites > 0
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,6 @@
|
||||||
%br
|
%br
|
||||||
|
|
||||||
#people_stream.stream
|
#people_stream.stream
|
||||||
- for pending_req in @requests
|
|
||||||
- person = pending_req.sender
|
|
||||||
|
|
||||||
= render :partial => 'people/person', :locals => {:request => pending_req, :person => person, :contact => nil}
|
|
||||||
- for friend in @friends
|
- for friend in @friends
|
||||||
= render :partial => 'people/person', :locals => {:request => friend.request, :person => friend.person, :contact => friend.contact}
|
= render :partial => 'people/person', :locals => {:request => friend.request, :person => friend.person, :contact => friend.contact}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ SQL
|
||||||
remove_foreign_key :conversation_visibilities, :people
|
remove_foreign_key :conversation_visibilities, :people
|
||||||
|
|
||||||
remove_foreign_key :messages, :conversations
|
remove_foreign_key :messages, :conversations
|
||||||
remove_foreign_key :messages, :people, :column => :author_id
|
remove_foreign_key :messages, :column => :author_id
|
||||||
|
|
||||||
remove_foreign_key :conversations, :people, :column => :author_id
|
remove_foreign_key :conversations, :column => :author_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
19
db/schema.rb
19
db/schema.rb
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20110405171412) do
|
ActiveRecord::Schema.define(:version => 20110406202932) do
|
||||||
|
|
||||||
create_table "aspect_memberships", :force => true do |t|
|
create_table "aspect_memberships", :force => true do |t|
|
||||||
t.integer "aspect_id", :null => false
|
t.integer "aspect_id", :null => false
|
||||||
|
|
@ -275,20 +275,6 @@ ActiveRecord::Schema.define(:version => 20110405171412) do
|
||||||
add_index "profiles", ["mongo_id"], :name => "index_profiles_on_mongo_id"
|
add_index "profiles", ["mongo_id"], :name => "index_profiles_on_mongo_id"
|
||||||
add_index "profiles", ["person_id"], :name => "index_profiles_on_person_id"
|
add_index "profiles", ["person_id"], :name => "index_profiles_on_person_id"
|
||||||
|
|
||||||
create_table "requests", :force => true do |t|
|
|
||||||
t.integer "sender_id", :null => false
|
|
||||||
t.integer "recipient_id", :null => false
|
|
||||||
t.integer "aspect_id"
|
|
||||||
t.datetime "created_at"
|
|
||||||
t.datetime "updated_at"
|
|
||||||
t.string "mongo_id"
|
|
||||||
end
|
|
||||||
|
|
||||||
add_index "requests", ["mongo_id"], :name => "index_requests_on_mongo_id"
|
|
||||||
add_index "requests", ["recipient_id"], :name => "index_requests_on_recipient_id"
|
|
||||||
add_index "requests", ["sender_id", "recipient_id"], :name => "index_requests_on_sender_id_and_recipient_id", :unique => true
|
|
||||||
add_index "requests", ["sender_id"], :name => "index_requests_on_sender_id"
|
|
||||||
|
|
||||||
create_table "service_users", :force => true do |t|
|
create_table "service_users", :force => true do |t|
|
||||||
t.string "uid", :null => false
|
t.string "uid", :null => false
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
|
|
@ -413,9 +399,6 @@ ActiveRecord::Schema.define(:version => 20110405171412) do
|
||||||
|
|
||||||
add_foreign_key "profiles", "people", :name => "profiles_person_id_fk", :dependent => :delete
|
add_foreign_key "profiles", "people", :name => "profiles_person_id_fk", :dependent => :delete
|
||||||
|
|
||||||
add_foreign_key "requests", "people", :name => "requests_recipient_id_fk", :column => "recipient_id", :dependent => :delete
|
|
||||||
add_foreign_key "requests", "people", :name => "requests_sender_id_fk", :column => "sender_id", :dependent => :delete
|
|
||||||
|
|
||||||
add_foreign_key "services", "users", :name => "services_user_id_fk", :dependent => :delete
|
add_foreign_key "services", "users", :name => "services_user_id_fk", :dependent => :delete
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
Feature: managing contact requests
|
|
||||||
|
|
||||||
Background:
|
|
||||||
Given I am signed in
|
|
||||||
And I have an aspect called "Family"
|
|
||||||
And I have one follower
|
|
||||||
|
|
||||||
Scenario: seeing contact request notifications
|
|
||||||
When I am on the home page
|
|
||||||
Then I should see "All Aspects" in the header
|
|
||||||
When I follow "All Aspects"
|
|
||||||
Then I should see "new request!"
|
|
||||||
|
|
||||||
@javascript
|
|
||||||
Scenario: viewing a requests profile
|
|
||||||
When I am on the manage aspects page
|
|
||||||
When I click on the contact request
|
|
||||||
And I wait for "the requestors profile" to load
|
|
||||||
Then I should be on the requestors profile
|
|
||||||
And I should see "wants to share with you"
|
|
||||||
|
|
||||||
@javascript
|
|
||||||
Scenario: accepting a contact request
|
|
||||||
When I am on the home page
|
|
||||||
And I follow "new request!"
|
|
||||||
Then I should see 0 contacts in "Family"
|
|
||||||
|
|
||||||
When I drag the contact request to the "Family" aspect
|
|
||||||
And I wait for the ajax to finish
|
|
||||||
Then I should see 1 contact in "Family"
|
|
||||||
|
|
||||||
@javascript @wip
|
|
||||||
Scenario: ignoring a contact request
|
|
||||||
When I am on the aspects manage page
|
|
||||||
Then I should see 1 contact request
|
|
||||||
When I click "X" on the contact request
|
|
||||||
And I wait for the ajax to finish
|
|
||||||
Then I should see 0 contact requests
|
|
||||||
|
|
@ -11,7 +11,7 @@ describe PostVisibilitiesController do
|
||||||
a2 = bob.aspects.create(:name => "two")
|
a2 = bob.aspects.create(:name => "two")
|
||||||
bob.contacts.create(:person => alice.person, :aspects => [a2])
|
bob.contacts.create(:person => alice.person, :aspects => [a2])
|
||||||
|
|
||||||
@status = bob.post(:status_message, :text => "hello", :public => true, :to => a2)
|
@status = bob.post(:status_message, :text => "hello", :to => a2)
|
||||||
@vis = @status.post_visibilities.first
|
@vis = @status.post_visibilities.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,10 +131,6 @@ describe Contact do
|
||||||
Postzord::Dispatch.should_receive(:new).and_return(m)
|
Postzord::Dispatch.should_receive(:new).and_return(m)
|
||||||
@contact.dispatch_request
|
@contact.dispatch_request
|
||||||
end
|
end
|
||||||
it 'persists no request' do
|
|
||||||
@contact.dispatch_request
|
|
||||||
Request.where(:sender_id => @user.person.id, :recipient_id => @person.id).should be_empty
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ describe Notification do
|
||||||
before do
|
before do
|
||||||
@request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect)
|
@request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calls Notification.create if the object has a notification_type' do
|
it 'calls Notification.create if the object has a notification_type' do
|
||||||
Notification.should_receive(:make_notification).once
|
Notification.should_receive(:make_notification).once
|
||||||
Notification.notify(@user, @request, @person)
|
Notification.notify(@user, @request, @person)
|
||||||
|
|
@ -56,7 +57,7 @@ describe Notification do
|
||||||
|
|
||||||
it 'creates the notification already read' do
|
it 'creates the notification already read' do
|
||||||
n = Notification.notify(@user, @request, @person)
|
n = Notification.notify(@user, @request, @person)
|
||||||
n.unread?.should be_false
|
n.should_not be_unread
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sockets to the recipient' do
|
it 'sockets to the recipient' do
|
||||||
|
|
|
||||||
|
|
@ -6,86 +6,85 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Request do
|
describe Request do
|
||||||
before do
|
before do
|
||||||
@user = alice
|
@aspect = alice.aspects.first
|
||||||
@user2 = eve
|
|
||||||
@person = Factory :person
|
|
||||||
@aspect = @user.aspects.first
|
|
||||||
@aspect2 = @user2.aspects.first
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'validations' do
|
describe 'validations' do
|
||||||
before do
|
before do
|
||||||
@request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect)
|
@request = Request.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is valid' do
|
it 'is valid' do
|
||||||
@request.sender.should == @user.person
|
@request.sender.should == alice.person
|
||||||
@request.recipient.should == @user2.person
|
@request.recipient.should == eve.person
|
||||||
@request.aspect.should == @aspect
|
@request.aspect.should == @aspect
|
||||||
@request.should be_valid
|
@request.should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is from a person' do
|
it 'is from a person' do
|
||||||
@request.sender = nil
|
@request.sender = nil
|
||||||
@request.should_not be_valid
|
@request.should_not be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is to a person' do
|
it 'is to a person' do
|
||||||
@request.recipient = nil
|
@request.recipient = nil
|
||||||
@request.should_not be_valid
|
@request.should_not be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is not necessarily into an aspect' do
|
it 'is not necessarily into an aspect' do
|
||||||
@request.aspect = nil
|
@request.aspect = nil
|
||||||
@request.should be_valid
|
@request.should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is not from an existing friend' do
|
it 'is not from an existing friend' do
|
||||||
Contact.create(:user => @user2, :person => @user.person, :aspects => [@aspect2])
|
Contact.create(:user => eve, :person => alice.person, :aspects => [eve.aspects.first])
|
||||||
@request.should_not be_valid
|
@request.should_not be_valid
|
||||||
end
|
end
|
||||||
it 'is not a duplicate of an existing pending request' do
|
|
||||||
@request.save
|
|
||||||
duplicate_request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect)
|
|
||||||
duplicate_request.should_not be_valid
|
|
||||||
end
|
|
||||||
it 'is not to yourself' do
|
it 'is not to yourself' do
|
||||||
@request = Request.diaspora_initialize(:from => @user.person, :to => @user.person, :into => @aspect)
|
@request = Request.diaspora_initialize(:from => alice.person, :to => alice.person, :into => @aspect)
|
||||||
@request.should_not be_valid
|
@request.should_not be_valid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#notification_type' do
|
describe '#notification_type' do
|
||||||
it 'returns request_accepted' do
|
it 'returns request_accepted' do
|
||||||
request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect)
|
person = Factory :person
|
||||||
@user.contacts.create(:person_id => @person.id)
|
|
||||||
|
|
||||||
request.notification_type(@user, @person).should == Notifications::StartedSharing
|
request = Request.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
|
||||||
|
alice.contacts.create(:person_id => person.id)
|
||||||
|
|
||||||
|
request.notification_type(alice, person).should == Notifications::StartedSharing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#subscribers' do
|
describe '#subscribers' do
|
||||||
it 'returns an array with to field on a request' do
|
it 'returns an array with to field on a request' do
|
||||||
request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect)
|
request = Request.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
|
||||||
request.subscribers(@user).should =~ [@user2.person]
|
request.subscribers(alice).should =~ [eve.person]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#receive' do
|
describe '#receive' do
|
||||||
it 'creates a contact' do
|
it 'creates a contact' do
|
||||||
request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect)
|
request = Request.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
|
||||||
@user2.contacts.should_receive(:create).with(hash_including(:person_id => @user.person.id))
|
eve.contacts.should_receive(:create).with(hash_including(:person_id => alice.person.id))
|
||||||
request.receive(@user2, @user.person)
|
request.receive(eve, alice.person)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'xml' do
|
context 'xml' do
|
||||||
before do
|
before do
|
||||||
@request = Request.new(:sender => @user.person, :recipient => @user2.person, :aspect => @aspect)
|
@request = Request.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
|
||||||
@xml = @request.to_xml.to_s
|
@xml = @request.to_xml.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'serialization' do
|
describe 'serialization' do
|
||||||
it 'produces valid xml' do
|
it 'produces valid xml' do
|
||||||
@xml.should include @user.person.diaspora_handle
|
@xml.should include alice.person.diaspora_handle
|
||||||
@xml.should include @user2.person.diaspora_handle
|
@xml.should include eve.person.diaspora_handle
|
||||||
@xml.should_not include @user.person.exported_key
|
@xml.should_not include alice.person.exported_key
|
||||||
@xml.should_not include @user.person.profile.first_name
|
@xml.should_not include alice.person.profile.first_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -93,8 +92,8 @@ describe Request do
|
||||||
it 'produces a request object' do
|
it 'produces a request object' do
|
||||||
marshalled = Request.from_xml @xml
|
marshalled = Request.from_xml @xml
|
||||||
|
|
||||||
marshalled.sender.should == @user.person
|
marshalled.sender.should == alice.person
|
||||||
marshalled.recipient.should == @user2.person
|
marshalled.recipient.should == eve.person
|
||||||
marshalled.aspect.should be_nil
|
marshalled.aspect.should be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,11 @@ describe Diaspora::UserModules::Connecting do
|
||||||
|
|
||||||
context 'contact requesting' do
|
context 'contact requesting' do
|
||||||
describe '#receive_contact_request' do
|
describe '#receive_contact_request' do
|
||||||
before do
|
|
||||||
@r = Request.diaspora_initialize(:to => alice.person, :from => person)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates a contact' do
|
it 'creates a contact' do
|
||||||
|
r = Request.diaspora_initialize(:to => alice.person, :from => person)
|
||||||
|
|
||||||
lambda {
|
lambda {
|
||||||
received_req = @r.receive(alice, person_one)
|
received_req = r.receive(alice, person_one)
|
||||||
}.should change(Contact, :count).by(1)
|
}.should change(Contact, :count).by(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -55,14 +53,6 @@ describe Diaspora::UserModules::Connecting do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'received a contact request' do
|
context 'received a contact request' do
|
||||||
before do
|
|
||||||
Request.diaspora_initialize(:from => person, :to => alice.person).save
|
|
||||||
Request.diaspora_initialize(:from => person_one, :to => alice.person).save
|
|
||||||
|
|
||||||
@received_request = Request.where(:sender_id => person.id, :recipient_id => alice.person.id).first
|
|
||||||
@received_request2 = Request.where(:sender_id => person_one.id, :recipient_id => alice.person.id).first
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should ignore a contact request from yourself' do
|
it 'should ignore a contact request from yourself' do
|
||||||
request_from_myself = Request.diaspora_initialize(:to => alice.person, :from => alice.person)
|
request_from_myself = Request.diaspora_initialize(:to => alice.person, :from => alice.person)
|
||||||
reversed_request = request_from_myself.reverse_for(alice)
|
reversed_request = request_from_myself.reverse_for(alice)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue