forked from e621ng/e621ng
[Tests] Add basic tests for takedowns
Would have ccaught the breakage from frozen string literals
This commit is contained in:
parent
2609990837
commit
979e2e4d5f
11
test/factories/takedown.rb
Normal file
11
test/factories/takedown.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory(:takedown) do
|
||||
creator_ip_addr { "127.0.0.1" }
|
||||
email { "dummy@example.com" }
|
||||
source { "example.com" }
|
||||
reason { "foo" }
|
||||
instructions { "bar" }
|
||||
end
|
||||
end
|
29
test/functional/takedowns_controller_test.rb
Normal file
29
test/functional/takedowns_controller_test.rb
Normal file
@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
|
||||
class TakedownsControllerTest < ActionDispatch::IntegrationTest
|
||||
should "render the index" do
|
||||
create_list(:takedown, 2)
|
||||
get takedowns_path
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render the index for admins" do
|
||||
create_list(:takedown, 2)
|
||||
get_auth takedowns_path, create(:admin_user)
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "allow creation" do
|
||||
takedown_post = create(:post)
|
||||
post takedowns_path, params: { takedown: { email: "dummy@example.com", reason: "foo", post_ids: "#{takedown_post.id} #{takedown_post.id + 1}" }, format: :json }
|
||||
|
||||
takedown = Takedown.last
|
||||
assert_redirected_to takedown_path(takedown, code: takedown.vericode)
|
||||
assert_equal(takedown_post.id.to_s, takedown.post_ids)
|
||||
assert_operator(takedown.vericode.length, :>, 8)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user