/posts/:id/events - fix exception when viewed by mod.
NoMethodError exception raised
undefined method `creator' for #<PostEvent:0x007f9a298e64d8> Did you mean? creator_id
app/views/post_events/index.html.erb:23:in `block in _app_views_post_events_index_html_erb__2088986421112502721_70150054247640'
app/views/post_events/index.html.erb:18:in `each'
app/views/post_events/index.html.erb:18:in `_app_views_post_events_index_html_erb__2088986421112502721_70150054247640'
app/controllers/post_events_controller.rb:6:in `index'
This commit is contained in:
@@ -4,7 +4,7 @@ class PostEvent
|
|||||||
include ActiveModel::Serializers::Xml
|
include ActiveModel::Serializers::Xml
|
||||||
|
|
||||||
attr_accessor :event
|
attr_accessor :event
|
||||||
delegate :creator_id, :reason, :is_resolved, :created_at, to: :event
|
delegate :creator, :creator_id, :reason, :is_resolved, :created_at, to: :event
|
||||||
|
|
||||||
def self.find_for_post(post_id)
|
def self.find_for_post(post_id)
|
||||||
post = Post.find(post_id)
|
post = Post.find(post_id)
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ class PostEventsControllerTest < ActionController::TestCase
|
|||||||
get :index, {:post_id => @post.id}, {:user_id => CurrentUser.user.id}
|
get :index, {:post_id => @post.id}, {:user_id => CurrentUser.user.id}
|
||||||
assert_response :ok
|
assert_response :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "render for mods" do
|
||||||
|
get :index, {:post_id => @post.id}, {:user_id => FactoryGirl.create(:moderator_user).id }
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "GET /posts/:post_id/events.xml" do
|
context "GET /posts/:post_id/events.xml" do
|
||||||
|
|||||||
Reference in New Issue
Block a user