Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. require 'rails_helper'
  2.  
  3. RSpec.describe EducationsController, :type => :controller do
  4. let(:candidate) { create(:candidate, archetype_score: 200)}
  5. let(:state) { create(:state)}
  6. let(:employer) {create(:employer, first_name: 'user', last_name: 'test')}
  7. let(:employer_profile) { create(:employer_profile, employer_id: @employer.id, state_id: @state.id, city: 'Wichita', zip: 5520, website: 'www.mywebsite.org') }
  8. let(:college) { create(:college)}
  9. let(:education_level) { create(:education_level)}
  10. let(:education) { create(:education, education_level_id: education_level.id, college_id: college.id, candidate_id: candidate.id)}
  11.  
  12. describe '#destroy' do
  13. context '.when candidate is sign_in' do
  14. before do
  15. sign_in candidate
  16. end
  17.  
  18. it 'should call set_education method' do
  19. expect(controller).to receive(:set_education).once.and_call_original
  20. delete :destroy, id: education.id
  21. end
  22.  
  23. context 'After education is destroyed' do
  24. before { delete :destroy, id: education.id }
  25.  
  26. it {expect(assigns(:education)).to eq(education)}
  27. it {expect(Education.count).to eq(0)}
  28. it {expect(response).to redirect_to(candidates_profile_path(candidate.id))}
  29. end
  30.  
  31. it 'should redirect to candidates_archetype_path' do
  32. candidate.update(archetype_score: nil)
  33. delete :destroy, id: education.id
  34. expect(response).to redirect_to(candidates_archetype_path)
  35. end
  36. end
  37.  
  38. context '.when employer is sign_in' do
  39. before {
  40. sign_in(employer)
  41. delete :destroy, id: education.id
  42. }
  43.  
  44. it 'should redirects to candidates sign_in page' do
  45. expect(Education.count).to eq(1)
  46. expect(Education.last).to eq(education)
  47. end
  48. end
  49. end
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement