From 63fbe02c13b6779e8e236be28f4c613b9d58d2f3 Mon Sep 17 00:00:00 2001 From: Javier Julio Date: Fri, 26 Jan 2024 13:37:07 -0500 Subject: [PATCH] Update create_item test to use existing model --- .../cassettes/zesty/instances/create_item.yml | 144 ++++++++++++++++++ spec/zesty/client_spec.rb | 42 ++--- 2 files changed, 153 insertions(+), 33 deletions(-) create mode 100644 spec/cassettes/zesty/instances/create_item.yml diff --git a/spec/cassettes/zesty/instances/create_item.yml b/spec/cassettes/zesty/instances/create_item.yml new file mode 100644 index 0000000..93a3f00 --- /dev/null +++ b/spec/cassettes/zesty/instances/create_item.yml @@ -0,0 +1,144 @@ +--- +http_interactions: +- request: + method: post + uri: https://auth.api.zesty.io/login + body: + encoding: ASCII-8BIT + string: "-----------------------07b6f0a2033597a319258a45e0a322a991bea61bdf\r\nContent-Disposition: + form-data; name=\"email\"\r\n\r\n\r\n-----------------------07b6f0a2033597a319258a45e0a322a991bea61bdf\r\nContent-Disposition: + form-data; name=\"password\"\r\n\r\n\r\n-----------------------07b6f0a2033597a319258a45e0a322a991bea61bdf--\r\n" + headers: + Accept: + - application/json + Connection: + - close + Content-Type: + - multipart/form-data; boundary=---------------------07b6f0a2033597a319258a45e0a322a991bea61bdf + Host: + - auth.api.zesty.io + User-Agent: + - http.rb/5.1.1 + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 26 Jan 2024 18:28:46 GMT + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '214' + Vary: + - Accept-Encoding + - Origin + X-Dns-Prefetch-Control: + - 'off' + X-Frame-Options: + - DENY + Strict-Transport-Security: + - max-age=15552000; includeSubDomains + X-Download-Options: + - noopen + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Surrogate-Control: + - no-store + Cache-Control: + - no-store, no-cache, must-revalidate, proxy-revalidate + Pragma: + - no-cache + Expires: + - '0' + Referrer-Policy: + - no-referrer + X-Permitted-Cross-Domain-Policies: + - none + Access-Control-Allow-Credentials: + - 'true' + Set-Cookie: + - APP_SID=; Domain=.zesty.io; Path=/; Secure + Etag: + - W/"d6-WN5CQNLLuZKo33BAXFzKkdIOSC8" + Via: + - 1.1 google + Alt-Svc: + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + Connection: + - close + body: + encoding: UTF-8 + string: '{"message":"Logged in successfully.","status":"OK","data":{"data":""},"meta":{"userZuid":"5-d8daa08585-l6620k","token":""},"code":200}' + recorded_at: Fri, 26 Jan 2024 18:28:46 GMT +- request: + method: post + uri: https://.api.zesty.io/v1/content/models/6-d08392dbc9-9gl4bk/items + body: + encoding: ASCII-8BIT + string: '{"web":{"metaTitle":"Example Only","metaLinkText":"Example Link Text"},"data":{"display_order":4,"lottery_name":"Test + Lottery","jackpot_amount":5000000,"next_drawing":"2024-01-26","primary_color":"#ff0000"}}' + headers: + Accept: + - application/json + Authorization: + - Bearer + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - ".api.zesty.io" + User-Agent: + - http.rb/5.1.1 + response: + status: + code: 201 + message: Created + headers: + Date: + - Fri, 26 Jan 2024 18:28:46 GMT + Content-Type: + - text/plain; charset=utf-8 + Content-Length: + - '142' + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Headers: + - Cookie, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, + accept, origin, Cache-Control, X-Requested-With, X-Auth + Access-Control-Allow-Methods: + - PUT, POST, GET, PATCH, DELETE, OPTIONS + Access-Control-Allow-Origin: + - '' + Content-Security-Policy: + - '' + Feature-Policy: + - '' + Instances-Api-Cache: + - unreachable + Referrer-Policy: + - no-referrer-when-downgrade + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - sameorigin + X-Permitted-Cross-Domain-Policies: + - '' + X-Xss-Protection: + - 1;mode=block + Via: + - 1.1 google + Alt-Svc: + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + Connection: + - close + body: + encoding: UTF-8 + string: '{"_meta":{"timestamp":"2024-01-26T18:28:46.52808851Z","totalResults":1,"start":0,"offset":0,"limit":1},"data":{"ZUID":"7-d48aa29bd3-r1nqf7"}} + + ' + recorded_at: Fri, 26 Jan 2024 18:28:46 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/zesty/client_spec.rb b/spec/zesty/client_spec.rb index 1d3c637..892a6e7 100644 --- a/spec/zesty/client_spec.rb +++ b/spec/zesty/client_spec.rb @@ -176,48 +176,24 @@ describe '#create_item' do it "creates an item successfully" do - model = VCR.use_cassette("zesty/instances/create_item") do + item = VCR.use_cassette("zesty/instances/create_item") do result = client.create_item( model_zuid, - parent_zuid, web: { - metaTitle: "Example Only", - metaLinkText: "Example Link Text", - pathPart: "example-only" + meta_title: "Example Only", + meta_link_text: "Example Link Text", }, data: { - event_details_title: "postman test only", - charity_name: "postman test", - sweepstakes_datetime: "September 28 5PM", - event_entry_start_date: "August 15, 2023", - event_entry_start_time: "3:00:00 PM", - event_stream_start_date: "December 21, 2023", - event_stream_start_time: "2:59:59 PM", - event_drawing_date: "December 23, 2034", - event_drawing_time: "5:00:00 PM", - event_reveal_date: "December 24, 2034", - event_reveal_time: "6:00:00 PM", - donation_increment_title: "two", - donation_increment_amount: 2, - drawing_1_winning_pattern_name: "Line", - drawing_1_winning_pattern_description: "five (5) Clicked Numbers in any straight line on a Card", - drawing_1_prize_amount: 50, - drawing_1_prize_text: "fifty", - drawing_2_winning_pattern_name: "Stamp", - drawing_2_winning_pattern_description: "sixteen (16) Clicked Numbers around the edges of a Card", - drawing_2_prize_amount: 30, - drawing_2_prize_text: "thirty", - drawing_3_winning_pattern_name: "Corners", - drawing_3_winning_pattern_description: "twenty-five (25) Clicked Numbers on a Card", - drawing_3_prize_amount: 100, - drawing_3_prize_text: "one hundred", - drawings_total_prize_text: "five thousand five hundred fifty", - drawings_total_prize_amount: "5,550" + display_order: 4, + lottery_name: "Test Lottery", + jackpot_amount: 5_000_000, + next_drawing: "2024-01-26", + primary_color: "#ff0000" } ) end - pp model + pp item end end