diff --git a/app/views/wiki_pages/_form.html.erb b/app/views/wiki_pages/_form.html.erb index ecd190014..9d02f1458 100644 --- a/app/views/wiki_pages/_form.html.erb +++ b/app/views/wiki_pages/_form.html.erb @@ -1,10 +1,8 @@
<%= error_messages_for("wiki_page") %> - <%= simple_form_for(@wiki_page) do |f| %> - <% if @wiki_page.new_record? %> - <%= f.input :title, error: false, input_html: { data: { autocomplete: "tag" } } %> - <% elsif CurrentUser.is_builder? %> + <%= simple_form_for(@wiki_page, url: wiki_page_path(@wiki_page.id)) do |f| %> + <% if CurrentUser.is_builder? %> <%= f.input :title, error: false, input_html: { data: { autocomplete: "tag" } }, hint: "Change to rename this wiki page. Move the tag and update any wikis linking to this page first." %> <% else %>

<%= @wiki_page.pretty_title %>

@@ -26,8 +24,7 @@ <%= f.input :skip_secondary_validations, as: :boolean, label: "Force rename", hint: "Ignore the renaming requirements" %> <% end %> - <%= f.button :submit, "Submit" %> + <%= f.submit "Submit" %> <%= dtext_preview_button "wiki_page", "body" %> <% end %>
- diff --git a/app/views/wiki_pages/_secondary_links.html.erb b/app/views/wiki_pages/_secondary_links.html.erb index 66e9c61c1..f2e4aabca 100644 --- a/app/views/wiki_pages/_secondary_links.html.erb +++ b/app/views/wiki_pages/_secondary_links.html.erb @@ -14,7 +14,7 @@ <%= subnav_link_to "Posts (#{@wiki_page.tag.try(:post_count) || 0})", posts_path(:tags => @wiki_page.title) %> <%= subnav_link_to "History", wiki_page_versions_path(:search => {:wiki_page_id => @wiki_page.id}) %> <% if CurrentUser.is_member? %> - <%= subnav_link_to "Edit", edit_wiki_page_path(@wiki_page), "data-shortcut": "e" %> + <%= subnav_link_to "Edit", edit_wiki_page_path(@wiki_page.id), "data-shortcut": "e" %> <% end %> <% if CurrentUser.is_builder? && !@wiki_page.is_deleted? %> <%= subnav_link_to "Delete", wiki_page_path(@wiki_page), :remote => true, :method => :delete, :"data-shortcut" => "shift+d", :"data-confirm" => "Are you sure you want to delete this wiki page?" %> diff --git a/app/views/wiki_pages/new.html.erb b/app/views/wiki_pages/new.html.erb index 2434d0011..e6ea9a428 100644 --- a/app/views/wiki_pages/new.html.erb +++ b/app/views/wiki_pages/new.html.erb @@ -9,7 +9,16 @@ <% end %> - <%= render "form" %> + <%= error_messages_for("wiki_page") %> + + <%= simple_form_for(@wiki_page) do |f| %> + <%= f.input :title, error: false, input_html: { data: { autocomplete: "tag" } } %> + <%= f.input :other_names_string, as: :text, input_html: { size: "30x1" }, label: "Other names (#{link_to_wiki "help", "help:translated_tags"})".html_safe, hint: "Names used for this tag on other sites such as Pixiv. Separate with spaces." %> + <%= dtext_field "wiki_page", "body" %> + <%= f.submit "Submit" %> + <%= dtext_preview_button "wiki_page", "body" %> + <% end %> + <%= wiki_page_alias_and_implication_list(@wiki_page)%> <%= wiki_page_post_previews(@wiki_page) %> <% end %> diff --git a/test/system/wiki_pages_test.rb b/test/system/wiki_pages_test.rb new file mode 100644 index 000000000..21cab457d --- /dev/null +++ b/test/system/wiki_pages_test.rb @@ -0,0 +1,19 @@ +require "application_system_test_case" + +class WikiPagesTest < ApplicationSystemTestCase + context "renaming a wiki" do + should "work" do + @user = create(:user, level: User::Levels::BUILDER, created_at: 1.month.ago) + @wiki = as(@user) { create(:wiki_page, title: "kancolle") } + + signin @user + visit wiki_page_path(@wiki) + click_on "Edit" + fill_in "Title", with: "kantai_collection" + click_on "Submit" + + assert_selector "#wiki-page-title", text: "kantai collection" + assert_equal("kantai_collection", @wiki.reload.title) + end + end +end