diff --git a/app/controllers/print_hosts_controller.rb b/app/controllers/print_hosts_controller.rb index 1ef509bdb..c33623e44 100644 --- a/app/controllers/print_hosts_controller.rb +++ b/app/controllers/print_hosts_controller.rb @@ -63,7 +63,8 @@ def print_host_params params.require(:print_host).permit( # rubocop:todo Rails/StrongParametersExpect :name, # i18n-tasks-use t("activerecord.attributes.print_host.name") :endpoint, # i18n-tasks-use t("activerecord.attributes.print_host.endpoint") - :protocol # i18n-tasks-use t("activerecord.attributes.print_host.protocol") + :protocol, # i18n-tasks-use t("activerecord.attributes.print_host.protocol") + :credentials # i18n-tasks-use t("activerecord.attributes.print_host.credentials") ) end diff --git a/app/views/print_hosts/_form.html.erb b/app/views/print_hosts/_form.html.erb index 9d02bf1dd..e4b0b6f88 100644 --- a/app/views/print_hosts/_form.html.erb +++ b/app/views/print_hosts/_form.html.erb @@ -4,6 +4,7 @@ <%= TextInputRow(form: form, attribute: :endpoint, label: PrintHost.human_attribute_name(:endpoint), help: t(".endpoint.help")) %> <%= SelectInputRow form: form, attribute: :protocol, label: PrintHost.human_attribute_name(:protocol), help: t(".protocol.help"), select_options: Naturally.sort(PrintHost::PROTOCOLS.keys).map { [translate("print_hosts.protocols.%{protocol}" % {protocol: it}), it] } %> + <%= PasswordInputRow(form: form, attribute: :credentials, label: PrintHost.human_attribute_name(:credentials), help: t(".credentials.help")) %>
<%= form.submit class: "btn btn-primary" %> diff --git a/config/locales/cs.yml b/config/locales/cs.yml index f430e9586..3daa4fd8a 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -128,6 +128,7 @@ cs: size: Velikost souboru y_up: Y nahoru print_host: + credentials: endpoint: name: protocol: @@ -988,6 +989,8 @@ cs: destroy: success: form: + credentials: + help: endpoint: help: name: diff --git a/config/locales/de.yml b/config/locales/de.yml index aed522714..39ff2013f 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -128,6 +128,7 @@ de: size: Dateigröße y_up: Y Aufwärts print_host: + credentials: endpoint: name: protocol: @@ -992,6 +993,8 @@ de: destroy: success: form: + credentials: + help: endpoint: help: name: diff --git a/config/locales/en.yml b/config/locales/en.yml index 519c5046d..6766fd923 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -128,6 +128,7 @@ en: size: File Size y_up: Y Up print_host: + credentials: Credentials endpoint: Endpoint name: Name protocol: Protocol @@ -988,6 +989,8 @@ en: destroy: success: Printer removed form: + credentials: + help: API key or password, if required endpoint: help: The URL of your printer's API (e.g. http://printer.local) name: diff --git a/config/locales/es.yml b/config/locales/es.yml index 1d5731168..00f4b8b7d 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -128,6 +128,7 @@ es: size: Tamaño del archivo y_up: Eje Y Arriba print_host: + credentials: endpoint: name: protocol: @@ -988,6 +989,8 @@ es: destroy: success: form: + credentials: + help: endpoint: help: name: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 05cf72b28..6984c272c 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -130,6 +130,7 @@ fr: size: Taille du fichier y_up: Y Up print_host: + credentials: endpoint: name: protocol: @@ -990,6 +991,8 @@ fr: destroy: success: form: + credentials: + help: endpoint: help: name: diff --git a/config/locales/ja.yml b/config/locales/ja.yml index d4b41660f..cb66dafde 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -128,6 +128,7 @@ ja: size: ファイルサイズ y_up: Y上 print_host: + credentials: endpoint: name: protocol: @@ -988,6 +989,8 @@ ja: destroy: success: form: + credentials: + help: endpoint: help: name: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index a77baf32d..6428eb735 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -128,6 +128,7 @@ nl: size: Bestandsgrootte y_up: Y Omhoog print_host: + credentials: endpoint: name: protocol: @@ -988,6 +989,8 @@ nl: destroy: success: form: + credentials: + help: endpoint: help: name: diff --git a/config/locales/pl.yml b/config/locales/pl.yml index e5dac41b2..648c4b431 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -128,6 +128,7 @@ pl: size: Rozmiar pliku y_up: print_host: + credentials: endpoint: name: protocol: @@ -988,6 +989,8 @@ pl: destroy: success: form: + credentials: + help: endpoint: help: name: diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 8370ab691..577673fa7 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -128,6 +128,7 @@ pt: size: y_up: print_host: + credentials: endpoint: name: protocol: @@ -988,6 +989,8 @@ pt: destroy: success: form: + credentials: + help: endpoint: help: name: diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 9edb361f7..70bcc48a2 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -128,6 +128,7 @@ ru: size: Размер файла y_up: Осью Y вверх print_host: + credentials: endpoint: name: protocol: @@ -988,6 +989,8 @@ ru: destroy: success: form: + credentials: + help: endpoint: help: name: diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index dedf3c829..1afdb8a4f 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -128,6 +128,7 @@ zh-CN: size: 文件大小 y_up: Y 向上 print_host: + credentials: endpoint: name: protocol: @@ -988,6 +989,8 @@ zh-CN: destroy: success: form: + credentials: + help: endpoint: help: name: diff --git a/spec/requests/print_hosts_spec.rb b/spec/requests/print_hosts_spec.rb index 69f5e61d9..dc44d25e8 100644 --- a/spec/requests/print_hosts_spec.rb +++ b/spec/requests/print_hosts_spec.rb @@ -57,12 +57,20 @@ end describe "PATCH /print_hosts/:id" do - before { patch "/print_hosts/#{print_host.to_param}", params: {print_host: {name: "changed"}} } + before { patch "/print_hosts/#{print_host.to_param}", params: {print_host: {name: "changed", credentials: "passw0rd"}} } - it "updates the print host", :as_administrator do + it "redirects back to list afterwards", :as_administrator do expect(response).to redirect_to("/print_hosts") end + it "updates credentials", :as_administrator do + expect(print_host.reload.credentials).to eq "passw0rd" + end + + it "updates name", :as_administrator do + expect(print_host.reload.name).to eq "changed" + end + it "is denied to non-administrators", :as_moderator do expect(response).to have_http_status(:forbidden) end