View | Details | Raw Unified | Return to bug 27593
Collapse All | Expand All

(-)a/t/db_dependent/api/v1/clubs_holds.t (-3 / +57 lines)
Lines 61-67 subtest 'add() tests' => sub { Link Here
61
61
62
    subtest 'librarian access tests' => sub {
62
    subtest 'librarian access tests' => sub {
63
63
64
        plan tests => 8;
64
        plan tests => 20;
65
65
66
        $schema->storage->txn_begin;
66
        $schema->storage->txn_begin;
67
67
Lines 71-83 subtest 'add() tests' => sub { Link Here
71
        my $librarian = $builder->build_object(
71
        my $librarian = $builder->build_object(
72
            {
72
            {
73
                class => 'Koha::Patrons',
73
                class => 'Koha::Patrons',
74
                value => { flags => 2**6 }    # reserveforothers flag = 6
74
                value => { flags => 2 ** 6 }    # reserveforothers flag = 6
75
            }
75
            }
76
        );
76
        );
77
        my $password = 'thePassword123';
77
        my $password = 'thePassword123';
78
        $librarian->set_password( { password => $password, skip_validation => 1 } );
78
        $librarian->set_password( { password => $password, skip_validation => 1 } );
79
        my $userid = $librarian->userid;
79
        my $userid = $librarian->userid;
80
80
81
        my $non_existent_item   = $builder->build_sample_item;
82
        my $non_existent_biblio = $non_existent_item->biblio;
83
84
        my $non_existent_item_id   = $non_existent_item->id;
85
        my $non_existent_biblio_id = $non_existent_biblio->id;
86
        my $non_existent_item_homebranch =
87
          $non_existent_item->home_branch->branchcode;
88
89
        $non_existent_item->delete;
90
        $non_existent_biblio->delete;
91
92
        my $biblio = $builder->build_sample_biblio;
93
94
        $t->post_ok(
95
                "//$userid:$password@/api/v1/clubs/"
96
              . $club_with_enrollments->id
97
              . "/holds" => json => {
98
                biblio_id         => $biblio->id,
99
                item_id           => $item->id,
100
                pickup_library_id => $item->home_branch->branchcode
101
              }
102
        )->status_is(400)
103
          ->json_is( '/error' => "Item "
104
              . $item->id
105
              . " doesn't belong to biblio "
106
              . $biblio->id );
107
108
        $t->post_ok(
109
                "//$userid:$password@/api/v1/clubs/"
110
              . $club_with_enrollments->id
111
              . "/holds" => json => {
112
                pickup_library_id => $non_existent_item_homebranch
113
              }
114
        )->status_is(400)
115
          ->json_is(
116
            '/error' => 'At least one of biblio_id, item_id should be given' );
117
118
        $t->post_ok(
119
                "//$userid:$password@/api/v1/clubs/"
120
              . $club_with_enrollments->id
121
              . "/holds" => json => {
122
                biblio_id         => $non_existent_biblio_id,
123
                pickup_library_id => $non_existent_item_homebranch
124
              }
125
        )->status_is(404)->json_is( '/error' => 'Biblio not found' );
126
127
        $t->post_ok(
128
                "//$userid:$password@/api/v1/clubs/"
129
              . $club_with_enrollments->id
130
              . "/holds" => json => {
131
                item_id           => $non_existent_item_id,
132
                pickup_library_id => $non_existent_item_homebranch
133
              }
134
        )->status_is(404)->json_is( '/error' => 'Item not found' );
135
81
        my $data = {
136
        my $data = {
82
            biblio_id         => $item->biblionumber,
137
            biblio_id         => $item->biblionumber,
83
            pickup_library_id => $item->home_branch->branchcode
138
            pickup_library_id => $item->home_branch->branchcode
84
- 

Return to bug 27593