Sha256: c425c1754405b2e417f2b599d2363532bf8f82b94bb39fe4e1e50ca2593c89e5

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

module AsyncRequest
  describe JobsController do
    routes { AsyncRequest::Engine.routes }

    describe '#show' do
      context 'when there is no job with the given id' do
        let!(:job) { FactoryGirl.create(:async_request_job, :waiting) }
        it 'returns 404' do
          get :show, id: job.uid + 'ABC'
          expect(response.status).to eq(404)
        end
      end

      context 'when the job exists but it is in a waiting status' do
        let!(:job) { FactoryGirl.create(:async_request_job, :waiting) }
        it 'returns 202' do
          get :show, id: job.uid
          expect(response.status).to eq(202)
        end
      end

      context 'when the job exists but it is in a processing status' do
        let!(:job) { FactoryGirl.create(:async_request_job, :processing) }
        it 'returns 202' do
          get :show, id: job.uid
          expect(response.status).to eq(202)
        end
      end

      context 'when the job exists and has finished' do
        let!(:job) { FactoryGirl.create(:async_request_job, :processed) }

        it 'returns the saved status code' do
          get :show, id: job.uid
          expect(response.status).to eq(job.status_code)
        end

        it 'returns the saved status code' do
          get :show, id: job.uid
          expect(response_body).to eq(JSON.parse(job.response))
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
async_request-0.0.7 spec/controllers/async_request/jobs_controller_spec.rb
async_request-0.0.6 spec/controllers/async_request/jobs_controller_spec.rb
async_request-0.0.5 spec/controllers/async_request/jobs_controller_spec.rb
async_request-0.0.4 spec/controllers/async_request/jobs_controller_spec.rb
async_request-0.0.3 spec/controllers/async_request/jobs_controller_spec.rb
async_request-0.0.2 spec/controllers/async_request/jobs_controller_spec.rb
async_request-0.0.1 spec/controllers/async_request/jobs_controller_spec.rb