Browse Source

support user request tests to create are passing

pull/787/head
JG 3 years ago
parent
commit
afe3073dba
  1. 1
      app/controllers/users_controller.rb
  2. 2
      app/models/user.rb
  3. 1
      config/locales/en.yml
  4. 2
      spec/requests/users_controller_spec.rb

1
app/controllers/users_controller.rb

@ -63,7 +63,6 @@ class UsersController < ApplicationController
end
def new
debugger
@organisation_id = params["organisation_id"]
@user = User.new
end

2
app/models/user.rb

@ -159,7 +159,7 @@ private
def validate_email
unless email_valid?(email)
if User.exists?(["email LIKE ?", "%#{email}%"])
errors.add :email, I18n.t("validations.email.taken")
errors.add :email
else
errors.add :email, I18n.t("validations.email.invalid")
end

1
config/locales/en.yml

@ -87,6 +87,7 @@ en:
email:
invalid: "Enter an email address in the correct format, like name@example.com"
blank: "Enter an email address"
taken: "Enter an email address that hasn’t already been used to sign up"
role:
invalid: "Role must be data accessor, data provider or data coordinator"
blank: "Select role"

2
spec/requests/users_controller_spec.rb

@ -1613,7 +1613,7 @@ RSpec.describe UsersController, type: :request do
it "shows an error" do
request
expect(response).to have_http_status(:unprocessable_entity)
expect(page).to have_content(I18n.t("validations.email.taken"))
expect(page).to have_content(I18n.t("activerecord.errors.models.user.attributes.email.taken"))
end
end

Loading…
Cancel
Save