# frozen_string_literal: true require "rails_helper" # These examples exist to exercise the view layer end to end - HAML, the asset # pipeline, the layout, form helpers and the session middleware. The rest of the # request specs only assert on redirects, so without these nothing in the suite # would notice if a Rails upgrade broke rendering. RSpec.describe "rendering", type: :request do before do host! Postal::Config.postal.web_hostname end describe "the login page" do it "renders" do get "/login" expect(response).to have_http_status(:ok) expect(response.media_type).to eq "text/html" expect(response.body).to include "]+stylesheets?/i).or match(/]+\.css/i) expect(response.body).to match(/]+\.js/i) end end describe "when not authenticated" do it "redirects to the login page" do get "/" expect(response).to redirect_to("/login?return_to=%2F") end end describe "when authenticated" do let(:user) { create(:user) } before do post "/login", params: { email_address: user.email_address, password: "passw0rd" } end it "renders the organizations index" do get "/" expect(response).to have_http_status(:ok) expect(response.body).to include ") expect(response.body).to include "
  • First name can't be blank
  • " end end it "does not render an error container on a form which has no errors" do get "/settings" expect(response.body).to_not include "errorExplanation" end end end