DynamoMTL / spree_chimpy

Spree/MailChimp Integration
BSD 3-Clause "New" or "Revised" License
35 stars 123 forks source link

*** NoMethodError Exception: undefined method `detect' for nil:NilClass #28

Closed AteqEjaz closed 11 years ago

AteqEjaz commented 11 years ago

Hi guys,

Spree::Chimpy::SubscribersController is throwing following error in create method any idea?

*\ NoMethodError Exception: undefined method `detect' for nil:NilClass.

Thanks,

johanb commented 11 years ago

Hey @AteqEjaz thx for reporting. I'll look into this tonight. I don't have time to look into it sooner. Do you maybe have some more information ? like which version of spree and a longer stacktrace ? that would make debugging easier.

AteqEjaz commented 11 years ago

Thanks johnab,

I'm using spree 2.0.0 and i was just trying to test its controller create method.like

it "responds successfully with an HTTP 200 status code" do spree_post :create , chimpy_subscriber: valid_attributes
expect(response).to be_success expect(response.status).to eq(200) end

I found root cause in my case which is list.rb line 40. if i put a check over there def find_list_id(name) @api.lists["data"].detect { |r| r["name"] == name }["id"] if @api.lists["data"].present? end this error removes But subscription_controller following line throws error undefined url.

respond_with @subscriber, location: request.referer.

Let me know if i'm missing some configuration?

joshnuss commented 11 years ago

@AteqEjaz Usually in a controller spec you would mock out the model layer. Without mocking, you would need a bunch of setup code to make this work.