add combined flag+appeal listing for posts #262
This commit is contained in:
29
test/functional/post_events_controller_test.rb
Normal file
29
test/functional/post_events_controller_test.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PostEventsControllerTest < ActionController::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
Timecop.travel(2.weeks.ago) do
|
||||
CurrentUser.user = FactoryGirl.create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
@post = FactoryGirl.create(:post)
|
||||
@post_flag = PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false)
|
||||
@post_appeal = PostAppeal.create(:post => @post, :reason => "aaa")
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "GET /posts/:post_id/events" do
|
||||
should "render" do
|
||||
get :index, {:post_id => @post.id}, {:user_id => CurrentUser.user.id}
|
||||
assert_response :ok
|
||||
end
|
||||
end
|
||||
end
|
||||
31
test/unit/post_event_test.rb
Normal file
31
test/unit/post_event_test.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PostEventTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
Timecop.travel(2.weeks.ago) do
|
||||
CurrentUser.user = FactoryGirl.create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
@post = FactoryGirl.create(:post)
|
||||
@post_flag = PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false)
|
||||
@post_appeal = PostAppeal.create(:post => @post, :reason => "aaa")
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "PostEvent.find_for_post" do
|
||||
should "work" do
|
||||
results = PostEvent.find_for_post(@post.id)
|
||||
assert_equal(2, results.size)
|
||||
assert(results[0].flag?)
|
||||
assert(results[1].appeal?)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user