Cast me sync
This commit is contained in:
124
spec/controllers/admin/casting_submissions_controller_spec.rb
Normal file
124
spec/controllers/admin/casting_submissions_controller_spec.rb
Normal file
@@ -0,0 +1,124 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Admin::CastingSubmissionsController, type: :controller do
|
||||
|
||||
let!(:current_user) { create(:user, :admin) }
|
||||
|
||||
before do
|
||||
sign_in(current_user)
|
||||
end
|
||||
|
||||
describe "#index" do
|
||||
it "returns a successful response" do
|
||||
get :index
|
||||
|
||||
expect(response).to be_successful
|
||||
end
|
||||
end
|
||||
|
||||
describe "#new" do
|
||||
it "returns a successful response" do
|
||||
get :new
|
||||
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it "assigns user, accounts" do
|
||||
get :new
|
||||
|
||||
expect(assigns(:casting_submission)).not_to be_nil
|
||||
expect(assigns(:accounts)).to eq Account.all
|
||||
end
|
||||
end
|
||||
|
||||
describe "#create" do
|
||||
it "does create a new record" do
|
||||
expect {
|
||||
post :create, params: { casting_submission: casting_submission_params }
|
||||
}.to change(CastingSubmission, :count)
|
||||
end
|
||||
|
||||
it "does not create new record if zoom meeting url is not valid" do
|
||||
expect {
|
||||
post :create, params: {
|
||||
casting_submission: casting_submission_params
|
||||
.except(:zoom_meeting_url)
|
||||
.merge(zoom_meeting_url: "malformed_url")
|
||||
}
|
||||
}.to change(CastingSubmission, :count).by(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#edit" do
|
||||
let(:casting_submission) { create(:casting_submission) }
|
||||
|
||||
it "returns a successful response" do
|
||||
get :edit, params: { id: casting_submission }
|
||||
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it "assigns casting submission" do
|
||||
get :edit, params: { id: casting_submission }
|
||||
|
||||
expect(assigns(:casting_submission)).to eq casting_submission
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
let(:casting_submission) { create(:casting_submission) }
|
||||
|
||||
it "redirects to casting submissions page" do
|
||||
patch :update, params: { id: casting_submission, casting_submission: update_params }
|
||||
|
||||
expect(response).to be_redirect
|
||||
expect(response).to redirect_to admin_casting_submissions_path
|
||||
end
|
||||
|
||||
it "sets a flash notice" do
|
||||
patch :update, params: { id: casting_submission, casting_submission: update_params }
|
||||
|
||||
expect(flash.notice).to eq "The casting submission has been updated"
|
||||
end
|
||||
|
||||
it "updates casting submission" do
|
||||
patch :update, params: { id: casting_submission, casting_submission: update_params }
|
||||
|
||||
expect(casting_submission.reload.zoom_meeting_url).to eq new_zoom_meeting_url
|
||||
end
|
||||
end
|
||||
|
||||
describe "#complete" do
|
||||
let(:casting_submission) { create(:casting_submission) }
|
||||
|
||||
it "sets interviewed_at on casting submission" do
|
||||
expect(casting_submission.interviewed_at).to be_nil
|
||||
|
||||
post :complete, params: { id: casting_submission }
|
||||
|
||||
expect(casting_submission.reload.interviewed_at).not_to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def casting_submission_params
|
||||
casting_call = create(:casting_call)
|
||||
|
||||
attributes_for(:casting_submission).except(:interviewed_at).merge(casting_call_id: casting_call.id)
|
||||
end
|
||||
|
||||
def update_params
|
||||
{
|
||||
zoom_meeting_url: new_zoom_meeting_url
|
||||
}
|
||||
end
|
||||
|
||||
def new_zoom_meeting_url
|
||||
"https://s01web.zoom.us/j/11111?pwd=Ab123Cq34"
|
||||
end
|
||||
|
||||
def invalid_meeting_url_flash_error
|
||||
t 'casting_submissions.validation_errors.invalid_meeting_url'
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user