Skip to content

Commit 8556597

Browse files
committed
Add tests
1 parent 3af4067 commit 8556597

File tree

3 files changed

+96
-4
lines changed

3 files changed

+96
-4
lines changed

app/controllers/errors_controller.rb

+1-4
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ def maintenance
3232
private
3333

3434
def respond_with_status(status)
35-
respond_to do |format|
36-
format.html
37-
format.all { head status }
38-
end
35+
render status:
3936
end
4037
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require "rails_helper"
2+
3+
RSpec.describe Backoffice::HomeController, type: :controller do
4+
it "responds with redirect" do
5+
get :index
6+
expect(response).to be_redirect
7+
end
8+
end
+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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

Comments
 (0)