Skip to content

Check if default is a hash rather than checking if it responds to merge#20840

Closed
sgringwe wants to merge 1 commit into
rails:masterfrom
sgringwe:fix-integration-test-default-headers-glitch
Closed

Check if default is a hash rather than checking if it responds to merge#20840
sgringwe wants to merge 1 commit into
rails:masterfrom
sgringwe:fix-integration-test-default-headers-glitch

Conversation

@sgringwe

Copy link
Copy Markdown
Contributor

This fixes scenarios where objects (such as nil) have the 'merge' method defined for other reasons. In this situation, the CanCan gem had defined merge: CanCanCommunity/cancancan#229. It is debatable whether cancan or rails is 'at fault' here, but checking if default is a hash feels more correct based on my understanding of the intended behavior.

If you'd like for a test to be added just let me know.

This fixes #20837

…ge. This fixes scenarios where objects (such as nil) have the 'merge' method defined for other reasons.
@Senjai

Senjai commented Jul 12, 2015

Copy link
Copy Markdown
Contributor

@sgringwe See my comment on CanCanCommunity/cancancan#229. I believe duck typing instead of explicitly checking the class is the preferred approach for these scenarios with ruby.

@matthewd

Copy link
Copy Markdown
Member

I believe duck typing instead of explicitly checking the class is the preferred approach for these scenarios with ruby

Agree

@matthewd matthewd closed this Jul 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ActionDispatch::Response#[] delegated to @header.[], but @header is nil

3 participants