このコミットが含まれているのは:
@@ -110,7 +110,7 @@ RSpec.describe Post, type: :model do
|
||||
end
|
||||
|
||||
describe '.resized_thumbnail_attachment' do
|
||||
it 'centre-crops a wide image to 180x180 without distorting it' do
|
||||
it 'fits a wide image within 180x180 without distorting it' do
|
||||
blob = image_blob(
|
||||
width: 360,
|
||||
height: 180,
|
||||
@@ -123,13 +123,13 @@ RSpec.describe Post, type: :model do
|
||||
resized = described_class.resized_thumbnail_attachment(upload_for(blob))
|
||||
image = read_image(resized)
|
||||
|
||||
expect(image.dimensions).to eq([180, 180])
|
||||
expect_green(colour_at(image, 0, 90))
|
||||
expect_green(colour_at(image, 90, 90))
|
||||
expect_green(colour_at(image, 179, 90))
|
||||
expect(image.dimensions).to eq([180, 90])
|
||||
expect_red(colour_at(image, 0, 45))
|
||||
expect_green(colour_at(image, 90, 45))
|
||||
expect_red(colour_at(image, 179, 45))
|
||||
end
|
||||
|
||||
it 'centre-crops a tall image to 180x180 without distorting it' do
|
||||
it 'fits a tall image within 180x180 without distorting it' do
|
||||
blob = image_blob(
|
||||
width: 180,
|
||||
height: 360,
|
||||
@@ -142,10 +142,10 @@ RSpec.describe Post, type: :model do
|
||||
resized = described_class.resized_thumbnail_attachment(upload_for(blob))
|
||||
image = read_image(resized)
|
||||
|
||||
expect(image.dimensions).to eq([180, 180])
|
||||
expect_green(colour_at(image, 90, 0))
|
||||
expect_green(colour_at(image, 90, 90))
|
||||
expect_green(colour_at(image, 90, 179))
|
||||
expect(image.dimensions).to eq([90, 180])
|
||||
expect_red(colour_at(image, 45, 0))
|
||||
expect_green(colour_at(image, 45, 90))
|
||||
expect_red(colour_at(image, 45, 179))
|
||||
end
|
||||
|
||||
it 'keeps a square image square without distortion' do
|
||||
@@ -192,7 +192,7 @@ RSpec.describe Post, type: :model do
|
||||
|
||||
expect(post.thumbnail).to be_attached
|
||||
image = read_image(post.thumbnail)
|
||||
expect(image.dimensions).to eq([180, 180])
|
||||
expect(image.dimensions).to eq([180, 135])
|
||||
end
|
||||
|
||||
it 'does not attach anything when thumbnail conversion fails' do
|
||||
|
||||
新しい課題から参照
ユーザをブロックする