|
450 | 450 | end |
451 | 451 | end |
452 | 452 | end |
| 453 | + |
| 454 | + describe '.list_organization_feature_flags' do |
| 455 | + context 'with no options' do |
| 456 | + it 'returns feature flags for organization' do |
| 457 | + expected_metadata = { |
| 458 | + after: nil, |
| 459 | + before: nil, |
| 460 | + } |
| 461 | + |
| 462 | + VCR.use_cassette 'organization/list_organization_feature_flags' do |
| 463 | + feature_flags = described_class.list_organization_feature_flags( |
| 464 | + organization_id: 'org_01HX7Q7R12H1JMAKN75SH2G529', |
| 465 | + ) |
| 466 | + |
| 467 | + expect(feature_flags.data.size).to eq(2) |
| 468 | + expect(feature_flags.list_metadata).to eq(expected_metadata) |
| 469 | + end |
| 470 | + end |
| 471 | + end |
| 472 | + |
| 473 | + context 'with the before option' do |
| 474 | + it 'forms the proper request to the API' do |
| 475 | + request_args = [ |
| 476 | + '/organizations/org_01HX7Q7R12H1JMAKN75SH2G529/feature-flags?before=before-id&'\ |
| 477 | + 'order=desc', |
| 478 | + 'Content-Type' => 'application/json' |
| 479 | + ] |
| 480 | + |
| 481 | + expected_request = Net::HTTP::Get.new(*request_args) |
| 482 | + |
| 483 | + expect(Net::HTTP::Get).to receive(:new).with(*request_args). |
| 484 | + and_return(expected_request) |
| 485 | + |
| 486 | + VCR.use_cassette 'organization/list_organization_feature_flags', match_requests_on: [:path] do |
| 487 | + feature_flags = described_class.list_organization_feature_flags( |
| 488 | + organization_id: 'org_01HX7Q7R12H1JMAKN75SH2G529', |
| 489 | + options: { before: 'before-id' }, |
| 490 | + ) |
| 491 | + |
| 492 | + expect(feature_flags.data.size).to eq(2) |
| 493 | + end |
| 494 | + end |
| 495 | + end |
| 496 | + |
| 497 | + context 'with the after option' do |
| 498 | + it 'forms the proper request to the API' do |
| 499 | + request_args = [ |
| 500 | + '/organizations/org_01HX7Q7R12H1JMAKN75SH2G529/feature-flags?after=after-id&'\ |
| 501 | + 'order=desc', |
| 502 | + 'Content-Type' => 'application/json' |
| 503 | + ] |
| 504 | + |
| 505 | + expected_request = Net::HTTP::Get.new(*request_args) |
| 506 | + |
| 507 | + expect(Net::HTTP::Get).to receive(:new).with(*request_args). |
| 508 | + and_return(expected_request) |
| 509 | + |
| 510 | + VCR.use_cassette 'organization/list_organization_feature_flags', match_requests_on: [:path] do |
| 511 | + feature_flags = described_class.list_organization_feature_flags( |
| 512 | + organization_id: 'org_01HX7Q7R12H1JMAKN75SH2G529', |
| 513 | + options: { after: 'after-id' }, |
| 514 | + ) |
| 515 | + |
| 516 | + expect(feature_flags.data.size).to eq(2) |
| 517 | + end |
| 518 | + end |
| 519 | + end |
| 520 | + |
| 521 | + context 'with the limit option' do |
| 522 | + it 'forms the proper request to the API' do |
| 523 | + request_args = [ |
| 524 | + '/organizations/org_01HX7Q7R12H1JMAKN75SH2G529/feature-flags?limit=10&'\ |
| 525 | + 'order=desc', |
| 526 | + 'Content-Type' => 'application/json' |
| 527 | + ] |
| 528 | + |
| 529 | + expected_request = Net::HTTP::Get.new(*request_args) |
| 530 | + |
| 531 | + expect(Net::HTTP::Get).to receive(:new).with(*request_args). |
| 532 | + and_return(expected_request) |
| 533 | + |
| 534 | + VCR.use_cassette 'organization/list_organization_feature_flags', match_requests_on: [:path] do |
| 535 | + feature_flags = described_class.list_organization_feature_flags( |
| 536 | + organization_id: 'org_01HX7Q7R12H1JMAKN75SH2G529', |
| 537 | + options: { limit: 10 }, |
| 538 | + ) |
| 539 | + |
| 540 | + expect(feature_flags.data.size).to eq(2) |
| 541 | + end |
| 542 | + end |
| 543 | + end |
| 544 | + |
| 545 | + context 'with multiple pagination options' do |
| 546 | + it 'forms the proper request to the API' do |
| 547 | + request_args = [ |
| 548 | + '/organizations/org_01HX7Q7R12H1JMAKN75SH2G529/feature-flags?after=after-id&'\ |
| 549 | + 'limit=5&order=asc', |
| 550 | + 'Content-Type' => 'application/json' |
| 551 | + ] |
| 552 | + |
| 553 | + expected_request = Net::HTTP::Get.new(*request_args) |
| 554 | + |
| 555 | + expect(Net::HTTP::Get).to receive(:new).with(*request_args). |
| 556 | + and_return(expected_request) |
| 557 | + |
| 558 | + VCR.use_cassette 'organization/list_organization_feature_flags', match_requests_on: [:path] do |
| 559 | + feature_flags = described_class.list_organization_feature_flags( |
| 560 | + organization_id: 'org_01HX7Q7R12H1JMAKN75SH2G529', |
| 561 | + options: { after: 'after-id', limit: 5, order: 'asc' }, |
| 562 | + ) |
| 563 | + |
| 564 | + expect(feature_flags.data.size).to eq(2) |
| 565 | + end |
| 566 | + end |
| 567 | + end |
| 568 | + end |
453 | 569 | end |
0 commit comments