Commit 63eb6e562f8ae9c2fa2f8094d4ad7c2d4697d7b2

Authored by Spencer Alan
1 parent 0b433800
Exists in master

• add spec for PUT reprovisioning

• refactor PUT params
spec/controllers/scim_rails/scim_users_controller_spec.rb
... ... @@ -382,64 +382,35 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do
382 382 end
383 383  
384 384 it "returns scim+json content type" do
385   - put :put_update, params: {
386   - id: 1,
387   - userName: "test@example.com",
388   - name: {
389   - givenName: "Test",
390   - familyName: "User"
391   - },
392   - emails: [
393   - {
394   - value: "test@example.com"
395   - },
396   - ],
397   - active: "true"
398   - }
  385 + put :put_update, params: put_params
399 386  
400 387 expect(response.content_type).to eq "application/scim+json, application/json"
401 388 end
402 389  
403 390 it "is successful with with valid credentials" do
404   - put :put_update, params: {
405   - id: 1,
406   - userName: "test@example.com",
407   - name: {
408   - givenName: "Test",
409   - familyName: "User"
410   - },
411   - emails: [
412   - {
413   - value: "test@example.com"
414   - },
415   - ],
416   - active: "true"
417   - }
  391 + put :put_update, params: put_params
418 392  
419 393 expect(response.status).to eq 200
420 394 end
421 395  
422   - it "archives an inactive record" do
  396 + it "deprovisions an active record" do
423 397 request.content_type = "application/scim+json"
424   - put :put_update, params: {
425   - id: 1,
426   - userName: "test@example.com",
427   - name: {
428   - givenName: "Test",
429   - familyName: "User"
430   - },
431   - emails: [
432   - {
433   - value: "test@example.com"
434   - },
435   - ],
436   - active: false
437   - }
  398 + put :put_update, params: put_params(active: false)
438 399  
439 400 expect(response.status).to eq 200
440 401 expect(user.reload.active?).to eq false
441 402 end
442 403  
  404 + it "reprovisions an inactive record" do
  405 + user.archive!
  406 + expect(user.reload.active?).to eq false
  407 + request.content_type = "application/scim+json"
  408 + put :put_update, params: put_params(active: true)
  409 +
  410 + expect(response.status).to eq 200
  411 + expect(user.reload.active?).to eq true
  412 + end
  413 +
443 414 it "returns :not_found for id that cannot be found" do
444 415 get :put_update, params: { id: "fake_id" }
445 416  
... ... @@ -593,4 +564,21 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do
593 564 ]
594 565 }
595 566 end
  567 +
  568 + def put_params(active: true)
  569 + {
  570 + id: 1,
  571 + userName: "test@example.com",
  572 + name: {
  573 + givenName: "Test",
  574 + familyName: "User"
  575 + },
  576 + emails: [
  577 + {
  578 + value: "test@example.com"
  579 + },
  580 + ],
  581 + active: active
  582 + }
  583 + end
596 584 end
... ...