Browse Source

Bug Fixes (#618)

* Don't trigger confirmation emails for inactive users

* Show organisation type
pull/619/head
baarkerlounger 3 years ago committed by baarkerlounger
parent
commit
c868e75bf2
  1. 5
      app/helpers/organisation_helper.rb
  2. 8
      app/models/organisation.rb
  3. 6
      app/models/user.rb
  4. 2
      app/views/organisations/_organisation_list.html.erb
  5. 12
      spec/models/user_spec.rb

5
app/helpers/organisation_helper.rb

@ -8,9 +8,4 @@ module OrganisationHelper
current_organisation.name
end
end
DISPLAY_PROVIDER_TYPE = { "LA": "Local authority", "PRP": "Private registered provider" }.freeze
def display_provider_type(provider_type)
DISPLAY_PROVIDER_TYPE[provider_type.to_sym]
end
end

8
app/models/organisation.rb

@ -62,12 +62,18 @@ class Organisation < ApplicationRecord
data_protection_confirmed? ? "Accepted" : "Not accepted"
end
DISPLAY_PROVIDER_TYPE = { "LA": "Local authority", "PRP": "Private registered provider" }.freeze
def display_provider_type
DISPLAY_PROVIDER_TYPE[provider_type.to_sym]
end
def display_attributes
[
{ name: "name", value: name, editable: true },
{ name: "address", value: address_string, editable: true },
{ name: "telephone_number", value: phone, editable: true },
{ name: "type", value: "Org type", editable: false },
{ name: "type", value: display_provider_type, editable: false },
{ name: "local_authorities_operated_in", value: local_authority_names, editable: false, format: :bullet },
{ name: "rent_periods", value: rent_period_labels, editable: false, format: :bullet },
{ name: "holds_own_stock", value: holds_own_stock.to_s.humanize, editable: false },

6
app/models/user.rb

@ -90,8 +90,10 @@ class User < ApplicationRecord
old_user_id.present?
end
def skip_confirmation!
!active?
def send_confirmation_instructions
return unless active?
super
end
def need_two_factor_authentication?(_request)

2
app/views/organisations/_organisation_list.html.erb

@ -28,7 +28,7 @@
<%= govuk_link_to(organisation.name, "organisations/#{organisation.id}/logs") %>
<% end %>
<% row.cell(text: organisation.housing_registration_no) %>
<% row.cell(text: display_provider_type(organisation.provider_type)) %>
<% row.cell(text: organisation.display_provider_type) %>
<% end %>
<% end %>
<% end %>

12
spec/models/user_spec.rb

@ -85,6 +85,18 @@ RSpec.describe User, type: :model do
)
end
it "does not send a confirmation email to inactive users" do
expect(DeviseNotifyMailer).not_to receive(:confirmation_instructions)
described_class.create!(
name: "unconfirmed_user",
email: "unconfirmed_user@example.com",
password: "password123",
organisation: other_organisation,
role: "data_provider",
active: false,
)
end
context "when the user is a data provider" do
it "cannot assign roles" do
expect(user.assignable_roles).to eq({})

Loading…
Cancel
Save