|
154 | 154 | end |
155 | 155 | end |
156 | 156 |
|
157 | | - # describe 'GET /api/v1/airlines/list' do |
158 | | - # let(:country) { 'United States' } |
159 | | - # let(:limit) { '10' } |
160 | | - # let(:offset) { '0' } |
161 | | - # let(:expected_airlines) do |
162 | | - # [ |
163 | | - # { 'name' => '40-Mile Air', 'iata' => 'Q5', 'icao' => 'MLA', 'callsign' => 'MILE-AIR', |
164 | | - # 'country' => 'United States' }, |
165 | | - # { 'name' => 'Texas Wings', 'iata' => 'TQ', 'icao' => 'TXW', 'callsign' => 'TXW', 'country' => 'United States' }, |
166 | | - # { 'name' => 'Atifly', 'iata' => 'A1', 'icao' => 'A1F', 'callsign' => 'atifly', 'country' => 'United States' }, |
167 | | - # { 'name' => 'Locair', 'iata' => 'ZQ', 'icao' => 'LOC', 'callsign' => 'LOCAIR', 'country' => 'United States' }, |
168 | | - # { 'name' => 'SeaPort Airlines', 'iata' => 'K5', 'icao' => 'SQH', 'callsign' => 'SASQUATCH', |
169 | | - # 'country' => 'United States' }, |
170 | | - # { 'name' => 'Alaska Central Express', 'iata' => 'KO', 'icao' => 'AER', 'callsign' => 'ACE AIR', |
171 | | - # 'country' => 'United States' }, |
172 | | - # { 'name' => 'AirTran Airways', 'iata' => 'FL', 'icao' => 'TRS', 'callsign' => 'CITRUS', |
173 | | - # 'country' => 'United States' }, |
174 | | - # { 'name' => 'U.S. Air', 'iata' => '-+', 'icao' => '--+', 'callsign' => nil, 'country' => 'United States' }, |
175 | | - # { 'name' => 'PanAm World Airways', 'iata' => 'WQ', 'icao' => 'PQW', 'callsign' => nil, |
176 | | - # 'country' => 'United States' }, |
177 | | - # { 'name' => 'Bemidji Airlines', 'iata' => 'CH', 'icao' => 'BMJ', 'callsign' => 'BEMIDJI', |
178 | | - # 'country' => 'United States' } |
179 | | - # ] |
180 | | - # end |
| 157 | + describe 'GET /api/v1/airlines/list' do |
| 158 | + let(:country) { 'United States' } |
| 159 | + let(:limit) { '10' } |
| 160 | + let(:offset) { '0' } |
| 161 | + let(:expected_airlines) do |
| 162 | + [ |
| 163 | + { 'name' => '40-Mile Air', 'iata' => 'Q5', 'icao' => 'MLA', 'callsign' => 'MILE-AIR', |
| 164 | + 'country' => 'United States' }, |
| 165 | + { 'name' => 'Texas Wings', 'iata' => 'TQ', 'icao' => 'TXW', 'callsign' => 'TXW', 'country' => 'United States' }, |
| 166 | + { 'name' => 'Atifly', 'iata' => 'A1', 'icao' => 'A1F', 'callsign' => 'atifly', 'country' => 'United States' }, |
| 167 | + { 'name' => 'Locair', 'iata' => 'ZQ', 'icao' => 'LOC', 'callsign' => 'LOCAIR', 'country' => 'United States' }, |
| 168 | + { 'name' => 'SeaPort Airlines', 'iata' => 'K5', 'icao' => 'SQH', 'callsign' => 'SASQUATCH', |
| 169 | + 'country' => 'United States' }, |
| 170 | + { 'name' => 'Alaska Central Express', 'iata' => 'KO', 'icao' => 'AER', 'callsign' => 'ACE AIR', |
| 171 | + 'country' => 'United States' }, |
| 172 | + { 'name' => 'AirTran Airways', 'iata' => 'FL', 'icao' => 'TRS', 'callsign' => 'CITRUS', |
| 173 | + 'country' => 'United States' }, |
| 174 | + { 'name' => 'U.S. Air', 'iata' => '-+', 'icao' => '--+', 'callsign' => nil, 'country' => 'United States' }, |
| 175 | + { 'name' => 'PanAm World Airways', 'iata' => 'WQ', 'icao' => 'PQW', 'callsign' => nil, |
| 176 | + 'country' => 'United States' }, |
| 177 | + { 'name' => 'Bemidji Airlines', 'iata' => 'CH', 'icao' => 'BMJ', 'callsign' => 'BEMIDJI', |
| 178 | + 'country' => 'United States' } |
| 179 | + ] |
| 180 | + end |
181 | 181 |
|
182 | | - # it 'returns a list of airlines for a given country' do |
183 | | - # get '/api/v1/airlines/list', params: { country:, limit:, offset: } |
| 182 | + it 'returns a list of airlines for a given country' do |
| 183 | + get '/api/v1/airlines/list', params: { country:, limit:, offset: } |
184 | 184 |
|
185 | | - # expect(response).to have_http_status(:ok) |
186 | | - # expect(response.content_type).to eq('application/json; charset=utf-8') |
187 | | - # expect(JSON.parse(response.body)).to eq(expected_airlines) |
188 | | - # end |
189 | | - # end |
| 185 | + expect(response).to have_http_status(:ok) |
| 186 | + expect(response.content_type).to eq('application/json; charset=utf-8') |
| 187 | + expect(JSON.parse(response.body)).to eq(expected_airlines) |
| 188 | + end |
| 189 | + end |
190 | 190 |
|
191 | | - # describe 'GET /api/v1/airlines/to-airport' do |
192 | | - # let(:destination_airport_code) { 'MRS' } |
193 | | - # let(:limit) { '10' } |
194 | | - # let(:offset) { '0' } |
195 | | - # let(:expected_airlines) do |
196 | | - # [ |
197 | | - # { |
198 | | - # 'callsign' => 'AIRFRANS', |
199 | | - # 'country' => 'France', |
200 | | - # 'iata' => 'AF', |
201 | | - # 'icao' => 'AFR', |
202 | | - # 'name' => 'Air France' |
203 | | - # }, |
204 | | - # { |
205 | | - # 'callsign' => 'SPEEDBIRD', |
206 | | - # 'country' => 'United Kingdom', |
207 | | - # 'iata' => 'BA', |
208 | | - # 'icao' => 'BAW', |
209 | | - # 'name' => 'British Airways' |
210 | | - # }, |
211 | | - # { |
212 | | - # 'callsign' => 'AIRLINAIR', |
213 | | - # 'country' => 'France', |
214 | | - # 'iata' => 'A5', |
215 | | - # 'icao' => 'RLA', |
216 | | - # 'name' => 'Airlinair' |
217 | | - # }, |
218 | | - # { |
219 | | - # 'callsign' => 'STARWAY', |
220 | | - # 'country' => 'France', |
221 | | - # 'iata' => 'SE', |
222 | | - # 'icao' => 'SEU', |
223 | | - # 'name' => 'XL Airways France' |
224 | | - # }, |
225 | | - # { |
226 | | - # 'callsign' => 'TWINJET', |
227 | | - # 'country' => 'France', |
228 | | - # 'iata' => 'T7', |
229 | | - # 'icao' => 'TJT', |
230 | | - # 'name' => 'Twin Jet' |
231 | | - # }, |
232 | | - # { |
233 | | - # 'callsign' => 'EASY', |
234 | | - # 'country' => 'United Kingdom', |
235 | | - # 'iata' => 'U2', |
236 | | - # 'icao' => 'EZY', |
237 | | - # 'name' => 'easyJet' |
238 | | - # }, |
239 | | - # { |
240 | | - # 'callsign' => 'AMERICAN', |
241 | | - # 'country' => 'United States', |
242 | | - # 'iata' => 'AA', |
243 | | - # 'icao' => 'AAL', |
244 | | - # 'name' => 'American Airlines' |
245 | | - # }, |
246 | | - # { |
247 | | - # 'callsign' => 'CORSICA', |
248 | | - # 'country' => 'France', |
249 | | - # 'iata' => 'XK', |
250 | | - # 'icao' => 'CCM', |
251 | | - # 'name' => 'Corse-Mediterranee' |
252 | | - # } |
253 | | - # ] |
254 | | - # end |
| 191 | + describe 'GET /api/v1/airlines/to-airport' do |
| 192 | + let(:destination_airport_code) { 'MRS' } |
| 193 | + let(:limit) { '10' } |
| 194 | + let(:offset) { '0' } |
| 195 | + let(:expected_airlines) do |
| 196 | + [ |
| 197 | + { |
| 198 | + 'callsign' => 'AIRFRANS', |
| 199 | + 'country' => 'France', |
| 200 | + 'iata' => 'AF', |
| 201 | + 'icao' => 'AFR', |
| 202 | + 'name' => 'Air France' |
| 203 | + }, |
| 204 | + { |
| 205 | + 'callsign' => 'SPEEDBIRD', |
| 206 | + 'country' => 'United Kingdom', |
| 207 | + 'iata' => 'BA', |
| 208 | + 'icao' => 'BAW', |
| 209 | + 'name' => 'British Airways' |
| 210 | + }, |
| 211 | + { |
| 212 | + 'callsign' => 'AIRLINAIR', |
| 213 | + 'country' => 'France', |
| 214 | + 'iata' => 'A5', |
| 215 | + 'icao' => 'RLA', |
| 216 | + 'name' => 'Airlinair' |
| 217 | + }, |
| 218 | + { |
| 219 | + 'callsign' => 'STARWAY', |
| 220 | + 'country' => 'France', |
| 221 | + 'iata' => 'SE', |
| 222 | + 'icao' => 'SEU', |
| 223 | + 'name' => 'XL Airways France' |
| 224 | + }, |
| 225 | + { |
| 226 | + 'callsign' => 'TWINJET', |
| 227 | + 'country' => 'France', |
| 228 | + 'iata' => 'T7', |
| 229 | + 'icao' => 'TJT', |
| 230 | + 'name' => 'Twin Jet' |
| 231 | + }, |
| 232 | + { |
| 233 | + 'callsign' => 'EASY', |
| 234 | + 'country' => 'United Kingdom', |
| 235 | + 'iata' => 'U2', |
| 236 | + 'icao' => 'EZY', |
| 237 | + 'name' => 'easyJet' |
| 238 | + }, |
| 239 | + { |
| 240 | + 'callsign' => 'AMERICAN', |
| 241 | + 'country' => 'United States', |
| 242 | + 'iata' => 'AA', |
| 243 | + 'icao' => 'AAL', |
| 244 | + 'name' => 'American Airlines' |
| 245 | + }, |
| 246 | + { |
| 247 | + 'callsign' => 'CORSICA', |
| 248 | + 'country' => 'France', |
| 249 | + 'iata' => 'XK', |
| 250 | + 'icao' => 'CCM', |
| 251 | + 'name' => 'Corse-Mediterranee' |
| 252 | + } |
| 253 | + ] |
| 254 | + end |
255 | 255 |
|
256 | | - # context 'when destinationAirportCode is provided' do |
257 | | - # it 'returns a list of airlines flying to the destination airport' do |
258 | | - # get '/api/v1/airlines/to-airport', |
259 | | - # params: { destinationAirportCode: destination_airport_code, limit:, offset: } |
| 256 | + context 'when destinationAirportCode is provided' do |
| 257 | + it 'returns a list of airlines flying to the destination airport' do |
| 258 | + get '/api/v1/airlines/to-airport', |
| 259 | + params: { destinationAirportCode: destination_airport_code, limit:, offset: } |
260 | 260 |
|
261 | | - # expect(response).to have_http_status(:ok) |
262 | | - # expect(response.content_type).to eq('application/json; charset=utf-8') |
263 | | - # expect(JSON.parse(response.body)).to eq(expected_airlines) |
264 | | - # end |
265 | | - # end |
| 261 | + expect(response).to have_http_status(:ok) |
| 262 | + expect(response.content_type).to eq('application/json; charset=utf-8') |
| 263 | + expect(JSON.parse(response.body)).to eq(expected_airlines) |
| 264 | + end |
| 265 | + end |
266 | 266 |
|
267 | | - # context 'when destinationAirportCode is not provided' do |
268 | | - # it 'returns a bad request error' do |
269 | | - # get '/api/v1/airlines/to-airport', params: { limit:, offset: } |
| 267 | + context 'when destinationAirportCode is not provided' do |
| 268 | + it 'returns a bad request error' do |
| 269 | + get '/api/v1/airlines/to-airport', params: { limit:, offset: } |
270 | 270 |
|
271 | | - # expect(response).to have_http_status(:bad_request) |
272 | | - # expect(JSON.parse(response.body)).to eq({ 'message' => 'Destination airport code is required' }) |
273 | | - # end |
274 | | - # end |
275 | | - # end |
| 271 | + expect(response).to have_http_status(:bad_request) |
| 272 | + expect(JSON.parse(response.body)).to eq({ 'error' => 'Invalid request', |
| 273 | + 'message' => 'Destination airport is missing' }) |
| 274 | + end |
| 275 | + end |
| 276 | + end |
276 | 277 | end |
0 commit comments