diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index e446c77a7..b7106959f 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -8,7 +8,6 @@ class PhotosController < ApplicationController def create @photo = Photo.new(params[:photo]) @photo.person = current_user - if @photo.save flash[:notice] = "Successfully uploaded photo." redirect_to photos_url diff --git a/config/sprinkle/provision.rb b/config/sprinkle/provision.rb index 215ca83f1..b922a4137 100644 --- a/config/sprinkle/provision.rb +++ b/config/sprinkle/provision.rb @@ -44,6 +44,7 @@ policy :diaspora, :roles => [:tom, :backer] do requires :scm end =begin + policy :ci, :roles => :ci do requires :tools requires :rubygems @@ -54,6 +55,7 @@ policy :ci, :roles => :ci do requires :scm #add sqlite end + =end # Deployment # diff --git a/lib/encryptable.rb b/lib/encryptable.rb index 226ae5e1f..cc5682f95 100644 --- a/lib/encryptable.rb +++ b/lib/encryptable.rb @@ -21,14 +21,12 @@ protected def sign_if_mine - puts "In sign_if_mine" if self.person == User.owner self.creator_signature = sign end end def sign - puts "signing" sign_with_key(User.owner.key) end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 148251e8d..feb320cbd 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -4,20 +4,35 @@ describe Photo do before do @user = Factory.create(:user) @fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg' + @fail_fixture_name = File.dirname(__FILE__) + '/../fixtures/msg.xml' + @photo = Photo.new(:person => @user) end - it 'should save a photo to GridFS' do - photo = Photo.new(:person => @user) + it 'should save a @photo to GridFS' do file = File.open(@fixture_name) - photo.image = file - photo.save.should == true - binary = photo.image.read + @photo.image = file + @photo.save.should == true + binary = @photo.image.read fixture_binary = File.open(@fixture_name).read binary.should == fixture_binary end + describe 'non-image files' do + it 'should not store' do + file = File.open(@fail_fixture_name) + @photo.image.should_receive(:check_whitelist!) + lambda { + @photo.image.store! file + }.should raise_error + end - it 'should create thumbnails' do - pending('need to figure this out... tearing issue') + it 'should not save' do + pending "We need to figure out the difference between us and the example app" + file = File.open(@fail_fixture_name) + @photo.image.should_receive(:check_whitelist!) + @photo.image = file + @photo.save.should == false + end end + describe 'with encryption' do before do @@ -28,11 +43,10 @@ describe Photo do stub_signature_verification end - it 'should save a signed photo to GridFS' do - photo = Photo.new(:person => @user) - photo.image = File.open(@fixture_name) - photo.save.should == true - photo.verify_creator_signature.should be true + it 'should save a signed @photo to GridFS' do + @photo.image = File.open(@fixture_name) + @photo.save.should == true + @photo.verify_creator_signature.should be true end end