From b62f0d17391dbe6428c903121b698a4a37f799c8 Mon Sep 17 00:00:00 2001 From: siso25 Date: Sat, 30 Sep 2023 13:39:22 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=E8=A8=98=E4=BA=8B=E3=81=AE=E7=99=BB?= =?UTF-8?q?=E9=8C=B2=E6=97=A5=E6=99=82=E3=81=8C=E3=81=AA=E3=81=8F=E3=81=A6?= =?UTF-8?q?=E3=82=82=E4=BE=8B=E5=A4=96=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/external_entry.rb | 60 +++++++++---- test/models/external_entry_test.rb | 139 +++++++++++++++++++++++------ 2 files changed, 156 insertions(+), 43 deletions(-) diff --git a/app/models/external_entry.rb b/app/models/external_entry.rb index 4215f9a6aa2..cd10428bcd3 100644 --- a/app/models/external_entry.rb +++ b/app/models/external_entry.rb @@ -17,15 +17,15 @@ class << self def fetch_and_save_rss_feeds(users) threads = Concurrent::Promises.future do users.each do |user| - rss_items = ExternalEntry.parse_rss_feed(user.feed_url) + feed = ExternalEntry.parse_rss_feed(user.feed_url) - next unless rss_items + next unless feed - rss_items.each do |item| + feed.items.each do |item| case item.class.name - when 'RSS::Atom::Feed::Entry' then ExternalEntry.save_atom_feed(user, item) - when 'RSS::Rss::Channel::Item' then ExternalEntry.save_rss_feed(user, item) - when 'RSS::RDF::Item' then ExternalEntry.save_rdf_feed(user, item) + when 'RSS::Atom::Feed::Entry' then ExternalEntry.save_atom_feed(user, item, feed.channel&.dc_date) + when 'RSS::Rss::Channel::Item' then ExternalEntry.save_rss_feed(user, item, feed.channel&.lastBuildDate) + when 'RSS::RDF::Item' then ExternalEntry.save_rdf_feed(user, item, feed.updated&.content) end end end @@ -38,14 +38,14 @@ def parse_rss_feed(feed_url) return nil if feed_url.blank? begin - RSS::Parser.parse(feed_url).items + RSS::Parser.parse(feed_url) rescue StandardError => e logger.warn("[RSS Feed] #{feed_url}: #{e.message}") nil end end - def save_rdf_feed(user, rdf_item) + def save_rdf_feed(user, rdf_item, feed_updated) return if ExternalEntry.find_by(url: rdf_item.link) ExternalEntry.create( @@ -53,12 +53,12 @@ def save_rdf_feed(user, rdf_item) url: rdf_item.link, summary: rdf_item.description, thumbnail_image_url: nil, - published_at: rdf_item.dc_date, + published_at: rdf_publish_date(rdf_item, feed_updated), user: ) end - def save_rss_feed(user, rss_item) + def save_rss_feed(user, rss_item, feed_updated) return if ExternalEntry.find_by(url: rss_item.link) ExternalEntry.create( @@ -66,22 +66,46 @@ def save_rss_feed(user, rss_item) url: rss_item.link, summary: rss_item.description, thumbnail_image_url: rss_item.enclosure&.url, - published_at: rss_item.pubDate, + published_at: rss_publish_date(rss_item, feed_updated), user: ) end - def save_atom_feed(user, atom_item) - return if ExternalEntry.find_by(url: atom_item.link.href) + def save_atom_feed(user, atom_item, feed_updated) + return if ExternalEntry.find_by(url: atom_item.link&.href) ExternalEntry.create( - title: atom_item.title.content, - url: atom_item.link.href, - summary: atom_item.content.content, - thumbnail_image_url: atom_item.links.find { |link| !link.type.nil? && link.type.include?('image') }&.href, - published_at: atom_item.published.content, + title: atom_item.title&.content, + url: atom_item.link&.href, + summary: atom_item.content&.content, + thumbnail_image_url: atom_item.links&.find { |link| !link.type.nil? && link.type.include?('image') }&.href, + published_at: atom_publish_date(atom_item, feed_updated), user: ) end + + private + + def rdf_publish_date(rdf_item, feed_updated) + return rdf_item.dc_date if rdf_item.dc_date + return feed_updated if feed_updated + + Time.zone.today + end + + def rss_publish_date(rss_item, feed_updated) + return rss_item.pubDate if rss_item.pubDate + return feed_updated if feed_updated + + Time.zone.today + end + + def atom_publish_date(atom_item, feed_updated) + return atom_item.published.content if atom_item.published + return atom_item.updated.content if atom_item.updated + return feed_updated if feed_updated + + Time.zone.today + end end end diff --git a/test/models/external_entry_test.rb b/test/models/external_entry_test.rb index c8d50685279..7a23ff4325e 100644 --- a/test/models/external_entry_test.rb +++ b/test/models/external_entry_test.rb @@ -32,8 +32,33 @@ class ExternalEntryTest < ActiveSupport::TestCase rdf_item.expect(:link, 'https://test.com/index.rdf') rdf_item.expect(:description, 'article description') rdf_item.expect(:dc_date, Time.zone.local(2022, 1, 1, 0, 0, 0)) + rdf_item.expect(:dc_date, Time.zone.local(2022, 1, 1, 0, 0, 0)) + + assert ExternalEntry.save_rdf_feed(user, rdf_item, nil) + end + + test 'save rdf feed with no article publish date' do + user = users(:hatsuno) + rdf_item = Minitest::Mock.new + rdf_item.expect(:link, 'https://test.com/index.rdf') + rdf_item.expect(:title, 'test title') + rdf_item.expect(:link, 'https://test.com/index.rdf') + rdf_item.expect(:description, 'article description') + rdf_item.expect(:dc_date, nil) - assert ExternalEntry.save_rdf_feed(user, rdf_item) + assert ExternalEntry.save_rdf_feed(user, rdf_item, nil) + end + + test 'no exception even if all rdf elements are nil' do + user = users(:hatsuno) + rdf_item = Minitest::Mock.new + rdf_item.expect(:link, nil) + rdf_item.expect(:title, nil) + rdf_item.expect(:link, nil) + rdf_item.expect(:description, nil) + rdf_item.expect(:dc_date, nil) + + assert ExternalEntry.save_rdf_feed(user, rdf_item, nil) end test '.save_rss_feed' do @@ -46,8 +71,35 @@ class ExternalEntryTest < ActiveSupport::TestCase rss_item.expect(:enclosure, rss_item) rss_item.expect(:url, 'https://test.com/image.png') rss_item.expect(:pubDate, Time.zone.local(2022, 1, 1, 0, 0, 0)) + rss_item.expect(:pubDate, Time.zone.local(2022, 1, 1, 0, 0, 0)) - assert ExternalEntry.save_rss_feed(user, rss_item) + assert ExternalEntry.save_rss_feed(user, rss_item, nil) + end + + test 'save rss feed with no article publish date' do + user = users(:hatsuno) + rss_item = Minitest::Mock.new + rss_item.expect(:link, 'https://test.com/rss') + rss_item.expect(:title, 'test title') + rss_item.expect(:link, 'https://test.com/rss') + rss_item.expect(:description, 'article description') + rss_item.expect(:enclosure, nil) + rss_item.expect(:pubDate, nil) + + assert ExternalEntry.save_rss_feed(user, rss_item, Time.zone.local(2023, 1, 1, 0, 0, 0)) + end + + test 'no exception even if all rss elements are nil' do + user = users(:hatsuno) + rss_item = Minitest::Mock.new + rss_item.expect(:link, nil) + rss_item.expect(:title, nil) + rss_item.expect(:link, nil) + rss_item.expect(:description, nil) + rss_item.expect(:enclosure, nil) + rss_item.expect(:pubDate, nil) + + assert ExternalEntry.save_rss_feed(user, rss_item, nil) end test '.save_atom_feed' do @@ -66,33 +118,70 @@ class ExternalEntryTest < ActiveSupport::TestCase atom_item.expect(:nil?, atom_item) atom_item.expect(:href, 'https://test.com/image.png') atom_item.expect(:published, atom_item) + atom_item.expect(:published, atom_item) atom_item.expect(:content, Time.zone.local(2022, 1, 1, 0, 0, 0)) - assert ExternalEntry.save_atom_feed(user, atom_item) + assert ExternalEntry.save_atom_feed(user, atom_item, nil) end - test '.fetch_and_save_rss_feeds' do - users = [users(:kimura), users(:hatsuno), users(:komagata)] - - assert_difference 'ExternalEntry.count', 56 do - VCR.use_cassette 'external_entry/fetch3', vcr_options do - VCR.use_cassette 'external_entry/fetch2', vcr_options do - VCR.use_cassette 'external_entry/fetch' do - ExternalEntry.fetch_and_save_rss_feeds(users) - end - end - end - end + test 'save atom feed with no article publish date' do + user = users(:hatsuno) + atom_item = Minitest::Mock.new + atom_item.expect(:link, atom_item) + atom_item.expect(:href, 'https://test.com/feed') + atom_item.expect(:title, atom_item) + atom_item.expect(:content, 'test title') + atom_item.expect(:link, atom_item) + atom_item.expect(:href, 'https://test.com/feed') + atom_item.expect(:content, atom_item) + atom_item.expect(:content, 'article description') + atom_item.expect(:links, atom_item) + atom_item.expect(:find, atom_item) + atom_item.expect(:nil?, atom_item) + atom_item.expect(:href, 'https://test.com/image.png') + atom_item.expect(:published, nil) + atom_item.expect(:updated, nil) - assert_no_difference 'ExternalEntry.count' do - # 同じ記事は重複して保存しない - VCR.use_cassette 'external_entry/fetch3', vcr_options do - VCR.use_cassette 'external_entry/fetch2', vcr_options do - VCR.use_cassette 'external_entry/fetch' do - ExternalEntry.fetch_and_save_rss_feeds(users) - end - end - end - end + assert ExternalEntry.save_atom_feed(user, atom_item, Time.zone.local(2023, 1, 1, 0, 0, 0)) end + + test 'no exception even if all atom elements are nil' do + user = users(:hatsuno) + atom_item = Minitest::Mock.new + atom_item.expect(:link, nil) + atom_item.expect(:title, nil) + atom_item.expect(:content, nil) + atom_item.expect(:link, nil) + atom_item.expect(:content, nil) + atom_item.expect(:links, nil) + atom_item.expect(:published, nil) + atom_item.expect(:updated, nil) + + assert ExternalEntry.save_atom_feed(user, atom_item, nil) + end + + # test '.fetch_and_save_rss_feeds' do + # users = [users(:kimura), users(:hatsuno), users(:komagata)] + # + # assert_difference 'ExternalEntry.count', 56 do + # VCR.use_cassette 'external_entry/fetch3', vcr_options do + # VCR.use_cassette 'external_entry/fetch2', vcr_options do + # VCR.use_cassette 'external_entry/fetch' do + # ExternalEntry.fetch_and_save_rss_feeds(users) + # end + # end + # end + # end + # + # assert_no_difference 'ExternalEntry.count' do + # # 同じ記事は重複して保存しない + # VCR.use_cassette 'external_entry/fetch3', vcr_options do + # VCR.use_cassette 'external_entry/fetch2', vcr_options do + # VCR.use_cassette 'external_entry/fetch' do + # ExternalEntry.fetch_and_save_rss_feeds(users) + # end + # end + # end + # end + # end end From 560dd49301f2099568db48884c6e296418a9208f Mon Sep 17 00:00:00 2001 From: siso25 Date: Sat, 30 Sep 2023 13:49:54 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=BC=E3=83=89?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=A5=E3=81=A8=E3=81=97=E3=81=A6=E6=B8=A1?= =?UTF-8?q?=E3=81=99=E5=80=A4=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/external_entry.rb | 4 +-- test/models/external_entry_test.rb | 48 +++++++++++++++--------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/app/models/external_entry.rb b/app/models/external_entry.rb index cd10428bcd3..02b89b53e45 100644 --- a/app/models/external_entry.rb +++ b/app/models/external_entry.rb @@ -23,9 +23,9 @@ def fetch_and_save_rss_feeds(users) feed.items.each do |item| case item.class.name - when 'RSS::Atom::Feed::Entry' then ExternalEntry.save_atom_feed(user, item, feed.channel&.dc_date) + when 'RSS::Atom::Feed::Entry' then ExternalEntry.save_atom_feed(user, item, feed.updated&.content) when 'RSS::Rss::Channel::Item' then ExternalEntry.save_rss_feed(user, item, feed.channel&.lastBuildDate) - when 'RSS::RDF::Item' then ExternalEntry.save_rdf_feed(user, item, feed.updated&.content) + when 'RSS::RDF::Item' then ExternalEntry.save_rdf_feed(user, item, feed.channel&.dc_date) end end end diff --git a/test/models/external_entry_test.rb b/test/models/external_entry_test.rb index 7a23ff4325e..39e79a90e88 100644 --- a/test/models/external_entry_test.rb +++ b/test/models/external_entry_test.rb @@ -160,28 +160,28 @@ class ExternalEntryTest < ActiveSupport::TestCase assert ExternalEntry.save_atom_feed(user, atom_item, nil) end - # test '.fetch_and_save_rss_feeds' do - # users = [users(:kimura), users(:hatsuno), users(:komagata)] - # - # assert_difference 'ExternalEntry.count', 56 do - # VCR.use_cassette 'external_entry/fetch3', vcr_options do - # VCR.use_cassette 'external_entry/fetch2', vcr_options do - # VCR.use_cassette 'external_entry/fetch' do - # ExternalEntry.fetch_and_save_rss_feeds(users) - # end - # end - # end - # end - # - # assert_no_difference 'ExternalEntry.count' do - # # 同じ記事は重複して保存しない - # VCR.use_cassette 'external_entry/fetch3', vcr_options do - # VCR.use_cassette 'external_entry/fetch2', vcr_options do - # VCR.use_cassette 'external_entry/fetch' do - # ExternalEntry.fetch_and_save_rss_feeds(users) - # end - # end - # end - # end - # end + test '.fetch_and_save_rss_feeds' do + users = [users(:kimura), users(:hatsuno), users(:komagata)] + + assert_difference 'ExternalEntry.count', 56 do + VCR.use_cassette 'external_entry/fetch3', vcr_options do + VCR.use_cassette 'external_entry/fetch2', vcr_options do + VCR.use_cassette 'external_entry/fetch' do + ExternalEntry.fetch_and_save_rss_feeds(users) + end + end + end + end + + assert_no_difference 'ExternalEntry.count' do + # 同じ記事は重複して保存しない + VCR.use_cassette 'external_entry/fetch3', vcr_options do + VCR.use_cassette 'external_entry/fetch2', vcr_options do + VCR.use_cassette 'external_entry/fetch' do + ExternalEntry.fetch_and_save_rss_feeds(users) + end + end + end + end + end end From b1e9b36616348ed25746fef4537f43d731899ded Mon Sep 17 00:00:00 2001 From: siso25 Date: Sat, 30 Sep 2023 13:58:10 +0900 Subject: [PATCH 3/5] =?UTF-8?q?rubocop=E3=81=AE=E6=8C=87=E6=91=98=E4=BA=8B?= =?UTF-8?q?=E9=A0=85=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 複雑度が高かったため、Atomフィードの画像URL取得処理をメソッドに切り出し --- app/models/external_entry.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/external_entry.rb b/app/models/external_entry.rb index 02b89b53e45..a5e64a5dec0 100644 --- a/app/models/external_entry.rb +++ b/app/models/external_entry.rb @@ -78,7 +78,7 @@ def save_atom_feed(user, atom_item, feed_updated) title: atom_item.title&.content, url: atom_item.link&.href, summary: atom_item.content&.content, - thumbnail_image_url: atom_item.links&.find { |link| !link.type.nil? && link.type.include?('image') }&.href, + thumbnail_image_url: atom_image_url(atom_item), published_at: atom_publish_date(atom_item, feed_updated), user: ) @@ -100,6 +100,10 @@ def rss_publish_date(rss_item, feed_updated) Time.zone.today end + def atom_image_url(atom_item) + atom_item.links&.find { |link| !link.type.nil? && link.type.include?('image') }&.href + end + def atom_publish_date(atom_item, feed_updated) return atom_item.published.content if atom_item.published return atom_item.updated.content if atom_item.updated From b053570a5c59448ee6c2c3f06a5f7411c25fb50e Mon Sep 17 00:00:00 2001 From: siso25 Date: Mon, 2 Oct 2023 20:40:00 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=A0=E3=82=BE?= =?UTF-8?q?=E3=83=BC=E3=83=B3=E3=81=AB=E5=8D=94=E5=AE=9A=E4=B8=96=E7=95=8C?= =?UTF-8?q?=E6=99=82=E3=81=8C=E8=A8=AD=E5=AE=9A=E3=81=95=E3=82=8C=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=AE=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit タイムゾーンに協定世界時が設定されていたら、アプリデフォルトのタイムゾーンを 設定して登録するように修正。 --- app/models/external_entry.rb | 15 +++++++++------ test/models/external_entry_test.rb | 28 ++++++++++++++-------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/app/models/external_entry.rb b/app/models/external_entry.rb index a5e64a5dec0..9c5addefa3b 100644 --- a/app/models/external_entry.rb +++ b/app/models/external_entry.rb @@ -48,12 +48,13 @@ def parse_rss_feed(feed_url) def save_rdf_feed(user, rdf_item, feed_updated) return if ExternalEntry.find_by(url: rdf_item.link) + published_at = rdf_publish_date(rdf_item, feed_updated) ExternalEntry.create( title: rdf_item.title, url: rdf_item.link, summary: rdf_item.description, thumbnail_image_url: nil, - published_at: rdf_publish_date(rdf_item, feed_updated), + published_at: published_at.utc? ? Time.zone.parse(published_at.to_s) : published_at, user: ) end @@ -61,12 +62,13 @@ def save_rdf_feed(user, rdf_item, feed_updated) def save_rss_feed(user, rss_item, feed_updated) return if ExternalEntry.find_by(url: rss_item.link) + published_at = rss_publish_date(rss_item, feed_updated) ExternalEntry.create( title: rss_item.title, url: rss_item.link, summary: rss_item.description, thumbnail_image_url: rss_item.enclosure&.url, - published_at: rss_publish_date(rss_item, feed_updated), + published_at: published_at.utc? ? Time.zone.parse(published_at.to_s) : published_at, user: ) end @@ -74,12 +76,13 @@ def save_rss_feed(user, rss_item, feed_updated) def save_atom_feed(user, atom_item, feed_updated) return if ExternalEntry.find_by(url: atom_item.link&.href) + published_at = atom_publish_date(atom_item, feed_updated) ExternalEntry.create( title: atom_item.title&.content, url: atom_item.link&.href, summary: atom_item.content&.content, thumbnail_image_url: atom_image_url(atom_item), - published_at: atom_publish_date(atom_item, feed_updated), + published_at: published_at.utc? ? Time.zone.parse(published_at.to_s) : published_at, user: ) end @@ -90,14 +93,14 @@ def rdf_publish_date(rdf_item, feed_updated) return rdf_item.dc_date if rdf_item.dc_date return feed_updated if feed_updated - Time.zone.today + Time.zone.now end def rss_publish_date(rss_item, feed_updated) return rss_item.pubDate if rss_item.pubDate return feed_updated if feed_updated - Time.zone.today + Time.zone.now end def atom_image_url(atom_item) @@ -109,7 +112,7 @@ def atom_publish_date(atom_item, feed_updated) return atom_item.updated.content if atom_item.updated return feed_updated if feed_updated - Time.zone.today + Time.zone.now end end end diff --git a/test/models/external_entry_test.rb b/test/models/external_entry_test.rb index 39e79a90e88..40c218368e3 100644 --- a/test/models/external_entry_test.rb +++ b/test/models/external_entry_test.rb @@ -58,20 +58,20 @@ class ExternalEntryTest < ActiveSupport::TestCase rdf_item.expect(:description, nil) rdf_item.expect(:dc_date, nil) - assert ExternalEntry.save_rdf_feed(user, rdf_item, nil) + assert ExternalEntry.save_rdf_feed(user, rdf_item, Time.zone.local(2023, 1, 1, 0, 0, 0).utc) end test '.save_rss_feed' do user = users(:hatsuno) rss_item = Minitest::Mock.new rss_item.expect(:link, 'https://test.com/rss') + rss_item.expect(:pubDate, Time.zone.local(2022, 1, 1, 0, 0, 0)) + rss_item.expect(:pubDate, Time.zone.local(2022, 1, 1, 0, 0, 0)) rss_item.expect(:title, 'test title') rss_item.expect(:link, 'https://test.com/rss') rss_item.expect(:description, 'article description') rss_item.expect(:enclosure, rss_item) rss_item.expect(:url, 'https://test.com/image.png') - rss_item.expect(:pubDate, Time.zone.local(2022, 1, 1, 0, 0, 0)) - rss_item.expect(:pubDate, Time.zone.local(2022, 1, 1, 0, 0, 0)) assert ExternalEntry.save_rss_feed(user, rss_item, nil) end @@ -80,24 +80,24 @@ class ExternalEntryTest < ActiveSupport::TestCase user = users(:hatsuno) rss_item = Minitest::Mock.new rss_item.expect(:link, 'https://test.com/rss') + rss_item.expect(:pubDate, nil) rss_item.expect(:title, 'test title') rss_item.expect(:link, 'https://test.com/rss') rss_item.expect(:description, 'article description') rss_item.expect(:enclosure, nil) - rss_item.expect(:pubDate, nil) - assert ExternalEntry.save_rss_feed(user, rss_item, Time.zone.local(2023, 1, 1, 0, 0, 0)) + assert ExternalEntry.save_rss_feed(user, rss_item, Time.zone.local(2023, 1, 1, 0, 0, 0).utc) end test 'no exception even if all rss elements are nil' do user = users(:hatsuno) rss_item = Minitest::Mock.new rss_item.expect(:link, nil) + rss_item.expect(:pubDate, nil) rss_item.expect(:title, nil) rss_item.expect(:link, nil) rss_item.expect(:description, nil) rss_item.expect(:enclosure, nil) - rss_item.expect(:pubDate, nil) assert ExternalEntry.save_rss_feed(user, rss_item, nil) end @@ -107,6 +107,9 @@ class ExternalEntryTest < ActiveSupport::TestCase atom_item = Minitest::Mock.new atom_item.expect(:link, atom_item) atom_item.expect(:href, 'https://test.com/feed') + atom_item.expect(:published, atom_item) + atom_item.expect(:published, atom_item) + atom_item.expect(:content, Time.zone.local(2022, 1, 1, 0, 0, 0)) atom_item.expect(:title, atom_item) atom_item.expect(:content, 'test title') atom_item.expect(:link, atom_item) @@ -117,9 +120,6 @@ class ExternalEntryTest < ActiveSupport::TestCase atom_item.expect(:find, atom_item) atom_item.expect(:nil?, atom_item) atom_item.expect(:href, 'https://test.com/image.png') - atom_item.expect(:published, atom_item) - atom_item.expect(:published, atom_item) - atom_item.expect(:content, Time.zone.local(2022, 1, 1, 0, 0, 0)) assert ExternalEntry.save_atom_feed(user, atom_item, nil) end @@ -129,6 +129,8 @@ class ExternalEntryTest < ActiveSupport::TestCase atom_item = Minitest::Mock.new atom_item.expect(:link, atom_item) atom_item.expect(:href, 'https://test.com/feed') + atom_item.expect(:published, nil) + atom_item.expect(:updated, nil) atom_item.expect(:title, atom_item) atom_item.expect(:content, 'test title') atom_item.expect(:link, atom_item) @@ -139,23 +141,21 @@ class ExternalEntryTest < ActiveSupport::TestCase atom_item.expect(:find, atom_item) atom_item.expect(:nil?, atom_item) atom_item.expect(:href, 'https://test.com/image.png') - atom_item.expect(:published, nil) - atom_item.expect(:updated, nil) - assert ExternalEntry.save_atom_feed(user, atom_item, Time.zone.local(2023, 1, 1, 0, 0, 0)) + assert ExternalEntry.save_atom_feed(user, atom_item, Time.zone.local(2023, 1, 1, 0, 0, 0).utc) end test 'no exception even if all atom elements are nil' do user = users(:hatsuno) atom_item = Minitest::Mock.new atom_item.expect(:link, nil) + atom_item.expect(:published, nil) + atom_item.expect(:updated, nil) atom_item.expect(:title, nil) atom_item.expect(:content, nil) atom_item.expect(:link, nil) atom_item.expect(:content, nil) atom_item.expect(:links, nil) - atom_item.expect(:published, nil) - atom_item.expect(:updated, nil) assert ExternalEntry.save_atom_feed(user, atom_item, nil) end From b87df791516a6fa5e15bc57d36f220456a2f92bb Mon Sep 17 00:00:00 2001 From: siso25 Date: Sun, 22 Oct 2023 21:52:42 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E5=90=8D?= =?UTF-8?q?=E3=82=92=E3=83=86=E3=82=B9=E3=83=88=E5=AF=BE=E8=B1=A1=E3=81=8C?= =?UTF-8?q?=E5=88=86=E3=81=8B=E3=82=8B=E5=90=8D=E7=A7=B0=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/external_entry_test.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/models/external_entry_test.rb b/test/models/external_entry_test.rb index 40c218368e3..3809e44f51e 100644 --- a/test/models/external_entry_test.rb +++ b/test/models/external_entry_test.rb @@ -37,7 +37,7 @@ class ExternalEntryTest < ActiveSupport::TestCase assert ExternalEntry.save_rdf_feed(user, rdf_item, nil) end - test 'save rdf feed with no article publish date' do + test '.save_rdf_feed with no article publish date' do user = users(:hatsuno) rdf_item = Minitest::Mock.new rdf_item.expect(:link, 'https://test.com/index.rdf') @@ -49,7 +49,7 @@ class ExternalEntryTest < ActiveSupport::TestCase assert ExternalEntry.save_rdf_feed(user, rdf_item, nil) end - test 'no exception even if all rdf elements are nil' do + test '.save_rdf_feed no exception even if all rdf elements are nil' do user = users(:hatsuno) rdf_item = Minitest::Mock.new rdf_item.expect(:link, nil) @@ -76,7 +76,7 @@ class ExternalEntryTest < ActiveSupport::TestCase assert ExternalEntry.save_rss_feed(user, rss_item, nil) end - test 'save rss feed with no article publish date' do + test '.save_rss_feed with no article publish date' do user = users(:hatsuno) rss_item = Minitest::Mock.new rss_item.expect(:link, 'https://test.com/rss') @@ -89,7 +89,7 @@ class ExternalEntryTest < ActiveSupport::TestCase assert ExternalEntry.save_rss_feed(user, rss_item, Time.zone.local(2023, 1, 1, 0, 0, 0).utc) end - test 'no exception even if all rss elements are nil' do + test '.save_rss_feed no exception even if all rss elements are nil' do user = users(:hatsuno) rss_item = Minitest::Mock.new rss_item.expect(:link, nil) @@ -124,7 +124,7 @@ class ExternalEntryTest < ActiveSupport::TestCase assert ExternalEntry.save_atom_feed(user, atom_item, nil) end - test 'save atom feed with no article publish date' do + test '.save_atom_feed with no article publish date' do user = users(:hatsuno) atom_item = Minitest::Mock.new atom_item.expect(:link, atom_item) @@ -145,7 +145,7 @@ class ExternalEntryTest < ActiveSupport::TestCase assert ExternalEntry.save_atom_feed(user, atom_item, Time.zone.local(2023, 1, 1, 0, 0, 0).utc) end - test 'no exception even if all atom elements are nil' do + test '.save_atom_feed no exception even if all atom elements are nil' do user = users(:hatsuno) atom_item = Minitest::Mock.new atom_item.expect(:link, nil)