Browse Source

Add role to invite

pull/140/head
baarkerlounger 4 years ago
parent
commit
7bc35b5ed7
  1. 2
      app/controllers/users_controller.rb
  2. 4
      app/views/users/new.html.erb
  3. 2
      spec/features/organisation_spec.rb

2
app/controllers/users_controller.rb

@ -46,6 +46,6 @@ private
end
def user_params
params.require(:user).permit(:email, :name, :password)
params.require(:user).permit(:email, :name, :password, :role)
end
end

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

@ -20,6 +20,10 @@
autocomplete: "name"
%>
<%= roles = User::ROLES.map { |key, value| OpenStruct.new(id:key, name: key.humanize) }
f.govuk_collection_select :role, roles, :id, :name, label: { text: "Role" }
%>
<%= f.govuk_email_field :email,
label: { text: "Email address" },
autocomplete: "email",

2
spec/features/organisation_spec.rb

@ -38,8 +38,10 @@ RSpec.describe "User Features" do
expect(page).to have_content("Invite user to submit CORE data")
fill_in("user[name]", with: "New User")
fill_in("user[email]", with: "new_user@example.com")
select("Data provider", from: "user[role]")
expect { click_button("Continue") }.to change { ActionMailer::Base.deliveries.count }.by(1)
expect(page).to have_current_path("/organisations/#{org_id}/users")
expect(User.last.role).to eq("data_provider")
end
end
end

Loading…
Cancel
Save