add max_image_height site setting

This commit is contained in:
Régis Hanol
2013-08-26 00:24:24 +02:00
parent 7f185b6a6f
commit 32f717420d
7 changed files with 45 additions and 8 deletions

View File

@ -4,10 +4,11 @@ require 'image_sizer'
describe ImageSizer do
before do
SiteSetting.expects(:max_image_width).returns(500)
SiteSetting.stubs(:max_image_width).returns(500)
SiteSetting.stubs(:max_image_height).returns(500)
end
it 'returns the same dimensions if the width is less than the maximum' do
it 'returns the same dimensions when smaller than the maximums' do
ImageSizer.resize(400, 200).should == [400, 200]
end
@ -23,7 +24,7 @@ describe ImageSizer do
ImageSizer.resize('100', '101').should == [100, 101]
end
describe 'when larger than the maximum' do
describe 'when larger than the maximum width' do
before do
@w, @h = ImageSizer.resize(600, 123)
@ -39,4 +40,33 @@ describe ImageSizer do
end
describe 'when larger than the maximum height' do
before do
@w, @h = ImageSizer.resize(123, 600)
end
it 'returns the maxmimum height if larger than the maximum' do
@h.should == 500
end
it 'resizes the width retaining the aspect ratio' do
@w.should == 102
end
end
describe 'when larger than the maximums' do
before do
@w, @h = ImageSizer.resize(533, 800)
end
it 'resizes both dimensions retaining the aspect ratio' do
@h.should == 500
@w.should == 333
end
end
end