require "rails_helper" RSpec.describe CastingSubmissionsController, type: :controller do render_views let(:user) { create(:user) } let(:account) { user.primary_account } let(:project) { create(:project, account: user.primary_account) } let(:casting_call) { create(:casting_call, project: project, title: "My Interview") } before do sign_in(user) end describe "#index" do it "returns a successful response" do get :index, params: { project_id: project } expect(response).to be_successful end it "only shows completed submissions" do create(:casting_submission, casting_call: casting_call, interviewed_at: Time.zone.now, performer_name: "John Doe") create(:casting_submission, casting_call: casting_call, interviewed_at: nil, performer_name: "Jane Doe") get :index, params: { project_id: project } expect(response.body).to have_content("John Doe") expect(response.body).not_to have_content("Jane Doe") end end describe "#show" do let!(:casting_submission) { create(:casting_submission, :with_files, casting_call: casting_call, interviewed_at: Time.zone.now, performer_name: "Jane Doe") } it "shows files of casting submission" do get :show, params: { project_id: project, id: casting_submission.id } expect(response.body).to have_content("Filename") expect(response.body).to have_content("location_photo.png") end end end