How to inject a value in params when testing a helper method

I what to try this method in a helper class:

def moderator_buttons?
return true if params[:question_status] == ‘HOST_INBOX’
return true if params[:question_status] == ‘HOST_INBOX_READ’
return true if params[:question_status] == ‘DELETED’
return true if params[:question_status] == ‘LATER’
return true if params[:question_status] == ‘MODERATOR_TO_APPROVE’

false

end

How can I assign ‘HOST_INBOX’ string to params[:question_status]
before

assert true, moderator_buttons?

Riccardo T. wrote:

I what to try this method in a helper class:

def moderator_buttons?
return true if params[:question_status] == ‘HOST_INBOX’
return true if params[:question_status] == ‘HOST_INBOX_READ’
return true if params[:question_status] == ‘DELETED’
return true if params[:question_status] == ‘LATER’
return true if params[:question_status] == ‘MODERATOR_TO_APPROVE’

false

end

No you don’t. Your helpers don’t have access to params, since they live
in the view layer. You’ll need to pass params[:question_status] in as
an @instance variable.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Aug 4, 4:09 pm, Marnen Laibow-Koser [email protected] wrote:

No you don’t. Your helpers don’t have access to params, since they live
in the view layer. You’ll need to pass params[:question_status] in as
an @instance variable.

They do - ActionView::Base delegates the params method (among others)
to the controller

Fred

Frederick C. wrote:

On Aug 4, 4:09�pm, Marnen Laibow-Koser [email protected] wrote:

No you don’t. �Your helpers don’t have access to params, since they live
in the view layer. �You’ll need to pass params[:question_status] in as
an @instance variable.

They do - ActionView::Base delegates the params method (among others)
to the controller

OK, then I’m sorry for the error. I still can’t see why it’s ever a
good idea to touch the params array in the view…

…though I suppose you could make the argument that the controller
shouldn’t have to know it needs to set @question_status.

Fred

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]