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 end
def new def new
debugger
@organisation_id = params["organisation_id"] @organisation_id = params["organisation_id"]
@user = User.new @user = User.new
end end

2
app/models/user.rb

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

1
config/locales/en.yml

@ -87,6 +87,7 @@ en:
email: email:
invalid: "Enter an email address in the correct format, like name@example.com" invalid: "Enter an email address in the correct format, like name@example.com"
blank: "Enter an email address" blank: "Enter an email address"
taken: "Enter an email address that hasn’t already been used to sign up"
role: role:
invalid: "Role must be data accessor, data provider or data coordinator" invalid: "Role must be data accessor, data provider or data coordinator"
blank: "Select role" 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 it "shows an error" do
request request
expect(response).to have_http_status(:unprocessable_entity) 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
end end

Loading…
Cancel
Save