require 'rails_helper'

RSpec.describe "Admin::Teams", type: :request do
  include_context "a configured contest"
  let(:admin) { Account.create! username: "proctor", password: 'asdf123', contest: Contest.instance, admin: true }

  describe "GET /admin/teams" do

    it "works! (now write some real specs)" do
      # I hate this so much.  Request specs should be able to test _a single
      # request_ in isolation.  Without access to the session, we are forced
      # to treat these as full integrations, with multiple page posts
      post login_path params: {
        session: { username: admin.username, password: admin.password }
      }

      get admin_teams_path
      expect(response).to have_http_status(200)
    end
  end
end

Add a request level spec for admin testing
Add a request level spec for admin testing

This operates more at the API level, but it appears that Rails5.1 has
taken away access to the session variable, so it becomes necessary to
interact with multiple different controller endpoints, instead of simply
preconfiguring a value in the session.

Apparently, DHH thinks this is an "implementation detail", and that it's
better to require hitting multiple endpoints for any single test (Or,
authenticate through header values).  The man does not care about test
efficency, or any of the myriad corner cases in a typical session-based
app, in the slightest.

https://github.com/rails/rails/issues/23386
