From 99ee7da75124d8cfc6bca7c1f9448934fb45d20d Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Tue, 3 Jan 2017 22:27:50 +0200 Subject: [PATCH] TT#8272 Add necessary form_validation exceptions for the template fields Change-Id: I6fbccfce06d53d6cf0db58b8b84cb71a96e2057a --- lib/NGCP/Panel/Controller/API/Customers.pm | 2 +- lib/NGCP/Panel/Role/API/Customers.pm | 4 ++-- t/api-rest/api-customers-collection.t | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/NGCP/Panel/Controller/API/Customers.pm b/lib/NGCP/Panel/Controller/API/Customers.pm index 07579cfabb..644cb99c15 100644 --- a/lib/NGCP/Panel/Controller/API/Customers.pm +++ b/lib/NGCP/Panel/Controller/API/Customers.pm @@ -232,7 +232,7 @@ sub POST :Allow { c => $c, resource => $resource, form => $form, - exceptions => [ "contact_id", "billing_profile_id", "profile_package_id" ], + exceptions => [ "contact_id", "billing_profile_id", "profile_package_id", "invoice_template_id", "invoice_email_template_id", "passreset_email_template_id", "subscriber_email_template_id" ], ); #$resource->{profile_package_id} = undef unless NGCP::Panel::Utils::ProfilePackages::ENABLE_PROFILE_PACKAGES; diff --git a/lib/NGCP/Panel/Role/API/Customers.pm b/lib/NGCP/Panel/Role/API/Customers.pm index ddc42a0b4b..5b9837ad81 100644 --- a/lib/NGCP/Panel/Role/API/Customers.pm +++ b/lib/NGCP/Panel/Role/API/Customers.pm @@ -116,7 +116,7 @@ sub hal_from_customer { form => $form, resource => \%resource, run => 0, - exceptions => [ "contact_id", "billing_profile_id", "profile_package_id" ], + exceptions => [ "contact_id", "billing_profile_id", "profile_package_id", "invoice_template_id", "invoice_email_template_id", "passreset_email_template_id", "subscriber_email_template_id" ], ); # return the virtual "type" instead of the actual product id @@ -160,7 +160,7 @@ sub update_customer { c => $c, form => $form, resource => $resource, - exceptions => [ "contact_id", "billing_profile_id", "profile_package_id"], + exceptions => [ "contact_id", "billing_profile_id", "profile_package_id", "invoice_template_id", "invoice_email_template_id", "passreset_email_template_id", "subscriber_email_template_id"], ); #$resource->{profile_package_id} = undef unless NGCP::Panel::Utils::ProfilePackages::ENABLE_PROFILE_PACKAGES; diff --git a/t/api-rest/api-customers-collection.t b/t/api-rest/api-customers-collection.t index 9405c271f6..644f2b0e3e 100644 --- a/t/api-rest/api-customers-collection.t +++ b/t/api-rest/api-customers-collection.t @@ -47,7 +47,12 @@ SKIP:{ $test_machine->form_data_item( ); # create 3 new sound sets from DATA_ITEM - $test_machine->check_create_correct( 1, sub{ $_[0]->{external_id} .= $_[1]->{i}; } ); + my $customer = $test_machine->check_create_correct( 1, sub{ $_[0]->{external_id} .= $_[1]->{i}; } )->[0]; + is($customer->{content}->{invoice_template_id}, $invoicetemplate->{content}->{id}, "Check invoice template id of the created customer."); + for my $template_id (qw/subscriber_email_template_id passreset_email_template_id invoice_email_template_id/){ + is($customer->{content}->{$template_id}, $test_machine->DATA_ITEM->{$template_id}, "Check $template_id of the created customer."); + } + $test_machine->check_bundle(); }