tests: add iqdb queries controller tests.

This commit is contained in:
evazion
2017-02-06 16:06:23 -06:00
parent e26fb61ee9
commit 3edd814be5
4 changed files with 46 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
require 'test_helper'
require 'helpers/iqdb_test_helper'
class IqdbQueriesControllerTest < ActionController::TestCase
include IqdbTestHelper
context "The iqdb controller" do
setup do
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
@posts = FactoryGirl.create_list(:post, 2)
mock_iqdb_service!
end
context "create action" do
should "render with a post_id" do
mock_iqdb_matches!(@posts[0], @posts)
post :create, { post_id: @posts[0].id, format: "js" }, { user_id: @user.id }
assert_response :success
end
should "render with an url" do
mock_iqdb_matches!(@posts[0].source, @posts)
post :create, { url: @posts[0].source }, { user_id: @user.id }
assert_response :success
end
end
end
end