Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/govuk_design_system_formb…
Browse files Browse the repository at this point in the history
…uilder-5.4.0
  • Loading branch information
PaulDoyle-DEFRA committed May 21, 2024
2 parents d355c1b + dd85a01 commit fb03def
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 63 deletions.
116 changes: 58 additions & 58 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,67 +28,67 @@ GEM
specs:
aasm (5.5.0)
concurrent-ruby (~> 1.0)
actioncable (7.0.8.1)
actionpack (= 7.0.8.1)
activesupport (= 7.0.8.1)
actioncable (7.0.8.3)
actionpack (= 7.0.8.3)
activesupport (= 7.0.8.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.8.1)
actionpack (= 7.0.8.1)
activejob (= 7.0.8.1)
activerecord (= 7.0.8.1)
activestorage (= 7.0.8.1)
activesupport (= 7.0.8.1)
actionmailbox (7.0.8.3)
actionpack (= 7.0.8.3)
activejob (= 7.0.8.3)
activerecord (= 7.0.8.3)
activestorage (= 7.0.8.3)
activesupport (= 7.0.8.3)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.8.1)
actionpack (= 7.0.8.1)
actionview (= 7.0.8.1)
activejob (= 7.0.8.1)
activesupport (= 7.0.8.1)
actionmailer (7.0.8.3)
actionpack (= 7.0.8.3)
actionview (= 7.0.8.3)
activejob (= 7.0.8.3)
activesupport (= 7.0.8.3)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.8.1)
actionview (= 7.0.8.1)
activesupport (= 7.0.8.1)
actionpack (7.0.8.3)
actionview (= 7.0.8.3)
activesupport (= 7.0.8.3)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.8.1)
actionpack (= 7.0.8.1)
activerecord (= 7.0.8.1)
activestorage (= 7.0.8.1)
activesupport (= 7.0.8.1)
actiontext (7.0.8.3)
actionpack (= 7.0.8.3)
activerecord (= 7.0.8.3)
activestorage (= 7.0.8.3)
activesupport (= 7.0.8.3)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.8.1)
activesupport (= 7.0.8.1)
actionview (7.0.8.3)
activesupport (= 7.0.8.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.8.1)
activesupport (= 7.0.8.1)
activejob (7.0.8.3)
activesupport (= 7.0.8.3)
globalid (>= 0.3.6)
activemodel (7.0.8.1)
activesupport (= 7.0.8.1)
activerecord (7.0.8.1)
activemodel (= 7.0.8.1)
activesupport (= 7.0.8.1)
activestorage (7.0.8.1)
actionpack (= 7.0.8.1)
activejob (= 7.0.8.1)
activerecord (= 7.0.8.1)
activesupport (= 7.0.8.1)
activemodel (7.0.8.3)
activesupport (= 7.0.8.3)
activerecord (7.0.8.3)
activemodel (= 7.0.8.3)
activesupport (= 7.0.8.3)
activestorage (7.0.8.3)
actionpack (= 7.0.8.3)
activejob (= 7.0.8.3)
activerecord (= 7.0.8.3)
activesupport (= 7.0.8.3)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.8.1)
activesupport (7.0.8.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand Down Expand Up @@ -240,7 +240,7 @@ GEM
net-smtp
marcel (1.0.4)
matrix (0.4.2)
method_source (1.0.0)
method_source (1.1.0)
mime-types (3.5.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.1003)
Expand All @@ -259,17 +259,17 @@ GEM
mongoid-locker (2.0.2)
mongoid (>= 5.0, < 9)
multi_json (1.15.0)
net-imap (0.4.10)
net-imap (0.4.11)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0.1)
net-smtp (0.5.0)
net-protocol
netrc (0.11.0)
nio4r (2.7.0)
nio4r (2.7.3)
nokogiri (1.15.6)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
Expand Down Expand Up @@ -303,20 +303,20 @@ GEM
rack (2.2.9)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8.1)
actioncable (= 7.0.8.1)
actionmailbox (= 7.0.8.1)
actionmailer (= 7.0.8.1)
actionpack (= 7.0.8.1)
actiontext (= 7.0.8.1)
actionview (= 7.0.8.1)
activejob (= 7.0.8.1)
activemodel (= 7.0.8.1)
activerecord (= 7.0.8.1)
activestorage (= 7.0.8.1)
activesupport (= 7.0.8.1)
rails (7.0.8.3)
actioncable (= 7.0.8.3)
actionmailbox (= 7.0.8.3)
actionmailer (= 7.0.8.3)
actionpack (= 7.0.8.3)
actiontext (= 7.0.8.3)
actionview (= 7.0.8.3)
activejob (= 7.0.8.3)
activemodel (= 7.0.8.3)
activerecord (= 7.0.8.3)
activestorage (= 7.0.8.3)
activesupport (= 7.0.8.3)
bundler (>= 1.15.0)
railties (= 7.0.8.1)
railties (= 7.0.8.3)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -328,9 +328,9 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.0.8.1)
actionpack (= 7.0.8.1)
activesupport (= 7.0.8.1)
railties (7.0.8.3)
actionpack (= 7.0.8.3)
activesupport (= 7.0.8.3)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand Down Expand Up @@ -461,7 +461,7 @@ GEM
websocket-extensions (0.1.5)
wicked_pdf (2.6.3)
activesupport
zeitwerk (2.6.13)
zeitwerk (2.6.14)

PLATFORMS
ruby
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def run(source_instance:, target_class:, embedded_documents: [], attributes_to_e
end

def source_attributes
source_instance.attributes.except(*attributes_to_exclude)
attributes = source_instance.is_a?(BSON::Document) ? source_instance : source_instance.attributes

attributes.except(*attributes_to_exclude)
end

def target_fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ module WasteCarriersEngine

# ensure all available attributes are populated on the source
before do
source_instance.class.fields.keys.excluding("_id").each do |attr|
next unless source_instance.send(attr).blank? && source_instance.respond_to?("#{attr}=")
unless source_instance.is_a?(BSON::Document)
source_instance.class.fields.keys.excluding("_id").each do |attr|
next unless source_instance.send(attr).blank? && source_instance.respond_to?("#{attr}=")

source_instance.send "#{attr}=", 0
source_instance.send "#{attr}=", 0
end
end
end

Expand Down Expand Up @@ -47,7 +49,7 @@ module WasteCarriersEngine
context "when the target is a Registration" do
let(:target_class) { Registration }
# include all embeds_many relationships
let(:embedded_documents) { %w[addresses finainceDetails metaData] }
let(:embedded_documents) { %w[addresses financeDetails metaData] }
let(:copyable_attributes) { %w[location contactEmail] }
let(:non_copyable_attributes) { %w[workflow_state temp_contact_postcode not_even_an_attribute] }
let(:exclusion_list) { %w[_id email_history] }
Expand All @@ -69,6 +71,12 @@ module WasteCarriersEngine

it_behaves_like "returns the correct attributes"
end

context "when the source is a BSON::Document" do
let(:source_instance) { BSON::Document.new(build(:new_registration, :has_required_data).attributes) }

it_behaves_like "returns the correct attributes"
end
end

context "when the source and target are Addresses" do
Expand Down

0 comments on commit fb03def

Please sign in to comment.