From 293001ac9f7a4eaeff831aad6e8a7422ead856dd Mon Sep 17 00:00:00 2001 From: r74tech Date: Tue, 8 Oct 2024 16:32:24 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Added=20`force=5Fedit`=20option?= =?UTF-8?q?=20to=20page=20creation=20tests=20to=20handle=20locked=20or=20e?= =?UTF-8?q?xisting=20pages.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ensured that the `force_edit: true` option is used during page creation tests to allow forced editing in cases where pages already exist or are locked. - Modified the `SitePageMethods` context to validate that existing pages cannot be forcibly overwritten unless `force_edit` is specified. --- wikidotrb/spec/module/page_spec.rb | 12 ++++++++---- wikidotrb/spec/module/site_spec.rb | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/wikidotrb/spec/module/page_spec.rb b/wikidotrb/spec/module/page_spec.rb index 6a28395..48d7687 100644 --- a/wikidotrb/spec/module/page_spec.rb +++ b/wikidotrb/spec/module/page_spec.rb @@ -57,7 +57,8 @@ page = site.page.create( fullname: @test_page_name, title: test_page_title, - source: test_page_source + source: test_page_source, + force_edit: true ) rescue Wikidotrb::Common::Exceptions::TargetErrorException => e if e.message.include?("locked") @@ -80,7 +81,8 @@ page ||= site.page.create( fullname: @test_page_name, title: test_page_title, - source: test_page_source + source: test_page_source, + force_edit: true ) # ページを編集 @@ -100,7 +102,8 @@ site.page.create( fullname: @test_page_name, title: test_page_title, - source: test_page_source + source: test_page_source, + force_edit: true ) pages = site.pages.search( @@ -118,7 +121,8 @@ site.page.create( fullname: @test_page_name, title: test_page_title, - source: test_page_source + source: test_page_source, + force_edit: true ) page = site.page.get(@test_page_name) diff --git a/wikidotrb/spec/module/site_spec.rb b/wikidotrb/spec/module/site_spec.rb index 3a85ddd..7234ba5 100644 --- a/wikidotrb/spec/module/site_spec.rb +++ b/wikidotrb/spec/module/site_spec.rb @@ -82,7 +82,8 @@ @cached_page ||= site.page.create( fullname: new_page_fullname, title: page_title, - source: page_source + source: page_source, + force_edit: true ) expect(@cached_page.title).to eq(page_title) expect(@cached_page.source.wiki_text).to eq(page_source) @@ -93,7 +94,8 @@ @cached_page ||= site.page.create( fullname: new_page_fullname, title: page_title, - source: page_source + source: page_source, + force_edit: true ) # キャッシュされたページが存在していることを確認