|
14 | 14 | flag_names_in_response = parsed_response['resources'].map { |flag| flag['name'] } |
15 | 15 | expect(flag_names_in_response).to eq(flag_names_sorted.map(&:to_s)) |
16 | 16 | end |
| 17 | + |
| 18 | + context 'filtering timestamps on update' do |
| 19 | + # before must occur before the let! otherwise the resources will be created with |
| 20 | + # update_on_create: true |
| 21 | + before do |
| 22 | + VCAP::CloudController::FeatureFlag.plugin :timestamps, update_on_create: false |
| 23 | + end |
| 24 | + |
| 25 | + let!(:resource_1) { VCAP::CloudController::FeatureFlag.make(name: 'set_roles_by_username', updated_at: '2020-05-26T18:47:01Z') } |
| 26 | + let!(:resource_2) { VCAP::CloudController::FeatureFlag.make(name: 'task_creation', updated_at: '2020-05-26T18:47:02Z') } |
| 27 | + let!(:resource_3) { VCAP::CloudController::FeatureFlag.make(name: 'user_org_creation', updated_at: '2020-05-26T18:47:03Z') } |
| 28 | + let!(:resource_4) { VCAP::CloudController::FeatureFlag.make(name: 'unset_roles_by_username', updated_at: '2020-05-26T18:47:04Z') } |
| 29 | + |
| 30 | + after do |
| 31 | + VCAP::CloudController::FeatureFlag.plugin :timestamps, update_on_create: true |
| 32 | + end |
| 33 | + |
| 34 | + it 'filters' do |
| 35 | + get '/v3/feature_flags?updated_ats[gt]=2020-05-26T18:47:02Z', nil, admin_headers |
| 36 | + |
| 37 | + expect(last_response).to have_status_code(200) |
| 38 | + expect(parsed_response['resources'].map { |r| r['name'] }).to contain_exactly('user_org_creation', 'unset_roles_by_username') |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + context 'filtering timestamps on created_ats' do |
| 43 | + it 'filters' do |
| 44 | + get '/v3/feature_flags?created_ats[gt]=2020-05-26T18:47:04Z', nil, admin_headers |
| 45 | + |
| 46 | + expect(last_response).to have_status_code(400) |
| 47 | + expect(last_response).to have_error_message("The query parameter is invalid: Filtering by 'created_ats' is not allowed on this resource.") |
| 48 | + end |
| 49 | + end |
17 | 50 | end |
18 | 51 |
|
19 | 52 | describe 'GET /v3/feature_flags/:name' do |
|
0 commit comments