post replacements: refactor and fix tests.
* Move replacement tests from test/unit/upload_service_test.rb to test/functional/post_replacement_controller_test.rb * Move UploadService::Replacer to PostReplacementProcessor. * Fix a minor bug where if you used the API to replace a post with a file, the replacement would fail unless you passed an empty string for the replacement_url.
This commit is contained in:
@@ -9,11 +9,11 @@ class PostReplacementsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@post = authorize Post.find(params[:post_id]), policy_class: PostReplacementPolicy
|
||||
@post_replacement = @post.replace!(permitted_attributes(PostReplacement))
|
||||
@post_replacement = authorize PostReplacement.new(creator: CurrentUser.user, post_id: params[:post_id], **permitted_attributes(PostReplacement))
|
||||
@post_replacement.save
|
||||
@post_replacement.process!
|
||||
|
||||
flash[:notice] = "Post replaced"
|
||||
respond_with(@post_replacement, location: @post)
|
||||
respond_with(@post_replacement, location: @post_replacement.post, notice: "Post replaced")
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
Reference in New Issue
Block a user