/posts/:id/events: list is_resolved correctly for appeals.
/posts/:id/events incorrectly lists appeals as always being resolved. This is because events UNION together appeals and flags, which doesn't quite work because for appeals is_resolved is a method, not an attribute. is_resolved was hardcoded to true so it'd work in the UNION. This changes PostEvent to be a wrapper object around PostFlag / PostAppeal, instead of a UNION. PostEvent delegates everything to the inner flag/appeals object, so that is_resolved works correctly. Also, this incidentally fixes a problem with /posts/:id/event.xml not serializing correctly.
This commit is contained in:
@@ -26,4 +26,21 @@ class PostEventsControllerTest < ActionController::TestCase
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user