-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basics for editionable topical events
Topical Events aren't currently editionable and I'd very much like them to be
- Loading branch information
1 parent
594dbe5
commit 64badf2
Showing
13 changed files
with
137 additions
and
52 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
app/controllers/admin/editionable_topical_events_controller.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,7 @@ | ||
class Admin::EditionableTopicalEventsController < Admin::EditionsController | ||
private | ||
|
||
def edition_class | ||
EditionableTopicalEvent | ||
end | ||
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
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
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,5 @@ | ||
class EditionableTopicalEvent < Edition | ||
def display_type_key | ||
"editionable_topical_event" | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<%= form_with model: topical_event, url: [:admin, topical_event], multipart: true do |form| %> | ||
<%= render "govuk_publishing_components/components/input", { | ||
label: { | ||
text: "Name (required)", | ||
heading_size: "l", | ||
}, | ||
value: topical_event.name, | ||
name: "topical_event[name]", | ||
id: "topical_event_name", | ||
error_items: errors_for(topical_event.errors, :name), | ||
} %> | ||
|
||
<% 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
7 changes: 7 additions & 0 deletions
7
lib/whitehall/authority/rules/editionable_topical_event_rules.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,7 @@ | ||
module Whitehall::Authority::Rules | ||
EditionableTopicalEventRules = Struct.new(:actor, :subject) do | ||
def can?(_action) | ||
Flipflop.editionable_topical_events? | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FactoryBot.define do | ||
factory :editionable_topical_event, class: EditionableTopicalEvent, parent: :edition do | ||
title { "editionable-topical-event-title" } | ||
end | ||
|
||
factory :draft_editionable_topical_event, parent: :editionable_topical_event, traits: [:draft] | ||
end |
22 changes: 22 additions & 0 deletions
22
test/functional/admin/editionable_topical_events_controller_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,22 @@ | ||
require "test_helper" | ||
|
||
class Admin::EditionableTopicalEventsControllerTest < ActionController::TestCase | ||
setup do | ||
feature_flags.switch! :editionable_topical_events, true | ||
login_as :writer | ||
end | ||
|
||
should_be_an_admin_controller | ||
|
||
should_allow_creating_of :editionable_topical_event | ||
should_allow_editing_of :editionable_topical_event | ||
|
||
test "actions are forbidden when the editionable_topical_events feature flag is disabled" do | ||
feature_flags.switch! :editionable_topical_events, false | ||
topical_event = create(:editionable_topical_event) | ||
|
||
get :show, params: { id: topical_event.id } | ||
|
||
assert_response :forbidden | ||
end | ||
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