|
24 | 24 | .with(path: path, query_params: nil) |
25 | 25 | .and_return(response) |
26 | 26 |
|
27 | | - bookings_response = bookings.find(booking_id: booking_id, query_params: nil) |
| 27 | + bookings_response = bookings.find(booking_id: booking_id) |
| 28 | + |
| 29 | + expect(bookings_response).to eq(response) |
| 30 | + end |
| 31 | + |
| 32 | + it "calls the get method with the correct query params" do |
| 33 | + booking_id = "booking-123" |
| 34 | + query_params = { "foo": "bar" } |
| 35 | + path = "#{api_uri}/v3/scheduling/bookings/#{booking_id}" |
| 36 | + allow(bookings).to receive(:get) |
| 37 | + .with(path: path, query_params: query_params) |
| 38 | + .and_return(response) |
| 39 | + |
| 40 | + bookings_response = bookings.find(booking_id: booking_id, query_params: query_params) |
28 | 41 |
|
29 | 42 | expect(bookings_response).to eq(response) |
30 | 43 | end |
|
50 | 63 | .with(path: path, request_body: request_body, query_params: nil) |
51 | 64 | .and_return(response) |
52 | 65 |
|
53 | | - bookings_response = bookings.create(request_body: request_body, query_params: nil) |
| 66 | + bookings_response = bookings.create(request_body: request_body) |
| 67 | + |
| 68 | + expect(bookings_response).to eq(response) |
| 69 | + end |
| 70 | + |
| 71 | + it "calls the post method with the correct query parameters" do |
| 72 | + request_body = { |
| 73 | + start_time: 1730194200, |
| 74 | + end_time: 1730196000, |
| 75 | + participants: [ |
| 76 | + { |
| 77 | + email: "scheduler-booking@nylas.com" |
| 78 | + } |
| 79 | + ], |
| 80 | + guest: { |
| 81 | + name: "TEST", |
| 82 | + email: "test@nylas.com" |
| 83 | + } |
| 84 | + } |
| 85 | + query_params = { "foo": "bar" } |
| 86 | + path = "#{api_uri}/v3/scheduling/bookings" |
| 87 | + allow(bookings).to receive(:post) |
| 88 | + .with(path: path, request_body: request_body, query_params: query_params) |
| 89 | + .and_return(response) |
| 90 | + |
| 91 | + bookings_response = bookings.create(request_body: request_body, query_params: query_params) |
54 | 92 |
|
55 | 93 | expect(bookings_response).to eq(response) |
56 | 94 | end |
|
68 | 106 | .with(path: path, request_body: request_body, query_params: nil) |
69 | 107 | .and_return(response) |
70 | 108 |
|
| 109 | + bookings_response = bookings.update( |
| 110 | + request_body: request_body, |
| 111 | + booking_id: booking_id |
| 112 | + ) |
| 113 | + |
| 114 | + expect(bookings_response).to eq(response) |
| 115 | + end |
| 116 | + |
| 117 | + it "calls the patch method with the correct query parameters" do |
| 118 | + booking_id = "booking-123" |
| 119 | + query_params = { "foo": "bar" } |
| 120 | + request_body = { |
| 121 | + start_time: 1730194200, |
| 122 | + end_time: 1730196000 |
| 123 | + } |
| 124 | + path = "#{api_uri}/v3/scheduling/bookings/#{booking_id}" |
| 125 | + allow(bookings).to receive(:patch) |
| 126 | + .with(path: path, request_body: request_body, query_params: query_params) |
| 127 | + .and_return(response) |
| 128 | + |
71 | 129 | bookings_response = bookings.update( |
72 | 130 | request_body: request_body, |
73 | 131 | booking_id: booking_id, |
74 | | - query_params: nil |
| 132 | + query_params: query_params |
75 | 133 | ) |
76 | 134 |
|
77 | 135 | expect(bookings_response).to eq(response) |
78 | 136 | end |
79 | 137 | end |
80 | 138 |
|
81 | | - describe "#confirm_booking" do |
| 139 | + describe "#confirm" do |
82 | 140 | it "calls the put method with the correct parameters" do |
83 | 141 | booking_id = "booking-123" |
84 | 142 | request_body = { |
|
90 | 148 | .with(path: path, request_body: request_body, query_params: nil) |
91 | 149 | .and_return(response) |
92 | 150 |
|
93 | | - bookings_response = bookings.confirm_booking( |
| 151 | + bookings_response = bookings.confirm( |
| 152 | + booking_id: booking_id, |
| 153 | + request_body: request_body |
| 154 | + ) |
| 155 | + |
| 156 | + expect(bookings_response).to eq(response) |
| 157 | + end |
| 158 | + |
| 159 | + it "calls the put method with the correct query parameters" do |
| 160 | + booking_id = "booking-123" |
| 161 | + query_params = { "foo": "bar" } |
| 162 | + request_body = { |
| 163 | + salt: "_salt", |
| 164 | + status: "cancelled" |
| 165 | + } |
| 166 | + path = "#{api_uri}/v3/scheduling/bookings/#{booking_id}" |
| 167 | + allow(bookings).to receive(:put) |
| 168 | + .with(path: path, request_body: request_body, query_params: query_params) |
| 169 | + .and_return(response) |
| 170 | + |
| 171 | + bookings_response = bookings.confirm( |
94 | 172 | booking_id: booking_id, |
95 | 173 | request_body: request_body, |
96 | | - query_params: nil |
| 174 | + query_params: query_params |
97 | 175 | ) |
98 | 176 |
|
99 | 177 | expect(bookings_response).to eq(response) |
|
110 | 188 | .with(path: path, query_params: nil) |
111 | 189 | .and_return(delete_response) |
112 | 190 |
|
113 | | - bookings_response = bookings.destroy(booking_id: booking_id, query_params: nil) |
| 191 | + bookings_response = bookings.destroy(booking_id: booking_id) |
| 192 | + expect(bookings_response).to eq(delete_response) |
| 193 | + end |
| 194 | + |
| 195 | + it "calls the delete method with the correct query parameters" do |
| 196 | + booking_id = "booking-123" |
| 197 | + query_params = { "foo": "bar" } |
| 198 | + path = "#{api_uri}/v3/scheduling/bookings/#{booking_id}" |
| 199 | + allow(bookings).to receive(:delete) |
| 200 | + .with(path: path, query_params: query_params) |
| 201 | + .and_return(delete_response) |
| 202 | + |
| 203 | + bookings_response = bookings.destroy(booking_id: booking_id, query_params: query_params) |
114 | 204 | expect(bookings_response).to eq(delete_response) |
115 | 205 | end |
116 | 206 | end |
|
0 commit comments