Skip to content

Commit

Permalink
Add success message on update
Browse files Browse the repository at this point in the history
  • Loading branch information
syed-ali-tw committed Sep 23, 2024
1 parent 6835f59 commit 40f01d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/controllers/editions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class EditionsController < InheritedResources::Base
include TabbedNavHelper
layout "design_system"

defaults resource_class: Edition, collection_name: "editions", instance_name: "resource"
Expand All @@ -10,6 +11,8 @@ def index

def show
@artefact = @resource.artefact

flash[:success] = "#{current_tab.humanize} has successfully updated".html_safe
render action: "show"
end

Expand Down
4 changes: 2 additions & 2 deletions app/views/editions/secondary_nav_tabs/_metadata.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
text: "Slug"
},
hint: "If you change the slug of a published page, the old slug will automatically redirect to the new one.",
name: "slug",
name: "artefact[slug]",
value: publication.slug,
heading_level: 2,
heading_size: "m"
} %>
<%= render "govuk_publishing_components/components/radio", {
heading: "Language",
name: "inline-radios",
name: "artefact[language]",
inline: true,
items: [
{
Expand Down
12 changes: 11 additions & 1 deletion test/integration/edition_edit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ class EditionEditTest < IntegrationTest
should "show slug input box prefilled" do
assert page.has_text?("Slug")
assert page.has_text?("If you change the slug of a published page, the old slug will automatically redirect to the new one.")
assert page.has_field?('slug', with: /slug/)
assert page.has_field?('artefact[slug]', with: /slug/)

Check failure on line 50 in test/integration/edition_edit_test.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://rubystyle.guide#consistent-string-literals)
end

should "update and show success message" do
fill_in "artefact[slug]", with: "changed-slug"
choose("Welsh")
click_button("Update")

assert find(".gem-c-radio input[value='cy']").checked?
assert page.has_text?("Metadata has successfully updated")
assert page.has_field?('artefact[slug]', with: "changed-slug")

Check failure on line 60 in test/integration/edition_edit_test.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://rubystyle.guide#consistent-string-literals)
end
end
end

0 comments on commit 40f01d0

Please sign in to comment.