mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Add rubocop to our build. (#5004)
This commit is contained in:
@@ -31,7 +31,7 @@ describe CookedPostProcessor do
|
||||
end
|
||||
|
||||
context "admin user" do
|
||||
let(:post) { Fabricate(:post, user: Fabricate(:admin) ) }
|
||||
let(:post) { Fabricate(:post, user: Fabricate(:admin)) }
|
||||
|
||||
it "omits nofollow" do
|
||||
cpp = CookedPostProcessor.new(post)
|
||||
@@ -41,8 +41,8 @@ describe CookedPostProcessor do
|
||||
end
|
||||
|
||||
context ".keep_reverse_index_up_to_date" do
|
||||
let(:video_upload) { Fabricate(:upload, url: '/uploads/default/1/1234567890123456.mp4' ) }
|
||||
let(:image_upload) { Fabricate(:upload, url: '/uploads/default/1/1234567890123456.jpg' ) }
|
||||
let(:video_upload) { Fabricate(:upload, url: '/uploads/default/1/1234567890123456.mp4') }
|
||||
let(:image_upload) { Fabricate(:upload, url: '/uploads/default/1/1234567890123456.jpg') }
|
||||
let(:audio_upload) { Fabricate(:upload, url: '/uploads/default/1/1234567890123456.ogg') }
|
||||
let(:attachment_upload) { Fabricate(:upload, url: '/uploads/default/1/1234567890123456.csv') }
|
||||
|
||||
@@ -100,7 +100,7 @@ describe CookedPostProcessor do
|
||||
before { cpp.post_process_images }
|
||||
|
||||
context "valid" do
|
||||
let(:image_sizes) { {"http://foo.bar/image.png" => {"width" => 111, "height" => 222}} }
|
||||
let(:image_sizes) { { "http://foo.bar/image.png" => { "width" => 111, "height" => 222 } } }
|
||||
|
||||
it "uses them" do
|
||||
|
||||
@@ -113,17 +113,17 @@ describe CookedPostProcessor do
|
||||
end
|
||||
|
||||
context "invalid width" do
|
||||
let(:image_sizes) { {"http://foo.bar/image.png" => {"width" => 0, "height" => 222}} }
|
||||
let(:image_sizes) { { "http://foo.bar/image.png" => { "width" => 0, "height" => 222 } } }
|
||||
include_examples "leave dimensions alone"
|
||||
end
|
||||
|
||||
context "invalid height" do
|
||||
let(:image_sizes) { {"http://foo.bar/image.png" => {"width" => 111, "height" => 0}} }
|
||||
let(:image_sizes) { { "http://foo.bar/image.png" => { "width" => 111, "height" => 0 } } }
|
||||
include_examples "leave dimensions alone"
|
||||
end
|
||||
|
||||
context "invalid width & height" do
|
||||
let(:image_sizes) { {"http://foo.bar/image.png" => {"width" => 0, "height" => 0}} }
|
||||
let(:image_sizes) { { "http://foo.bar/image.png" => { "width" => 0, "height" => 0 } } }
|
||||
include_examples "leave dimensions alone"
|
||||
end
|
||||
|
||||
@@ -287,31 +287,31 @@ describe CookedPostProcessor do
|
||||
let(:cpp) { CookedPostProcessor.new(post) }
|
||||
|
||||
it "returns the size when width and height are specified" do
|
||||
img = { 'src' => 'http://foo.bar/image3.png', 'width' => 50, 'height' => 70}
|
||||
img = { 'src' => 'http://foo.bar/image3.png', 'width' => 50, 'height' => 70 }
|
||||
expect(cpp.get_size_from_attributes(img)).to eq([50, 70])
|
||||
end
|
||||
|
||||
it "returns the size when width and height are floats" do
|
||||
img = { 'src' => 'http://foo.bar/image3.png', 'width' => 50.2, 'height' => 70.1}
|
||||
img = { 'src' => 'http://foo.bar/image3.png', 'width' => 50.2, 'height' => 70.1 }
|
||||
expect(cpp.get_size_from_attributes(img)).to eq([50, 70])
|
||||
end
|
||||
|
||||
it "resizes when only width is specified" do
|
||||
img = { 'src' => 'http://foo.bar/image3.png', 'width' => 100}
|
||||
img = { 'src' => 'http://foo.bar/image3.png', 'width' => 100 }
|
||||
SiteSetting.crawl_images = true
|
||||
FastImage.expects(:size).returns([200, 400])
|
||||
expect(cpp.get_size_from_attributes(img)).to eq([100, 200])
|
||||
end
|
||||
|
||||
it "resizes when only height is specified" do
|
||||
img = { 'src' => 'http://foo.bar/image3.png', 'height' => 100}
|
||||
img = { 'src' => 'http://foo.bar/image3.png', 'height' => 100 }
|
||||
SiteSetting.crawl_images = true
|
||||
FastImage.expects(:size).returns([100, 300])
|
||||
expect(cpp.get_size_from_attributes(img)).to eq([33, 100])
|
||||
end
|
||||
|
||||
it "doesn't raise an error with a weird url" do
|
||||
img = { 'src' => nil, 'height' => 100}
|
||||
img = { 'src' => nil, 'height' => 100 }
|
||||
SiteSetting.crawl_images = true
|
||||
expect(cpp.get_size_from_attributes(img)).to be_nil
|
||||
end
|
||||
@@ -414,12 +414,12 @@ describe CookedPostProcessor do
|
||||
end
|
||||
|
||||
it "returns the original filename of the upload when there is an upload" do
|
||||
upload = build(:upload, { original_filename: "upload.jpg" })
|
||||
upload = build(:upload, original_filename: "upload.jpg")
|
||||
expect(cpp.get_filename(upload, "http://domain.com/image.png")).to eq("upload.jpg")
|
||||
end
|
||||
|
||||
it "returns a generic name for pasted images" do
|
||||
upload = build(:upload, { original_filename: "blob.png" })
|
||||
upload = build(:upload, original_filename: "blob.png")
|
||||
expect(cpp.get_filename(upload, "http://domain.com/image.png")).to eq(I18n.t('upload.pasted_image_filename'))
|
||||
end
|
||||
|
||||
@@ -432,8 +432,8 @@ describe CookedPostProcessor do
|
||||
|
||||
before do
|
||||
Oneboxer.expects(:onebox)
|
||||
.with("http://www.youtube.com/watch?v=9bZkp7q19f0", post_id: 123, invalidate_oneboxes: true)
|
||||
.returns("<div>GANGNAM STYLE</div>")
|
||||
.with("http://www.youtube.com/watch?v=9bZkp7q19f0", post_id: 123, invalidate_oneboxes: true)
|
||||
.returns("<div>GANGNAM STYLE</div>")
|
||||
cpp.post_process_oneboxes
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user