Merge branch 'master' of github.com:diaspora/diaspora_rails
This commit is contained in:
commit
715a6ae770
8 changed files with 40 additions and 17 deletions
|
|
@ -8,7 +8,6 @@ class PhotosController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@photo = Photo.new(params[:photo])
|
@photo = Photo.new(params[:photo])
|
||||||
@photo.person = current_user
|
@photo.person = current_user
|
||||||
|
|
||||||
if @photo.save
|
if @photo.save
|
||||||
flash[:notice] = "Successfully uploaded photo."
|
flash[:notice] = "Successfully uploaded photo."
|
||||||
redirect_to photos_url
|
redirect_to photos_url
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
= link_to (image_tag post.image.url(:thumb_medium)), object_path(post)
|
= link_to (image_tag post.image.url(:thumb_medium)), object_path(post)
|
||||||
|
|
||||||
%div.time
|
%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"
|
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
|
||||||
= render "comments/comments", :post => post
|
= render "comments/comments", :post => post
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
- title "Photo"
|
- title "Photo"
|
||||||
|
|
||||||
= image_tag @photo.image.url
|
#show_photo
|
||||||
|
= image_tag @photo.image.url
|
||||||
|
|
||||||
%h4= "comments (#{@photo.comments.count})"
|
%h4= "comments (#{@photo.comments.count})"
|
||||||
= render "comments/comments", :post => @photo
|
= render "comments/comments", :post => @photo
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ policy :diaspora, :roles => [:tom, :backer] do
|
||||||
requires :scm
|
requires :scm
|
||||||
end
|
end
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
policy :ci, :roles => :ci do
|
policy :ci, :roles => :ci do
|
||||||
requires :tools
|
requires :tools
|
||||||
requires :rubygems
|
requires :rubygems
|
||||||
|
|
@ -54,6 +55,7 @@ policy :ci, :roles => :ci do
|
||||||
requires :scm
|
requires :scm
|
||||||
#add sqlite
|
#add sqlite
|
||||||
end
|
end
|
||||||
|
|
||||||
=end
|
=end
|
||||||
# Deployment
|
# Deployment
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,12 @@
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def sign_if_mine
|
def sign_if_mine
|
||||||
puts "In sign_if_mine"
|
|
||||||
if self.person == User.owner
|
if self.person == User.owner
|
||||||
self.creator_signature = sign
|
self.creator_signature = sign
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign
|
def sign
|
||||||
puts "signing"
|
|
||||||
sign_with_key(User.owner.key)
|
sign_with_key(User.owner.key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ a {
|
||||||
a:hover {
|
a:hover {
|
||||||
color: #018790; }
|
color: #018790; }
|
||||||
|
|
||||||
|
#show_photo img {
|
||||||
|
width: 100%; }
|
||||||
|
|
||||||
#flash_notice,
|
#flash_notice,
|
||||||
#flash_error,
|
#flash_error,
|
||||||
#flash_alert {
|
#flash_alert {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ a
|
||||||
&:hover
|
&:hover
|
||||||
:color #018790
|
:color #018790
|
||||||
|
|
||||||
|
|
||||||
#flash_notice,
|
#flash_notice,
|
||||||
#flash_error,
|
#flash_error,
|
||||||
#flash_alert
|
#flash_alert
|
||||||
|
|
@ -271,6 +272,11 @@ li.comment > img.person_picture
|
||||||
&:first-child
|
&:first-child
|
||||||
:margin-right 1em
|
:margin-right 1em
|
||||||
|
|
||||||
|
#show_photo
|
||||||
|
img
|
||||||
|
:width 100%
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#debug_info
|
#debug_info
|
||||||
:margin-top 20px
|
:margin-top 20px
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,35 @@ describe Photo do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
@fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg'
|
@fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg'
|
||||||
|
@fail_fixture_name = File.dirname(__FILE__) + '/../fixtures/msg.xml'
|
||||||
|
@photo = Photo.new(:person => @user)
|
||||||
end
|
end
|
||||||
it 'should save a photo to GridFS' do
|
it 'should save a @photo to GridFS' do
|
||||||
photo = Photo.new(:person => @user)
|
|
||||||
file = File.open(@fixture_name)
|
file = File.open(@fixture_name)
|
||||||
photo.image = file
|
@photo.image = file
|
||||||
photo.save.should == true
|
@photo.save.should == true
|
||||||
binary = photo.image.read
|
binary = @photo.image.read
|
||||||
fixture_binary = File.open(@fixture_name).read
|
fixture_binary = File.open(@fixture_name).read
|
||||||
binary.should == fixture_binary
|
binary.should == fixture_binary
|
||||||
end
|
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
|
it 'should not save' do
|
||||||
pending('need to figure this out... tearing issue')
|
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
|
end
|
||||||
|
|
||||||
describe 'with encryption' do
|
describe 'with encryption' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
@ -28,11 +43,10 @@ describe Photo do
|
||||||
stub_signature_verification
|
stub_signature_verification
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should save a signed photo to GridFS' do
|
it 'should save a signed @photo to GridFS' do
|
||||||
photo = Photo.new(:person => @user)
|
@photo.image = File.open(@fixture_name)
|
||||||
photo.image = File.open(@fixture_name)
|
@photo.save.should == true
|
||||||
photo.save.should == true
|
@photo.verify_creator_signature.should be true
|
||||||
photo.verify_creator_signature.should be true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue