Skip to content

Commit

Permalink
🐛 Added force_edit option to page creation tests to handle locked o…
Browse files Browse the repository at this point in the history
…r existing pages.

- 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.
  • Loading branch information
r74tech committed Oct 8, 2024
1 parent 07d28e0 commit 293001a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions wikidotrb/spec/module/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
)

# ページを編集
Expand All @@ -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(
Expand All @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions wikidotrb/spec/module/site_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
)

# キャッシュされたページが存在していることを確認
Expand Down

0 comments on commit 293001a

Please sign in to comment.