Sha256: b5e47f6d13d1a84107937c232bffc599e535239ce266e8a22ae24c691ad9e2fb

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

describe Applicants::Spike::ApplicantsController do
  render_views

  include AuthHelper
  before(:each) do
    http_login
  end

  let(:email)     { 'fake@example.com' }
  let(:state)     { :reviewable }
  let(:applicant) do
    Applicants::Applicant.create(email: email, terms_of_use: '1').tap do |a|
      a.update_column :state, state
    end
  end
  let!(:video)    { Applicants::Video.create applicant: applicant, video_url: "http://a.com/blah.mp4" }

  describe "GET :show" do
    context "using the correct video URL for the player" do
      it "uses the video URL from the video record if it exists" do
        get :show, id: applicant.id, format: :json
        response.should be_success
        response.body.should include "blah.mp4"
        response.body.should include "=3600"
      end
    end
  end

  describe "DELETE :destroy" do
    let(:delete_action) { delete :destroy, id: applicant.id, format: :json }
    let(:video_utility) { double Applicants::VideoUrlUtility, remove!: nil }

    before { allow(Applicants::VideoUrlUtility).to receive(:new).and_return video_utility }

    it 'returns success' do
      delete_action
      response.should be_success
    end

    it 'overwrites their email' do
      expect {
        delete_action
      }.to change { applicant.reload.email }.to "disabled#{applicant.id}@deleted.com"
    end

    it 'should remove the video' do
      expect(Applicants::VideoUrlUtility).to receive(:new)
        .with("http://a.com/blah.mp4")
        .and_return video_utility
      expect(video_utility).to receive :remove!

      delete_action
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
applicants-0.11.0 spec/controllers/applicants/spike/applicants_controller_spec.rb