Merge branch 'master' of github.com:diaspora/diaspora

This commit is contained in:
zhitomirskiyi 2010-11-15 11:02:53 -08:00
commit cede80d47b
12 changed files with 978 additions and 870 deletions

1
.gitignore vendored
View file

@ -17,6 +17,7 @@ public/uploads/*
public/source.tar*
tmp/**/*
db/*.sqlite3
.redcar
# Temporary files of every sort
.DS_Store

View file

@ -37,8 +37,9 @@ class Person
before_destroy :remove_all_traces
before_validation :clean_url
validates_presence_of :url, :profile, :serialized_public_key
validates_format_of :url, :with =>
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
validates_uniqueness_of :diaspora_handle, :case_sensitive => false
#validates_format_of :url, :with =>
# /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
ensure_index :diaspora_handle

View file

@ -3,25 +3,57 @@
# the COPYRIGHT file.
default:
# Hostname of this host, as seen from the internet.
pod_url: "http://example.org/"
# Enable extensive logging to log/{development,test,production}.log
debug: false
# Websocket server setup, see script/websocket_server.rb
# Enable extensive logging to websocket server.
socket_debug : false
# Websocket host, leave as 0.0.0.0 unless you know what you are doing
socket_host: 0.0.0.0
# File containing pid of running script/websocket_server.rb
socket_pidfile: "log/diaspora-wsd.pid"
# Websocket port, should normally be 8080 or 8081.
socket_port: 8080
socket_collection_name: 'websocket'
# Diaspora is only tested against this default pubsub server.
pubsub_server: 'https://pubsubhubbub.appspot.com/'
# Host/port for running mongodb server. See also mongodb.conf
mongo_host: 'localhost'
mongo_port: 27017
# Setting this to true enables diaspora's "send email" functionality
# requiring meaningful smtp_* settings. These are options for RoR's
# ActionMailer class.
mailer_on: false
# Address/port to smtp server handing outgoing mail.
smtp_address: 'smtp.example.com'
smtp_port: '587'
smtp_domain: 'mail.example.com'
smtp_authentication: 'plain'
smtp_sender_address: 'no-reply@example.com'
smtp_username: 'no-reply@example.com'
smtp_password: 'secret'
# Domain administered of smtp server.
smtp_domain: 'example.com'
# Sender address in diaspora's outgoing mail.
smtp_sender_address: 'no-reply@example.com'
# Authentication required to send mail. One of "plain",
# "login" or "cram-md5"
smtp_authentication: 'plain'
# Credentails possibly required to log in to SMTP server if
# smtp_authentication != 'plain'
smtp_username: 'smtp_username'
smtp_password: 'secret'
development:

View file

@ -0,0 +1,22 @@
Feature: managing contact requests
Background:
Given I am signed in
And I have one contact request
Scenario: seeing contact requests
When I am on the home page
Then I should see "Manage (1)" in the header
@javascript @wip
Scenario: accepting a contact request
Given I have an aspect called "Family"
When I am on the home page
And I follow "Manage (1)"
Then I should see 1 contact request
And 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"

View file

@ -24,4 +24,9 @@ end
When /^I wait for the home page to load$/ do
wait_until { current_path == root_path }
end
When /^I wait for the ajax to finish$/ do
pending
# wait_until { ??? }
end

View file

@ -5,4 +5,36 @@ end
When /^I click on my name$/ do
click_link("#{@me.first_name} #{@me.last_name}")
end
end
Given /^I have an aspect called "([^"]*)"$/ do |aspect_name|
@me.aspects.create!(:name => aspect_name)
@me.reload
end
Given /^I have one contact request$/ do
other_user = make_user
other_user.aspects.create!(:name => "meh")
other_user.reload
other_user.send_contact_request_to(@me.person, other_user.aspects.first)
@me.reload
end
Then /^I should see (\d+) contact request(?:s)?$/ do |request_count|
number_of_requests = evaluate_script("$('.person.request.ui-draggable').length")
number_of_requests.should == request_count.to_i
end
Then /^I should see (\d+) contact(?:s)? in "([^"]*)"$/ do |contact_count, aspect_name|
aspect = @me.reload.aspects.find_by_name(aspect_name)
number_of_contacts = evaluate_script("$('li.person.ui-draggable[data-aspect_id=\"#{aspect.id}\"]').length")
number_of_contacts.should == contact_count.to_i
end
When /^I drag the contact request to the "([^"]*)" aspect$/ do |aspect_name|
aspect = @me.reload.aspects.find_by_name(aspect_name)
aspect_div = find("ul.dropzone[data-aspect_id='#{aspect.id}']")
request_li = find(".person.request.ui-draggable")
request_li.drag_to(aspect_div)
end

View file

@ -41,3 +41,11 @@ begin
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "mongo_mapper"
end
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")
include HelperMethods
Before do
UserFixer.regenerate_user_fixtures
UserFixer.load_user_fixtures
end

View file

@ -50,7 +50,7 @@ var AspectEdit = {
type: "DELETE",
url: "/requests/" + person.attr('data-guid'),
data: {"accept" : true, "aspect_id" : dropzone.attr('data-aspect_id') },
success: function() { AspectEdit.onDeleteRequestSuccess(person); }
success: function() { AspectEdit.onDeleteRequestSuccess(person, dropzone); }
});
}
@ -70,9 +70,11 @@ var AspectEdit = {
dropzone.closest("ul").append(person);
},
onDeleteRequestSuccess: function(person) {
onDeleteRequestSuccess: function(person, dropzone) {
AspectEdit.decrementRequestsCounter();
person.removeClass('request');
person.attr('data-aspect_id', dropzone.attr('data-aspect_id'));
person.removeAttr('data-person_id');
},
onMovePersonSuccess: function(person, dropzone) {

View file

@ -10,7 +10,34 @@ describe RequestsController do
@user = make_user
sign_in :user, @user
@user.aspects.create(:name => "lame-os")
@user.aspects.create!(:name => "lame-os")
@user.reload
end
describe '#destroy' do
before do
@other_user = make_user
@other_user.aspects.create!(:name => "meh")
@other_user.reload
@other_user.send_contact_request_to(@user.person, @other_user.aspects.first)
@user.reload # so it can find its pending requests.
@friend_request = @user.pending_requests.first
end
describe 'when accepting a contact request' do
it "succeeds" do
xhr :delete, :destroy, "accept" => "true", "aspect_id" => @user.aspects.first.id.to_s, "id" => @friend_request.id.to_s
response.should redirect_to(aspect_path(@user.aspects.first))
end
end
describe 'when ignoring a contact request' do
it "succeeds" do
xhr :delete, :destroy, "id" => @friend_request.id.to_s
response.should redirect_to(requests_path)
end
end
end
describe '#create' do
@ -22,7 +49,7 @@ describe RequestsController do
)
response.should redirect_to aspects_manage_path
end
it "flashes and redirects when requesting an invalid identity" do
put(:create, {
:destination_handle => "not_a_@valid_email",
@ -32,7 +59,7 @@ describe RequestsController do
flash[:error].should_not be_blank
response.should redirect_to aspects_manage_path
end
it "flashes and redirects when requesting an invalid identity with a port number" do
put(:create, {
:destination_handle => "johndoe@email.com:3000",
@ -42,7 +69,7 @@ describe RequestsController do
flash[:error].should_not be_blank
response.should redirect_to aspects_manage_path
end
it "redirects when requesting an identity from an invalid server" do
stub_request(:get, /notadiasporaserver\.com/).to_raise(Errno::ETIMEDOUT)
put(:create, {
@ -52,7 +79,7 @@ describe RequestsController do
)
response.should redirect_to aspects_manage_path
end
it 'should redirect to the page which you called it from ' do
pending "This controller should probably redirect to :back"
put(:create, {

1654
spec/fixtures/users.yaml vendored

File diff suppressed because it is too large Load diff

View file

@ -183,14 +183,32 @@ describe("AspectEdit", function() {
);
});
it("decrements the request counter", function() {
var person = $('li.person');
var dropzone = $('.dropzone.ui-droppable[data-aspect_id="guid-of-target-aspect"]');
spyOn(AspectEdit, "decrementRequestsCounter");
AspectEdit.onDeleteRequestSuccess($('li.person'));
AspectEdit.onDeleteRequestSuccess(person, dropzone);
expect(AspectEdit.decrementRequestsCounter).toHaveBeenCalled();
});
it("takes the request class off the person li", function() {
expect($('li.person')).toHaveClass('request');
AspectEdit.onDeleteRequestSuccess($('li.person'));
expect($('li.person')).not.toHaveClass('request');
var person = $('li.person');
var dropzone = $('.dropzone.ui-droppable[data-aspect_id="guid-of-target-aspect"]');
expect(person).toHaveClass('request');
AspectEdit.onDeleteRequestSuccess(person, dropzone);
expect(person).not.toHaveClass('request');
});
it("removes data-person_id from the li", function() {
var person = $('li.person');
var dropzone = $('.dropzone.ui-droppable[data-aspect_id="guid-of-target-aspect"]');
expect(person.attr("data-person_id")).toBeDefined();
AspectEdit.onDeleteRequestSuccess(person, dropzone);
expect(person.attr("data-person_id")).not.toBeDefined();
});
it("puts a data-aspect_id on the li", function() {
var person = $('li.person');
var dropzone = $('.dropzone.ui-droppable[data-aspect_id="guid-of-target-aspect"]');
expect(person.attr("data-aspect_id")).not.toBeDefined();
AspectEdit.onDeleteRequestSuccess(person, dropzone);
expect(person.attr("data-aspect_id")).toEqual("guid-of-target-aspect");
});
});

View file

@ -29,7 +29,7 @@ describe Person do
describe "vaild url" do
it 'should allow for https urls' do
person = Factory.create(:person, :url => "https://example.com")
person.valid?.should == true
person.should be_valid
end
end
@ -51,12 +51,12 @@ describe Person do
describe 'validation' do
it 'is unique' do
person_two = Factory.build(:person, :diaspora_handle => @person.diaspora_handle)
person_two.valid?.should be_false
person_two.should_not be_valid
end
it 'is case insensitive' do
person_two = Factory.build(:person, :url => @person.url.upcase)
person_two.valid?.should be_false
person_two = Factory.build(:person, :diaspora_handle => @person.diaspora_handle.upcase)
person_two.should_not be_valid
end
end
end