@@ -9,7 +9,13 @@ def base_url_for(user_id = nil)
99 let ( :request_headers ) { { 'Accept' => 'application/json' , 'Authorization' => "apikey #{ alma_api_key } " } }
1010
1111 before do
12- allow ( Rails . application . config ) . to receive ( :alma_api_key ) . and_return ( alma_api_key )
12+ allow ( AlmaJwtValidator ) . to receive ( :decode_and_verify_jwt ) . and_return (
13+ [ { 'userName' => '10335026' } ]
14+ )
15+ allow ( Rails . application . config ) . to receive_messages (
16+ alma_api_key : alma_api_key ,
17+ alma_jwt_secret : 'fake-jwt-secret'
18+ )
1319 end
1420
1521 it 'redirects to the fallback URL if there is no jwt' do
@@ -18,7 +24,8 @@ def base_url_for(user_id = nil)
1824 end
1925
2026 it 'redirects to error page if request has a non-existant alma id' do
21- stub_request ( :get , "#{ base_url_for } fees" )
27+ user_id = '10335026'
28+ stub_request ( :get , "#{ base_url_for ( user_id ) } /fees" )
2229 . with ( headers : request_headers )
2330 . to_return ( status : 404 , body : '' )
2431
@@ -53,9 +60,10 @@ def base_url_for(user_id = nil)
5360 end
5461
5562 it 'payments page redirects to index if no fee was selected for payment' do
56- post '/fees/payment' , params : { jwt : File . read ( 'spec/data/fees/alma-fees-jwt.txt' ) }
63+ jwt = File . read ( 'spec/data/fees/alma-fees-jwt.txt' ) . strip
64+ post '/fees/payment' , params : { jwt : jwt }
5765 expect ( response ) . to have_http_status ( :found )
58- expect ( response ) . to redirect_to ( "#{ fees_path } ?jwt=#{ File . read ( 'spec/data/fees/alma-fees- jwt.txt' ) } " )
66+ expect ( response ) . to redirect_to ( "#{ fees_path } ?jwt=#{ jwt } " )
5967 end
6068
6169 it 'successful transaction_complete returns status 200' do
0 commit comments