Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
aaff5083f0
11 changed files with 109 additions and 34 deletions
|
|
@ -48,7 +48,8 @@ class DevUtilitiesController < ApplicationController
|
|||
|
||||
@fixture_name = File.join(File.dirname(__FILE__), "..", "..", "public", "images", "user", "#{username}.jpg")
|
||||
|
||||
photo = Photo.new(:person => current_user.person, :album => album)
|
||||
photo = Photo.new(:album => album)
|
||||
photo.person = current_user.person
|
||||
photo.image.store! File.open(@fixture_name)
|
||||
photo.save
|
||||
photo.reload
|
||||
|
|
|
|||
|
|
@ -97,7 +97,9 @@ class PhotosController < ApplicationController
|
|||
respond_with @photo
|
||||
else
|
||||
flash[:error] = I18n.t 'photos.update.error'
|
||||
render :action => :edit
|
||||
@album = @photo.album
|
||||
set_friends_and_status
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ class Aspect
|
|||
validates_presence_of :name
|
||||
validates_uniqueness_of :name, :scope => :user_id
|
||||
attr_accessible :name
|
||||
|
||||
|
||||
before_validation do
|
||||
name.strip!
|
||||
end
|
||||
|
||||
timestamps!
|
||||
|
||||
def to_s
|
||||
|
|
|
|||
|
|
@ -32,12 +32,16 @@ class Photo < Post
|
|||
|
||||
before_destroy :ensure_user_picture
|
||||
|
||||
attr_protected :person
|
||||
|
||||
def self.instantiate(params = {})
|
||||
image_file = params[:user_file]
|
||||
params.delete :user_file
|
||||
image_file = params.delete(:user_file)
|
||||
person = params.delete(:person)
|
||||
|
||||
photo = Photo.new(params)
|
||||
|
||||
photo.image.store! image_file
|
||||
photo.person = person
|
||||
photo.save
|
||||
photo
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
#
|
||||
# See config/locales/devise/devise.sv.yml for Swedish Diaspora terms.
|
||||
|
||||
sv:
|
||||
errors:
|
||||
|
|
|
|||
|
|
@ -4,9 +4,23 @@
|
|||
|
||||
# Localization file for Swedish
|
||||
#
|
||||
# This file has parts from rails-i18n project at
|
||||
# This file has parts from rails-i18n project at
|
||||
# http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale
|
||||
|
||||
#
|
||||
# --- And now, Swedish! ---
|
||||
#
|
||||
# Svensk terminologi i denna översättning:
|
||||
#
|
||||
# album: fotoalbum
|
||||
# aspect: sida
|
||||
# diaspora-handle: diaspora-adress
|
||||
# diaspora-id: (diaspora-) användarnamn
|
||||
# email: mail, ebrev (diskussion pågår);
|
||||
# pod: plats
|
||||
# request: (vän-) förfrågan
|
||||
# profile: profil
|
||||
# seed: frö
|
||||
#
|
||||
sv:
|
||||
activemodel:
|
||||
errors:
|
||||
|
|
@ -182,7 +196,7 @@ sv:
|
|||
sent: 'Din inbjudan är nu skickad.'
|
||||
no_more: 'Du har inga fler inbjudningar.'
|
||||
already_sent: 'Du har redan bjudit in denna person.'
|
||||
already_friends: 'Du är redan vän med den här personen'
|
||||
already_friends: 'Du är redan vän med den här personen'
|
||||
invitation_token_invalid: 'Din inbjudningskod är inte giltig!'
|
||||
updated: 'Ditt lösenord är nu uppdaterat, och du har loggats in.'
|
||||
|
||||
|
|
@ -348,13 +362,13 @@ sv:
|
|||
errors:
|
||||
# model.errors.full_messages format.
|
||||
format: "%{attribute} %{message}"
|
||||
|
||||
|
||||
template:
|
||||
header:
|
||||
one: "Ett fel förhindrade denna %{model} från att sparas"
|
||||
other: "%{count} fel förhindrade denna %{model} från att sparas"
|
||||
body: "Det var problem med följande fält:"
|
||||
|
||||
|
||||
# The values :model, :attribute and :value are always available for interpolation
|
||||
# The value :count is available when applicable. Can be used for pluralization.
|
||||
messages:
|
||||
|
|
|
|||
|
|
@ -8,22 +8,25 @@
|
|||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
# USAGE: ./script/ubuntu-setup.bash
|
||||
|
||||
# USAGE: ./pkg/ubuntu-setup.bash [external hostname]
|
||||
# Do NOT run this script as root.
|
||||
|
||||
arg_hostname="$1"
|
||||
|
||||
# Set extented globbing
|
||||
shopt -s extglob
|
||||
|
||||
# fail on error
|
||||
set -e
|
||||
|
||||
[ "$(whoami)" == "root" ] && echo "Please do not run this script as root/sudo
|
||||
[[ "$(whoami)" == "root" ]] && echo "Please do not run this script as root/sudo
|
||||
We need to do some actions as an ordinary user. We use sudo where necessary." && exit 1
|
||||
|
||||
# Check if the user has sudo privileges.
|
||||
sudo -v >/dev/null 2>&1 || { echo $(whoami) has no sudo privileges ; exit 1; }
|
||||
|
||||
# Check if universal repository is enabled
|
||||
# Check if universal repository is enabled
|
||||
grep -ie '^deb .*universe' /etc/apt/sources.list > /dev/null || \
|
||||
{ echo "Please enable universe repository" ; exit 1 ; }
|
||||
|
||||
|
|
@ -63,8 +66,8 @@ then
|
|||
then
|
||||
echo "Lanchpad bug https://bugs.launchpad.net/ubuntu/+source/mongodb/+bug/557024
|
||||
has not been fixed using workaround:"
|
||||
echo "sudo ln -s /usr/lib/xulrunner-1.9.2.10/libmozjs.so /usr/lib/libmozjs.so"
|
||||
sudo ln -s /usr/lib/xulrunner-1.9.2.10/libmozjs.so /usr/lib/libmozjs.so
|
||||
echo "sudo ln -sf /usr/lib/xulrunner-1.9.2.10/libmozjs.so /usr/lib/libmozjs.so"
|
||||
sudo ln -sf /usr/lib/xulrunner-1.9.2.10/libmozjs.so /usr/lib/libmozjs.so
|
||||
fi
|
||||
|
||||
sudo apt-get -y --no-install-recommends install mongodb
|
||||
|
|
@ -101,13 +104,13 @@ echo "Fetching and installing ruby gems.."
|
|||
if [ $RELEASE == "maverick" ]
|
||||
then
|
||||
sudo apt-get install --no-install-recommends -y rubygems
|
||||
sudo ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
|
||||
sudo ln -sf /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
|
||||
elif [ $RELEASE == "lucid" ]
|
||||
then
|
||||
sudo add-apt-repository ppa:maco.m/ruby
|
||||
sudo apt-get update
|
||||
sudo apt-get install --no-install-recommends -y rubygems
|
||||
sudo ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
|
||||
sudo ln -sf /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
|
||||
else
|
||||
# Old version
|
||||
echo "."
|
||||
|
|
@ -147,26 +150,49 @@ echo "Installed bundler.."
|
|||
|
||||
#Configure diaspora
|
||||
cp config/app_config.yml.example config/app_config.yml
|
||||
echo "You need to configure diaspora to tell it which URL it has.
|
||||
Opening editor in 5 seconds and then continuing with install."
|
||||
sleep 5
|
||||
#ensure EDITOR is set
|
||||
if [ -z "${EDITOR}"]
|
||||
then
|
||||
EDITOR=vi
|
||||
hostname=$( awk '/pod_url:/ { print $2; exit }' <config/app_config.yml)
|
||||
|
||||
if [ -n "$arg_hostname" ]; then
|
||||
sed -i "/pod_url:/s|$hostname|$arg_hostname|g" config/app_config.yml &&
|
||||
echo "config/app_config.yml updated."
|
||||
exit 0
|
||||
else
|
||||
while : ; do
|
||||
echo "Current hostname is \"$hostname\""
|
||||
echo -n "Enter new hostname [$hostname] :"
|
||||
read new_hostname garbage
|
||||
echo -n "Use \"$new_hostname\" as pod_url (Yes/No) [Yes]? :"
|
||||
read yesno garbage
|
||||
[ "${yesno:0:1}" = 'y' -o "${yesno:0:1}" = 'Y' -o -z "$yesno" ] && {
|
||||
sed -i "/pod_url:/s|$hostname|$new_hostname|g" \
|
||||
config/app_config.yml &&
|
||||
echo "config/app_config.yml updated."
|
||||
break
|
||||
}
|
||||
done
|
||||
fi
|
||||
$EDITOR config/app_config.yml
|
||||
|
||||
|
||||
# Create the shared directory which is used by rake db:seed:tom
|
||||
mkdir shared
|
||||
### mkdir shared
|
||||
|
||||
# Install DB setup
|
||||
echo "Seting up DB.."
|
||||
rake db:seed:tom
|
||||
echo "DB ready. Login -> tom and password -> evankorth.
|
||||
More details ./diaspora/db/seeds/tom.rb."
|
||||
echo "Setting up DB..."
|
||||
if rake db:seed:dev ; then
|
||||
cat <<- EOF
|
||||
DB ready. Login -> tom and password -> evankorth.
|
||||
More details ./diaspora/db/seeds/tom.rb. and ./diaspora/db/seeds/dev.rb.
|
||||
EOF
|
||||
else
|
||||
cat <<- EOF
|
||||
Database config failed. You might want to remove all db files with
|
||||
'rm -rf /var/lib/mongodb/*' and/or reset the config file by
|
||||
'cp config/app_config.yml.example config/app_config.yml' before
|
||||
making a new try. Also, make sure the mongodb server is running
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Run appserver
|
||||
echo "Starting server"
|
||||
bundle exec thin start
|
||||
script/server
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ describe PhotosController do
|
|||
image = File.open(@fixture_name)
|
||||
#@photo = Photo.instantiate(
|
||||
# :person => @user.person, :album => @album, :user_file => image)
|
||||
@photo = @user.post(:photo, :album_id => @album.id, :user_file => image, :to => @aspect.id)
|
||||
@photo = @user.post(:photo, :album_id => @album.id, :user_file => image, :to => @aspect.id)
|
||||
sign_in :user, @user
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -18,11 +18,17 @@ describe Aspect do
|
|||
let(:aspect3) {user3.aspect(:name => "lala")}
|
||||
|
||||
describe 'creation' do
|
||||
let(:aspect){user.aspect(:name => 'losers')}
|
||||
let!(:aspect){user.aspect(:name => 'losers')}
|
||||
it 'should have a name' do
|
||||
aspect.name.should == "losers"
|
||||
end
|
||||
|
||||
it 'should not allow duplicate names' do
|
||||
lambda {
|
||||
invalid_aspect = user.aspect(:name => "losers ")
|
||||
}.should_not change(Aspect, :count)
|
||||
end
|
||||
|
||||
it 'should not be creatable with people' do
|
||||
aspect = user.aspect(:name => 'losers', :people => [friend, friend_2])
|
||||
aspect.people.size.should == 0
|
||||
|
|
|
|||
|
|
@ -14,7 +14,21 @@ describe Photo do
|
|||
@fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @fixture_filename)
|
||||
@fail_fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', 'msg.xml')
|
||||
|
||||
@photo = Photo.new(:person => @user.person, :album => @album)
|
||||
@photo = Photo.new(:album => @album)
|
||||
@photo.person = @user.person
|
||||
end
|
||||
|
||||
describe "protected attributes" do
|
||||
it "doesn't allow mass assignment of person" do
|
||||
@photo.save!
|
||||
@photo.update_attributes(:person => Factory(:person))
|
||||
@photo.reload.person.should == @user.person
|
||||
end
|
||||
it "doesn't allow mass assignment of person_id" do
|
||||
@photo.save!
|
||||
@photo.update_attributes(:person_id => Factory(:person).id)
|
||||
@photo.reload.person.should == @user.person
|
||||
end
|
||||
end
|
||||
|
||||
it 'has a constructor' do
|
||||
|
|
|
|||
|
|
@ -16,11 +16,13 @@ describe User do
|
|||
|
||||
describe 'overwriting people' do
|
||||
it 'does not overwrite old users with factory' do
|
||||
pending "Why do you want to set ids directly? MONGOMAPPERRRRR!!!"
|
||||
new_user = Factory.create(:user, :id => user.id)
|
||||
new_user.persisted?.should be_true
|
||||
new_user.id.should_not == user.id
|
||||
end
|
||||
it 'does not overwrite old users with create' do
|
||||
pending "Why do you want to set ids directly? MONGOMAPPERRRRR!!!"
|
||||
params = {:username => "ohai",
|
||||
:email => "ohai@example.com",
|
||||
:password => "password",
|
||||
|
|
|
|||
Loading…
Reference in a new issue