require 'rails_helper'

RSpec.describe IepDocumentsController, type: :controller do

  describe '#show' do

    context 'educator has permissions for associated student' do
      it 'renders a pdf' do

      end
    end

    context 'educator does not have permissions for associated student' do
      it 'does not render' do

      end
    end

  end

end

require 'rails_helper'

RSpec.describe IepDocumentsController, type: :controller do

  describe '#show' do

    def make_request(id)
      request.env['HTTPS'] = 'on'
      get :show, params: { id: id }
    end

    class FakeAwsResponse
      def body; self end
      def read; 'eee' end
    end

    before do
      allow_any_instance_of(
        Aws::S3::Client
      ).to receive(
        :get_object
      ).and_return FakeAwsResponse.new
    end

    let(:student) { FactoryGirl.create(:student) }

    subject {
      IepDocument.create(
        file_date: DateTime.current,
        file_name: 'IEP Document',
        student: student,
      )
    }

    context 'educator has permissions for associated student' do
      let(:educator) { FactoryGirl.create(:educator, districtwide_access: true) }
      before { sign_in(educator) }

      it 'renders a pdf' do
        make_request(subject.id)
        expect(response).to be_success
      end
    end

    context 'educator does not have permissions for associated student' do
      let(:educator) { FactoryGirl.create(:educator) }
      before { sign_in(educator) }

      it 'does not render' do
        expect { make_request(subject.id) }.to raise_error Exceptions::EducatorNotAuthorized
      end
    end

  end

end

Add basic authorization spec for IepDocumentsController
Add basic authorization spec for IepDocumentsController

+ Stub out AWS response
