diff --git a/test/functional/post_replacements_controller_test.rb b/test/functional/post_replacements_controller_test.rb index aa0ef157d..2d6823c45 100644 --- a/test/functional/post_replacements_controller_test.rb +++ b/test/functional/post_replacements_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PostReplacementsControllerTest < ActionController::TestCase context "The post replacements controller" do setup do - @user = FactoryGirl.create(:user, can_approve_posts: true) + @user = FactoryGirl.create(:user, can_approve_posts: true, created_at: 1.month.ago) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" @@ -11,6 +11,28 @@ class PostReplacementsControllerTest < ActionController::TestCase @post_replacement = FactoryGirl.create(:post_replacement, post_id: @post.id) end + context "create action" do + should "render" do + params = { + format: :json, + post_id: @post.id, + post_replacement: { + replacement_url: "https://www.google.com/intl/en_ALL/images/logo.gif", + } + } + + assert_difference("@post.replacements.size") do + post :create, params, { user_id: @user.id } + @post.reload + end + + assert_response :success + assert_equal("https://www.google.com/intl/en_ALL/images/logo.gif", @post.source) + assert_equal("e80d1c59a673f560785784fb1ac10959", @post.md5) + assert_equal("e80d1c59a673f560785784fb1ac10959", Digest::MD5.file(@post.file_path).hexdigest) + end + end + context "index action" do should "render" do get :index, {format: :json}