mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-10 17:43:55 +01:00
Use response.parsed_body
for error view application controller spec (#33515)
This commit is contained in:
parent
ce1501c3a7
commit
f4b463ecb1
1 changed files with 17 additions and 2 deletions
|
@ -3,6 +3,8 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ApplicationController do
|
RSpec.describe ApplicationController do
|
||||||
|
render_views
|
||||||
|
|
||||||
controller do
|
controller do
|
||||||
def success
|
def success
|
||||||
head 200
|
head 200
|
||||||
|
@ -23,9 +25,22 @@ RSpec.describe ApplicationController do
|
||||||
|
|
||||||
shared_examples 'respond_with_error' do |code|
|
shared_examples 'respond_with_error' do |code|
|
||||||
it "returns http #{code} for http and renders template" do
|
it "returns http #{code} for http and renders template" do
|
||||||
expect(subject).to render_template("errors/#{code}", layout: 'error')
|
subject
|
||||||
|
|
||||||
expect(response).to have_http_status(code)
|
expect(response)
|
||||||
|
.to have_http_status(code)
|
||||||
|
expect(response.parsed_body)
|
||||||
|
.to have_css('body[class=error]')
|
||||||
|
expect(response.parsed_body.css('h1').to_s)
|
||||||
|
.to include(error_content(code))
|
||||||
|
end
|
||||||
|
|
||||||
|
def error_content(code)
|
||||||
|
if code == 422
|
||||||
|
I18n.t('errors.422.content')
|
||||||
|
else
|
||||||
|
I18n.t("errors.#{code}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue