From 80db1132d1dcd4be2caa89ed1e773a266818a645 Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 28 Jul 2010 16:50:38 -0700 Subject: [PATCH] Fixed the tests; --- app/controllers/photos_controller.rb | 1 + app/controllers/users_controller.rb | 2 ++ app/models/photo.rb | 5 +++-- app/models/profile.rb | 10 ++++++++++ gpg/diaspora-test/pubring.gpg | Bin 37380 -> 37991 bytes gpg/diaspora-test/secring.gpg | Bin 2006 -> 2670 bytes gpg/diaspora-test/trustdb.gpg | Bin 1600 -> 1680 bytes spec/factories.rb | 2 +- spec/models/comments_spec.rb | 2 +- spec/models/person_spec.rb | 2 +- spec/models/photo_spec.rb | 15 +++++++++++---- spec/models/profile_spec.rb | 2 +- spec/models/request_spec.rb | 2 +- spec/models/retraction_spec.rb | 2 +- spec/models/user_spec.rb | 26 +++++++++++++++++++++++++- 15 files changed, 58 insertions(+), 13 deletions(-) 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 7fe0816872d13da360d5edd77d6ca74a2615731a..edac5d95b216f263b94be3fe285f4da92da09f51 100644 GIT binary patch delta 582 zcmV-M0=fN!qyp!t0NSGcKvlT4sp0kf++5)TGv*N*M{5+vpNL@f1g7xTIkh8eO$sz zXBhx_=y8HN@HWsDWQz7&y93iXobw<+0sn0~Q(D9r`#A69Za-7=3g7L!NzqpAtSy_V zU#56TNU*j=fO!^axZL0K!uJ)R=?ml*Ls{M{3Kf%P5>2C+oZ7TEVsBy~Vrgt_d30}g zZXhUVbaZe!FE4j@lg5h_88taTVQ*|MV{dIfh++g25dr`r1p-V^wp^3I2_S!~F$?b{ zbP%Tj>;1%{NF*V5U@JGa^xtNHhRsRY{HlG;51=7>SzBf%3X}Lx@QP7!d*h2?YX7 zP_|qG8w>yn2@tC>3-2X#5VehP0H1sp4|}buG@#I_GhOv8{f~9ee9syHoCyL3OiWd* U>=Oylmy5>Z3%plI(69mk0|prc;{X5v delta 9 QcmaF9f~jQ*(*~AF02Xuv0ssI2 diff --git a/gpg/diaspora-test/secring.gpg b/gpg/diaspora-test/secring.gpg index 9f945d3f1e68aac39851a98abd25127a806880bd..c27cdfcaddaf43e55dd52eff4c78e9e7f6b844a1 100644 GIT binary patch delta 623 zcmV-#0+9XI5AGDO)(3x-`vgo-wpa{FJdkT#Q3Yp|FQ`vgu`k|`i@|IM*yIcpyA`+?xFo&LLe*N zrw^l`Q1vwd{wEb|eh_y3bu$iexJ!a4?y6eXR*u((+zYch1qFYfLoQnA)kJ+a{;AV2~CZ97w1#2EWH@8oVjQ}YVn?Yl|QR_&}Uo2g%> zcu7dGwncz>7HPQL-}A!v6`<)0Dd(0G>6>K(kY%Cq&Qa z(^m^mc^;itKKQT#005k+1WZu2To3{Pl43pLd&$%SnOW!alHpOnjL#@jH~oCYr}MDS zd*R9ODeo`3+}%`E=BJ$0J_IN9R4Aq!y~6bd$fC-^d#zW@UV0sm0>=8`y5FJ`}) z!o?$&*!jm3OR*K&ZZwKqFyIyTDls+ReCdrM&NCuWkVrHDWK~Iy0yJxjbQp=6&Vll} zc|!mIwHMe`G94xr>r;Mu4xSZZ_mmOdcuvHTMG55HSdo0H0YdI!KH1Ilt0Obq5lzZJKaI JB^9s&0065z5^Dee delta 7 OcmaDSa*cn(HFf|GE(3J{ diff --git a/gpg/diaspora-test/trustdb.gpg b/gpg/diaspora-test/trustdb.gpg index 1fec81fc8c39a371e7de456d93e66eb9dd3172ee..87e4dbb8a4fa7498184172b4162397f70d2ff066 100644 GIT binary patch delta 124 zcmX@WGl5rtF})z2nVFH5k%581CtzFb#6aRwE&8bCh7RwC}6Zj_=Fkjpp$o!rO0L7#WB>(^b 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