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

Remove support for temporary redirects #656

Merged
merged 1 commit into from
Sep 4, 2024
Merged
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
2 changes: 2 additions & 0 deletions app/controllers/routes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def show
def update
route_details = @request_data[:route]
incoming_path = route_details.delete(:incoming_path)
# TODO: remove this once gds-api-adapters no longer send this attribute
route_details.delete("redirect_type")
tries = 3
begin
@route = Route.find_or_initialize_by(incoming_path:)
Expand Down
4 changes: 1 addition & 3 deletions app/models/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Route
field :handler, type: String
field :backend_id, type: String
field :redirect_to, type: String
field :redirect_type, type: String
field :segments_mode, type: String

index({ incoming_path: 1 }, unique: true)
Expand All @@ -30,7 +29,6 @@ class Route
with_options if: :redirect? do
validates :redirect_to, presence: true
validate :validate_redirect_to
validates :redirect_type, inclusion: { in: %w[permanent temporary] }
validates :segments_mode, inclusion: { in: %w[ignore preserve] }
end

Expand Down Expand Up @@ -61,7 +59,7 @@ def soft_delete
if has_parent_prefix_routes?
destroy!
else
update!(handler: "gone", backend_id: nil, redirect_to: nil, redirect_type: nil)
update!(handler: "gone", backend_id: nil, redirect_to: nil)
end
end

Expand Down
1 change: 0 additions & 1 deletion lib/tasks/redirect.rake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def redirect(old_path, new_path)
route_type: "exact",
handler: "redirect",
backend_id: "whitehall-frontend",
redirect_type: "permanent",
segments_mode: "ignore",
)
end
1 change: 0 additions & 1 deletion spec/factories/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
factory :redirect_route do
handler { "redirect" }
redirect_to { "/bar" }
redirect_type { "permanent" }
end

factory :gone_route do
Expand Down
1 change: 0 additions & 1 deletion spec/models/route_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@
route.update!(
handler: "redirect",
redirect_to: "/",
redirect_type: "permanent",
)
route.reload

Expand Down