このコミットが含まれているのは:
@@ -20,12 +20,12 @@ RSpec.describe PostCreator do
|
||||
allow(PostVersionRecorder).to receive(:record!)
|
||||
end
|
||||
|
||||
it 'prefers an explicit upload over thumbnail_base' do
|
||||
allow(Post).to receive(:resized_thumbnail_attachment).and_return(
|
||||
io: StringIO.new('upload'),
|
||||
it 'prefers thumbnail_base over an explicit upload' do
|
||||
expect(Post).not_to receive(:resized_thumbnail_attachment)
|
||||
allow(Post).to receive(:remote_thumbnail_attachment).and_return(
|
||||
io: StringIO.new('remote'),
|
||||
filename: 'resized_thumbnail.jpg',
|
||||
content_type: 'image/jpeg')
|
||||
expect_any_instance_of(Post).not_to receive(:attach_thumbnail_from_url!)
|
||||
|
||||
post = described_class.new(
|
||||
actor:,
|
||||
@@ -41,13 +41,12 @@ RSpec.describe PostCreator do
|
||||
end
|
||||
|
||||
it 'uses the common remote thumbnail attach path when thumbnail_base is given' do
|
||||
expect_any_instance_of(Post).to receive(:attach_thumbnail_from_url!)
|
||||
.with('https://example.com/thumb.jpg') do |post, _url|
|
||||
post.thumbnail.attach(
|
||||
io: StringIO.new('thumbnail'),
|
||||
filename: 'thumbnail.jpg',
|
||||
content_type: 'image/jpeg')
|
||||
end
|
||||
expect(Post).to receive(:remote_thumbnail_attachment)
|
||||
.with('https://example.com/thumb.jpg')
|
||||
.and_return(
|
||||
io: StringIO.new('thumbnail'),
|
||||
filename: 'thumbnail.jpg',
|
||||
content_type: 'image/jpeg')
|
||||
|
||||
post = described_class.new(
|
||||
actor:,
|
||||
@@ -61,8 +60,8 @@ RSpec.describe PostCreator do
|
||||
expect(post.thumbnail).to be_attached
|
||||
end
|
||||
|
||||
it 'keeps creating the post and records a warning when remote thumbnail fetch fails' do
|
||||
allow_any_instance_of(Post).to receive(:attach_thumbnail_from_url!)
|
||||
it 'does not create a post when remote thumbnail fetch fails' do
|
||||
allow(Post).to receive(:remote_thumbnail_attachment)
|
||||
.and_raise(Post::RemoteThumbnailFetchFailed, 'サムネール画像を取得できませんでした.')
|
||||
creator = described_class.new(
|
||||
actor:,
|
||||
@@ -72,11 +71,8 @@ RSpec.describe PostCreator do
|
||||
thumbnail_base: 'https://example.com/thumb.jpg',
|
||||
tags: '' })
|
||||
|
||||
post = creator.create!
|
||||
|
||||
expect(post.thumbnail_base).to eq('https://example.com/thumb.jpg')
|
||||
expect(post.thumbnail).not_to be_attached
|
||||
expect(creator.field_warnings).to eq(
|
||||
thumbnail_base: ['サムネール画像を取得できませんでした.'])
|
||||
post_count = Post.count
|
||||
expect { creator.create! }.to raise_error(Post::RemoteThumbnailFetchFailed)
|
||||
expect(Post.count).to eq(post_count)
|
||||
end
|
||||
end
|
||||
|
||||
新しい課題から参照
ユーザをブロックする