aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-06-01 16:10:05 +0100
committerChristopher Baines <mail@cbaines.net>2018-06-01 18:23:14 +0100
commit57825439e68e62fc6844bee6c666ac7ad2f01bca (patch)
treed64b1c33ea8a641166b024c626dde49ce521d2fe
parente043d884e9dc077f1ab366d956ee7dd9df4c7460 (diff)
downloadgovuk-mini-environment-admin-57825439e68e62fc6844bee6c666ac7ad2f01bca.tar
govuk-mini-environment-admin-57825439e68e62fc6844bee6c666ac7ad2f01bca.tar.gz
Change the signature of Backends.find_by_type_and_id
It now takes two arguments, and when used by the MiniEnvironmentsController, the split is performed there. This makes it easier to reuse elsewhere in the codebase.
-rw-r--r--app/controllers/mini_environments_controller.rb2
-rw-r--r--app/models/backends.rb4
2 files changed, 2 insertions, 4 deletions
diff --git a/app/controllers/mini_environments_controller.rb b/app/controllers/mini_environments_controller.rb
index 237e8c5..0cee75b 100644
--- a/app/controllers/mini_environments_controller.rb
+++ b/app/controllers/mini_environments_controller.rb
@@ -90,7 +90,7 @@ class MiniEnvironmentsController < ApplicationController
.except(:backend)
)
@mini_environment.backend = Backends.find_by_type_and_id(
- parameters[:backend]
+ *parameters[:backend].split('=')
)
@mini_environment.signon_users[0]['passphrase'] = SecureRandom.hex
@mini_environment.save!
diff --git a/app/models/backends.rb b/app/models/backends.rb
index 0caf8fe..526ae76 100644
--- a/app/models/backends.rb
+++ b/app/models/backends.rb
@@ -40,9 +40,7 @@ module Backends
classes.flat_map(&:all)
end
- def self.find_by_type_and_id(type_and_id)
- type_name, id = type_and_id.split('=')
-
+ def self.find_by_type_and_id(type_name, id)
type = classes.find { |c| c.name == type_name }
type.find(id.to_i)