Browse Source

Use radio buttons rather than check box

pull/428/head
baarkerlounger 3 years ago
parent
commit
ab12d204d9
  1. 10
      app/views/users/edit.html.erb
  2. 10
      app/views/users/new.html.erb
  3. 6
      spec/requests/users_controller_spec.rb

10
app/views/users/edit.html.erb

@ -26,9 +26,13 @@
spellcheck: "false" spellcheck: "false"
%> %>
<%= f.govuk_check_boxes_fieldset :is_dpo, multiple: false, legend: { text: "Are #{@user == current_user ? "you" : "they"} a data protection officer?", size: "m" } do %> <%= f.govuk_collection_radio_buttons :is_dpo,
<%= f.govuk_check_box :is_dpo, 1, 0, multiple: false, link_errors: true, label: { text: "Yes" } %> [OpenStruct.new(id: false, name: "No"), OpenStruct.new(id: true, name: "Yes")],
<% end %> :id,
:name,
inline: true,
legend: { text: "Are they a data protection officer?", size: "m" }
%>
<%= f.govuk_submit "Save changes" %> <%= f.govuk_submit "Save changes" %>
</div> </div>

10
app/views/users/new.html.erb

@ -31,9 +31,13 @@
f.govuk_collection_radio_buttons :role, roles, :id, :name, legend: { text: "Role", size: "m" } f.govuk_collection_radio_buttons :role, roles, :id, :name, legend: { text: "Role", size: "m" }
%> %>
<%= f.govuk_check_boxes_fieldset :is_dpo, legend: { text: "Are they a data protection officer?", size: "m" } do %> <%= f.govuk_collection_radio_buttons :is_dpo,
<%= f.govuk_check_box :is_dpo, :is_dpo, label: { text: "Yes" } %> [OpenStruct.new(id: false, name: "No"), OpenStruct.new(id: true, name: "Yes")],
<% end %> :id,
:name,
inline: true,
legend: { text: "Are they a data protection officer?", size: "m" }
%>
<%= f.govuk_submit "Continue" %> <%= f.govuk_submit "Continue" %>
</div> </div>

6
spec/requests/users_controller_spec.rb

@ -211,7 +211,7 @@ RSpec.describe UsersController, type: :request do
end end
context "when user changes email and dpo" do context "when user changes email and dpo" do
let(:params) { { id: user.id, user: { name: new_name, email: new_email, is_dpo: "1" } } } let(:params) { { id: user.id, user: { name: new_name, email: new_email, is_dpo: "true" } } }
it "allows changing email and dpo" do it "allows changing email and dpo" do
user.reload user.reload
@ -399,7 +399,7 @@ RSpec.describe UsersController, type: :request do
end end
context "when user changes email and dpo" do context "when user changes email and dpo" do
let(:params) { { id: user.id, user: { name: new_name, email: new_email, is_dpo: "1" } } } let(:params) { { id: user.id, user: { name: new_name, email: new_email, is_dpo: "true" } } }
it "allows changing email and dpo" do it "allows changing email and dpo" do
user.reload user.reload
@ -444,7 +444,7 @@ RSpec.describe UsersController, type: :request do
end end
context "when user changes email and dpo" do context "when user changes email and dpo" do
let(:params) { { id: other_user.id, user: { name: new_name, email: new_email, is_dpo: "1" } } } let(:params) { { id: other_user.id, user: { name: new_name, email: new_email, is_dpo: "true" } } }
it "allows changing email and dpo" do it "allows changing email and dpo" do
patch "/users/#{other_user.id}", headers: headers, params: params patch "/users/#{other_user.id}", headers: headers, params: params

Loading…
Cancel
Save