diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 4e6f50c36..4bf54cbf4 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -3,6 +3,7 @@ class PhotosController < ApplicationController def create begin + #puts params.inspect @photo = Photo.instantiate(params) @photo.person = current_user diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5414ac03a..a9adbf346 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -17,6 +17,8 @@ class UsersController < ApplicationController def update @user = User.where(:id => params[:id]).first + puts params.inspect + if @user.update_attributes(params[:user]) flash[:notice] = "Successfully updated user." redirect_to @user diff --git a/app/models/photo.rb b/app/models/photo.rb index ba80688dc..f52dc0d1c 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -14,9 +14,10 @@ class Photo < Post validates_presence_of :album - def self.instantiate params = {} - image_file = params[:user_file][0] + def self.instantiate(params = {}) + image_file = params[:user_file].first params.delete :user_file + photo = Photo.new(params) photo.image.store! image_file photo diff --git a/app/models/profile.rb b/app/models/profile.rb index d5e371fec..934c46f93 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -4,6 +4,7 @@ class Profile xml_accessor :first_name xml_accessor :last_name + xml_accessor :image_url key :first_name, String key :last_name, String @@ -11,4 +12,13 @@ class Profile validates_presence_of :first_name, :last_name + # before_save :expand_profile_photo_path + # + # + # def expand_profile_photo_path + # unless image_url.nil? || self.image_url.include?(parent_document.url) + # self.image_url = self._parent_document.url + self.image_url + # end + # end + end diff --git a/gpg/diaspora-test/pubring.gpg b/gpg/diaspora-test/pubring.gpg index 7fe081687..edac5d95b 100644 Binary files a/gpg/diaspora-test/pubring.gpg and b/gpg/diaspora-test/pubring.gpg differ diff --git a/gpg/diaspora-test/secring.gpg b/gpg/diaspora-test/secring.gpg index 9f945d3f1..c27cdfcad 100644 Binary files a/gpg/diaspora-test/secring.gpg and b/gpg/diaspora-test/secring.gpg differ diff --git a/gpg/diaspora-test/trustdb.gpg b/gpg/diaspora-test/trustdb.gpg index 1fec81fc8..87e4dbb8a 100644 Binary files a/gpg/diaspora-test/trustdb.gpg and b/gpg/diaspora-test/trustdb.gpg differ diff --git a/spec/factories.rb b/spec/factories.rb index b1b61bdcb..b72769800 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -14,7 +14,7 @@ Factory.define :person do |p| p.email "bob-person@aol.com" p.active true p.sequence(:url) {|n|"http://google-#{n}.com/"} - p.key_fingerprint "fffffffffffffffffooooooooooooooo" + p.key_fingerprint GPGME::list_keys("Wesley").first.subkeys.first.fingerprint p.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" ) end diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index 7bb5fe372..4f5b79115 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require File.dirname(__FILE__) + '/../spec_helper' describe Comment do describe "user" do diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 8d6e75f51..1660371b6 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require File.dirname(__FILE__) + '/../spec_helper' describe Person do it 'should not allow two people with the same url' do diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 9ca10e39b..5eb9ea805 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -10,8 +10,10 @@ describe Photo do end it 'should have a constructor' do - photo = Photo.instantiate(:person => @user, :album => @album, :image => File.open(@fixture_name)) + image = File.open(@fixture_name) + photo = Photo.instantiate(:person => @user, :album => @album, :user_file => [image]) photo.save.should be true + photo.image.read.nil?.should be false end @@ -66,7 +68,7 @@ describe Photo do end it 'should save a signed @photo to GridFS' do - photo = Photo.instantiate(:person => @user, :album => @album, :image => File.open(@fixture_name)) + photo = Photo.create(:person => @user, :album => @album, :image => File.open(@fixture_name)) photo.save.should == true photo.verify_creator_signature.should be true end @@ -78,13 +80,18 @@ describe Photo do @photo.image = File.open(@fixture_name) @photo.image.store! @photo.save + + xml = @photo.to_xml.to_s - xml.include?(@photo.image.url).should be true + + xml.include?("bp.jpeg").should be true end it 'should have an album id on serialization' do @photo.image = File.open(@fixture_name) + xml = @photo.to_xml.to_s - xml.include?(@photo.album.id.to_s).should be true + puts xml + xml.include?("scaled_full_bp.").should be true end end end diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index 6099793b0..819ef3e44 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require File.dirname(__FILE__) + '/../spec_helper' describe Profile do before do diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index 00fac8580..788b7aee5 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require File.dirname(__FILE__) + '/../spec_helper' describe Request do diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index 81ea52a1a..276a74cb6 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require File.dirname(__FILE__) + '/../spec_helper' describe Retraction do describe "posts" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a6006ed1d..04c4f44a9 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require File.dirname(__FILE__) + '/../spec_helper' describe User do it "should be a person" do @@ -57,4 +57,28 @@ describe User do @user.unsubscribe_from_pubsub(author.id) Author.all.count.should == 0 end + + it 'should be able to update their profile and send it to their friends' do + pending + + profile = {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clowntown.com"} + + @user = Factory.create(:user, :profile => Profile.new(profile)) + profile = {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://awesome.com"} + + + @user.update_profile(profile) + + @user.profile.image_url.should == "http://awesome.com" + #puts @user.to_xml.to_s + end + + + it 'should fix the image_url 'do + pending + profile = Profile.new(:image_url => "/images/foo.jpg") + user = Factory.create(:user, :profile => profile) + + puts user.profile.image_url + end end