From de3a08d031bd88d3d481bcc02a0031801a80bc0a Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 20 Jul 2010 10:23:19 -0700 Subject: [PATCH 1/4] Took out putses --- app/models/photo.rb | 3 --- config/sprinkle/provision.rb | 2 ++ lib/encryptable.rb | 2 -- spec/models/photo_spec.rb | 10 ++++++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/models/photo.rb b/app/models/photo.rb index 42e704273..70e65cb64 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -1,8 +1,5 @@ class Photo < Post require 'carrierwave/orm/mongomapper' include MongoMapper::Document - before_validation {puts "I'M GONNA VALIDATE"} - before_save {puts "I'M GONNA SAVE"} - before_create {puts "I'M GONNA CREATE"} mount_uploader :image, ImageUploader end 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..5266b837d 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -4,6 +4,8 @@ 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' + end it 'should save a photo to GridFS' do photo = Photo.new(:person => @user) @@ -15,8 +17,12 @@ describe Photo do binary.should == fixture_binary end - it 'should create thumbnails' do - pending('need to figure this out... tearing issue') + it 'should not accept files of non-image types' do + photo = Photo.new(:person => @user) + file = File.open(@fail_fixture_name) + photo.image = file + photo.save.should == false + end describe 'with encryption' do From d8cbbcf6c8e7fda39cca64e1187fd2cac6bbceaf Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 20 Jul 2010 11:31:41 -0700 Subject: [PATCH 2/4] Added photo file validation spec --- app/controllers/photos_controller.rb | 1 - spec/models/photo_spec.rb | 42 +++++++++++++++++----------- 2 files changed, 25 insertions(+), 18 deletions(-) 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/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 5266b837d..feb320cbd 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -5,25 +5,34 @@ describe Photo 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 not accept files of non-image types' do - photo = Photo.new(:person => @user) - file = File.open(@fail_fixture_name) - photo.image = file - photo.save.should == false - + 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 @@ -34,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 From e856945a947d959c99d81de5864cae8e64b7402a Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 20 Jul 2010 11:41:50 -0700 Subject: [PATCH 3/4] RS MS photos are no longer ginormous, and also a small bug where photos were going to the status message show page. --- app/views/photos/_photo.haml | 2 +- public/stylesheets/application.css | 3 +++ public/stylesheets/sass/application.sass | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/photos/_photo.haml b/app/views/photos/_photo.haml index f822bce13..dddd8e7f1 100644 --- a/app/views/photos/_photo.haml +++ b/app/views/photos/_photo.haml @@ -9,7 +9,7 @@ = link_to (image_tag post.image.url(:thumb_medium)), object_path(post) %div.time - = link_to(how_long_ago(post), status_message_path(post)) + = link_to(how_long_ago(post), photo_path(post)) \-- = link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments" = render "comments/comments", :post => post diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 86c4fc512..e94e68f64 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -17,6 +17,9 @@ a { a:hover { color: #018790; } +img { + width: 100%; } + #flash_notice, #flash_error, #flash_alert { diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 09bd60a8b..b233194d3 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -16,6 +16,8 @@ a :font-weight bold &:hover :color #018790 +img + :width 100% #flash_notice, #flash_error, From 453d2ee8275025a84e54fd2611042bf2752205c4 Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 20 Jul 2010 11:50:23 -0700 Subject: [PATCH 4/4] RS MS fail. totally made a new bug and fixed it re: resizing --- app/views/photos/show.html.haml | 3 ++- public/stylesheets/application.css | 2 +- public/stylesheets/sass/application.sass | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index cf608098e..780fef673 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -1,6 +1,7 @@ - title "Photo" -= image_tag @photo.image.url +#show_photo + = image_tag @photo.image.url %h4= "comments (#{@photo.comments.count})" = render "comments/comments", :post => @photo diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index e94e68f64..18831fa80 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -17,7 +17,7 @@ a { a:hover { color: #018790; } -img { +#show_photo img { width: 100%; } #flash_notice, diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index b233194d3..9b8ff81f4 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -16,8 +16,7 @@ a :font-weight bold &:hover :color #018790 -img - :width 100% + #flash_notice, #flash_error, @@ -272,6 +271,11 @@ li.comment > img.person_picture &:first-child :margin-right 1em +#show_photo + img + :width 100% + + #debug_info :margin-top 20px