Files
danbooru/test/functional/moderator/ip_addrs_controller_test.rb
evazion b4ce2d83a6 models: remove belongs_to_creator macro.
The belongs_to_creator macro was used to initialize the creator_id field
to the CurrentUser. This made tests complicated because it meant you had
to create and set the current user every time you wanted to create an
object, when lead to the current user being set over and over again. It
also meant you had to constantly be aware of what the CurrentUser was in
many different contexts, which was often confusing. Setting creators
explicitly simplifies everything greatly.
2020-01-21 00:09:38 -06:00

36 lines
1.0 KiB
Ruby

require 'test_helper'
module Moderator
class IpAddrsControllerTest < ActionDispatch::IntegrationTest
context "The ip addrs controller" do
setup do
PoolArchive.delete_all
PostArchive.delete_all
@user = create(:moderator_user, created_at: 1.month.ago)
as(@user) { create(:comment, creator: @user) }
end
should "find by ip addr" do
get_auth moderator_ip_addrs_path, @user, params: {:search => {:ip_addr => "127.0.0.1"}}
assert_response :success
end
should "find by user id" do
get_auth moderator_ip_addrs_path, @user, params: {:search => {:user_id => @user.id.to_s}}
assert_response :success
end
should "find by user name" do
get_auth moderator_ip_addrs_path, @user, params: {:search => {:user_name => @user.name}}
assert_response :success
end
should "render the search page" do
get_auth search_moderator_ip_addrs_path, @user
assert_response :success
end
end
end
end