|
| 1 | +require "spec_helper" |
| 2 | + |
| 3 | +RSpec.describe ErrorsController, type: :controller do |
| 4 | + context "when invalid session" do |
| 5 | + it "renders the expected template" do |
| 6 | + get :invalid_session |
| 7 | + expect(response).to render_template(:invalid_session) |
| 8 | + end |
| 9 | + |
| 10 | + it "uses the expected status" do |
| 11 | + get :invalid_session |
| 12 | + expect(response).to be_not_found |
| 13 | + end |
| 14 | + end |
| 15 | + |
| 16 | + context "when not found" do |
| 17 | + it "renders the expected template" do |
| 18 | + get :not_found |
| 19 | + expect(response).to render_template(:not_found) |
| 20 | + end |
| 21 | + |
| 22 | + it "uses the expected status" do |
| 23 | + get :not_found |
| 24 | + expect(response).to be_not_found |
| 25 | + end |
| 26 | + end |
| 27 | + |
| 28 | + context "when results not found" do |
| 29 | + it "renders the expected template" do |
| 30 | + get :results_not_found |
| 31 | + expect(response).to render_template(:results_not_found) |
| 32 | + end |
| 33 | + |
| 34 | + it "uses the expected status" do |
| 35 | + get :results_not_found |
| 36 | + expect(response).to be_not_found |
| 37 | + end |
| 38 | + end |
| 39 | + |
| 40 | + context "when report completed" do |
| 41 | + it "renders the expected template" do |
| 42 | + get :report_completed |
| 43 | + expect(response).to render_template(:report_completed) |
| 44 | + end |
| 45 | + |
| 46 | + it "uses the expected status" do |
| 47 | + get :report_completed |
| 48 | + expect(response).to be_unprocessable |
| 49 | + end |
| 50 | + end |
| 51 | + |
| 52 | + context "when report not completed" do |
| 53 | + it "renders the expected template" do |
| 54 | + get :report_not_completed |
| 55 | + expect(response).to render_template(:report_not_completed) |
| 56 | + end |
| 57 | + |
| 58 | + it "uses the expected status" do |
| 59 | + get :report_not_completed |
| 60 | + expect(response).to be_unprocessable |
| 61 | + end |
| 62 | + end |
| 63 | + |
| 64 | + context "when unhandled" do |
| 65 | + it "renders the expected template" do |
| 66 | + get :unhandled |
| 67 | + expect(response).to render_template(:unhandled) |
| 68 | + end |
| 69 | + |
| 70 | + it "uses the expected status" do |
| 71 | + get :unhandled |
| 72 | + expect(response).to be_server_error |
| 73 | + end |
| 74 | + end |
| 75 | + |
| 76 | + context "when maintenance" do |
| 77 | + it "renders the expected template" do |
| 78 | + get :maintenance |
| 79 | + expect(response).to render_template(:maintenance) |
| 80 | + end |
| 81 | + |
| 82 | + it "uses the expected status" do |
| 83 | + get :maintenance |
| 84 | + expect(response.status).to eq 503 |
| 85 | + end |
| 86 | + end |
| 87 | +end |
0 commit comments