|
|
|
@ -213,11 +213,11 @@ RSpec.describe UsersController, type: :request do
|
|
|
|
|
context "when user changes email, dpo, key_contact" do |
|
|
|
|
let(:params) { { id: user.id, user: { name: new_name, email: new_email, is_dpo: "true", is_key_contact: "true" } } } |
|
|
|
|
|
|
|
|
|
it "allows changing email and dpo" do |
|
|
|
|
it "allows changing email but not dpo or key_contact" do |
|
|
|
|
user.reload |
|
|
|
|
expect(user.email).to eq(new_email) |
|
|
|
|
expect(user.is_data_protection_officer?).to be true |
|
|
|
|
expect(user.is_key_contact?).to be true |
|
|
|
|
expect(user.is_data_protection_officer?).to be false |
|
|
|
|
expect(user.is_key_contact?).to be false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -266,6 +266,32 @@ RSpec.describe UsersController, type: :request do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#create" do |
|
|
|
|
let(:params) do |
|
|
|
|
{ |
|
|
|
|
"user": { |
|
|
|
|
name: "new user", |
|
|
|
|
email: "new_user@example.com", |
|
|
|
|
role: "data_coordinator", |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
let(:request) { post "/users/", headers: headers, params: params } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
sign_in user |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "does not invite a new user" do |
|
|
|
|
expect { request }.not_to change(User, :count) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns 401 unauthorized" do |
|
|
|
|
request |
|
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when user is signed in as a data coordinator" do |
|
|
|
@ -513,9 +539,9 @@ RSpec.describe UsersController, type: :request do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#create" do |
|
|
|
|
let(:user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
|
let(:params) do |
|
|
|
|
{ |
|
|
|
|
"user": { |
|
|
|
@ -552,6 +578,7 @@ RSpec.describe UsersController, type: :request do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "title link" do |
|
|
|
|
before do |
|
|
|
|