Skip to content

Commit

Permalink
Rails 5.0 -- Fix comments_controller_spec.rb and moderations_controll…
Browse files Browse the repository at this point in the history
…er_spec.rb (#330)

* permit params and convert to_hash because params no longer inherits from HashWithIndifferentAccess

* fix backwards breaking behavior. update moderations_controller. need to permit params in order for added attributes to be included when converting to a hash with to_h
  • Loading branch information
yuenmichelle1 committed Jul 1, 2024
1 parent 2a7b7af commit 94073bb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ def destroy
def filter_subject_default
board_ids = Board.where(section: params[:section], subject_default: params[:subject_default]).pluck :id
params[:board_id] = board_ids.join ','
params.permit!
end
end
1 change: 1 addition & 0 deletions app/controllers/moderations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ def invert_enums
inverted_state = Moderation.states[params[:state]]
raise Talk::InvalidParameterError.new(:state, "in #{ Moderation.states.keys }", params[:state]) unless inverted_state
params[:state] = inverted_state
params.permit!
end
end
2 changes: 1 addition & 1 deletion app/serializers/concerns/talk_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def resource(params = { }, scope = nil, context = { })
end

def page(params = { }, scope = nil, context = { })
super params, scope_preloading_for(scope), context.merge(params: params)
super params.to_h, scope_preloading_for(scope), context.merge(params: params)
end

def page_with_options(options)
Expand Down

0 comments on commit 94073bb

Please sign in to comment.