|
|
|
@ -236,5 +236,48 @@ RSpec.describe "User Features" do
|
|
|
|
|
expect(page).to have_content(/Enter an email address in the correct format, like name@example.com/) |
|
|
|
|
expect(page).to have_title("Error") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "sets name, email, role and is_dpo" do |
|
|
|
|
visit("users/new") |
|
|
|
|
fill_in("user[name]", with: "New User") |
|
|
|
|
fill_in("user[email]", with: "newuser@example.com") |
|
|
|
|
choose("user-role-data-provider-field") |
|
|
|
|
choose("user-is-dpo-true-field") |
|
|
|
|
click_button("Continue") |
|
|
|
|
expect( |
|
|
|
|
User.find_by(name: "New User", email: "newuser@example.com", role: "data_provider", is_dpo: true) |
|
|
|
|
).to be_a(User) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "defaults to is_dpo false" do |
|
|
|
|
visit("users/new") |
|
|
|
|
expect(page).to have_field("user[is_dpo]", with: false) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when editing someone elses account details" do |
|
|
|
|
let!(:user) { FactoryBot.create(:user, :data_coordinator, last_sign_in_at: Time.zone.now) } |
|
|
|
|
let!(:other_user) { FactoryBot.create(:user, name: "Other name", is_dpo: true, organisation: user.organisation) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
visit("/logs") |
|
|
|
|
fill_in("user[email]", with: user.email) |
|
|
|
|
fill_in("user[password]", with: "pAssword1") |
|
|
|
|
click_button("Sign in") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "allows updating other users details" do |
|
|
|
|
visit("/organisations/#{user.organisation.id}") |
|
|
|
|
click_link("Users") |
|
|
|
|
click_link(other_user.name) |
|
|
|
|
expect(page).to have_title("Other name’s account") |
|
|
|
|
first(:link, "Change").click |
|
|
|
|
expect(page).to have_field("user[is_dpo]", with: true) |
|
|
|
|
choose("user-is-dpo-field") |
|
|
|
|
fill_in("user[name]", with: "Updated new name") |
|
|
|
|
click_button("Save changes") |
|
|
|
|
expect(page).to have_title("Updated new name’s account") |
|
|
|
|
expect(User.find_by(name: "Updated new name", role: "data_provider", is_dpo: false)).to be_a(User) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|