automatically resizes images

This commit is contained in:
Régis Hanol
2013-04-15 23:32:26 +02:00
parent 97ba06d954
commit c2e58b61c9
8 changed files with 131 additions and 64 deletions
@@ -41,6 +41,7 @@ describe CookedPostProcessor do
before do
@topic = Fabricate(:topic)
@post = Fabricate.build(:post_with_image_url, topic: @topic, user: @topic.user)
ImageSorcery.any_instance.stubs(:convert).returns(false)
@cpp = CookedPostProcessor.new(@post, image_sizes: {'http://www.forumwarz.com/images/header/logo.png' => {'width' => 111, 'height' => 222}})
@cpp.expects(:get_size).returns([111,222])
end
@@ -63,6 +64,7 @@ describe CookedPostProcessor do
before do
FastImage.stubs(:size).returns([123, 456])
ImageSorcery.any_instance.stubs(:convert).returns(false)
CookedPostProcessor.any_instance.expects(:image_dimensions).returns([123, 456])
creator = PostCreator.new(user, raw: Fabricate.build(:post_with_images).raw, topic_id: topic.id)
@post = creator.create
@@ -70,7 +72,7 @@ describe CookedPostProcessor do
it "adds a topic image if there's one in the post" do
@post.topic.reload
@post.topic.image_url.should == "/path/to/img.jpg"
@post.topic.image_url.should == "http://test.localhost/path/to/img.jpg"
end
it "adds the height and width to images that don't have them" do
+4
View File
@@ -3,6 +3,10 @@ require_dependency 'post_destroyer'
describe PostAction do
before do
ImageSorcery.any_instance.stubs(:convert).returns(false)
end
it { should belong_to :user }
it { should belong_to :post }
it { should belong_to :post_action_type }
+4
View File
@@ -3,6 +3,10 @@ require_dependency 'post_destroyer'
describe PostAlertObserver do
before do
ImageSorcery.any_instance.stubs(:convert).returns(false)
end
let!(:evil_trout) { Fabricate(:evil_trout) }
let(:post) { Fabricate(:post) }
+4
View File
@@ -3,6 +3,10 @@ require_dependency 'post_destroyer'
describe Post do
before do
ImageSorcery.any_instance.stubs(:convert).returns(false)
end
it { should belong_to :user }
it { should belong_to :topic }
it { should validate_presence_of :raw }