From 01afc46f7435800ea9b73daccad8b1608507b9f1 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 3 Dec 2016 20:06:50 -0600 Subject: [PATCH 1/2] Fix failures in commenting tests. Restricting users from upvoting their own comments broke some tests. Switch these tests to downvoting instead. --- test/functional/comment_votes_controller_test.rb | 8 ++++---- test/unit/comment_test.rb | 2 +- test/unit/user_test.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/functional/comment_votes_controller_test.rb b/test/functional/comment_votes_controller_test.rb index 62d689d04..953b500aa 100644 --- a/test/functional/comment_votes_controller_test.rb +++ b/test/functional/comment_votes_controller_test.rb @@ -24,9 +24,9 @@ class CommentVotesControllerTest < ActionController::TestCase end should "fail silently on errors" do - FactoryGirl.create(:comment_vote, :comment => @comment) + FactoryGirl.create(:comment_vote, :comment => @comment, :score => -1) assert_difference("CommentVote.count", 0) do - post :create, {:format => "json", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id} + post :create, {:format => "json", :comment_id => @comment.id, :score => -1}, {:user_id => @user.id} assert_response 422 assert_equal("{\"errors\":{\"user_id\":[\"have already voted for this comment\"]}}", @response.body.strip) end @@ -42,9 +42,9 @@ class CommentVotesControllerTest < ActionController::TestCase end should "fail silently on errors" do - FactoryGirl.create(:comment_vote, :comment => @comment) + FactoryGirl.create(:comment_vote, :comment => @comment, :score => -1) assert_difference("CommentVote.count", 0) do - post :create, {:format => "js", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id} + post :create, {:format => "js", :comment_id => @comment.id, :score => -1}, {:user_id => @user.id} assert_response :success end end diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index abea5c72a..6c7a4d481 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -58,7 +58,7 @@ class CommentTest < ActiveSupport::TestCase end dmail = Dmail.last - assert_equal("You were mentioned in a \"comment\":http://#{Danbooru.config.hostname}/posts/#{@comment.post_id}#comment-#{@comment.id}\n\n---\n\n[i]#{CurrentUser.name} said:[/i]\n\nHey @#{@user2.name} check this out!", dmail.body) + assert_equal("You were mentioned in a \"comment\":/posts/#{@comment.post_id}#comment-#{@comment.id}\n\n---\n\n[i]#{CurrentUser.name} said:[/i]\n\nHey @#{@user2.name} check this out!", dmail.body) end end end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index f390cfd2a..e453b1004 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -111,7 +111,7 @@ class UserTest < ActiveSupport::TestCase assert(@user.can_comment_vote?) 10.times do comment = FactoryGirl.create(:comment) - FactoryGirl.create(:comment_vote, :comment_id => comment.id) + FactoryGirl.create(:comment_vote, :comment_id => comment.id, :score => -1) end assert(!@user.can_comment_vote?) From f8d5add0cc73d5e5e34cbd5fa76997f5c97b8a4f Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 3 Dec 2016 20:09:58 -0600 Subject: [PATCH 2/2] Silence git messages to stdout during app boot. Caused this to be printed every time tests were run: git is /usr/bin/git /home/user/src/danbooru --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 9b37c4b8d..ba75484cc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -24,7 +24,7 @@ module Danbooru if File.exists?("#{config.root}/REVISION") config.x.git_hash = File.read("#{config.root}/REVISION").strip - elsif system("type git && git rev-parse --show-toplevel") + elsif system("type git > /dev/null && git rev-parse --show-toplevel > /dev/null") config.x.git_hash = %x(git rev-parse --short HEAD).strip else config.x.git_hash = nil