Fixed the tests;

This commit is contained in:
maxwell 2010-07-28 16:50:38 -07:00
parent 5723d91dae
commit 80db1132d1
15 changed files with 58 additions and 13 deletions

View file

@ -3,6 +3,7 @@ class PhotosController < ApplicationController
def create
begin
#puts params.inspect
@photo = Photo.instantiate(params)
@photo.person = current_user

View file

@ -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

View file

@ -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

View file

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -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

View file

@ -1,4 +1,4 @@
require 'spec_helper'
require File.dirname(__FILE__) + '/../spec_helper'
describe Comment do
describe "user" do

View file

@ -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

View file

@ -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

View file

@ -1,4 +1,4 @@
require 'spec_helper'
require File.dirname(__FILE__) + '/../spec_helper'
describe Profile do
before do

View file

@ -1,4 +1,4 @@
require 'spec_helper'
require File.dirname(__FILE__) + '/../spec_helper'
describe Request do

View file

@ -1,4 +1,4 @@
require 'spec_helper'
require File.dirname(__FILE__) + '/../spec_helper'
describe Retraction do
describe "posts" do

View file

@ -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