Skip to content
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
3 changes: 2 additions & 1 deletion app/controllers/print_hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions app/views/print_hosts/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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")) %>
<hr>
<div>
<%= form.submit class: "btn btn-primary" %>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ cs:
size: Velikost souboru
y_up: Y nahoru
print_host:
credentials:
endpoint:
name:
protocol:
Expand Down Expand Up @@ -988,6 +989,8 @@ cs:
destroy:
success:
form:
credentials:
help:
endpoint:
help:
name:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ de:
size: Dateigröße
y_up: Y Aufwärts
print_host:
credentials:
endpoint:
name:
protocol:
Expand Down Expand Up @@ -992,6 +993,8 @@ de:
destroy:
success:
form:
credentials:
help:
endpoint:
help:
name:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ en:
size: File Size
y_up: Y Up
print_host:
credentials: Credentials
endpoint: Endpoint
name: Name
protocol: Protocol
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ es:
size: Tamaño del archivo
y_up: Eje Y Arriba
print_host:
credentials:
endpoint:
name:
protocol:
Expand Down Expand Up @@ -988,6 +989,8 @@ es:
destroy:
success:
form:
credentials:
help:
endpoint:
help:
name:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ fr:
size: Taille du fichier
y_up: Y Up
print_host:
credentials:
endpoint:
name:
protocol:
Expand Down Expand Up @@ -990,6 +991,8 @@ fr:
destroy:
success:
form:
credentials:
help:
endpoint:
help:
name:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ ja:
size: ファイルサイズ
y_up: Y上
print_host:
credentials:
endpoint:
name:
protocol:
Expand Down Expand Up @@ -988,6 +989,8 @@ ja:
destroy:
success:
form:
credentials:
help:
endpoint:
help:
name:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ nl:
size: Bestandsgrootte
y_up: Y Omhoog
print_host:
credentials:
endpoint:
name:
protocol:
Expand Down Expand Up @@ -988,6 +989,8 @@ nl:
destroy:
success:
form:
credentials:
help:
endpoint:
help:
name:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pl:
size: Rozmiar pliku
y_up:
print_host:
credentials:
endpoint:
name:
protocol:
Expand Down Expand Up @@ -988,6 +989,8 @@ pl:
destroy:
success:
form:
credentials:
help:
endpoint:
help:
name:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pt:
size:
y_up:
print_host:
credentials:
endpoint:
name:
protocol:
Expand Down Expand Up @@ -988,6 +989,8 @@ pt:
destroy:
success:
form:
credentials:
help:
endpoint:
help:
name:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ ru:
size: Размер файла
y_up: Осью Y вверх
print_host:
credentials:
endpoint:
name:
protocol:
Expand Down Expand Up @@ -988,6 +989,8 @@ ru:
destroy:
success:
form:
credentials:
help:
endpoint:
help:
name:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ zh-CN:
size: 文件大小
y_up: Y 向上
print_host:
credentials:
endpoint:
name:
protocol:
Expand Down Expand Up @@ -988,6 +989,8 @@ zh-CN:
destroy:
success:
form:
credentials:
help:
endpoint:
help:
name:
Expand Down
12 changes: 10 additions & 2 deletions spec/requests/print_hosts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading