|
|
|
@ -434,7 +434,7 @@ RSpec.describe UsersController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
context "when user is signed in as a data coordinator" do |
|
|
|
context "when user is signed in as a data coordinator" do |
|
|
|
let(:user) { create(:user, :data_coordinator, email: "coordinator@example.com", organisation: create(:organisation, :without_dpc)) } |
|
|
|
let(:user) { create(:user, :data_coordinator, email: "coordinator@example.com", organisation: create(:organisation, :without_dpc)) } |
|
|
|
let!(:other_user) { create(:user, organisation: user.organisation, name: "filter name", email: "filter@example.com") } |
|
|
|
let!(:other_user) { create(:user, organisation: user.organisation, name: "filter name", email: "filter@example.com", unconfirmed_email: "email@something.com") } |
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
before do |
|
|
|
sign_in user |
|
|
|
sign_in user |
|
|
|
@ -885,6 +885,11 @@ RSpec.describe UsersController, type: :request do |
|
|
|
expect { patch "/users/#{other_user.id}", headers:, params: } |
|
|
|
expect { patch "/users/#{other_user.id}", headers:, params: } |
|
|
|
.to change { other_user.reload.active }.from(true).to(false) |
|
|
|
.to change { other_user.reload.active }.from(true).to(false) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "discards unconfirmed email" do |
|
|
|
|
|
|
|
expect { patch "/users/#{other_user.id}", headers:, params: } |
|
|
|
|
|
|
|
.to change { other_user.reload.unconfirmed_email }.from("email@something.com").to(nil) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "and tries to activate deactivated user" do |
|
|
|
context "and tries to activate deactivated user" do |
|
|
|
@ -997,6 +1002,7 @@ RSpec.describe UsersController, type: :request do |
|
|
|
email: "new_user@example.com", |
|
|
|
email: "new_user@example.com", |
|
|
|
role: "data_coordinator", |
|
|
|
role: "data_coordinator", |
|
|
|
phone: "12345678910", |
|
|
|
phone: "12345678910", |
|
|
|
|
|
|
|
phone_extension: "1234", |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
end |
|
|
|
end |
|
|
|
@ -1020,12 +1026,14 @@ RSpec.describe UsersController, type: :request do |
|
|
|
request |
|
|
|
request |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "creates a new scheme for user organisation with valid params" do |
|
|
|
it "creates a new user for user organisation with valid params" do |
|
|
|
request |
|
|
|
request |
|
|
|
|
|
|
|
|
|
|
|
expect(User.last.name).to eq("new user") |
|
|
|
expect(User.last.name).to eq("new user") |
|
|
|
expect(User.last.email).to eq("new_user@example.com") |
|
|
|
expect(User.last.email).to eq("new_user@example.com") |
|
|
|
expect(User.last.role).to eq("data_coordinator") |
|
|
|
expect(User.last.role).to eq("data_coordinator") |
|
|
|
|
|
|
|
expect(User.last.phone).to eq("12345678910") |
|
|
|
|
|
|
|
expect(User.last.phone_extension).to eq("1234") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "redirects back to organisation users page" do |
|
|
|
it "redirects back to organisation users page" do |
|
|
|
@ -1612,11 +1620,12 @@ RSpec.describe UsersController, type: :request do |
|
|
|
expect(page).to have_content("Change your personal details") |
|
|
|
expect(page).to have_content("Change your personal details") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "has fields for name, email, role, dpo and key contact" do |
|
|
|
it "has fields for name, email, role, phone number and phone extension" do |
|
|
|
expect(page).to have_field("user[name]") |
|
|
|
expect(page).to have_field("user[name]") |
|
|
|
expect(page).to have_field("user[email]") |
|
|
|
expect(page).to have_field("user[email]") |
|
|
|
expect(page).to have_field("user[role]") |
|
|
|
expect(page).to have_field("user[role]") |
|
|
|
expect(page).to have_field("user[phone]") |
|
|
|
expect(page).to have_field("user[phone]") |
|
|
|
|
|
|
|
expect(page).to have_field("user[phone_extension]") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "allows setting the role to `support`" do |
|
|
|
it "allows setting the role to `support`" do |
|
|
|
@ -1638,10 +1647,12 @@ RSpec.describe UsersController, type: :request do |
|
|
|
expect(page).to have_content("Change #{other_user.name}’s personal details") |
|
|
|
expect(page).to have_content("Change #{other_user.name}’s personal details") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "has fields for name, email, role, dpo and key contact" do |
|
|
|
it "has fields for name, email, role, phone number and phone extension" do |
|
|
|
expect(page).to have_field("user[name]") |
|
|
|
expect(page).to have_field("user[name]") |
|
|
|
expect(page).to have_field("user[email]") |
|
|
|
expect(page).to have_field("user[email]") |
|
|
|
expect(page).to have_field("user[role]") |
|
|
|
expect(page).to have_field("user[role]") |
|
|
|
|
|
|
|
expect(page).to have_field("user[phone]") |
|
|
|
|
|
|
|
expect(page).to have_field("user[phone_extension]") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@ -1656,10 +1667,12 @@ RSpec.describe UsersController, type: :request do |
|
|
|
expect(page).to have_content("Change #{other_user.name}’s personal details") |
|
|
|
expect(page).to have_content("Change #{other_user.name}’s personal details") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "has fields for name, email, role, dpo and key contact" do |
|
|
|
it "has fields for name, email, role, phone number and phone extension" do |
|
|
|
expect(page).to have_field("user[name]") |
|
|
|
expect(page).to have_field("user[name]") |
|
|
|
expect(page).to have_field("user[email]") |
|
|
|
expect(page).to have_field("user[email]") |
|
|
|
expect(page).to have_field("user[role]") |
|
|
|
expect(page).to have_field("user[role]") |
|
|
|
|
|
|
|
expect(page).to have_field("user[phone]") |
|
|
|
|
|
|
|
expect(page).to have_field("user[phone_extension]") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@ -1989,6 +2002,7 @@ RSpec.describe UsersController, type: :request do |
|
|
|
email:, |
|
|
|
email:, |
|
|
|
role: "data_coordinator", |
|
|
|
role: "data_coordinator", |
|
|
|
phone: "12345612456", |
|
|
|
phone: "12345612456", |
|
|
|
|
|
|
|
phone_extension: "1234", |
|
|
|
organisation_id: organisation.id, |
|
|
|
organisation_id: organisation.id, |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
@ -2004,6 +2018,14 @@ RSpec.describe UsersController, type: :request do |
|
|
|
expect(User.find_by(email:).organisation).to eq(organisation) |
|
|
|
expect(User.find_by(email:).organisation).to eq(organisation) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "sets expected values on the user" do |
|
|
|
|
|
|
|
request |
|
|
|
|
|
|
|
user = User.find_by(email:) |
|
|
|
|
|
|
|
expect(user.name).to eq("new user") |
|
|
|
|
|
|
|
expect(user.phone).to eq("12345612456") |
|
|
|
|
|
|
|
expect(user.phone_extension).to eq("1234") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "redirects back to users page" do |
|
|
|
it "redirects back to users page" do |
|
|
|
request |
|
|
|
request |
|
|
|
expect(response).to redirect_to("/users") |
|
|
|
expect(response).to redirect_to("/users") |
|
|
|
|