Sha256: c4d90dc8cb0b15f289b25ef3d51fb3abc7471491546f015853f62e09bcc959dc
Contents?: true
Size: 1.39 KB
Versions: 5
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../../", __FILE__) require "rails_helper" RSpec.describe PrivateController do describe "#show" do context "user is not authenticated" do it "redirects to the sign_in page" do get "/private" expect(response).to redirect_to("#{OmniAuth.config.path_prefix}/sign_in") end context "dev_mode is enabled" do around(:each) do |example| original_value = Omniauth::Rails::Configuration.dev_mode Omniauth::Rails::Configuration.dev_mode = true example.run Omniauth::Rails::Configuration.dev_mode = original_value end it "responds with a 200" do get "/private" expect(response).to have_http_status(:success) end end end context "user is authenticated" do context "user is authorized" do before do sign_in("foo@bar.com") end it "responds with a 200" do get "/private" expect(response).to have_http_status(:success) end end context "not authorized" do before do sign_in("foo@baz.com") # This domain is not in the allowed list of domains. end it "responds with a 403:forbidden" do get "/private" expect(response).to have_http_status(:forbidden) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems