2014-11-20 11:29:32 +09:00
|
|
|
require "test_helper"
|
2010-04-20 23:05:11 +00:00
|
|
|
|
|
|
|
class ReportControllerTest < ActionController::TestCase
|
|
|
|
fixtures :users
|
2014-08-23 16:19:01 +09:00
|
|
|
|
2010-04-20 23:05:11 +00:00
|
|
|
def create_post(tags, post_number = 1, params = {})
|
2014-11-20 22:32:05 +09:00
|
|
|
Thread.current["danbooru-user_id"] = 1
|
2024-01-08 19:39:01 +09:00
|
|
|
Post.create({ user_id: 1, score: 0, source: "", rating: "s", width: 100, height: 100, ip_addr: "127.0.0.1", updater_ip_addr: "127.0.0.1", updater_user_id: 1, tags: tags, status: "active", file: upload_file("#{Rails.root}/test/mocks/test/test#{post_number}.jpg") }.merge(params))
|
2010-04-20 23:05:11 +00:00
|
|
|
end
|
2014-08-23 16:19:01 +09:00
|
|
|
|
2010-04-20 23:05:11 +00:00
|
|
|
def update_post(post, params = {})
|
2024-01-08 19:39:01 +09:00
|
|
|
post.update({ updater_user_id: 1, updater_ip_addr: "127.0.0.1" }.merge(params))
|
2010-04-20 23:05:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create_note(params = {})
|
2024-01-08 19:39:01 +09:00
|
|
|
Note.create({ post_id: 1, user_id: 1, x: 0, y: 0, width: 100, height: 100, is_active: true, ip_addr: "127.0.0.1" }.merge(params))
|
2010-04-20 23:05:11 +00:00
|
|
|
end
|
2014-08-23 16:19:01 +09:00
|
|
|
|
2010-04-20 23:05:11 +00:00
|
|
|
def create_wiki(params = {})
|
2024-01-08 19:39:01 +09:00
|
|
|
WikiPage.create({ title: "hoge", user_id: 1, body: "hoge", ip_addr: "127.0.0.1", is_locked: false }.merge(params))
|
2010-04-20 23:05:11 +00:00
|
|
|
end
|
2014-08-23 16:19:01 +09:00
|
|
|
|
2014-11-20 22:32:05 +09:00
|
|
|
def test_tag_updates
|
2010-04-20 23:05:11 +00:00
|
|
|
p1 = create_post("hoge", 1)
|
2024-01-08 19:39:01 +09:00
|
|
|
update_post(p1, tags: "moge")
|
2014-08-23 16:19:01 +09:00
|
|
|
|
2016-08-16 07:50:23 +09:00
|
|
|
get :tag_updates
|
2010-04-20 23:05:11 +00:00
|
|
|
assert_response :success
|
|
|
|
end
|
2014-08-23 16:19:01 +09:00
|
|
|
|
2014-11-20 22:32:05 +09:00
|
|
|
def test_note_updates
|
2024-01-08 19:39:01 +09:00
|
|
|
n1 = create_note(body: "hoge")
|
|
|
|
n1.update(body: "moge")
|
2014-08-23 16:19:01 +09:00
|
|
|
|
2016-08-16 07:50:23 +09:00
|
|
|
get :note_updates
|
2010-04-20 23:05:11 +00:00
|
|
|
assert_response :success
|
|
|
|
end
|
2014-08-23 16:19:01 +09:00
|
|
|
|
2014-11-20 22:32:05 +09:00
|
|
|
def test_wiki_updates
|
2010-04-20 23:05:11 +00:00
|
|
|
w1 = create_wiki
|
2024-01-08 19:39:01 +09:00
|
|
|
w1.update(body: "moge")
|
2014-08-23 16:19:01 +09:00
|
|
|
|
2016-08-16 07:50:23 +09:00
|
|
|
get :wiki_updates
|
2010-04-20 23:05:11 +00:00
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
end
|