Sha256: 54411c782dd12b0cda0450f936273dc08c024825f77d8e8f4f7e80545be37e30

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true
require "rails_helper"

module ThinkFeelDoDashboard
  RSpec.describe ParticipantsController, type: :controller do
    routes { Engine.routes }

    let(:authorized_user) do
      instance_double(User, admin?: true)
    end

    describe "when unauthorized" do
      describe "GET show" do
        context "for unauthenticated requests" do
          before { get :show, id: 1 }

          it_behaves_like "a rejected user action"
        end
      end
    end

    describe "when authorized" do
      before do
        sign_in_user authorized_user
      end

      describe "GET show" do
        describe "when participant can't be found" do
          before do
            allow(Participant)
              .to receive(:find)
              .and_raise(ActiveRecord::RecordNotFound)

            get :show, id: 1
          end

          it "should redirect to the participant listing page" do
            expect(response)
              .to redirect_to(participants_path)
          end

          it "should displays error alert" do
            expect(flash[:alert])
              .to match(/The participant you were looking for can't be found./)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
think_feel_do_dashboard-1.2.1 spec/controllers/think_feel_do_dashboard/participants_controller_spec.rb