forked from codebar/planner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication_controller_spec.rb
More file actions
72 lines (61 loc) · 1.5 KB
/
Copy pathapplication_controller_spec.rb
File metadata and controls
72 lines (61 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
RSpec.describe ApplicationController do
describe '#render_not_found' do
controller do
def index
raise ActiveRecord::RecordNotFound
end
end
context 'with HTML format' do
before do
get :index, format: :html
end
it 'renders the not_found template' do
expect(response.status).to eq(404)
expect(response).not_to be_redirect
end
end
context 'with JSON format' do
before do
get :index, format: :json
end
it 'returns empty 404 response' do
expect(response.status).to eq(404)
expect(response.body).to be_empty
end
end
end
describe '#render_not_acceptable' do
controller do
def index
raise ActionController::UnknownFormat
end
end
context 'with HTML format' do
before do
get :index, format: :html
end
it 'renders the not_acceptable template' do
expect(response.status).to eq(406)
expect(response).not_to be_redirect
end
end
context 'with JSON format' do
before do
get :index, format: :json
end
it 'returns empty 406 response' do
expect(response.status).to eq(406)
expect(response.body).to be_empty
end
end
context 'with XML format' do
before do
get :index, format: :xml
end
it 'returns empty 406 response' do
expect(response.status).to eq(406)
expect(response.body).to be_empty
end
end
end
end