diff --git a/app/components/persona_sign_in_component.html.erb b/app/components/persona_sign_in_component.html.erb new file mode 100644 index 000000000..739b7537e --- /dev/null +++ b/app/components/persona_sign_in_component.html.erb @@ -0,0 +1,31 @@ +

+ <%= persona.first_name %> +

+ + <%= t(".#{persona.first_name.downcase}.persona_type", default: "") %> + +

+ <%= t(".#{persona.first_name.downcase}.description", default: "") %> +

+ +<% if t(".#{persona.first_name.downcase}.roles", default: "").present? %> +

+ <%= t(".roles_include", persona_name: persona.first_name, default: "") %> +

+ +<% end %> + +<%= form_tag("/auth/developer/callback", method: "post", data: { turbo: false }) do %> + <%= hidden_field_tag "email", persona.email %> + <%= hidden_field_tag "first_name", persona.first_name %> + <%= hidden_field_tag "last_name", persona.last_name %> + +<% end %> + +
diff --git a/app/components/persona_sign_in_component.rb b/app/components/persona_sign_in_component.rb new file mode 100644 index 000000000..615ebf07f --- /dev/null +++ b/app/components/persona_sign_in_component.rb @@ -0,0 +1,24 @@ +class PersonaSignInComponent < ApplicationComponent + attr_reader :persona + + def initialize(persona, classes: [], html_attributes: {}) + super(classes:, html_attributes:) + + @persona = persona + end + + def type_tag_colour + case persona.first_name + when "Anne" + "purple" + when "Patricia" + "orange" + when "Mary" + "yellow" + when "Colin" + "blue" + else + "turquoise" + end + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2974def71..3d6d9b1e7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -24,7 +24,7 @@ def current_user end def after_sign_in_path - if current_user.support_user? + if current_user.is_support_user? support_root_path else organisations_path diff --git a/app/controllers/claims/support/application_controller.rb b/app/controllers/claims/support/application_controller.rb index 510ada9d3..aacf2aa5f 100644 --- a/app/controllers/claims/support/application_controller.rb +++ b/app/controllers/claims/support/application_controller.rb @@ -4,7 +4,7 @@ class Claims::Support::ApplicationController < ApplicationController private def authorize_user! - return if current_user.support_user? + return if current_user.is_support_user? redirect_to claims_root_path, alert: t("you_cannot_perform_this_action") end diff --git a/app/controllers/concerns/claims/belongs_to_school.rb b/app/controllers/concerns/claims/belongs_to_school.rb index fcf5adad4..5dc8b5195 100644 --- a/app/controllers/concerns/claims/belongs_to_school.rb +++ b/app/controllers/concerns/claims/belongs_to_school.rb @@ -11,7 +11,7 @@ def set_school end def scoped_schools - return Claims::School.all if current_user.support_user? + return Claims::School.all if current_user.is_support_user? current_user.schools end diff --git a/app/controllers/personas_controller.rb b/app/controllers/personas_controller.rb index 7b698b448..f0637d985 100644 --- a/app/controllers/personas_controller.rb +++ b/app/controllers/personas_controller.rb @@ -4,6 +4,8 @@ class PersonasController < ApplicationController skip_before_action :authenticate_user!, only: %i[index] def index - @personas = Persona.public_send(current_service).decorate + @personas = User.where(email: PERSONA_EMAILS) + .where(type: ["#{current_service.to_s.titleize}::User", + "#{current_service.to_s.titleize}::SupportUser"]) end end diff --git a/app/controllers/placements/support/application_controller.rb b/app/controllers/placements/support/application_controller.rb index fd838489b..e076cd6d5 100644 --- a/app/controllers/placements/support/application_controller.rb +++ b/app/controllers/placements/support/application_controller.rb @@ -4,7 +4,7 @@ class Placements::Support::ApplicationController < ApplicationController private def authorize_user! - return if current_user.support_user? + return if current_user.is_support_user? redirect_to placements_root_path, alert: t("you_cannot_perform_this_action") end diff --git a/app/forms/user_invite_form.rb b/app/forms/user_invite_form.rb index 124cabbf4..9cffe2886 100644 --- a/app/forms/user_invite_form.rb +++ b/app/forms/user_invite_form.rb @@ -11,7 +11,7 @@ class UserInviteForm def invite return false unless valid? - UserInviteService.call(user, organisation) if save_user + UserInviteService.call(user, organisation, service) if save_user end def as_form_params diff --git a/app/mailers/notify_mailer.rb b/app/mailers/notify_mailer.rb index 89b57d0a8..5f354a05f 100644 --- a/app/mailers/notify_mailer.rb +++ b/app/mailers/notify_mailer.rb @@ -1,14 +1,14 @@ class NotifyMailer < ApplicationMailer # NotifyMailer.send_organisation_invite_email.deliver_later - def send_organisation_invite_email(user, organisation, sign_in_url) - body = t("#{user.service}.mailers.notify_mailer.body", + def send_organisation_invite_email(user, organisation, service, sign_in_url) + body = t("#{service}.mailers.notify_mailer.body", user_name: user.full_name, organisation_name: organisation.name, sign_in_url:) mailer_options = { to: user.email, subject: t( - "#{user.service}.mailers.notify_mailer.subject", + "#{service}.mailers.notify_mailer.subject", organisation_name: organisation.name, ), body: } diff --git a/app/models/claims/support_user.rb b/app/models/claims/support_user.rb new file mode 100644 index 000000000..61c0f2085 --- /dev/null +++ b/app/models/claims/support_user.rb @@ -0,0 +1,21 @@ +# == Schema Information +# +# Table name: users +# +# id :uuid not null, primary key +# email :string not null +# first_name :string not null +# last_name :string not null +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_type_and_email (type,email) UNIQUE +# +class Claims::SupportUser < User + def is_support_user? + true + end +end diff --git a/app/models/claims/user.rb b/app/models/claims/user.rb index 82ff0e387..78c2e3f64 100644 --- a/app/models/claims/user.rb +++ b/app/models/claims/user.rb @@ -2,22 +2,19 @@ # # Table name: users # -# id :uuid not null, primary key -# email :string not null -# first_name :string not null -# last_name :string not null -# service :enum not null -# support_user :boolean default(FALSE) -# created_at :datetime not null -# updated_at :datetime not null +# id :uuid not null, primary key +# email :string not null +# first_name :string not null +# last_name :string not null +# type :string +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # -# index_users_on_service_and_email (service,email) UNIQUE +# index_users_on_type_and_email (type,email) UNIQUE # class Claims::User < User - default_scope { claims } - has_many :schools, -> { claims_service }, through: :memberships, diff --git a/app/models/dfe_sign_in_user.rb b/app/models/dfe_sign_in_user.rb index f46cef7c8..beacb4757 100644 --- a/app/models/dfe_sign_in_user.rb +++ b/app/models/dfe_sign_in_user.rb @@ -45,30 +45,10 @@ def self.load_from_session(session) def user # TODO: When dfe sign-in is fully implemented, we will be able to find the user by the id == id_token. - @user ||= - begin - user = user_klass.find_by(email:) - - if service == :placements && user&.support_user? - user = user.becomes(Placements::SupportUser) - end - - user - end + @user ||= User.find_by(email:) end def self.end_session!(session) session.clear end - - private - - def user_klass - case service - when :claims - Claims::User - when :placements - Placements::User - end - end end diff --git a/app/models/persona.rb b/app/models/persona.rb deleted file mode 100644 index cbfc08d24..000000000 --- a/app/models/persona.rb +++ /dev/null @@ -1,21 +0,0 @@ -# == Schema Information -# -# Table name: users -# -# id :uuid not null, primary key -# email :string not null -# first_name :string not null -# last_name :string not null -# service :enum not null -# support_user :boolean default(FALSE) -# created_at :datetime not null -# updated_at :datetime not null -# -# Indexes -# -# index_users_on_service_and_email (service,email) UNIQUE -# -class Persona < User - default_scope { where(email: PERSONA_EMAILS) } - validates :email, inclusion: { in: PERSONA_EMAILS } -end diff --git a/app/models/placements/support_user.rb b/app/models/placements/support_user.rb index e142fad90..045c24515 100644 --- a/app/models/placements/support_user.rb +++ b/app/models/placements/support_user.rb @@ -2,19 +2,20 @@ # # Table name: users # -# id :uuid not null, primary key -# email :string not null -# first_name :string not null -# last_name :string not null -# service :enum not null -# support_user :boolean default(FALSE) -# created_at :datetime not null -# updated_at :datetime not null +# id :uuid not null, primary key +# email :string not null +# first_name :string not null +# last_name :string not null +# type :string +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # -# index_users_on_service_and_email (service,email) UNIQUE +# index_users_on_type_and_email (type,email) UNIQUE # -class Placements::SupportUser < Placements::User - default_scope { support_users } +class Placements::SupportUser < User + def is_support_user? + true + end end diff --git a/app/models/placements/user.rb b/app/models/placements/user.rb index 36f1aaea9..2c425e1f7 100644 --- a/app/models/placements/user.rb +++ b/app/models/placements/user.rb @@ -2,22 +2,19 @@ # # Table name: users # -# id :uuid not null, primary key -# email :string not null -# first_name :string not null -# last_name :string not null -# service :enum not null -# support_user :boolean default(FALSE) -# created_at :datetime not null -# updated_at :datetime not null +# id :uuid not null, primary key +# email :string not null +# first_name :string not null +# last_name :string not null +# type :string +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # -# index_users_on_service_and_email (service,email) UNIQUE +# index_users_on_type_and_email (type,email) UNIQUE # class Placements::User < User - default_scope { placements } - has_many :schools, -> { placements_service }, through: :memberships, diff --git a/app/models/user.rb b/app/models/user.rb index db204a5ef..a9a913a8a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,35 +2,35 @@ # # Table name: users # -# id :uuid not null, primary key -# email :string not null -# first_name :string not null -# last_name :string not null -# service :enum not null -# support_user :boolean default(FALSE) -# created_at :datetime not null -# updated_at :datetime not null +# id :uuid not null, primary key +# email :string not null +# first_name :string not null +# last_name :string not null +# type :string +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # -# index_users_on_service_and_email (service,email) UNIQUE +# index_users_on_type_and_email (type,email) UNIQUE # class User < ApplicationRecord has_many :memberships - enum :service, - { no_service: "no_service", claims: "claims", placements: "placements" }, - validate: true - validates :first_name, presence: true validates :last_name, presence: true validates :email, presence: true, format: { with: URI::MailTo::EMAIL_REGEXP } - validates :service, presence: true - validates :email, uniqueness: { scope: :service, case_sensitive: false } + validates :type, presence: true + validates :email, uniqueness: { scope: :type, case_sensitive: false } - scope :support_users, -> { where(support_user: true) } + scope :claims, -> { where(type: "Claims::User") } + scope :placements, -> { where(type: "Placements::User") } def full_name "#{first_name} #{last_name}".strip end + + def is_support_user? + false + end end diff --git a/app/services/user_invite_service.rb b/app/services/user_invite_service.rb index 70114770a..f1e05048b 100644 --- a/app/services/user_invite_service.rb +++ b/app/services/user_invite_service.rb @@ -1,16 +1,16 @@ class UserInviteService include ServicePattern - def initialize(user, organisation) + def initialize(user, organisation, service) @user = user @organisation = organisation - @service = user.service + @service = service end attr_reader :user, :organisation, :service def call - NotifyMailer.send_organisation_invite_email(user, organisation, url).deliver_later + NotifyMailer.send_organisation_invite_email(user, organisation, service.to_s, url).deliver_later end private @@ -21,6 +21,6 @@ def url def host { "claims" => ENV["CLAIMS_HOST"], - "placements" => ENV["PLACEMENTS_HOST"] }.fetch service + "placements" => ENV["PLACEMENTS_HOST"] }.fetch service.to_s end end diff --git a/app/views/personas/index.html.erb b/app/views/personas/index.html.erb index 84ac7b122..1ac8eeec2 100644 --- a/app/views/personas/index.html.erb +++ b/app/views/personas/index.html.erb @@ -6,37 +6,7 @@

<%= t(".title") %>

<% @personas.each do |persona| %> -

- <%= persona.first_name %> -

- - <%= t(".#{persona.first_name.downcase}.persona_type", default: "") %> - -

- <%= t(".#{persona.first_name.downcase}.description", default: "") %> -

- - <% if t(".#{persona.first_name.downcase}.roles", default: "").present? %> -

- <%= t(".roles_include", persona_name: persona.first_name, default: "") %> -

- - <% end %> - - <%= form_tag("/auth/developer/callback", method: "post", data: { turbo: false }) do %> - <%= hidden_field_tag "email", persona.email %> - <%= hidden_field_tag "first_name", persona.first_name %> - <%= hidden_field_tag "last_name", persona.last_name %> - - <% end %> - -
+ <%= render PersonaSignInComponent.new(persona) %> <% end %> diff --git a/config/environments/test.rb b/config/environments/test.rb index fce6bdc90..35653ef13 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -28,7 +28,7 @@ config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + config.action_dispatch.show_exceptions = :none # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false diff --git a/config/initializers/persona.rb b/config/initializers/persona.rb index c7b7438a6..30a9f6f04 100644 --- a/config/initializers/persona.rb +++ b/config/initializers/persona.rb @@ -5,20 +5,19 @@ first_name: "Anne", last_name: "Wilson", email: "anne_wilson@example.org", - service: :claims, + type: "Claims::User", }, { first_name: "Mary", last_name: "Lawson", email: "mary@example.com", - service: :claims, + type: "Claims::User", }, { first_name: "Colin", last_name: "Chapman", email: "colin@example.com", - support_user: true, - service: :claims, + type: "Claims::SupportUser", }, ].freeze @@ -27,26 +26,25 @@ first_name: "Anne", last_name: "Wilson", email: "anne_wilson@example.org", - service: :placements, + type: "Placements::User", }, { first_name: "Patricia", last_name: "Adebayo", email: "patricia@example.com", - service: :placements, + type: "Placements::User", }, { first_name: "Mary", last_name: "Lawson", email: "mary@example.com", - service: :placements, + type: "Placements::User", }, { first_name: "Colin", last_name: "Chapman", email: "colin@example.com", - support_user: true, - service: :placements, + type: "Placements::SupportUser", }, ].freeze diff --git a/config/locales/en/components/persona_sign_in_component.yml b/config/locales/en/components/persona_sign_in_component.yml new file mode 100644 index 000000000..63a45076a --- /dev/null +++ b/config/locales/en/components/persona_sign_in_component.yml @@ -0,0 +1,31 @@ +en: + components: + persona_sign_in_component: + anne: + persona_type: SCHOOL + description: Anne is a lead mentor within a school. + roles: + - "setting timetables for mentors within the school" + - "being the main point of contact for providers" + - "ensuring mentors’ training is up-to-date" + colin: + persona_type: SUPPORT + description: Colin is a DfE support agent who has administrator access to all organisations. + roles: "" + mary: + persona_type: MULTI-ORG + description: Mary is a part-time teacher in a multi academy trust (MAT), but also leads a SCITT. + roles: + - "recruiting and training mentors" + - "setting timetables for mentors within the school" + - "organising placements for trainees" + patricia: + persona_type: UNIVERSITY + description: Patricia is a placements manager at a higher education institute (HEI). + roles: + - recruiting and training mentors + - organising placements for trainees + - keeping track of known mentors + roles_include: "%{persona_name}’s role includes:" + sign_in_as: "Sign In as %{persona_name}" + title: Test users \ No newline at end of file diff --git a/config/locales/en/personas.yml b/config/locales/en/personas.yml index 07211570f..d613e9047 100644 --- a/config/locales/en/personas.yml +++ b/config/locales/en/personas.yml @@ -1,31 +1,4 @@ en: personas: index: - anne: - persona_type: SCHOOL - description: Anne is a lead mentor within a school. - roles: - - "setting timetables for mentors within the school" - - "being the main point of contact for providers" - - "ensuring mentors’ training is up-to-date" - colin: - persona_type: SUPPORT - description: Colin is a DfE support agent who has administrator access to all organisations. - roles: "" - mary: - persona_type: MULTI-ORG - description: Mary is a part-time teacher in a multi academy trust (MAT), but also leads a SCITT. - roles: - - "recruiting and training mentors" - - "setting timetables for mentors within the school" - - "organising placements for trainees" - patricia: - persona_type: UNIVERSITY - description: Patricia is a placements manager at a higher education institute (HEI). - roles: - - recruiting and training mentors - - organising placements for trainees - - keeping track of known mentors - roles_include: "%{persona_name}’s role includes:" - sign_in_as: "Sign In as %{persona_name}" title: Test users diff --git a/db/migrate/20240125154819_add_type_to_users.rb b/db/migrate/20240125154819_add_type_to_users.rb new file mode 100644 index 000000000..d8011c1a6 --- /dev/null +++ b/db/migrate/20240125154819_add_type_to_users.rb @@ -0,0 +1,5 @@ +class AddTypeToUsers < ActiveRecord::Migration[7.1] + def change + add_column :users, :type, :string + end +end diff --git a/db/migrate/20240126112508_remove_service_from_users.rb b/db/migrate/20240126112508_remove_service_from_users.rb new file mode 100644 index 000000000..8ce3613e6 --- /dev/null +++ b/db/migrate/20240126112508_remove_service_from_users.rb @@ -0,0 +1,5 @@ +class RemoveServiceFromUsers < ActiveRecord::Migration[7.1] + def change + remove_column :users, :service, :enum, enum_type: "service", null: false + end +end diff --git a/db/migrate/20240126112656_remove_support_user_from_users.rb b/db/migrate/20240126112656_remove_support_user_from_users.rb new file mode 100644 index 000000000..83a458545 --- /dev/null +++ b/db/migrate/20240126112656_remove_support_user_from_users.rb @@ -0,0 +1,5 @@ +class RemoveSupportUserFromUsers < ActiveRecord::Migration[7.1] + def change + remove_column :users, :support_user, :boolean, default: false + end +end diff --git a/db/migrate/20240126114650_add_index_to_users_on_email_and_type.rb b/db/migrate/20240126114650_add_index_to_users_on_email_and_type.rb new file mode 100644 index 000000000..d8cc0b577 --- /dev/null +++ b/db/migrate/20240126114650_add_index_to_users_on_email_and_type.rb @@ -0,0 +1,5 @@ +class AddIndexToUsersOnEmailAndType < ActiveRecord::Migration[7.1] + def change + add_index :users, %i[type email], unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 9d8fdcf06..b35647b2e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_01_24_095111) do +ActiveRecord::Schema[7.1].define(version: 2024_01_26_114650) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" enable_extension "plpgsql" @@ -151,9 +151,8 @@ t.string "email", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.boolean "support_user", default: false - t.enum "service", null: false, enum_type: "service" - t.index ["service", "email"], name: "index_users_on_service_and_email", unique: true + t.string "type" + t.index ["type", "email"], name: "index_users_on_type_and_email", unique: true end add_foreign_key "claims", "schools" diff --git a/db/seeds.rb b/db/seeds.rb index b4ddc92ed..c7102dd35 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -3,11 +3,11 @@ # Create the same personas for each service CLAIMS_PERSONAS.each do |persona_attributes| - Persona.find_or_create_by!(**persona_attributes) + User.find_or_create_by!(**persona_attributes) end PLACEMENTS_PERSONAS.each do |persona_attributes| - Persona.find_or_create_by!(**persona_attributes) + User.find_or_create_by!(**persona_attributes) end Rails.logger.debug "Personas successfully created!" @@ -25,36 +25,47 @@ # Create Providers Imported from Publfish Rake::Task["provider_data:import"].invoke unless Provider.any? -User - .where(first_name: %w[Anne Patricia]) - .find_each do |user| - school = School.where("#{user.service}_service": true).first - user.memberships.find_or_create_by!(organisation: school) - end +# Associate Placements Users with Organisations +# Single School Anne +placements_anne = Placements::User.find_by!(email: "anne_wilson@example.org") +placements_anne.memberships.find_or_create_by!(organisation: Placements::School.first) -User - .where(first_name: %w[Mary Colin]) - .find_each do |user| - schools = School.where("#{user.service}_service": true) +# Multi-school Mary +placements_mary = Placements::User.find_by!(email: "mary@example.com") +schools = Placements::School.all +schools.each do |school| + placements_mary.memberships.find_or_create_by!(organisation: school) +end - schools.each do |school| - user.memberships.find_or_create_by!(organisation: school) - end - end +# Provider Patrica +placements_patrica = Placements::User.find_by!(email: "patricia@example.com") +provider = Provider.first +provider.update!(placements_service: true) +placements_patrica.memberships.find_or_create_by!(organisation: provider) + +# Associate Claims Users with Schools +# Single School Anne +claims_anne = Claims::User.find_by!(email: "anne_wilson@example.org") +claims_anne.memberships.find_or_create_by!(organisation: Claims::School.first) + +# Multi-school Mary +claims_mary = Claims::User.find_by!(email: "mary@example.com") +schools = Claims::School.all +schools.each do |school| + claims_mary.memberships.find_or_create_by!(organisation: school) +end # Create dummy mentors -User.where(first_name: %w[Anne Patricia Mary Colin]).find_each do |user| - schools = School.where("#{user.service}_service": true) - - schools.each do |school| - %w[Sarah John Pomona].each_with_index do |first_name, index| - Mentor.find_or_create_by( - first_name:, - last_name: "Doe", - school:, - trn: index, - ) - end +schools = School.where(claims_service: true) + .or(School.where(placements_service: true)) +schools.each do |school| + %w[Sarah John Pomona].each_with_index do |first_name, index| + Mentor.find_or_create_by( + first_name:, + last_name: "Doe", + school:, + trn: index, + ) end end diff --git a/spec/decorators/persona_decorator_spec.rb b/spec/decorators/persona_decorator_spec.rb deleted file mode 100644 index 3e6931872..000000000 --- a/spec/decorators/persona_decorator_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require "rails_helper" - -RSpec.describe PersonaDecorator do - describe "#type_tag_colour" do - context "when the persona is Anne" do - it "returns purple" do - expect(build(:persona, :anne).decorate.type_tag_colour).to eq("purple") - end - end - - context "when the persona is Patricia" do - it "returns orange" do - expect(build(:persona, :patricia).decorate.type_tag_colour).to eq( - "orange", - ) - end - end - - context "when the persona is Mary" do - it "returns yellow" do - expect(build(:persona, :mary).decorate.type_tag_colour).to eq("yellow") - end - end - - context "when the persona is Colin" do - it "returns blue" do - expect(build(:persona, :colin).decorate.type_tag_colour).to eq("blue") - end - end - - context "when the persona is not listed in the decorator" do - it "returns turquoise" do - expect(build(:persona).decorate.type_tag_colour).to eq("turquoise") - end - end - end -end diff --git a/spec/factories/memberships.rb b/spec/factories/memberships.rb index ddacfcee5..c36bae689 100644 --- a/spec/factories/memberships.rb +++ b/spec/factories/memberships.rb @@ -21,7 +21,7 @@ # FactoryBot.define do factory :membership do - association :user + association :user, factory: :claims_user association :organisation, factory: :school end end diff --git a/spec/factories/persona.rb b/spec/factories/persona.rb deleted file mode 100644 index f583efac7..000000000 --- a/spec/factories/persona.rb +++ /dev/null @@ -1,32 +0,0 @@ -FactoryBot.define do - factory :persona do - email { "anne_wilson@example.org" } - first_name { "Persona" } - service { %w[claims placements].sample } - sequence(:last_name) - - trait :anne do - first_name { "Anne" } - last_name { "Wilson" } - end - - trait :patricia do - email { "patricia@example.com" } - first_name { "Patricia" } - last_name { "Adebayo" } - end - - trait :mary do - email { "mary@example.com" } - first_name { "Mary" } - last_name { "Lawson" } - end - - trait :colin do - email { "colin@example.com" } - first_name { "Colin" } - last_name { "Chapman" } - support_user { true } - end - end -end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 909f0155b..3ce2ef245 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -2,48 +2,58 @@ # # Table name: users # -# id :uuid not null, primary key -# email :string not null -# first_name :string not null -# last_name :string not null -# service :enum not null -# support_user :boolean default(FALSE) -# created_at :datetime not null -# updated_at :datetime not null +# id :uuid not null, primary key +# email :string not null +# first_name :string not null +# last_name :string not null +# type :string +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # -# index_users_on_service_and_email (service,email) UNIQUE +# index_users_on_type_and_email (type,email) UNIQUE # FactoryBot.define do factory :user do sequence(:email) { |n| "user#{n}@example.com" } first_name { "User" } - service { %w[placements claims].sample } sequence(:last_name) - trait :support do - support_user { true } + trait :anne do + first_name { "Anne" } + last_name { "Wilson" } + email { "anne_wilson@example.org" } end - end - factory :claims_user, class: "Claims::User", parent: :user do - service { "claims" } - end + trait :patricia do + first_name { "Patricia" } + last_name { "Adebayo" } + email { "patricia@example.com" } + end + + trait :mary do + first_name { "Mary" } + last_name { "Lawson" } + email { "mary@example.com" } + end - factory :placements_user, class: "Placements::User", parent: :user do - service { "placements" } + trait :colin do + first_name { "Colin" } + last_name { "Chapman" } + email { "colin@example.com" } + end end + factory :claims_user, class: "Claims::User", parent: :user + + factory :placements_user, class: "Placements::User", parent: :user + factory :placements_support_user, class: "Placements::SupportUser", - parent: :user do - service { "placements" } - end + parent: :user factory :claims_support_user, class: "Claims::SupportUser", - parent: :user do - service { "claims" } - end + parent: :user end diff --git a/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb b/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb index 1e758ac0a..e3643401b 100644 --- a/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb +++ b/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb @@ -7,8 +7,13 @@ Capybara.app_host = nil end + let(:anne) { create(:claims_user, :anne) } + let(:patricia) { create(:claims_user, :patricia) } + let(:mary) { create(:claims_user, :mary) } + let(:colin) { create(:claims_support_user, :colin) } + scenario "I sign in as persona Anne" do - given_there_is_an_existing_claims_persona_with_a_school_for("Anne") + given_there_is_an_existing_claims_persona_with_a_school_for(anne) when_i_visit_the_claims_personas_page then_i_see_the_claims_persona_for("Anne") when_i_click_sign_in_as("Anne") @@ -17,7 +22,7 @@ end scenario "I sign in as persona Patricia" do - given_there_is_an_existing_claims_persona_with_a_school_for("Patricia") + given_there_is_an_existing_claims_persona_with_a_school_for(patricia) when_i_visit_the_claims_personas_page then_i_see_the_claims_persona_for("Patricia") when_i_click_sign_in_as("Patricia") @@ -26,7 +31,7 @@ end scenario "I sign in as persona Mary" do - given_there_is_an_existing_claims_persona_with_a_school_for("Mary") + given_there_is_an_existing_claims_persona_with_a_school_for(mary) when_i_visit_the_claims_personas_page then_i_see_the_claims_persona_for("Mary") when_i_click_sign_in_as("Mary") @@ -35,7 +40,7 @@ end scenario "I sign in as persona colin" do - given_there_is_an_existing_claims_persona_with_a_school_for("Colin") + given_there_is_an_existing_claims_persona_with_a_school_for(colin) when_i_visit_the_claims_personas_page then_i_see_the_claims_persona_for("Colin") when_i_click_sign_in_as("Colin") @@ -46,10 +51,10 @@ private -def given_there_is_an_existing_claims_persona_with_a_school_for(persona_name) +def given_there_is_an_existing_claims_persona_with_a_school_for(user) create( :membership, - user: create(:persona, persona_name.downcase.to_sym, service: "claims"), + user:, organisation: create(:school, :claims), ) end diff --git a/spec/features/personas/sign_in_as_a_placements_user_persona_spec.rb b/spec/features/personas/sign_in_as_a_placements_user_persona_spec.rb index 2b1f6c076..52812cd0a 100644 --- a/spec/features/personas/sign_in_as_a_placements_user_persona_spec.rb +++ b/spec/features/personas/sign_in_as_a_placements_user_persona_spec.rb @@ -18,7 +18,7 @@ end scenario "I sign in as persona Patricia" do - given_there_is_an_existing_persona_for("Patricia") + given_there_is_an_existing_persona_for("Patrica") when_i_visit_the_personas_page then_i_see_the_persona_for("Patricia") when_i_click_sign_in_as("Patricia") @@ -52,7 +52,7 @@ private def given_there_is_an_existing_persona_for(persona_name) - create(:persona, persona_name.downcase.to_sym, service: "placements") + create(:placements_user, persona_name.downcase.to_sym) end def when_i_visit_the_personas_page diff --git a/spec/mailers/notify_mailer_spec.rb b/spec/mailers/notify_mailer_spec.rb index 239e4c88b..6b5ca97a6 100644 --- a/spec/mailers/notify_mailer_spec.rb +++ b/spec/mailers/notify_mailer_spec.rb @@ -2,11 +2,12 @@ RSpec.describe NotifyMailer, type: :mailer do describe "#send_organisation_invite_email" do - subject { described_class.send_organisation_invite_email(user, organisation, "") } + subject { described_class.send_organisation_invite_email(user, organisation, service, "") } context "when the user's service is Claims" do let(:user) { create(:claims_user, first_name: "Anne", last_name: "Wilson") } let(:organisation) { create(:school, :claims, name: "School 1") } + let(:service) { "claims" } it "invites the user to the organsation" do expect(subject.to).to contain_exactly(user.email) @@ -21,6 +22,7 @@ context "when the user's service is Placements" do let(:user) { create(:placements_user, first_name: "Anne", last_name: "Wilson") } + let(:service) { "placements" } context "when the organisation is a school" do let(:organisation) { create(:school, :placements, name: "School 1") } @@ -37,6 +39,7 @@ context "when the organisation is a Provider" do let(:organisation) { create(:placements_provider, name: "School 1") } + let(:service) { "placements" } it "invites the user to the organsation" do expect(subject.to).to contain_exactly(user.email) diff --git a/spec/models/claims/support_user_spec.rb b/spec/models/claims/support_user_spec.rb new file mode 100644 index 000000000..3a0e25331 --- /dev/null +++ b/spec/models/claims/support_user_spec.rb @@ -0,0 +1,25 @@ +# == Schema Information +# +# Table name: users +# +# id :uuid not null, primary key +# email :string not null +# first_name :string not null +# last_name :string not null +# type :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_type_and_email (type,email) UNIQUE +# +require "rails_helper" + +RSpec.describe Claims::SupportUser do + describe "#is_support_user?" do + it "returns true" do + expect(described_class.new.is_support_user?).to eq(true) + end + end +end \ No newline at end of file diff --git a/spec/models/claims/user_spec.rb b/spec/models/claims/user_spec.rb index 8305fec85..4edb688c6 100644 --- a/spec/models/claims/user_spec.rb +++ b/spec/models/claims/user_spec.rb @@ -2,18 +2,17 @@ # # Table name: users # -# id :uuid not null, primary key -# email :string not null -# first_name :string not null -# last_name :string not null -# service :enum not null -# support_user :boolean default(FALSE) -# created_at :datetime not null -# updated_at :datetime not null +# id :uuid not null, primary key +# email :string not null +# first_name :string not null +# last_name :string not null +# type :string +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # -# index_users_on_service_and_email (service,email) UNIQUE +# index_users_on_type_and_email (type,email) UNIQUE # require "rails_helper" diff --git a/spec/models/dfe_sign_in_user_spec.rb b/spec/models/dfe_sign_in_user_spec.rb index 1f56e2cec..ab22768a1 100644 --- a/spec/models/dfe_sign_in_user_spec.rb +++ b/spec/models/dfe_sign_in_user_spec.rb @@ -85,7 +85,7 @@ end it "returns a Placements::SupportUser for support users" do - support_user = create(:placements_user, :support) + support_user = create(:placements_support_user) session = { "dfe_sign_in_user" => { diff --git a/spec/models/persona_spec.rb b/spec/models/persona_spec.rb deleted file mode 100644 index 4ba8f45e3..000000000 --- a/spec/models/persona_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -# == Schema Information -# -# Table name: users -# -# id :uuid not null, primary key -# email :string not null -# first_name :string not null -# last_name :string not null -# service :enum not null -# support_user :boolean default(FALSE) -# created_at :datetime not null -# updated_at :datetime not null -# -# Indexes -# -# index_users_on_service_and_email (service,email) UNIQUE -# -RSpec.describe Persona, type: :model do - describe "validations" do - subject { create(:persona) } - it { is_expected.to validate_inclusion_of(:email).in_array(PERSONA_EMAILS) } - end -end diff --git a/spec/models/placements/support_user_spec.rb b/spec/models/placements/support_user_spec.rb index 4e1b0ed35..65e98aa6b 100644 --- a/spec/models/placements/support_user_spec.rb +++ b/spec/models/placements/support_user_spec.rb @@ -2,34 +2,24 @@ # # Table name: users # -# id :uuid not null, primary key -# email :string not null -# first_name :string not null -# last_name :string not null -# service :enum not null -# support_user :boolean default(FALSE) -# created_at :datetime not null -# updated_at :datetime not null +# id :uuid not null, primary key +# email :string not null +# first_name :string not null +# last_name :string not null +# type :string +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # -# index_users_on_service_and_email (service,email) UNIQUE +# index_users_on_type_and_email (type,email) UNIQUE # require "rails_helper" RSpec.describe Placements::SupportUser do - describe "default scope" do - let(:email) { "same_email@email.co.uk" } - let!(:support_user_with_placements_service) do - create(:placements_user, :support, email:) - end - let!(:support_user_with_claims_service) do - create(:claims_user, :support, email:) - end - - it "is scoped to placement support users" do - user = described_class.find(support_user_with_placements_service.id) - expect(described_class.all).to contain_exactly(user) + describe "#is_support_user?" do + it "returns true" do + expect(described_class.new.is_support_user?).to eq(true) end end end diff --git a/spec/models/placements/user_spec.rb b/spec/models/placements/user_spec.rb index 5a73ce093..00dfa1825 100644 --- a/spec/models/placements/user_spec.rb +++ b/spec/models/placements/user_spec.rb @@ -2,18 +2,17 @@ # # Table name: users # -# id :uuid not null, primary key -# email :string not null -# first_name :string not null -# last_name :string not null -# service :enum not null -# support_user :boolean default(FALSE) -# created_at :datetime not null -# updated_at :datetime not null +# id :uuid not null, primary key +# email :string not null +# first_name :string not null +# last_name :string not null +# type :string +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # -# index_users_on_service_and_email (service,email) UNIQUE +# index_users_on_type_and_email (type,email) UNIQUE # require "rails_helper" diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index fd9771207..0960c5b31 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2,23 +2,22 @@ # # Table name: users # -# id :uuid not null, primary key -# email :string not null -# first_name :string not null -# last_name :string not null -# service :enum not null -# support_user :boolean default(FALSE) -# created_at :datetime not null -# updated_at :datetime not null +# id :uuid not null, primary key +# email :string not null +# first_name :string not null +# last_name :string not null +# type :string +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # -# index_users_on_service_and_email (service,email) UNIQUE +# index_users_on_type_and_email (type,email) UNIQUE # require "rails_helper" RSpec.describe User, type: :model do - subject { create(:user) } + subject { build(:user) } context "associations" do it { should have_many(:memberships) } @@ -28,10 +27,41 @@ it { is_expected.to validate_presence_of(:email) } it do is_expected.to validate_uniqueness_of(:email).scoped_to( - :service, + :type, ).case_insensitive end it { is_expected.to validate_presence_of(:first_name) } it { is_expected.to validate_presence_of(:last_name) } + it { is_expected.to validate_presence_of(:type) } + end + + context "scopes" do + describe "#claims" do + it "only returns users of type Claims::User" do + claims_user = create(:claims_user) + create(:claims_support_user) + create(:placements_user) + create(:placements_support_user) + + expect(described_class.claims).to contain_exactly(claims_user) + end + end + + describe "#placements" do + it "only returns users of type Placements::User" do + create(:claims_user) + create(:claims_support_user) + create(:placements_support_user) + placements_user = create(:placements_user) + + expect(described_class.placements).to contain_exactly(placements_user) + end + end + end + + describe "#is_support_user?" do + it "returns false" do + expect(subject.is_support_user?).to eq(false) + end end end diff --git a/spec/services/user_invite_service_spec.rb b/spec/services/user_invite_service_spec.rb index ec3843c1f..f47cca19a 100644 --- a/spec/services/user_invite_service_spec.rb +++ b/spec/services/user_invite_service_spec.rb @@ -1,17 +1,18 @@ require "rails_helper" RSpec.describe UserInviteService do - subject { described_class.call(user, organisation) } + subject { described_class.call(user, organisation, service) } describe "call" do context "when the user's service is Claims" do describe "when the organisation is a school" do let(:user) { create(:claims_user) } let(:organisation) { create(:school, :claims) } + let(:service) { "claims" } it "calls mailer with correct prams" do notify_mailer = double(:notify_mailer) - expect(NotifyMailer).to receive(:send_organisation_invite_email).with(user, organisation, "http://claims.localhost/sign-in") { notify_mailer } + expect(NotifyMailer).to receive(:send_organisation_invite_email).with(user, organisation, service, "http://claims.localhost/sign-in") { notify_mailer } expect(notify_mailer).to receive(:deliver_later) subject end @@ -19,13 +20,15 @@ end context "when the user's service is Placements" do + let(:service) { "placements" } + describe "when the organisation is a school" do let(:user) { create(:placements_user) } let(:organisation) { create(:school, :placements) } it "calls mailer with correct prams" do notify_mailer = double(:notify_mailer) - expect(NotifyMailer).to receive(:send_organisation_invite_email).with(user, organisation, "http://placements.localhost/sign-in") { notify_mailer } + expect(NotifyMailer).to receive(:send_organisation_invite_email).with(user, organisation, service, "http://placements.localhost/sign-in") { notify_mailer } expect(notify_mailer).to receive(:deliver_later) subject end @@ -37,7 +40,7 @@ it "calls mailer with correct prams" do notify_mailer = double(:notify_mailer) - expect(NotifyMailer).to receive(:send_organisation_invite_email).with(user, organisation, "http://placements.localhost/sign-in") { notify_mailer } + expect(NotifyMailer).to receive(:send_organisation_invite_email).with(user, organisation, service, "http://placements.localhost/sign-in") { notify_mailer } expect(notify_mailer).to receive(:deliver_later) subject end diff --git a/spec/system/claims/create_claim_spec.rb b/spec/system/claims/create_claim_spec.rb index a724a2e43..12c95370f 100644 --- a/spec/system/claims/create_claim_spec.rb +++ b/spec/system/claims/create_claim_spec.rb @@ -4,9 +4,8 @@ let!(:school) { create(:school, :claims) } let!(:anne) do create( - :persona, + :claims_user, :anne, - service: "claims", memberships: [create(:membership, organisation: school)], ) end diff --git a/spec/system/claims/invite_a_user_to_a_school_spec.rb b/spec/system/claims/invite_a_user_to_a_school_spec.rb index e85f6faa3..3ecb360d0 100644 --- a/spec/system/claims/invite_a_user_to_a_school_spec.rb +++ b/spec/system/claims/invite_a_user_to_a_school_spec.rb @@ -78,12 +78,12 @@ def another_school_exists end def setup_school_and_anne_membership - @anne_persona = create(:persona, :anne, service: "claims") + @anne_persona = create(:claims_user, :anne) create(:membership, user: @anne_persona, organisation: @school) end def sign_in_as_support_user - create(:persona, :colin, service: "claims") + create(:claims_support_user, :colin) visit personas_path click_on "Sign In as Colin" end diff --git a/spec/system/claims/support/schools/add_a_school_spec.rb b/spec/system/claims/support/schools/add_a_school_spec.rb index 4a5c4aa2b..557144251 100644 --- a/spec/system/claims/support/schools/add_a_school_spec.rb +++ b/spec/system/claims/support/schools/add_a_school_spec.rb @@ -42,7 +42,7 @@ private def and_there_is_an_existing_persona_for(persona_name) - create(:persona, persona_name.downcase.to_sym, service: :claims) + create(:claims_support_user, persona_name.downcase.to_sym) end def and_i_visit_the_personas_page diff --git a/spec/system/claims/support/schools/add_a_school_without_javascript_spec.rb b/spec/system/claims/support/schools/add_a_school_without_javascript_spec.rb index 42274049c..05bc209e3 100644 --- a/spec/system/claims/support/schools/add_a_school_without_javascript_spec.rb +++ b/spec/system/claims/support/schools/add_a_school_without_javascript_spec.rb @@ -55,7 +55,7 @@ private def and_there_is_an_existing_persona_for(persona_name) - create(:persona, persona_name.downcase.to_sym, service: :claims) + create(:claims_support_user, persona_name.downcase.to_sym) end def and_i_visit_the_personas_page diff --git a/spec/system/claims/support/schools/invite_a_user_to_a_school_spec.rb b/spec/system/claims/support/schools/invite_a_user_to_a_school_spec.rb index d8e80e7db..28234a5b7 100644 --- a/spec/system/claims/support/schools/invite_a_user_to_a_school_spec.rb +++ b/spec/system/claims/support/schools/invite_a_user_to_a_school_spec.rb @@ -82,7 +82,7 @@ def another_school_exists end def sign_in_as_support_user - create(:persona, :colin, service: "claims") + create(:claims_support_user, :colin) visit personas_path click_on "Sign In as Colin" end diff --git a/spec/system/claims/support/schools/view_a_school_spec.rb b/spec/system/claims/support/schools/view_a_school_spec.rb index 30d2c9202..dce957917 100644 --- a/spec/system/claims/support/schools/view_a_school_spec.rb +++ b/spec/system/claims/support/schools/view_a_school_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" RSpec.describe "View a school", type: :system do - let!(:support_user) { create(:persona, :colin, service: :claims) } + let!(:support_user) { create(:claims_support_user, :colin) } let!(:school) { create(:school, :claims) } scenario "View a school's details as a support user" do diff --git a/spec/system/claims/view_a_users_details.rb b/spec/system/claims/view_a_users_details.rb index 8ebdbe58f..20f8ca4c8 100644 --- a/spec/system/claims/view_a_users_details.rb +++ b/spec/system/claims/view_a_users_details.rb @@ -28,7 +28,7 @@ def attach_user_to_school end def sign_in_as_support_user - create(:persona, :colin, service: "claims") + create(:claims_support_user, :colin) visit personas_path click_on "Sign In as Colin" end diff --git a/spec/system/claims/view_claims_spec.rb b/spec/system/claims/view_claims_spec.rb index db3b60095..3a81afc49 100644 --- a/spec/system/claims/view_claims_spec.rb +++ b/spec/system/claims/view_claims_spec.rb @@ -10,9 +10,8 @@ end let!(:anne) do create( - :persona, + :claims_user, :anne, - service: "claims", memberships: [create(:membership, organisation: school)], ) end diff --git a/spec/system/claims/view_organisations_spec.rb b/spec/system/claims/view_organisations_spec.rb index 7f6652196..72f955fbe 100644 --- a/spec/system/claims/view_organisations_spec.rb +++ b/spec/system/claims/view_organisations_spec.rb @@ -26,7 +26,7 @@ private def given_the_claims_persona(persona_name) - create(:persona, persona_name.downcase.to_sym, service: "claims") + create(:claims_user, persona_name.downcase.to_sym) end def and_persona_has_multiple_schools(persona) diff --git a/spec/system/claims/view_school_spec.rb b/spec/system/claims/view_school_spec.rb index 3e85a48d3..d4f422d43 100644 --- a/spec/system/claims/view_school_spec.rb +++ b/spec/system/claims/view_school_spec.rb @@ -36,7 +36,7 @@ def when_i_visit_claims_personas end def given_the_claims_persona(persona_name) - create(:persona, persona_name.downcase.to_sym, service: "claims") + create(:claims_user, persona_name.downcase.to_sym) end def and_persona_has_multiple_schools(persona) @@ -45,7 +45,7 @@ def and_persona_has_multiple_schools(persona) end def given_there_is_an_existing_persona_for(persona_name) - user = create(:persona, persona_name.downcase.to_sym, service: "claims") + user = create(:claims_user, persona_name.downcase.to_sym) create(:membership, user:, organisation: school1) user end diff --git a/spec/system/claims/view_schools_as_support_user_spec.rb b/spec/system/claims/view_schools_as_support_user_spec.rb index 5669c6c51..9aec6440f 100644 --- a/spec/system/claims/view_schools_as_support_user_spec.rb +++ b/spec/system/claims/view_schools_as_support_user_spec.rb @@ -37,7 +37,7 @@ def schools end def given_i_am_signed_in_as_support_user - create(:persona, :colin, service: "claims") + create(:claims_support_user, :colin) visit personas_path click_on "Sign In as Colin" end diff --git a/spec/system/claims/view_users_of_a_school_spec.rb b/spec/system/claims/view_users_of_a_school_spec.rb index 07c0322da..89f0ed374 100644 --- a/spec/system/claims/view_users_of_a_school_spec.rb +++ b/spec/system/claims/view_users_of_a_school_spec.rb @@ -15,12 +15,12 @@ def setup_school_and_anne_membership @school = create(:school, :claims, urn: "123456") - @anne_persona = create(:persona, :anne, service: "claims") + @anne_persona = create(:claims_user, :anne) create(:membership, user: @anne_persona, organisation: @school) end def sign_in_as_support_user - create(:persona, :colin, service: "claims") + create(:claims_support_user, :colin) visit personas_path click_on "Sign In as Colin" end diff --git a/spec/system/placements/support/organisations/support_filtering_and_searching_for_organisation_spec.rb b/spec/system/placements/support/organisations/support_filtering_and_searching_for_organisation_spec.rb index 6c25c8615..4d7c78837 100644 --- a/spec/system/placements/support/organisations/support_filtering_and_searching_for_organisation_spec.rb +++ b/spec/system/placements/support/organisations/support_filtering_and_searching_for_organisation_spec.rb @@ -185,7 +185,7 @@ def then_i_see_all_schools def given_i_am_signed_in_as_a_support_user Capybara.app_host = "http://#{ENV["PLACEMENTS_HOST"]}" - create(:persona, :colin, service: :placements) + create(:placements_support_user, :colin) visit personas_path click_on "Sign In as Colin" end diff --git a/spec/system/placements/support/organisations/support_user_selects_an_organisation_type_to_add_spec.rb b/spec/system/placements/support/organisations/support_user_selects_an_organisation_type_to_add_spec.rb index 1f054d00c..94ba149fb 100644 --- a/spec/system/placements/support/organisations/support_user_selects_an_organisation_type_to_add_spec.rb +++ b/spec/system/placements/support/organisations/support_user_selects_an_organisation_type_to_add_spec.rb @@ -28,7 +28,7 @@ private def and_there_is_an_existing_persona_for(persona_name) - create(:persona, persona_name.downcase.to_sym, service: :placements) + create(:placements_support_user, persona_name.downcase.to_sym) end def and_i_visit_the_personas_page diff --git a/spec/system/placements/support/providers/support_user_adds_a_provider_spec.rb b/spec/system/placements/support/providers/support_user_adds_a_provider_spec.rb index 0dc1a8ea6..990d96352 100644 --- a/spec/system/placements/support/providers/support_user_adds_a_provider_spec.rb +++ b/spec/system/placements/support/providers/support_user_adds_a_provider_spec.rb @@ -44,7 +44,7 @@ private def and_there_is_an_existing_persona_for(persona_name) - create(:persona, persona_name.downcase.to_sym, service: :placements) + create(:placements_support_user, persona_name.downcase.to_sym) end def and_i_visit_the_personas_page diff --git a/spec/system/placements/support/providers/support_user_adds_a_provider_without_javascript_spec.rb b/spec/system/placements/support/providers/support_user_adds_a_provider_without_javascript_spec.rb index e04b94c85..9ad9104b6 100644 --- a/spec/system/placements/support/providers/support_user_adds_a_provider_without_javascript_spec.rb +++ b/spec/system/placements/support/providers/support_user_adds_a_provider_without_javascript_spec.rb @@ -59,7 +59,7 @@ private def and_there_is_an_existing_persona_for(persona_name) - create(:persona, persona_name.downcase.to_sym, service: :placements) + create(:placements_support_user, persona_name.downcase.to_sym) end def and_i_visit_the_personas_page diff --git a/spec/system/placements/support/schools/support_user_adds_a_school_spec.rb b/spec/system/placements/support/schools/support_user_adds_a_school_spec.rb index beb73115c..d37cd6df0 100644 --- a/spec/system/placements/support/schools/support_user_adds_a_school_spec.rb +++ b/spec/system/placements/support/schools/support_user_adds_a_school_spec.rb @@ -43,7 +43,7 @@ private def and_there_is_an_existing_persona_for(persona_name) - create(:persona, persona_name.downcase.to_sym, service: :placements) + create(:placements_support_user, persona_name.downcase.to_sym) end def and_i_visit_the_personas_page diff --git a/spec/system/placements/support/schools/support_user_adds_a_school_without_javascript_spec.rb b/spec/system/placements/support/schools/support_user_adds_a_school_without_javascript_spec.rb index 89dd83e26..523f03c81 100644 --- a/spec/system/placements/support/schools/support_user_adds_a_school_without_javascript_spec.rb +++ b/spec/system/placements/support/schools/support_user_adds_a_school_without_javascript_spec.rb @@ -55,7 +55,7 @@ private def and_there_is_an_existing_persona_for(persona_name) - create(:persona, persona_name.downcase.to_sym, service: :placements) + create(:placements_support_user, persona_name.downcase.to_sym) end def and_i_visit_the_personas_page diff --git a/spec/system/placements/support/schools/view_school_as_support_user_spec.rb b/spec/system/placements/support/schools/view_school_as_support_user_spec.rb index ecb8e349c..ae241d50f 100644 --- a/spec/system/placements/support/schools/view_school_as_support_user_spec.rb +++ b/spec/system/placements/support/schools/view_school_as_support_user_spec.rb @@ -20,7 +20,7 @@ private def given_i_am_signed_in_as_a_support_user - create(:persona, :colin, service: :placements) + create(:placements_support_user, :colin) visit personas_path click_on "Sign In as Colin" end diff --git a/spec/system/placements/support/users/support_user_invites_a_new_user_spec.rb b/spec/system/placements/support/users/support_user_invites_a_new_user_spec.rb index 7655808f7..d297e2bd0 100644 --- a/spec/system/placements/support/users/support_user_invites_a_new_user_spec.rb +++ b/spec/system/placements/support/users/support_user_invites_a_new_user_spec.rb @@ -110,7 +110,7 @@ private def and_there_is_an_existing_persona_for(persona_name) - create(:persona, persona_name.downcase.to_sym, service: :placements) + create(:placements_support_user, persona_name.downcase.to_sym) end def and_i_visit_the_personas_page diff --git a/spec/system/placements/support/users/support_user_views_a_user_spec.rb b/spec/system/placements/support/users/support_user_views_a_user_spec.rb index 2175ed0a9..5655d8561 100644 --- a/spec/system/placements/support/users/support_user_views_a_user_spec.rb +++ b/spec/system/placements/support/users/support_user_views_a_user_spec.rb @@ -53,7 +53,7 @@ private def and_there_is_an_existing_persona_for(persona_name) - create(:persona, persona_name.downcase.to_sym, service: :placements) + create(:placements_support_user, persona_name.downcase.to_sym) end def and_i_visit_the_personas_page diff --git a/spec/system/placements/view_organisations_spec.rb b/spec/system/placements/view_organisations_spec.rb index 6f4123906..dabfc6681 100644 --- a/spec/system/placements/view_organisations_spec.rb +++ b/spec/system/placements/view_organisations_spec.rb @@ -51,7 +51,7 @@ private def persona(persona_name) - @persona ||= create(:persona, persona_name.downcase.to_sym, service: "placements") + @persona ||= create(:placements_user, persona_name.downcase.to_sym) end def given_the_placements_persona(persona_name)