-
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
There's been an RFC accepted to editionablise all the remaining content types that are currently published by Whitehall. As part of a gift week project we're attempting to do that to topical events. We're unsure as to how far we'll get and will be liasing with the Whitehall Tech team to ensure we don't do anything too silly. This sets up the core components needed for Topical events. We'll build on this until we're as close to feature pairity as we can reasonably get in a week. https://github.com/alphagov/govuk-rfcs/blob/main/rfc-177-edition-all-content.md
- Loading branch information
1 parent
b77a5bd
commit c5ebfd8
Showing
12 changed files
with
75 additions
and
0 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,3 @@ | ||
<%= standard_edition_form(edition) do |form| %> | ||
|
||
<% 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
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