mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
add max_image_height site setting
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user