From 8e00135390562fbd4895a21f7d015ad84fd6f49b Mon Sep 17 00:00:00 2001 From: Finn Date: Tue, 16 Jan 2018 15:55:19 +0000 Subject: [PATCH] Tests fixed adding for category --- t/api/upload.t | 8 ++++++++ t/etc/fixtures/config/transactions.pl | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/t/api/upload.t b/t/api/upload.t index 0522345..56e19ef 100644 --- a/t/api/upload.t +++ b/t/api/upload.t @@ -35,6 +35,11 @@ is $org_rs->count, 1, "1 testing organisation"; my $org_id_shinra = $shinra_entity->organisation->id; +$schema->resultset('Category')->create({ + id => 1, + name => "Test Category", +}); + #Valid customer, this also tests that redirects are disabled for register. print "test 1 - Create customer user account (Rufus)\n"; my $emailRufus = 'test1@example.com'; @@ -244,6 +249,7 @@ $json = { purchase_time => $test_purchase_time, organisation_id => $org_id_shinra, session_key => $session_key, + category => 1, }; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) @@ -282,6 +288,7 @@ $json = { street_name => "Slums, Sector 7", town => "Midgar", postcode => "E1 0AA", + category => 1, session_key => $session_key, }; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; @@ -380,6 +387,7 @@ $json = { purchase_time => $test_purchase_time, organisation_id => $unvalidatedOrganisationId, session_key => $session_key, + category => 1, }; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) diff --git a/t/etc/fixtures/config/transactions.pl b/t/etc/fixtures/config/transactions.pl index f98fddd..4f155c3 100644 --- a/t/etc/fixtures/config/transactions.pl +++ b/t/etc/fixtures/config/transactions.pl @@ -95,6 +95,11 @@ my $dtf = $schema->storage->datetime_parser; # Number of hours in 90 days my $time_count = 24 * 90; +$schema->resultset('Category')->create({ + id => 1, + name => "Test Category", +}); + for my $user ( $user1, $user2, $user3, $user4 ) { my $start = DateTime->new( @@ -109,12 +114,16 @@ for my $user ( $user1, $user2, $user3, $user4 ) { my $user_result = $schema->resultset('User')->find({ email => $user->{email} }); for ( 0 .. $time_count ) { - $user_result->create_related( 'transactions', { + my $test_transaction = $user_result->create_related( 'transactions', { seller_id => $org_result->id, value => ( int( rand( 10000 ) ) / 100 ), proof_image => 'a', purchase_time => $start->clone->subtract( hours => $_ ), }); + $schema->resultset('TransactionCategory')->create({ + category_id => 1, + transaction_id => $test_transaction->id, + }); } } @@ -125,4 +134,3 @@ $fixtures->dump({ schema => $schema, directory => "$Bin/../data/" . $data_set, }); -