Browse Source

Address code review

pull/1684/head
Jack S 3 years ago
parent
commit
bc5695cca7
  1. 2
      app/helpers/data_sharing_agreement_helper.rb
  2. 4
      app/models/log.rb
  3. 2
      app/views/organisations/data_sharing_agreement.html.erb
  4. 8
      db/seeds.rb
  5. 2
      spec/shared/shared_log_examples.rb

2
app/helpers/data_sharing_agreement_helper.rb

@ -40,7 +40,7 @@ module DataSharingAgreementHelper
end
# rubocop:disable Rails/HelperInstanceVariable
def section_12_2(data_protection_confirmation:, user:, organisation:)
def present_section_12_2(data_protection_confirmation:, user:, organisation:)
if data_protection_confirmation&.confirmed?
@org_address = data_protection_confirmation.organisation.address_row
@org_name = data_protection_confirmation.organisation.name

4
app/models/log.rb

@ -9,7 +9,7 @@ class Log < ApplicationRecord
belongs_to :bulk_upload, optional: true
before_save :update_status!
before_validation :verify_dsa_signed, on: :create
before_validation :verify_data_protection_confirmation, on: :create
STATUS = {
"not_started" => 0,
@ -178,7 +178,7 @@ class Log < ApplicationRecord
private
def verify_dsa_signed
def verify_data_protection_confirmation
return unless FeatureToggle.new_data_protection_confirmation?
return unless owning_organisation
return if owning_organisation.data_protection_confirmed?

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

@ -106,7 +106,7 @@
<h3 id="12-authorised-representatives" class="govuk-heading-m">12. Authorised representatives</h3>
<p class="govuk-body-m">12.1. CORE data providers and DLUHC will each appoint an Authorised Representative to be the primary point of contact in all day-to-day matters relating to this Agreement:</p>
<p class="govuk-body-m">
<%= section_12_2(data_protection_confirmation: @data_protection_confirmation, user: current_user, organisation: @organisation) %>
<%= present_section_12_2(data_protection_confirmation: @data_protection_confirmation, user: current_user, organisation: @organisation) %>
</p>
<p class="govuk-body-m">12.3. For DLUHC: Name: Rachel Worledge,
Postal Address: South-west section, 4th Floor, Fry Building, 2 Marsham Street, London, SW1P 4DF,

8
db/seeds.rb

@ -7,7 +7,7 @@
# Character.create(name: 'Luke', movie: movies.first)
# rubocop:disable Rails/Output
def create_dsa(user)
def create_data_protection_confirmation(user)
DataProtectionConfirmation.find_or_create_by!(
organisation: user.organisation,
confirmed: true,
@ -94,7 +94,7 @@ unless Rails.env.test?
) do |user|
user.password = "password"
user.confirmed_at = Time.zone.now
create_dsa(user)
create_data_protection_confirmation(user)
end
User.find_or_create_by!(
@ -105,7 +105,7 @@ unless Rails.env.test?
) do |user|
user.password = "password"
user.confirmed_at = Time.zone.now
create_dsa(user)
create_data_protection_confirmation(user)
end
standalone_no_stock = Organisation.find_or_create_by!(
@ -187,7 +187,7 @@ unless Rails.env.test?
user.confirmed_at = Time.zone.now
end
create_dsa(support_user)
create_data_protection_confirmation(support_user)
pp "Seeded 3 dummy users"
end

2
spec/shared/shared_log_examples.rb

@ -105,7 +105,7 @@ RSpec.shared_examples "shared log examples" do |log_type|
end
end
describe "#verify_dsa_signed" do
describe "#verify_data_protection_confirmation" do
before do
allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
end

Loading…
Cancel
Save