From 302502118dff17a9c937c5096c2ab8018ec1aad2 Mon Sep 17 00:00:00 2001 From: ryo Date: Tue, 1 Oct 2024 14:20:11 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Doc=E3=82=92=E5=88=9D=E5=9B=9E=E5=85=AC?= =?UTF-8?q?=E9=96=8B=E3=81=99=E3=82=8B=E6=99=82=E3=81=AE=E3=81=BF=E3=80=8C?= =?UTF-8?q?Doc=E5=85=AC=E9=96=8B=E3=80=8D=E3=80=81=E3=81=9D=E3=82=8C?= =?UTF-8?q?=E4=BB=A5=E5=A4=96=E3=81=AF=E3=80=8C=E5=86=85=E5=AE=B9=E3=82=92?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E3=80=8D=E3=81=A8=E8=A1=A8=E7=A4=BA=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=83=9C=E3=82=BF=E3=83=B3=E3=83=86?= =?UTF-8?q?=E3=82=AD=E3=82=B9=E3=83=88=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/pages/_form.html.slim | 5 ++--- test/system/notification/pages_test.rb | 2 +- test/system/pages_test.rb | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/views/pages/_form.html.slim b/app/views/pages/_form.html.slim index 089033f7904..b665396a277 100644 --- a/app/views/pages/_form.html.slim +++ b/app/views/pages/_form.html.slim @@ -75,10 +75,9 @@ i.fa-solid.fa-question = button_tag(class: 'a-button is-lg is-primary is-block') do - - case params[:action] - - when 'new', 'create' + - if page.published_at.blank? | Docを公開 - - when 'edit', 'update' + - else | 内容を更新 li.form-actions__item.is-sub - case params[:action] diff --git a/test/system/notification/pages_test.rb b/test/system/notification/pages_test.rb index 35ea8e6c774..2c66f51fd62 100644 --- a/test/system/notification/pages_test.rb +++ b/test/system/notification/pages_test.rb @@ -65,7 +65,7 @@ class Notification::PagesTest < ApplicationSystemTestCase visit_with_auth page_path(page), 'komagata' click_link '内容変更' - click_button '内容を更新' + click_button 'Docを公開' assert_text 'ドキュメントを更新しました。' visit_with_auth '/notifications', 'machida' diff --git a/test/system/pages_test.rb b/test/system/pages_test.rb index 25679f23731..1478a628a6a 100644 --- a/test/system/pages_test.rb +++ b/test/system/pages_test.rb @@ -224,7 +224,7 @@ class PagesTest < ApplicationSystemTestCase stub_info = proc { |i| mock_log << i } Rails.logger.stub(:info, stub_info) do - click_button '内容を更新' + click_button 'Docを公開' end assert_text 'ドキュメントを更新しました。' @@ -312,7 +312,7 @@ class PagesTest < ApplicationSystemTestCase click_button 'WIP' check 'ドキュメント公開のお知らせを書く', allow_label_click: true - click_button '内容を更新' + click_button 'Docを公開' assert_text 'ドキュメントを更新しました。' assert has_field?('announcement[title]', with: 'ドキュメント「お知らせにチェックを入れてWIP状態から新規Docを作成」を公開しました。') From 3c6ce5982153c1bcf5d3fd3bfa0ac2359228f030 Mon Sep 17 00:00:00 2001 From: ryo Date: Tue, 8 Oct 2024 16:38:29 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E3=83=A1=E3=83=83?= =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AE=E6=96=87=E8=A8=80=E3=82=92?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pages_controller.rb | 15 ++++++++------- test/system/notification/pages_test.rb | 2 +- test/system/pages_test.rb | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 0ce120ca80c..51f932db5f0 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -41,6 +41,7 @@ def create @page.last_updated_user = current_user @page.user ||= current_user set_wip + is_published = @page.published_at? if @page.save url = Redirection.determin_url(self, @page) if !@page.wip? @@ -50,7 +51,7 @@ def create become_watcher!(@page, [current_user, @page.user]) - redirect_to url, notice: notice_message(@page, :create) + redirect_to url, notice: notice_message(@page, is_published) else render :new end @@ -59,6 +60,7 @@ def create def update set_wip @page.last_updated_user = current_user + is_published = @page.published_at? if @page.update(page_params) url = Redirection.determin_url(self, @page) if @page.saved_change_to_attribute?(:wip, from: true, to: false) && @page.published_at.nil? @@ -68,7 +70,7 @@ def update become_watcher!(@page, [current_user, @page.user]) - redirect_to url, notice: notice_message(@page, :update) + redirect_to url, notice: notice_message(@page, is_published) else render :edit end @@ -95,14 +97,13 @@ def set_wip @page.wip = params[:commit] == 'WIP' end - def notice_message(page, action_name) + def notice_message(page, is_published) return 'ドキュメントをWIPとして保存しました。' if page.wip? - case action_name - when :create - 'ドキュメントを作成しました。' - when :update + if is_published 'ドキュメントを更新しました。' + else + 'ドキュメントを作成しました。' end end diff --git a/test/system/notification/pages_test.rb b/test/system/notification/pages_test.rb index 2c66f51fd62..5b9f180437b 100644 --- a/test/system/notification/pages_test.rb +++ b/test/system/notification/pages_test.rb @@ -66,7 +66,7 @@ class Notification::PagesTest < ApplicationSystemTestCase click_link '内容変更' click_button 'Docを公開' - assert_text 'ドキュメントを更新しました。' + assert_text 'ドキュメントを作成しました。' visit_with_auth '/notifications', 'machida' diff --git a/test/system/pages_test.rb b/test/system/pages_test.rb index 1478a628a6a..b029f63e939 100644 --- a/test/system/pages_test.rb +++ b/test/system/pages_test.rb @@ -227,7 +227,7 @@ class PagesTest < ApplicationSystemTestCase click_button 'Docを公開' end - assert_text 'ドキュメントを更新しました。' + assert_text 'ドキュメントを作成しました。' assert_match 'Message to Discord.', mock_log.to_s end @@ -314,7 +314,7 @@ class PagesTest < ApplicationSystemTestCase check 'ドキュメント公開のお知らせを書く', allow_label_click: true click_button 'Docを公開' - assert_text 'ドキュメントを更新しました。' + assert_text 'ドキュメントを作成しました。' assert has_field?('announcement[title]', with: 'ドキュメント「お知らせにチェックを入れてWIP状態から新規Docを作成」を公開しました。') assert_text '「お知らせにチェックを入れてWIP状態から新規Docを作成」の本文です。' end