Browse Source

Preliminary show DPO agreement on Org details page

pull/442/head
baarkerlounger 3 years ago
parent
commit
698444cf87
  1. 7
      app/models/organisation.rb
  2. 11
      spec/models/organisation_spec.rb

7
app/models/organisation.rb

@ -31,6 +31,10 @@ class Organisation < ApplicationRecord
%i[address_line1 address_line2 postcode].map { |field| public_send(field) }.join("\n")
end
def data_protection_confirmed?
!!data_protection_confirmations.order(created_at: :desc).first&.confirmed
end
def display_attributes
[
{ name: "name", value: name, editable: true },
@ -38,9 +42,10 @@ class Organisation < ApplicationRecord
{ name: "telephone_number", value: phone, editable: true },
{ name: "type", value: "Org type", editable: false },
{ name: "local_authorities_operated_in", value: local_authorities, editable: false },
{ name: "holds_own_stock", value: holds_own_stock, editable: false },
{ name: "holds_own_stock", value: holds_own_stock.to_s.humanize, editable: false },
{ name: "other_stock_owners", value: other_stock_owners, editable: false },
{ name: "managing_agents", value: managing_agents, editable: false },
{ name: "has_signed_data_protection_agreement?", value: data_protection_confirmed?.to_s.humanize, editable: false },
]
end
end

11
spec/models/organisation_spec.rb

@ -18,6 +18,17 @@ RSpec.describe Organisation, type: :model do
.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Provider type can't be blank")
end
context "with data protection confirmations" do
before do
FactoryBot.create(:data_protection_confirmation, organisation:, confirmed: false)
FactoryBot.create(:data_protection_confirmation, organisation:)
end
it "takes the most recently created" do
expect(organisation.data_protection_confirmed?).to be true
end
end
context "with case logs" do
let(:other_organisation) { FactoryBot.create(:organisation) }
let!(:owned_case_log) do

Loading…
Cancel
Save