width and height should now federate

This commit is contained in:
Maxwell Salzberg 2012-04-20 12:53:02 -07:00
parent 1b2440f68a
commit 63a0a37171
2 changed files with 26 additions and 9 deletions

View file

@ -21,6 +21,8 @@ class Photo < ActiveRecord::Base
:medium => photo.url(:thumb_medium),
:large => photo.url(:scaled_full) }
}, :as => :sizes
t.add :height
t.add :width
end
mount_uploader :processed_image, ProcessedImage
@ -32,6 +34,9 @@ class Photo < ActiveRecord::Base
xml_attr :text
xml_attr :status_message_guid
xml_attr :height
xml_attr :width
belongs_to :status_message, :foreign_key => :status_message_guid, :primary_key => :guid
validates_associated :status_message

View file

@ -4,6 +4,13 @@
require 'spec_helper'
def with_carrierwave_processing(&block)
UnprocessedImage.enable_processing = true
val = yield
UnprocessedImage.enable_processing = false
val
end
describe Photo do
before do
@user = alice
@ -125,11 +132,9 @@ describe Photo do
context 'with a saved photo' do
before do
UnprocessedImage.enable_processing = true
@photo.unprocessed_image.store! File.open(@fixture_name)
UnprocessedImage.enable_processing = false
with_carrierwave_processing do
@photo.unprocessed_image.store! File.open(@fixture_name)
end
end
it 'should have text' do
@photo.text= "cool story, bro"
@ -146,12 +151,11 @@ describe Photo do
end
it 'should not use the imported filename as the url' do
@photo.url.include?(@fixture_filename).should be false
@photo.url(:thumb_medium).include?("/" + @fixture_filename).should be false
@photo.url.should_not include @fixture_filename
@photo.url(:thumb_medium).should_not include ("/" + @fixture_filename)
end
it 'should save the image dimensions' do
@photo.width.should == 40
@photo.height.should == 40
end
@ -169,7 +173,9 @@ describe Photo do
describe 'serialization' do
before do
Jobs::ProcessPhoto.perform(@saved_photo.id)
@saved_photo = with_carrierwave_processing do
@user.build_post(:photo, :user_file => File.open(@fixture_name), :to => @aspect.id)
end
@xml = @saved_photo.to_xml.to_s
end
@ -181,6 +187,12 @@ describe Photo do
it 'serializes the diaspora_handle' do
@xml.include?(@user.diaspora_handle).should be true
end
it 'serializes the height and width' do
@xml.should include 'height'
@xml.include?('width').should be true
@xml.include?('40').should be true
end
end
describe 'remote photos' do