-
Notifications
You must be signed in to change notification settings - Fork 407
/
post_events_controller_test.rb
46 lines (37 loc) · 1.14 KB
/
post_events_controller_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
context "GET /posts/:post_id/events.xml" do
setup do
get :index, {:post_id => @post.id, :format => :xml}, {:user_id => CurrentUser.user.id}
@xml = Hash.from_xml(response.body)
@appeal = @xml["post_events"].find { |e| e["type"] == "a" }
end
should "render" do
assert_not_nil(@appeal)
end
should "return is_resolved correctly" do
assert_equal(false, @appeal["is_resolved"])
end
end
end