Browse Source

Add role to invite (#140)

* Add role to invite

* Make role field a radio button

* Fix broken specs on main
pull/142/head
baarkerlounger 3 years ago committed by GitHub
parent
commit
ab1f03d5ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/controllers/users_controller.rb
  2. 4
      app/views/users/new.html.erb
  3. 4
      spec/features/form/form_navigation_spec.rb
  4. 2
      spec/features/organisation_spec.rb
  5. 2
      spec/requests/case_log_controller_spec.rb

2
app/controllers/users_controller.rb

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

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

@ -26,6 +26,10 @@
value: @resource.email value: @resource.email
%> %>
<%= roles = User::ROLES.map { |key, value| OpenStruct.new(id:key, name: key.humanize) }
f.govuk_collection_radio_buttons :role, roles, :id, :name, legend: { text: "Role", size: "m" }
%>
<%= f.govuk_submit "Continue" %> <%= f.govuk_submit "Continue" %>
</div> </div>
</div> </div>

4
spec/features/form/form_navigation_spec.rb

@ -31,7 +31,7 @@ RSpec.describe "Form Navigation" do
visit("/case-logs") visit("/case-logs")
click_link("Create new log") click_link("Create new log")
id = CaseLog.order(created_at: :desc).first.id id = CaseLog.order(created_at: :desc).first.id
expect(page).to have_content("Tasklist for log #{id}") expect(page).to have_content("Case log #{id}")
end end
end end
@ -55,7 +55,7 @@ RSpec.describe "Form Navigation" do
visit("/case-logs/#{id}") visit("/case-logs/#{id}")
visit("/case-logs/#{id}/tenant-code") visit("/case-logs/#{id}/tenant-code")
click_link(text: "Back") click_link(text: "Back")
expect(page).to have_content("Tasklist for log #{id}") expect(page).to have_content("Case log #{id}")
end end
it "go back to tenant code page from tenant age page", js: true do it "go back to tenant code page from tenant age page", js: true do

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") expect(page).to have_content("Invite user to submit CORE data")
fill_in("user[name]", with: "New User") fill_in("user[name]", with: "New User")
fill_in("user[email]", with: "new_user@example.com") fill_in("user[email]", with: "new_user@example.com")
choose("user-role-data-provider-field")
expect { click_button("Continue") }.to change { ActionMailer::Base.deliveries.count }.by(1) expect { click_button("Continue") }.to change { ActionMailer::Base.deliveries.count }.by(1)
expect(page).to have_current_path("/organisations/#{org_id}/users") expect(page).to have_current_path("/organisations/#{org_id}/users")
expect(User.last.role).to eq("data_provider")
end end
end end
end end

2
spec/requests/case_log_controller_spec.rb

@ -187,7 +187,7 @@ RSpec.describe CaseLogsController, type: :request do
end end
it "shows the tasklist for case logs you have access to" do it "shows the tasklist for case logs you have access to" do
expect(response.body).to match("Tasklist for log") expect(response.body).to match("Case log")
expect(response.body).to match(case_log.id.to_s) expect(response.body).to match(case_log.id.to_s)
end end

Loading…
Cancel
Save