Skip to content

Commit

Permalink
mgr/dashboard: Verify the RGW mail reset behavior
Browse files Browse the repository at this point in the history
The current behavior when submitting an empty mail field in the RGW user form
that was previously filled was to replace it with "false".

This was a regression introduced through the use of "CdFormGroup" which had
a "_filterValue" method which converted empty strings into false, but it was
removed now.

Fixes: http://tracker.ceph.com/issues/26861
Signed-off-by: Stephan Müller <smueller@suse.com>
  • Loading branch information
Stephan Müller committed Nov 6, 2018
1 parent 56e8bca commit a159f5a
Showing 1 changed file with 19 additions and 8 deletions.
Expand Up @@ -15,6 +15,8 @@ import { RgwUserFormComponent } from './rgw-user-form.component';
describe('RgwUserFormComponent', () => {
let component: RgwUserFormComponent;
let fixture: ComponentFixture<RgwUserFormComponent>;
let rgwUserService: RgwUserService;
let formHelper: FormHelper;

configureTestBed({
declarations: [RgwUserFormComponent],
Expand All @@ -26,17 +28,16 @@ describe('RgwUserFormComponent', () => {
fixture = TestBed.createComponent(RgwUserFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
rgwUserService = TestBed.get(RgwUserService);
formHelper = new FormHelper(component.userForm);
});

it('should create', () => {
expect(component).toBeTruthy();
});

describe('s3 key management', () => {
let rgwUserService: RgwUserService;

beforeEach(() => {
rgwUserService = TestBed.get(RgwUserService);
spyOn(rgwUserService, 'addS3Key').and.stub();
});

Expand Down Expand Up @@ -113,13 +114,8 @@ describe('RgwUserFormComponent', () => {
});

describe('username validation', () => {
let rgwUserService: RgwUserService;
let formHelper: FormHelper;

beforeEach(() => {
rgwUserService = TestBed.get(RgwUserService);
spyOn(rgwUserService, 'enumerate').and.returnValue(observableOf(['abc', 'xyz']));
formHelper = new FormHelper(component.userForm);
});

it('should validate that username is required', () => {
Expand All @@ -144,4 +140,19 @@ describe('RgwUserFormComponent', () => {
})
);
});

describe('onSubmit', () => {
it('should be able to clear the mail field on update', () => {
spyOn(rgwUserService, 'update');
component.editing = true;
formHelper.setValue('email', '', true);
component.onSubmit();
expect(rgwUserService.update).toHaveBeenCalledWith(null, {
display_name: null,
email: '',
max_buckets: 1000,
suspended: false
});
});
});
});

0 comments on commit a159f5a

Please sign in to comment.