このコミットが含まれているのは:
2026-07-18 22:18:20 +09:00
コミット a847d93d2f
9個のファイルの変更198行の追加147行の削除
+17 -4
ファイルの表示
@@ -138,7 +138,8 @@ class Post < ApplicationRecord
end
def self.section_literal section
"[#{ Post.ms_to_time(section.begin_ms) }-#{ section.end_ms ? Post.ms_to_time(section.end_ms) : '' }]"
"[#{ Post.ms_to_time(section.begin_ms) }-"\
"#{ section.end_ms ? Post.ms_to_time(section.end_ms) : '' }]"
end
def self.ms_to_time ms
@@ -323,7 +324,9 @@ class Post < ApplicationRecord
end
def self.external_svg_reference?(attribute_name, attribute_value)
return external_svg_url?(attribute_value) if ['href', 'xlink:href', 'src'].include?(attribute_name)
if ['href', 'xlink:href', 'src'].include?(attribute_name)
return external_svg_url?(attribute_value)
end
return style_contains_disallowed_urls?(attribute_value) if attribute_name == 'style'
return svg_url_function_disallowed?(attribute_value) if attribute_value.match?(/url\s*\(/i)
@@ -344,7 +347,12 @@ class Post < ApplicationRecord
def self.svg_url_function_disallowed?(value)
value.to_s.scan(/url\s*\(([^)]*)\)/i).flatten.any? do |entry|
reference = entry.to_s.strip.delete_prefix("'").delete_prefix('"').delete_suffix("'").delete_suffix('"')
reference =
entry.to_s.strip
.delete_prefix("'")
.delete_prefix('"')
.delete_suffix("'")
.delete_suffix('"')
reference.present? && !(reference.start_with?('#'))
end
end
@@ -433,7 +441,12 @@ class Post < ApplicationRecord
match =
value.match(
/\A(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?\z/)
/
\A(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})
(?::(\d{2})(?:\.(\d+))?)?
(Z|[+-]\d{2}:?\d{2})?
\z
/x)
return nil if match.nil?
year = match[1].to_i
+3 -1
ファイルの表示
@@ -85,7 +85,9 @@ class PostCreatePlan
end_raw: match[3],
tag_name: name)
end
raise Tag::SectionLiteralParseError.new(raw_name, raw_name) if name.include?('[') || name.include?(']')
if name.include?('[') || name.include?(']')
raise Tag::SectionLiteralParseError.new(raw_name, raw_name)
end
[resolved_tag_name(name), category&.to_sym, sections]
end
+11 -10
ファイルの表示
@@ -124,7 +124,7 @@ RSpec.describe 'Posts API', type: :request do
end
end
it "returns posts with tag name in JSON" do
it 'returns posts with tag name in JSON' do
get "/posts"
expect(response).to have_http_status(:ok)
@@ -161,9 +161,9 @@ RSpec.describe 'Posts API', type: :request do
])
end
context "when q is provided" do
it "filters posts by q (hit case)" do
get "/posts", params: { tags: "spec_tag" }
context 'when q is provided' do
it 'filters posts by q (hit case)' do
get '/posts', params: { tags: 'spec_tag' }
expect(response).to have_http_status(:ok)
posts = json.fetch('posts')
@@ -181,8 +181,8 @@ RSpec.describe 'Posts API', type: :request do
end
end
it "filters posts by q (hit case by alias)" do
get "/posts", params: { tags: "manko" }
it 'filters posts by q (hit case by alias)' do
get '/posts', params: { tags: 'manko' }
expect(response).to have_http_status(:ok)
posts = json.fetch('posts')
@@ -200,7 +200,7 @@ RSpec.describe 'Posts API', type: :request do
end
end
it "returns empty posts when nothing matches" do
it 'returns empty posts when nothing matches' do
get "/posts", params: { tags: "no_such_keyword_12345" }
expect(response).to have_http_status(:ok)
@@ -1161,7 +1161,7 @@ RSpec.describe 'Posts API', type: :request do
)
end
context "when nico tag already exists in tags" do
context 'when nico tag already exists in tags' do
before do
Tag.find_undiscard_or_create_by!(
tag_name: TagName.find_undiscard_or_create_by!(name: 'nico:nico_tag'),
@@ -1455,7 +1455,7 @@ RSpec.describe 'Posts API', type: :request do
)
end
context "when nico tag already exists in tags" do
context 'when nico tag already exists in tags' do
before do
Tag.find_undiscard_or_create_by!(
tag_name: TagName.find_undiscard_or_create_by!(name: 'nico:nico_tag'),
@@ -1712,7 +1712,8 @@ RSpec.describe 'Posts API', type: :request do
expect(post_record.reload.title).to eq('updated by other user')
end
it 'returns 409 with mergeable true when stale tag changes do not conflict but merge is not requested' do
it 'returns 409 with mergeable true when stale tag changes'\
' do not conflict but merge is not requested' do
sign_in_as(member)
base_version = create_post_version_for!(post_record.reload)
+6 -6
ファイルの表示
@@ -16,11 +16,11 @@ RSpec.describe "nico:sync" do
NicoTagRelation.create!(nico_tag_id: nico_tag.id, tag_id: tag.id)
end
it "既存 post を見つけて、nico tag と linked tag を追加し、差分が出たら bot を付ける" do
it '既存 post を見つけて、nico tag と linked tag を追加し、差分が出たら bot を付ける' do
# 既存 post(正規表現で拾われるURL)
post = Post.create!(
title: "old",
url: "https://www.nicovideo.jp/watch/sm9",
title: 'old',
url: 'https://www.nicovideo.jp/watch/sm9',
uploaded_user: nil
)
@@ -108,10 +108,10 @@ RSpec.describe "nico:sync" do
expect(calls).to eq(2)
end
it "既存 post にあった古い nico tag は active から外され、履歴として discard される" do
it '既存 post にあった古い nico tag は active から外され、履歴として discard される' do
post = Post.create!(
title: "old",
url: "https://www.nicovideo.jp/watch/sm9",
title: 'old',
url: 'https://www.nicovideo.jp/watch/sm9',
uploaded_user: nil
)