Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

AO3-5138 Prevent 500 error when admin post's translated_post_id is invalid #3021

Merged
merged 3 commits into from Aug 30, 2017

Conversation

Projects
None yet
3 participants
Owner

sarken commented Aug 30, 2017

Issue

https://otwarchive.atlassian.net/browse/AO3-5138

Purpose

Makes sure admin post languages are properly loaded for all actions that need it, thereby preventing a 500 error that would occur when trying to create an admin post with an invalid translated_post_id.

I realized the specs didn't actually cover the proper scenario, but I left them in because why not.

Testing

See JIRA

sarken added some commits Aug 30, 2017

AO3-5138 Prevent 500 error related to languages when admin post trans…
…lation of is wrong

This loads languages as a before_action for all the admin post actions that need it, including create and edit. create and edit did not previously load the languages, which caused a 500 error if you entered a non-existent post in the 'translation of' field
AO3-5138 Test that new page renders when selecting a language and a n…
…on-existent translated_post_id for an admin post translation
@@ -1,6 +1,7 @@
class AdminPostsController < ApplicationController
before_action :admin_only, except: [:index, :show]
+ before_action :load_languages, except: [:show, :destroy]
@houndci-bot

houndci-bot Aug 30, 2017

Use %i or %I for an array of symbols.

click_button("Post")
end
+Then (/^the translation information should still be filled in$/) do
@houndci-bot

houndci-bot Aug 30, 2017

(...) interpreted as grouped expression.

@@ -0,0 +1,30 @@
+require "spec_helper"
@houndci-bot

houndci-bot Aug 30, 2017

Missing magic comment # frozen_string_literal: true.

+ describe "POST #create" do
+ before { fake_login_admin(create(:admin)) }
+
+ let(:base_params) { { title: "AdminPost Title",
@houndci-bot

houndci-bot Aug 30, 2017

Avoid using {...} for multi-line blocks.
Block body expression is on the same line as the block start.

+ before { fake_login_admin(create(:admin)) }
+
+ let(:base_params) { { title: "AdminPost Title",
+ content: "AdminPost content long enough to pass validation" } }
@houndci-bot

houndci-bot Aug 30, 2017

Expression at 11, 89 should be on its own line.

elzj approved these changes Aug 30, 2017

@elzj elzj merged commit 4bf661a into otwcode:master Aug 30, 2017

4 checks passed

Scrutinizer 2 new issues, 1 updated code elements
Details
codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
hound 1 violation found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment