Merge branch 'master' of github.com:diaspora/diaspora into production
This commit is contained in:
commit
25b4b409be
15 changed files with 157 additions and 49 deletions
|
|
@ -1,6 +1,8 @@
|
|||
## Commit Guidlines
|
||||
You are welcome to contribute, add and extend Diaspora however you see fit. We will do our best to incorporate everything that meets our guidelines.
|
||||
|
||||
We need you to fill out a [contributor agreement form](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq) before we can accept your patches. The agreement gives Diaspora joint ownership of the patch so the copyright isn't scattered. You can find it [here](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq).
|
||||
|
||||
All commits must be tested, and after each commit, all tests should be green before a pull request is sent. Please write your tests in Rspec or Test-Unit.
|
||||
|
||||
GEMS: We would like to keep external dependencies unduplicated. We're using Nokogiri, and Mongomapper, and EM::HttpRequest as much as possible. We have a few gems in the project we'd rather not use, but if you can, use dependencies we already have.
|
||||
|
|
@ -199,9 +201,9 @@ Diaspora's test suite uses [rspec](http://rspec.info/), a behavior driven testin
|
|||
We are maintaining a [public tracker project](http://www.pivotaltracker.com/projects/61641) and a [roadmap](https://github.com/diaspora/diaspora/wiki/Roadmap). Also, you can file [bug reports](https://github.com/diaspora/diaspora/issues) right here on github.
|
||||
|
||||
Ongoing discussion:
|
||||
|
||||
- [Diaspora Developer Google Group](http://groups.google.com/group/diaspora-dev)
|
||||
- [Diaspora Discussion Google Group](http://groups.google.com/group/diaspora-discuss)
|
||||
- [Diaspora Q&A site](http://diaspora.shapado.com/)
|
||||
- [#diaspora-dev](irc://irc.freenode.net/#diaspora-dev)
|
||||
|
||||
More general info and updates about the project can be found on our [blog](http://joindiaspora.com), [twitter](http://twitter.com/joindiaspora). Also, be sure to join the official [mailing list](http://http://eepurl.com/Vebk).
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class AlbumsController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
@album = Album.find_params_by_id params[:id]
|
||||
@album = Album.find_by_id params[:id]
|
||||
if @album.update_attributes params[:album]
|
||||
flash[:notice] = "Album #{@album.name} successfully edited."
|
||||
respond_with @album
|
||||
|
|
|
|||
|
|
@ -26,9 +26,15 @@ class AspectsController < ApplicationController
|
|||
|
||||
def destroy
|
||||
@aspect = Aspect.find_by_id params[:id]
|
||||
@aspect.destroy
|
||||
flash[:notice] = "You are no longer sharing the aspect called #{@aspect.name}."
|
||||
respond_with :location => aspects_url
|
||||
|
||||
begin
|
||||
current_user.drop_aspect @aspect
|
||||
flash[:notice] = "#{@aspect.name} was successfully removed."
|
||||
rescue RuntimeError => e
|
||||
flash[:error] = e.message
|
||||
end
|
||||
|
||||
respond_with :location => aspects_manage_path
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def object_path(object, opts = {})
|
||||
object = object.person if object.is_a? User
|
||||
eval("#{object.class.to_s.underscore}_path(object, opts)")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -7,4 +7,12 @@ module AspectsHelper
|
|||
def link_for_aspect( aspect )
|
||||
link_to aspect.name, aspect
|
||||
end
|
||||
|
||||
def remove_link( aspect )
|
||||
if aspect.people.size == 0
|
||||
link_to "remove", aspect, :method => :delete
|
||||
else
|
||||
"<span class='grey' title='Aspect not empty'>remove</span>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ class Request
|
|||
validates_presence_of :destination_url, :callback_url
|
||||
before_validation :clean_link
|
||||
|
||||
scope :for_user, lambda{ |user| where(:destination_url => user.receive_url) }
|
||||
scope :from_user, lambda{ |user| where(:destination_url.ne => user.receive_url) }
|
||||
scope :for_user, lambda{ |user| where(:destination_url => user.person.receive_url) }
|
||||
scope :from_user, lambda{ |user| where(:destination_url.ne => user.person.receive_url) }
|
||||
|
||||
def self.instantiate(options = {})
|
||||
person = options[:from]
|
||||
|
|
|
|||
|
|
@ -64,6 +64,15 @@ class User
|
|||
Aspect.create(opts)
|
||||
end
|
||||
|
||||
def drop_aspect( aspect )
|
||||
if aspect.people.size == 0
|
||||
aspect.destroy
|
||||
else
|
||||
raise "Aspect not empty"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def move_friend( opts = {})
|
||||
return true if opts[:to] == opts[:from]
|
||||
friend = Person.first(:_id => opts[:friend_id])
|
||||
|
|
@ -284,9 +293,13 @@ else
|
|||
|
||||
###Helpers############
|
||||
def self.instantiate!( opts = {} )
|
||||
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{URI::parse(opts[:url]).host}"
|
||||
hostname = opts[:url].gsub(/(https?:|www\.)\/\//, '')
|
||||
hostname.chop! if hostname[-1, 1] == '/'
|
||||
|
||||
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{hostname}"
|
||||
puts opts[:person][:diaspora_handle]
|
||||
opts[:person][:serialized_key] = generate_key
|
||||
User.create!(opts)
|
||||
User.create(opts)
|
||||
end
|
||||
|
||||
def seed_aspects
|
||||
|
|
@ -294,10 +307,6 @@ else
|
|||
aspect(:name => "Work")
|
||||
end
|
||||
|
||||
def self.create(opts ={})
|
||||
puts opts.inspect
|
||||
end
|
||||
|
||||
def terse_url
|
||||
terse = self.url.gsub(/(https?:|www\.)\/\//, '')
|
||||
terse = terse.chop! if terse[-1, 1] == '/'
|
||||
|
|
|
|||
|
|
@ -36,12 +36,12 @@
|
|||
.aspect_name
|
||||
%h1{:contenteditable => true}= aspect.name
|
||||
|
||||
.tools
|
||||
= link_to "add a new friend", "#add_request_pane_#{aspect.id}", :class => 'add_request_button'
|
||||
|
|
||||
= link_to "show", aspect_path(aspect)
|
||||
%ul.tools
|
||||
%li= link_to "add a new friend", "#add_request_pane_#{aspect.id}", :class => 'add_request_button'
|
||||
%li= link_to "show", aspect_path(aspect)
|
||||
%li!= remove_link(aspect)
|
||||
|
||||
%ul{:id => aspect.id}
|
||||
%ul.dropzone{:id => aspect.id}
|
||||
|
||||
-if aspect.people.size < 1
|
||||
%li.grey Drag to add people
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ module Diaspora
|
|||
def receive_friend_request(friend_request)
|
||||
Rails.logger.info("receiving friend request #{friend_request.to_json}")
|
||||
|
||||
if request_from_me?(friend_request)
|
||||
if request_from_me?(friend_request) && self.aspect_by_id(friend_request.aspect_id)
|
||||
aspect = self.aspect_by_id(friend_request.aspect_id)
|
||||
activate_friend(friend_request.person, aspect)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ namespace :db do
|
|||
require 'db/seeds/backer'
|
||||
create
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc 'Delete the collections in the current RAILS_ENV database'
|
||||
|
|
@ -53,4 +54,19 @@ namespace :db do
|
|||
Rake::Task['db:seed:dev'].invoke
|
||||
puts "you did it!"
|
||||
end
|
||||
|
||||
task :fix_diaspora_handle do
|
||||
puts "fixing the people in this seed"
|
||||
require 'config/environment'
|
||||
|
||||
people = Person.all
|
||||
|
||||
people.each do |person|
|
||||
if person.diaspora_handle[-1, 1]=='@' && person.owner.nil? == false
|
||||
person.diaspora_handle = person.owner.diaspora_handle
|
||||
person.save
|
||||
end
|
||||
end
|
||||
puts "everything should be peachy"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -513,20 +513,33 @@ h1.big_text {
|
|||
.requests .aspect_name,
|
||||
.remove .aspect_name {
|
||||
position: relative; }
|
||||
.aspect .aspect_name .tools,
|
||||
.requests .aspect_name .tools,
|
||||
.remove .aspect_name .tools {
|
||||
.aspect .aspect_name ul.tools,
|
||||
.requests .aspect_name ul.tools,
|
||||
.remove .aspect_name ul.tools {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 0;
|
||||
display: inline; }
|
||||
.aspect .aspect_name:hover .tools,
|
||||
.requests .aspect_name:hover .tools,
|
||||
.remove .aspect_name:hover .tools {
|
||||
display: inline; }
|
||||
.aspect ul,
|
||||
.requests ul,
|
||||
.remove ul {
|
||||
display: inline;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none; }
|
||||
.aspect .aspect_name ul.tools li,
|
||||
.requests .aspect_name ul.tools li,
|
||||
.remove .aspect_name ul.tools li {
|
||||
display: inline;
|
||||
margin-right: 1em; }
|
||||
.aspect .aspect_name ul.tools li:last-child,
|
||||
.requests .aspect_name ul.tools li:last-child,
|
||||
.remove .aspect_name ul.tools li:last-child {
|
||||
margin-right: 0; }
|
||||
.aspect .grey,
|
||||
.requests .grey,
|
||||
.remove .grey {
|
||||
color: #999999;
|
||||
cursor: default; }
|
||||
.aspect ul.dropzone,
|
||||
.requests ul.dropzone,
|
||||
.remove ul.dropzone {
|
||||
min-height: 20px;
|
||||
margin: 0;
|
||||
margin-bottom: 25px;
|
||||
|
|
@ -574,14 +587,6 @@ h1.big_text {
|
|||
-webkit-box-shadow: 0 1px 3px #333333;
|
||||
-moz-box-shadow: 0 2px 4px #333333;
|
||||
opacity: 0.9; }
|
||||
.aspect .person .grey,
|
||||
.aspect .requested_person .grey,
|
||||
.requests .person .grey,
|
||||
.requests .requested_person .grey,
|
||||
.remove .person .grey,
|
||||
.remove .requested_person .grey {
|
||||
font-style: italic;
|
||||
color: #666666; }
|
||||
|
||||
#notification_badge {
|
||||
position: fixed;
|
||||
|
|
|
|||
|
|
@ -678,17 +678,29 @@ h1.big_text
|
|||
.aspect_name
|
||||
:position relative
|
||||
|
||||
.tools
|
||||
ul.tools
|
||||
:position absolute
|
||||
:top 10px
|
||||
:right 0
|
||||
:display inline
|
||||
|
||||
&:hover
|
||||
.tools
|
||||
:padding 0
|
||||
:margin 0
|
||||
:list
|
||||
:style none
|
||||
li
|
||||
:display inline
|
||||
:margin
|
||||
:right 1em
|
||||
|
||||
ul
|
||||
&:last-child
|
||||
:margin
|
||||
:right 0
|
||||
|
||||
.grey
|
||||
:color #999
|
||||
:cursor default
|
||||
|
||||
ul.dropzone
|
||||
:min-height 20px
|
||||
:margin 0
|
||||
:bottom 25px
|
||||
|
|
@ -726,12 +738,6 @@ h1.big_text
|
|||
:-moz-box-shadow 0 2px 4px #333
|
||||
:opacity 0.9
|
||||
|
||||
|
||||
.grey
|
||||
:font
|
||||
:style italic
|
||||
:color #666
|
||||
|
||||
#notification_badge
|
||||
:position fixed
|
||||
:bottom 0
|
||||
|
|
|
|||
23
spec/controllers/albums_controller_spec.rb
Normal file
23
spec/controllers/albums_controller_spec.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
|
||||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
include ApplicationHelper
|
||||
describe AlbumsController do
|
||||
render_views
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
@user.aspect(:name => "lame-os")
|
||||
@album = Factory.create(:album)
|
||||
sign_in :user, @user
|
||||
end
|
||||
|
||||
it "should update the name of an album" do
|
||||
sign_in :user, @user
|
||||
put :update, :id => @album._id, :album => { :name => "new_name"}
|
||||
@album.reload.name.should eql("new_name")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -22,6 +22,11 @@ Factory.define :person do |p|
|
|||
p.serialized_key OpenSSL::PKey::RSA.generate(1024).public_key.export
|
||||
end
|
||||
|
||||
Factory.define :album do |p|
|
||||
p.name "my first album"
|
||||
p.person { |a| Factory.create(:person) }
|
||||
end
|
||||
|
||||
Factory.define :person_with_private_key, :parent => :person do |p|
|
||||
p.serialized_key OpenSSL::PKey::RSA.generate(1024).export
|
||||
end
|
||||
|
|
|
|||
|
|
@ -31,4 +31,31 @@ describe User do
|
|||
@user.profile.image_url.should == "http://clown.com"
|
||||
end
|
||||
end
|
||||
|
||||
describe 'aspects' do
|
||||
it 'should delete an empty aspect' do
|
||||
@user.aspects.include?(@aspect).should == true
|
||||
@user.drop_aspect(@aspect)
|
||||
@user.reload
|
||||
|
||||
@user.aspects.include?(@aspect).should == false
|
||||
end
|
||||
|
||||
it 'should not delete an aspect with friends' do
|
||||
user2 = Factory.create(:user)
|
||||
aspect2 = user2.aspect(:name => 'stuff')
|
||||
user2.reload
|
||||
aspect2.reload
|
||||
|
||||
friend_users(@user, Aspect.find_by_id(@aspect.id), user2, Aspect.find_by_id(aspect2.id))
|
||||
@aspect.reload
|
||||
|
||||
@user.aspects.include?(@aspect).should == true
|
||||
|
||||
proc{@user.drop_aspect(@aspect)}.should raise_error /Aspect not empty/
|
||||
|
||||
@user.reload
|
||||
@user.aspects.include?(@aspect).should == true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue