diff --git a/app/controllers/concerns/scim_rails/response.rb b/app/controllers/concerns/scim_rails/response.rb index 9daaac6..bdae626 100644 --- a/app/controllers/concerns/scim_rails/response.rb +++ b/app/controllers/concerns/scim_rails/response.rb @@ -5,7 +5,8 @@ module ScimRails def json_response(object, status = :ok) render \ json: object, - status: status + status: status, + content_type: CONTENT_TYPE end def json_scim_response(object:, status: :ok, counts: nil) diff --git a/spec/controllers/scim_rails/scim_users_controller_spec.rb b/spec/controllers/scim_rails/scim_users_controller_spec.rb index fa0379d..9b7eb1a 100644 --- a/spec/controllers/scim_rails/scim_users_controller_spec.rb +++ b/spec/controllers/scim_rails/scim_users_controller_spec.rb @@ -9,6 +9,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do let(:company) { create(:company) } context "when unauthorized" do + it "returns scim+json content type" do + get :index + + expect(response.content_type).to eq "application/scim+json, application/json" + end + it "fails with no credentials" do get :index @@ -29,6 +35,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do http_login(company) end + it "returns scim+json content type" do + get :index + + expect(response.content_type).to eq "application/scim+json, application/json" + end + it "is successful with valid credentials" do get :index @@ -134,6 +146,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do let(:company) { create(:company) } context "when unauthorized" do + it "returns scim+json content type" do + get :show, params: { id: 1 } + + expect(response.content_type).to eq "application/scim+json, application/json" + end + it "fails with no credentials" do get :show, params: { id: 1 } @@ -154,6 +172,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do http_login(company) end + it "returns scim+json content type" do + get :show, params: { id: 1 } + + expect(response.content_type).to eq "application/scim+json, application/json" + end + it "is successful with valid credentials" do create(:user, id: 1, company: company) get :show, params: { id: 1 } @@ -183,6 +207,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do let(:company) { create(:company) } context "when unauthorized" do + it "returns scim+json content type" do + post :create + + expect(response.content_type).to eq "application/scim+json, application/json" + end + it "fails with no credentials" do post :create @@ -203,6 +233,22 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do http_login(company) end + it "returns scim+json content type" do + post :create, params: { + name: { + givenName: "New", + familyName: "User" + }, + emails: [ + { + value: "new@example.com" + } + ] + } + + expect(response.content_type).to eq "application/scim+json, application/json" + end + it "is successful with valid credentials" do post :create, params: { name: { @@ -307,6 +353,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do let(:company) { create(:company) } context "when unauthorized" do + it "returns scim+json content type" do + put :put_update, params: { id: 1 } + + expect(response.content_type).to eq "application/scim+json, application/json" + end + it "fails with no credentials" do put :put_update, params: { id: 1 } @@ -329,6 +381,25 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do http_login(company) end + it "returns scim+json content type" do + put :put_update, params: { + id: 1, + userName: "test@example.com", + name: { + givenName: "Test", + familyName: "User" + }, + emails: [ + { + value: "test@example.com" + }, + ], + active: "true" + } + + expect(response.content_type).to eq "application/scim+json, application/json" + end + it "is successful with with valid credentials" do put :put_update, params: { id: 1, @@ -385,6 +456,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do let(:company) { create(:company) } context "when unauthorized" do + it "returns scim+json content type" do + patch :patch_update, params: { id: 1 } + + expect(response.content_type).to eq "application/scim+json, application/json" + end + it "fails with no credentials" do patch :patch_update, params: { id: 1 } @@ -407,6 +484,12 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do http_login(company) end + it "returns scim+json content type" do + patch :patch_update, params: { id: 1 } + + expect(response.content_type).to eq "application/scim+json, application/json" + end + it "is successful with valid credentials" do patch :patch_update, params: { id: 1 } -- libgit2 0.21.0