Testing strong parameters

63 views
Skip to first unread message

bertly_the_coder

unread,
Mar 4, 2014, 8:49:34 AM3/4/14
to rubyonra...@googlegroups.com
Hi guys,

Has anyone figured out how to test strong parameters?

Dave Aronson

unread,
Mar 4, 2014, 12:13:03 PM3/4/14
to rubyonrails-talk
On Tue, Mar 4, 2014 at 8:49 AM, bertly_the_coder <muc...@gmail.com> wrote:

> Has anyone figured out how to test strong parameters?

You mean test the concept itself, or test that your usage of it does
what you intend? I haven't done so, but offhand, I would guess you
could do that by testing a few requests with good or bad parameter
sets, and seeing whether Rails gritches about them or not.

-Dave

--
Dave Aronson, the T. Rex of Codosaurus LLC (www.codosaur.us);
FREELANCE SOFTWARE DEVELOPER, AVAILABLE AS OF MARCH 1st 2014;
creator of Pull Request Roulette, at PullRequestRoulette.com.

bertly_the_coder

unread,
Mar 4, 2014, 1:13:38 PM3/4/14
to rubyonra...@googlegroups.com
They all pass. That's the problem. Mass-assignment doesn't seem to get caught by the testing environment.

Dave Aronson

unread,
Mar 4, 2014, 2:02:50 PM3/4/14
to rubyonrails-talk
On Tue, Mar 4, 2014 at 1:13 PM, bertly_the_coder <muc...@gmail.com> wrote:

> They all pass. That's the problem. Mass-assignment
> doesn't seem to get caught by the testing environment.

Ah, yes, that is odd. Maybe you could check out the tests from that
part of Rails, or of the strong_parameters gem, and see how they do
it.

bertly_the_coder

unread,
Mar 4, 2014, 4:55:46 PM3/4/14
to rubyonra...@googlegroups.com
LOL! Thx Dave.

Anyone else figured/figuring this out or found some documentation about it?

Dheeraj Kumar

unread,
Mar 4, 2014, 9:12:07 PM3/4/14
to rubyonra...@googlegroups.com

Use permitters instead. Easily testable.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/26c2181f-9cf3-4608-a002-d923746d591c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Frederick Cheung

unread,
Mar 5, 2014, 6:34:17 AM3/5/14
to rubyonra...@googlegroups.com


On Tuesday, March 4, 2014 1:49:34 PM UTC, bertly_the_coder wrote:
Hi guys,

Has anyone figured out how to test strong parameters?

What have you got

config.action_controller.action_on_unpermitted_parameters 

set to?

I set it to :raise in test/development, so that submitting incorrect parameters will cause tests to fail


Fred 

muchira k.

unread,
Mar 6, 2014, 2:44:22 AM3/6/14
to rubyonra...@googlegroups.com
Thx Fredrick! You're a STAR!


--
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/j1a1NfKBbAg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubyonrails-ta...@googlegroups.com.

To post to this group, send email to rubyonra...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Clarity is self-created. The universe is waiting on you, not the other way around - Me.

“Life isn't about finding yourself. Life is about creating yourself.” - G. Bernard Shaw

"Life is what happens while you are busy making plans" - John Lennon

NAMASTE!!!!! Yeah I said it!!
Reply all
Reply to author
Forward
0 new messages