I believe that the relevant variable is just env, not env_table:

request.env["REMOTE_ADDR"]
# => 10.0.1.1

But probably what you really want is

request.remote_ip
# => 10.0.1.1, even behind a proxy

which is more robust.  See
http://www.railsbrain.com/api/rails-2.0.2/doc/index.html?a=M000413&name=remote_ip

Using either of those, your tests should pass.

Michael

On Thu, May 15, 2008 at 10:13 PM, Ehlo <[EMAIL PROTECTED]> wrote:
>
> Hi All,
> I'm nearly ready with the abuse report stuff.
> Anyway, at the moment it break several rake spec tests.
>
> In my controller I use something like this:
> message = Message.new(params[:message].merge(:sender =>
> current_person,
>                                                  :recipient =>
> person, :sender_ip => request.env_table["REMOTE_ADDR"]))
>
> On several tests I get a error like this:
> NoMethodError in 'CommentsController wall comments should associate a
> person to a comment'
> undefined method `env_table' for #<ActionController::TestRequest:
> 0xb6ee323c>
> /home/ber/rails/insoshi/app/controllers/comments_controller.rb:22:in
> `create'
> ./spec/controllers/comments_controller_spec.rb:94:
> ./spec/controllers/comments_controller_spec.rb:93:
>
>
> It's look like the rake tests don't set any environment variable
> related to HTTP.
>
> I tried this:
> def handle_replies(message, recipient, sender)
>    login_as(recipient)
>        @request.env_table['REMOTE_ADDR'] = '10.0.1.1'
>    lambda do
>      post :create, :message => { :subject => "The subject",
>                                  :content   => "This is a reply",
>                                  :parent_id => message },
>                    :person_id => sender
>      assigns(:message).should be_reply
>    end.should change(Message, :count).by(1)
>  end
>
> But it doesn't help!
>
> Has anybody an idea?
>
> Cheers,
> E
> >
>

--~--~---------~--~----~------------~-------~--~----~
Insoshi developer site: http://dogfood.insoshi.com/
Insoshi documentation: http://docs.insoshi.com/

You received this message because you are subscribed to the Google
Groups "Insoshi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/insoshi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to