From 962058edfd2b51890a7652f393fdc9eed127ff13 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Mon, 7 Aug 2023 22:59:27 -0700 Subject: [PATCH] fix specs --- app/models/identity_provider.rb | 3 +++ spec/models/identity_provider_spec.rb | 5 +++++ spec/requests/single_signon_request_spec.rb | 19 ++++++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/models/identity_provider.rb b/app/models/identity_provider.rb index 48cb35ae9..c9ba7148c 100644 --- a/app/models/identity_provider.rb +++ b/app/models/identity_provider.rb @@ -1,6 +1,9 @@ # frozen_string_literal: true class IdentityProvider < ApplicationRecord + validates :name, presence: true + validates :provider, presence: true + mount_uploader :logo_image, LogoUploader def parsed_options(rack_env = nil) diff --git a/spec/models/identity_provider_spec.rb b/spec/models/identity_provider_spec.rb index ddec4b3b8..d2a13fab6 100644 --- a/spec/models/identity_provider_spec.rb +++ b/spec/models/identity_provider_spec.rb @@ -15,6 +15,11 @@ expect(subject).to be_valid end + it 'is not valid without a name' do + subject.name = nil + expect(subject).not_to be_valid + end + it 'is not valid without a provider' do subject.provider = nil expect(subject).not_to be_valid diff --git a/spec/requests/single_signon_request_spec.rb b/spec/requests/single_signon_request_spec.rb index 6926ab72a..f03da32a8 100644 --- a/spec/requests/single_signon_request_spec.rb +++ b/spec/requests/single_signon_request_spec.rb @@ -4,9 +4,22 @@ RSpec.describe "SingleSignons", type: :request do describe "GET single_signon#index" do - it "returns http success" do - get "/single_signon" - expect(response).to have_http_status(:success) + describe "with no IdentityProviders" do + it "redirects to sign in" do + get "/single_signon" + expect(response).to have_http_status(:redirect) + end + end + + describe "with an IdentityProvider" do + before do + IdentityProvider.create(name: 'fake', provider: 'saml') + end + + it "renders succes" do + get "/single_signon" + expect(response).to have_http_status(:success) + end end end end