Files
danbooru/test/functional/iqdb_queries_controller_test.rb
2018-01-20 13:22:05 -06:00

38 lines
1.0 KiB
Ruby

require 'test_helper'
class IqdbQueriesControllerTest < ActionController::TestCase
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
should "render for a json response" do
mock_iqdb_matches!(@posts[0].source, @posts)
get :show, { url: @posts[0].source, format: "json" }, { user_id: @user.id }
assert_response :success
end
end
end
end