Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ms graph include reference number #1372

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 29 additions & 28 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ workflows:
branches:
only:
- main
- ms-graph-include-reference-number
- deploy_to_test_dev:
context: *moj-forms-context
requires:
Expand All @@ -282,31 +283,31 @@ workflows:
requires:
- deploy_to_test_dev
- deploy_to_test_production
- build_and_push_image_live:
context: *moj-forms-context
requires:
- acceptance_tests
filters:
branches:
only: main
- deploy_to_live_dev:
context: *moj-forms-context
requires:
- acceptance_tests
- build_and_push_image_live
filters:
branches:
only: main
- deploy_to_live_production:
context: *moj-forms-context
requires:
- acceptance_tests
- build_and_push_image_live
filters:
branches:
only: main
- smoke_tests:
context: *moj-forms-context
requires:
- deploy_to_live_dev
- deploy_to_live_production
# - build_and_push_image_live:
# context: *moj-forms-context
# requires:
# - acceptance_tests
# filters:
# branches:
# only: main
# - deploy_to_live_dev:
# context: *moj-forms-context
# requires:
# - acceptance_tests
# - build_and_push_image_live
# filters:
# branches:
# only: main
# - deploy_to_live_production:
# context: *moj-forms-context
# requires:
# - acceptance_tests
# - build_and_push_image_live
# filters:
# branches:
# only: main
# - smoke_tests:
# context: *moj-forms-context
# requires:
# - deploy_to_live_dev
# - deploy_to_live_production
1 change: 1 addition & 0 deletions app/services/platform/submitter_payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def ms_list_action
site_id: ENV['MS_SITE_ID'],
list_id: ENV['MS_LIST_ID'],
drive_id: ENV['MS_DRIVE_ID'],
reference_number: user_data['moj_forms_reference_number'] || '',
include_attachments: send_attachments_to_ms_list?
}
end
Expand Down
91 changes: 91 additions & 0 deletions spec/services/platform/submitter_payload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,62 @@ def content_components_text
end

describe 'ms list action' do
let(:user_data) do
{
'moj_forms_reference_number' => 'ref-123-xyz',
'name_text_1' => 'Legolas',
'email-address_email_1' => '[email protected]',
'parent-name_text_1' => 'Thranduil',
'your-age_number_1' => '2931',
'family-hobbies_textarea_1' => textarea_answer,
'do-you-like-star-wars_radios_1' => 'Only on weekends',
'holiday_date_1(3i)' => '30',
'holiday_date_1(2i)' => '12',
'holiday_date_1(1i)' => '2020',
'burgers_checkboxes_1' => ['Beef, cheese, tomato', 'Chicken, cheese, tomato'],
'star-wars-knowledge_text_1' => 'Max Rebo Band',
'star-wars-knowledge_radios_1' => 'Din Jarrin',
'dog-picture_upload_1' => {
'original_filename' => 'basset-hound.jpg',
'content_type' => 'image/jpg',
'tempfile' => upload_file.path,
'fingerprint' => '28d-6dbfe5a3fff4a67260e7057e49b13ae0794598a949907a',
'size' => 1_392_565,
'type' => 'image/jpg',
'date' => 1_624_540_833
},
'dog-picture_upload_2' => [
{
'original_filename' => 'basset-hound.jpg',
'content_type' => 'image/jpg',
'tempfile' => upload_file.path,
'fingerprint' => '28d-6dbfe5a3fff4a67260e7057e49b13ae0794598a949907a',
'size' => 1_392_565,
'type' => 'image/jpg',
'date' => 1_624_540_833
},
{
'original_filename' => 'basset-hound.jpg',
'content_type' => 'image/jpg',
'tempfile' => upload_file.path,
'fingerprint' => '28d-6dbfe5a3fff4a67260e7057e49b13ae0794598a949907a',
'size' => 1_392_565,
'type' => 'image/jpg',
'date' => 1_624_540_833
}
],
'countries_autocomplete_1' => '{"text":"Malawi","value":"MW"}',
'postal-address_address_1' => {
'address_line_one' => '1 road',
'address_line_two' => '',
'city' => 'ruby town',
'county' => '',
'postcode' => '99 999',
'country' => 'ruby land'
}
}
end

context 'when there is no email submission at all, only to send to list' do
before do
allow(ENV).to receive(:[]).with('SERVICE_EMAIL_OUTPUT').and_return(nil)
Expand All @@ -1011,6 +1067,7 @@ def content_components_text
site_id: 'a-site-id',
list_id: 'a-list-id',
drive_id: nil,
reference_number: 'ref-123-xyz',
include_attachments: false
}
]
Expand Down Expand Up @@ -1041,6 +1098,7 @@ def content_components_text
site_id: 'a-site-id',
list_id: 'a-list-id',
drive_id: 'a-drive-id',
reference_number: 'ref-123-xyz',
include_attachments: true
}
]
Expand All @@ -1051,13 +1109,46 @@ def content_components_text
end
end

context 'when reference number is not configured' do
before do
allow(ENV).to receive(:[]).with('SERVICE_EMAIL_OUTPUT').and_return(nil)
allow(ENV).to receive(:[]).with('SERVICE_OUTPUT_JSON_ENDPOINT').and_return(nil)
allow(ENV).to receive(:[]).with('SERVICE_OUTPUT_JSON_KEY').and_return(nil)
allow(ENV).to receive(:[]).with('MS_LIST_ID').and_return('a-list-id')
allow(ENV).to receive(:[]).with('MS_SITE_ID').and_return('a-site-id')
allow(ENV).to receive(:[]).with('MS_DRIVE_ID').and_return('a-drive-id')
user_data['moj_forms_reference_number'] = nil
# will default to the 1.0 graph api if not configured
allow(ENV).to receive(:[]).with('MS_GRAPH_ROOT_URL').and_return(nil)
end

let(:expected_actions) do
[
{
kind: 'mslist',
graph_url: 'https://graph.microsoft.com/v1.0/',
site_id: 'a-site-id',
list_id: 'a-list-id',
drive_id: 'a-drive-id',
reference_number: '',
include_attachments: true
}
]
end

it 'should return the action with a blank reference' do
expect(subject.actions).to eq(expected_actions)
end
end

context 'when missing some configuration' do
before do
allow(ENV).to receive(:[]).with('SERVICE_EMAIL_OUTPUT').and_return(nil)
allow(ENV).to receive(:[]).with('SERVICE_OUTPUT_JSON_ENDPOINT').and_return(nil)
allow(ENV).to receive(:[]).with('SERVICE_OUTPUT_JSON_KEY').and_return(nil)
allow(ENV).to receive(:[]).with('MS_LIST_ID').and_return(nil)
allow(ENV).to receive(:[]).with('MS_SITE_ID').and_return(nil)
user_data['moj_forms_reference_number'] = nil
end

context 'missing site id' do
Expand Down
Loading