Files
old-holivud2/spec/controllers/casting_submissions_controller_spec.rb
2020-07-22 13:37:34 +00:00

45 lines
1.6 KiB
Ruby

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(casting_submission.performer_name)
expect(response.body).to have_content(casting_submission.casting_call.title)
expect(response.body).to have_content(casting_submission.casting_call.project_description)
end
end
end