-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9821 from alphagov/content-modelling/819-cancel-bug
content-modelling/819 fix cancel button for reschedule form
- Loading branch information
Showing
12 changed files
with
167 additions
and
41 deletions.
There are no files selected for viewing
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
...manager/app/components/content_block_manager/shared/cancel_and_delete_button_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class ContentBlockManager::Shared::CancelAndDeleteButtonComponent < ViewComponent::Base | ||
def initialize(url:) | ||
@url = url | ||
end | ||
|
||
private | ||
|
||
attr_reader :url | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...lock_manager/app/components/content_block_manager/shared/schedule_publishing_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class ContentBlockManager::Shared::SchedulePublishingComponent < ViewComponent::Base | ||
def initialize(content_block_edition:, params:, context:, back_link:, form_url:, is_rescheduling:) | ||
@content_block_edition = content_block_edition | ||
@params = params | ||
@context = context | ||
@back_link = back_link | ||
@form_url = form_url | ||
@is_rescheduling = is_rescheduling | ||
end | ||
|
||
private | ||
|
||
attr_reader :is_rescheduling, :content_block_edition, :params, :context, :back_link, :form_url | ||
end |
15 changes: 10 additions & 5 deletions
15
...ck_manager/app/views/content_block_manager/content_block/documents/schedule/edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
<%= render "content_block_manager/content_block/shared/schedule_publishing", { | ||
context: "Edit a content block", | ||
back_link: content_block_manager.content_block_manager_content_block_document_path(id: @content_block_edition.document.id), | ||
form_url: content_block_manager.content_block_manager_content_block_document_update_schedule_path(document_id: @content_block_edition.document.id), | ||
} %> | ||
<%= | ||
render ContentBlockManager::Shared::SchedulePublishingComponent.new( | ||
context: "Edit a content block", | ||
content_block_edition: @content_block_edition, | ||
params:, | ||
back_link: content_block_manager.content_block_manager_content_block_document_path(id: @content_block_edition.document.id), | ||
form_url: content_block_manager.content_block_manager_content_block_document_update_schedule_path(document_id: @content_block_edition.document.id), | ||
is_rescheduling: true, | ||
) | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 16 additions & 11 deletions
27
.../views/content_block_manager/content_block/editions/workflow/schedule_publishing.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
<%= render "content_block_manager/content_block/shared/schedule_publishing", { | ||
context:, | ||
back_link: content_block_manager.content_block_manager_content_block_workflow_path( | ||
edition_id: @content_block_edition.id, | ||
step: ContentBlockManager::ContentBlock::Editions::WorkflowController::UPDATE_BLOCK_STEPS[:review_links], | ||
), | ||
form_url: content_block_manager.content_block_manager_content_block_workflow_path( | ||
edition_id: @content_block_edition.id, | ||
step: ContentBlockManager::ContentBlock::Editions::WorkflowController::UPDATE_BLOCK_STEPS[:schedule_publishing], | ||
), | ||
} %> | ||
<%= | ||
render ContentBlockManager::Shared::SchedulePublishingComponent.new( | ||
content_block_edition: @content_block_edition, | ||
params:, | ||
context:, | ||
back_link: content_block_manager.content_block_manager_content_block_workflow_path( | ||
edition_id: @content_block_edition.id, | ||
step: ContentBlockManager::ContentBlock::Editions::WorkflowController::UPDATE_BLOCK_STEPS[:review_links], | ||
), | ||
form_url: content_block_manager.content_block_manager_content_block_workflow_path( | ||
edition_id: @content_block_edition.id, | ||
step: ContentBlockManager::ContentBlock::Editions::WorkflowController::UPDATE_BLOCK_STEPS[:schedule_publishing], | ||
), | ||
is_rescheduling: false, | ||
) | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
lib/engines/content_block_manager/test/components/shared/cancel_and_delete_button_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require "test_helper" | ||
|
||
class ContentBlockManager::Shared::CancelAndDeleteButtonComponentTest < ViewComponent::TestCase | ||
extend Minitest::Spec::DSL | ||
|
||
let(:url) { "/url" } | ||
|
||
let(:cancel_and_delete_component) do | ||
ContentBlockManager::Shared::CancelAndDeleteButtonComponent.new(url:) | ||
end | ||
|
||
it "renders the delete form with given url" do | ||
render_inline(cancel_and_delete_component) | ||
|
||
assert_selector "form[action='#{url}']" do | ||
assert_selector "button[value='delete']", text: "Cancel" | ||
end | ||
end | ||
end |
55 changes: 55 additions & 0 deletions
55
...ngines/content_block_manager/test/components/shared/schedule_publishing_component_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require "test_helper" | ||
|
||
class ContentBlockManager::Shared::SchedulePublishingComponentTest < ViewComponent::TestCase | ||
extend Minitest::Spec::DSL | ||
include ContentBlockManager::Engine.routes.url_helpers | ||
|
||
let(:content_block_document) { create(:content_block_document, :email_address) } | ||
let(:content_block_edition) { create(:content_block_edition, :email_address, document: content_block_document) } | ||
let(:params) { {} } | ||
let(:context) { "Some context" } | ||
let(:back_link) { "/back-link" } | ||
let(:form_url) { "/form-url" } | ||
|
||
let(:rescheduling_component) do | ||
ContentBlockManager::Shared::SchedulePublishingComponent.new( | ||
content_block_edition:, | ||
params:, | ||
context:, | ||
back_link:, | ||
form_url:, | ||
is_rescheduling: true, | ||
) | ||
end | ||
|
||
let(:component) do | ||
ContentBlockManager::Shared::SchedulePublishingComponent.new( | ||
content_block_edition:, | ||
params:, | ||
context:, | ||
back_link:, | ||
form_url:, | ||
is_rescheduling: false, | ||
) | ||
end | ||
|
||
describe "when edition is being rescheduled" do | ||
it "renders the cancel button with back link" do | ||
render_inline(rescheduling_component) | ||
|
||
assert_selector "a[href='#{back_link}']", text: "Cancel" | ||
end | ||
end | ||
|
||
describe "when edition is not being rescheduled" do | ||
it "renders the cancel button with delete form" do | ||
render_inline(component) | ||
|
||
assert_selector ".govuk-button", text: "Cancel" | ||
assert_selector "form[action='#{content_block_manager_content_block_edition_path( | ||
content_block_edition, | ||
redirect_path: content_block_manager_content_block_document_path(content_block_edition.document), | ||
)}']" | ||
end | ||
end | ||
end |