-
Notifications
You must be signed in to change notification settings - Fork 8
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 #1742 from alphagov/make-second-route-easier-fflag
Make it easier to find where and how to add second route
- Loading branch information
Showing
14 changed files
with
202 additions
and
69 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,5 +1,24 @@ | ||
class Pages::RoutingPageInput < BaseInput | ||
attr_accessor :routing_page_id | ||
|
||
validates :routing_page_id, presence: true | ||
validate :routing_page_id_present | ||
|
||
def initialize(attributes = {}, branch_routing_enabled: false) | ||
@branch_routing_enabled = branch_routing_enabled | ||
super(attributes) | ||
end | ||
|
||
private | ||
|
||
def blank_error_symbol | ||
if @branch_routing_enabled | ||
:blank | ||
else | ||
:branch_routing_disabled_blank | ||
end | ||
end | ||
|
||
def routing_page_id_present | ||
errors.add(:routing_page_id, blank_error_symbol) if routing_page_id.blank? | ||
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
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 |
---|---|---|
@@ -1,17 +1,29 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Pages::RoutingPageInput, type: :model do | ||
let(:routing_page_input) { described_class.new(routing_page_id:) } | ||
let(:routing_page_input) { described_class.new({ routing_page_id: }, branch_routing_enabled:) } | ||
let(:form) { build :form, :ready_for_routing, id: 1 } | ||
let(:pages) { form.pages } | ||
let(:routing_page_id) { pages.first.id } | ||
let(:branch_routing_enabled) { false } | ||
|
||
describe "validations" do | ||
it "is invalid if routing_page_id is nil" do | ||
error_message = I18n.t("activemodel.errors.models.pages/routing_page_input.attributes.routing_page_id.blank") | ||
error_message = I18n.t("activemodel.errors.models.pages/routing_page_input.attributes.routing_page_id.branch_routing_disabled_blank") | ||
routing_page_input.routing_page_id = nil | ||
expect(routing_page_input).to be_invalid | ||
expect(routing_page_input.errors.full_messages_for(:routing_page_id)).to include("Routing page #{error_message}") | ||
end | ||
|
||
context "when branch_routing_enabled is true" do | ||
let(:branch_routing_enabled) { true } | ||
|
||
it "is invalid if routing_page_id is nil" do | ||
error_message = I18n.t("activemodel.errors.models.pages/routing_page_input.attributes.routing_page_id.blank") | ||
routing_page_input.routing_page_id = nil | ||
expect(routing_page_input).to be_invalid | ||
expect(routing_page_input.errors.full_messages_for(:routing_page_id)).to include("Routing page #{error_message}") | ||
end | ||
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
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
Oops, something went wrong.