Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert commit #2349

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ $govuk-page-width: 1140px;
@import 'govuk_publishing_components/components/lead-paragraph';
@import 'govuk_publishing_components/components/notice';
@import 'govuk_publishing_components/components/previous-and-next-navigation';
@import 'govuk_publishing_components/components/radio';
@import 'govuk_publishing_components/components/search';
@import 'govuk_publishing_components/components/secondary-navigation';
@import 'govuk_publishing_components/components/select';
Expand Down
11 changes: 1 addition & 10 deletions app/controllers/artefacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,17 @@ def update
artefact = Artefact.find(updatable_params[:id])
if artefact.update_as(current_user, updatable_params)
UpdateWorker.perform_async(artefact.latest_edition_id)
show_success_message
flash[:notice] = "Metadata updated"
else
flash[:danger] = artefact.errors.full_messages.join("\n")
end

redirect_to metadata_artefact_path(artefact)
end

helper_method :formats

private

def show_success_message
if Flipflop.enabled?("design_system_edit".to_sym)
flash[:success] = "Metadata has successfully updated".html_safe
else
flash[:notice] = "Metadata updated"
end
end

def formats
Artefact::FORMATS_BY_DEFAULT_OWNING_APP["publisher"] - Artefact::RETIRED_FORMATS
end
Expand Down
22 changes: 6 additions & 16 deletions app/controllers/editions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
require "edition_duplicator"
require "edition_progressor"

class EditionsController < InheritedResources::Base
include TabbedNavHelper
layout "design_system"

defaults resource_class: Edition, collection_name: "editions", instance_name: "resource"
before_action :setup_view_paths, except: %i[index]

helper_method :locale_to_language

def index
redirect_to root_path
end

def show
@artefact = @resource.artefact

render action: "show"
end

alias_method :metadata, :show
def metadata
render action: "show"
end

def history
render action: "show"
Expand Down Expand Up @@ -47,15 +48,4 @@ def setup_view_paths_for(publication)
prepend_view_path "app/views/editions"
prepend_view_path template_folder_for(publication)
end

def locale_to_language(locale)
case locale
when "en"
"English"
when "cy"
"Welsh"
else
""
end
end
end
14 changes: 2 additions & 12 deletions app/helpers/tabbed_nav_helper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module TabbedNavHelper
def edition_nav_items(edition)
nav_items = []
items = %w[edit tagging metadata history admin related_external_links unpublish]

all_tab_names.each do |item|
items.each do |item|
nav_items << standard_nav_items(item, edition)
end

Expand All @@ -28,15 +29,4 @@ def edit_nav_item(label, href, current)
},
]
end

def current_tab_name
current_tab = (request.path.split("/") & all_tab_names).first
current_tab == "metadata" ? "metadata" : "temp_nav_text"
end

private

def all_tab_names
%w[edit tagging metadata history admin related_external_links unpublish]
end
end
57 changes: 0 additions & 57 deletions app/views/editions/secondary_nav_tabs/_metadata.html.erb

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions app/views/editions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,4 @@
<div class="govuk-grid-column-full">
<%= render partial: "secondary_navigation" %>
</div>

<div class="govuk-grid-column-two-thirds">
<%= render partial: "secondary_nav_tabs/#{current_tab_name}", :locals => { :publication => @resource } %>
</div>
</div>
21 changes: 2 additions & 19 deletions test/functional/editions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class EditionsControllerTest < ActionController::TestCase

context "#show" do
setup do
artefact = FactoryBot.create(
artefact2 = FactoryBot.create(
:artefact,
slug: "test2",
kind: "guide",
name: "test",
owning_app: "publisher",
)
@guide = GuideEdition.create!(title: "test", slug: "test2", panopticon_id: artefact.id)
@guide = GuideEdition.create!(title: "test", slug: "test2", panopticon_id: artefact2.id)
end

should "requesting a publication that doesn't exist returns a 404" do
Expand All @@ -47,21 +47,4 @@ class EditionsControllerTest < ActionController::TestCase
assert_not_nil assigns(:resource)
end
end

context "#metadata" do
setup do
artefact = FactoryBot.create(
:artefact,
slug: "test2",
kind: "guide",
name: "test",
owning_app: "publisher",
)
@guide = GuideEdition.create!(title: "test", slug: "test2", panopticon_id: artefact.id)
end

should "alias to show method" do
assert_equal EditionsController.new.method(:metadata).super_method.name, :show
end
end
end
2 changes: 0 additions & 2 deletions test/integration/edit_artefact_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ class EditArtefactTest < LegacyIntegrationTest
setup_users
stub_linkables
stub_holidays_used_by_fact_check
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:design_system_edit, false)
end

should "edit a draft artefact" do
Expand Down
107 changes: 24 additions & 83 deletions test/integration/edition_edit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,90 +8,31 @@ class EditionEditTest < IntegrationTest
stub_linkables
end

context "when edition is draft" do
setup do
edition = FactoryBot.create(:guide_edition, title: "Edit page title", state: "draft")
visit edition_path(edition)
end

should "show document summary and title" do
assert page.has_title?("Edit page title")

row = find_all(".govuk-summary-list__row")
assert row[0].has_content?("Assigned to")
assert row[1].has_text?("Content type")
assert row[1].has_text?("Guide")
assert row[2].has_text?("Edition")
assert row[2].has_text?("1")
assert row[2].has_text?("Draft")
end

should "show all the tabs for the edit" do
assert page.has_text?("Edit")
assert page.has_text?("Tagging")
assert page.has_text?("Metadata")
assert page.has_text?("History and notes")
assert page.has_text?("Admin")
assert page.has_text?("Related external links")
assert page.has_text?("Unpublish")
end

context "metadata tab" do
setup do
click_link("Metadata")
end

should "show 'Metadata' header and an update button" do
within :css, ".gem-c-heading" do
assert page.has_text?("Metadata")
end
assert page.has_button?("Update")
end

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?("artefact[slug]", with: /slug/)
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")
end
end
should "show document summary and title" do
edition = FactoryBot.create(:guide_edition, title: "Edit page title", state: "draft")
visit edition_path(edition)

assert page.has_title?("Edit page title")

row = find_all(".govuk-summary-list__row")
assert row[0].has_content?("Assigned to")
assert row[1].has_text?("Content type")
assert row[1].has_text?("Guide")
assert row[2].has_text?("Edition")
assert row[2].has_text?("1")
assert row[2].has_text?("Draft")
end

context "when edition is published" do
context "metadata tab" do
setup do
edition = FactoryBot.create(
:completed_transaction_edition,
panopticon_id: FactoryBot.create(
:artefact,
slug: "can-i-get-a-driving-licence",
).id,
state: "published",
slug: "can-i-get-a-driving-licence",
)

visit edition_path(edition)
click_link("Metadata")
end

should "show un-editable current value for slug and language" do
assert page.has_no_field?("artefact[slug]")
assert page.has_no_field?("artefact[language]")

assert page.has_text?("Slug")
assert page.has_text?(/can-i-get-a-driving-licence/)
assert page.has_text?("Language")
assert page.has_text?(/English/)
end
end
should "show all the tabs for the edit" do
edition = FactoryBot.create(:guide_edition, title: "Edit page title", state: "draft")
visit edition_path(edition)

assert page.has_text?("Edit")
assert page.has_text?("Tagging")
assert page.has_text?("Metadata")
assert page.has_text?("History and notes")
assert page.has_text?("Admin")
assert page.has_text?("Related external links")
assert page.has_text?("Unpublish")
end
end
Loading