Lines 30-36
use Koha::Database;
Link Here
|
30 |
|
30 |
|
31 |
my $schema = Koha::Database->new->schema; |
31 |
my $schema = Koha::Database->new->schema; |
32 |
|
32 |
|
33 |
my $issn = '321321321'; |
33 |
my $isbn = '321321321'; |
34 |
|
34 |
|
35 |
subtest 'show_history_check' => sub { |
35 |
subtest 'show_history_check' => sub { |
36 |
|
36 |
|
Lines 53-59
subtest 'show_history_check' => sub {
Link Here
|
53 |
my $metadata = { |
53 |
my $metadata = { |
54 |
title => 'This is a title', |
54 |
title => 'This is a title', |
55 |
author => 'This is an author', |
55 |
author => 'This is an author', |
56 |
issn => $issn, |
56 |
isbn => $isbn, |
57 |
cardnumber => $fake_cardnumber, |
57 |
cardnumber => $fake_cardnumber, |
58 |
}; |
58 |
}; |
59 |
|
59 |
|
Lines 70-76
subtest 'show_history_check' => sub {
Link Here
|
70 |
|
70 |
|
71 |
is( |
71 |
is( |
72 |
$history_check->prep_metadata($sorted), |
72 |
$history_check->prep_metadata($sorted), |
73 |
'eyJhdXRob3IiOiJUaGlzIGlzIGFuIGF1dGhvciIsImNhcmRudW1iZXIiOiIxMjM0NTY3ODkiLCJp%0Ac3NuIjoiMzIxMzIxMzIxIiwidGl0bGUiOiJUaGlzIGlzIGEgdGl0bGUifQ%3D%3D%0A', |
73 |
'eyJhdXRob3IiOiJUaGlzIGlzIGFuIGF1dGhvciIsImNhcmRudW1iZXIiOiIxMjM0NTY3ODkiLCJp%0Ac2JuIjoiMzIxMzIxMzIxIiwidGl0bGUiOiJUaGlzIGlzIGEgdGl0bGUifQ%3D%3D%0A', |
74 |
'prep_metadata works' |
74 |
'prep_metadata works' |
75 |
); |
75 |
); |
76 |
|
76 |
|
Lines 89-107
subtest 'show_history_check' => sub {
Link Here
|
89 |
my $ill_request = $builder->build_sample_ill_request( { borrowernumber => $ill_patron->borrowernumber } ); |
89 |
my $ill_request = $builder->build_sample_ill_request( { borrowernumber => $ill_patron->borrowernumber } ); |
90 |
is( |
90 |
is( |
91 |
$history_check->show_history_check($ill_request), |
91 |
$history_check->show_history_check($ill_request), |
92 |
0, 'Request with ISSN ' . $issn . ' does not exist even though syspref is on. Not showing history check screen' |
92 |
0, 'Request with ISBN ' . $isbn . ' does not exist even though syspref is on. Not showing history check screen' |
93 |
); |
93 |
); |
94 |
|
94 |
|
95 |
$builder->build( |
95 |
$builder->build( |
96 |
{ |
96 |
{ |
97 |
source => 'Illrequestattribute', |
97 |
source => 'Illrequestattribute', |
98 |
value => { illrequest_id => $ill_request->illrequest_id, type => 'issn', value => $issn } |
98 |
value => { illrequest_id => $ill_request->illrequest_id, type => 'isbn', value => $isbn } |
99 |
} |
99 |
} |
100 |
); |
100 |
); |
101 |
|
101 |
|
102 |
is( |
102 |
is( |
103 |
$history_check->show_history_check($ill_request), |
103 |
$history_check->show_history_check($ill_request), |
104 |
1, 'Request with ISSN ' . $issn . ' exists, syspref is on and is same patron. Able to show history check screen' |
104 |
1, 'Request with ISBN ' . $isbn . ' exists, syspref is on and is same patron. Able to show history check screen' |
105 |
); |
105 |
); |
106 |
|
106 |
|
107 |
# Mock ILLHistoryCheck disabled |
107 |
# Mock ILLHistoryCheck disabled |
Lines 128-134
subtest 'after_request_created' => sub {
Link Here
|
128 |
my $metadata = { |
128 |
my $metadata = { |
129 |
title => 'This is a title', |
129 |
title => 'This is a title', |
130 |
author => 'This is an author', |
130 |
author => 'This is an author', |
131 |
issn => $issn |
131 |
isbn => $isbn |
132 |
}; |
132 |
}; |
133 |
|
133 |
|
134 |
my $authenticated_patron = $builder->build_object( |
134 |
my $authenticated_patron = $builder->build_object( |
Lines 139-186
subtest 'after_request_created' => sub {
Link Here
|
139 |
|
139 |
|
140 |
t::lib::Mocks::mock_userenv( { patron => $authenticated_patron } ); |
140 |
t::lib::Mocks::mock_userenv( { patron => $authenticated_patron } ); |
141 |
|
141 |
|
142 |
# Create a new request with new issn |
142 |
# Create a new request with new isbn |
143 |
my $new_ill_request = |
143 |
my $new_ill_request = |
144 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
144 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
145 |
my $original_staff_notes = $new_ill_request->notesstaff; |
145 |
my $original_staff_notes = $new_ill_request->notesstaff; |
146 |
$metadata->{issn} = 'nonexistentissn'; |
146 |
$metadata->{isbn} = 'nonexistentisbn'; |
147 |
$builder->build( |
147 |
$builder->build( |
148 |
{ |
148 |
{ |
149 |
source => 'Illrequestattribute', |
149 |
source => 'Illrequestattribute', |
150 |
value => { illrequest_id => $new_ill_request->illrequest_id, type => 'issn', value => $metadata->{issn} } |
150 |
value => { illrequest_id => $new_ill_request->illrequest_id, type => 'isbn', value => $metadata->{isbn} } |
151 |
} |
151 |
} |
152 |
); |
152 |
); |
153 |
my $opac_history_check = Koha::ILL::Request::Workflow::HistoryCheck->new( $metadata, 'opac' ); |
153 |
my $opac_history_check = Koha::ILL::Request::Workflow::HistoryCheck->new( $metadata, 'opac' ); |
154 |
$opac_history_check->after_request_created( $metadata, $new_ill_request ); |
154 |
$opac_history_check->after_request_created( $metadata, $new_ill_request ); |
155 |
|
155 |
|
156 |
is( |
156 |
is( |
157 |
$new_ill_request->notesstaff, |
157 |
$new_ill_request->extended_attributes->find( { 'type' => 'historycheck_requests' } ), |
158 |
$original_staff_notes, |
158 |
undef, |
159 |
'History check didn\'t find any matching requests. Staff notes have not been updated.' |
159 |
'History check didn\'t find any matching requests. historycheck_requests illrequestattribute has not been updated.' |
160 |
); |
160 |
); |
161 |
|
161 |
|
162 |
# Create a second request with preexisting issn by self patron |
162 |
# Create a second request with preexisting isbn by self patron |
163 |
my $second_ill_request = |
163 |
my $second_ill_request = |
164 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
164 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
165 |
my $third_ill_request = |
165 |
my $third_ill_request = |
166 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
166 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
167 |
$metadata->{issn} = $issn; |
167 |
$metadata->{isbn} = $isbn; |
168 |
$builder->build( |
168 |
$builder->build( |
169 |
{ |
169 |
{ |
170 |
source => 'Illrequestattribute', |
170 |
source => 'Illrequestattribute', |
171 |
value => { illrequest_id => $second_ill_request->illrequest_id, type => 'issn', value => $issn } |
171 |
value => { illrequest_id => $second_ill_request->illrequest_id, type => 'isbn', value => $isbn } |
172 |
} |
172 |
} |
173 |
); |
173 |
); |
174 |
$builder->build( |
174 |
$builder->build( |
175 |
{ |
175 |
{ |
176 |
source => 'Illrequestattribute', |
176 |
source => 'Illrequestattribute', |
177 |
value => { illrequest_id => $third_ill_request->illrequest_id, type => 'issn', value => $issn } |
177 |
value => { illrequest_id => $third_ill_request->illrequest_id, type => 'isbn', value => $isbn } |
178 |
} |
178 |
} |
179 |
); |
179 |
); |
180 |
$opac_history_check->after_request_created( $metadata, $third_ill_request ); |
180 |
$opac_history_check->after_request_created( $metadata, $third_ill_request ); |
181 |
|
181 |
|
182 |
like( |
182 |
is( |
183 |
$third_ill_request->notesstaff, qr/Request has been submitted by this patron in the past/, |
183 |
$third_ill_request->extended_attributes->find( { 'type' => 'historycheck_requests' } )->value, |
|
|
184 |
$second_ill_request->illrequest_id, |
184 |
'Contains staffnotes related submissions by self patron' |
185 |
'Contains staffnotes related submissions by self patron' |
185 |
); |
186 |
); |
186 |
|
187 |
|
187 |
- |
|
|