Giter Site home page Giter Site logo

Comments (5)

kurenn avatar kurenn commented on July 29, 2024

I probably missed to update the placements factory file: you have to make it look like:

FactoryGirl.define do
  factory :placement do
    order
    product
    quantity 1
  end

end

And also update the products factory file:

FactoryGirl.define do
  factory :product do
    title { FFaker::Product.product_name }
    price { rand() * 100 }
    published false
    user
    quantity 5
  end
end

Then all your tests should be green. Sorry about this mismatch between the book and the repo, I'll update the book. Thanks!

from market_place_api.

levi-l-damian avatar levi-l-damian commented on July 29, 2024

It worked perfectly, many thanks. I am able now to move to chapter 10.

On Tue, May 5, 2015 at 12:37 PM, Abraham [email protected] wrote:

I probably missed to update the placements factory file: you have to make
it look like:

FactoryGirl.define do
factory :placement do
order
product
quantity 1
end
end

And also update the products factory file:

FactoryGirl.define do
factory :product do
title { FFaker::Product.product_name }
price { rand() * 100 }
published false
user
quantity 5
endend

Then all your tests should be green. Sorry about this mismatch between the
book and the repo, I'll update the book. Thanks!


Reply to this email directly or view it on GitHub
#23 (comment)
.

Levi

from market_place_api.

rohitgoyal avatar rohitgoyal commented on July 29, 2024

@kurenn
1st error got resolved by the changes you have suggested.
But I am still failing the user controller tests.

Failures:

  1. Api::V1::OrdersController POST #create returns the just user order record
    Failure/Error: post :create, user_id: current_user.id, order: order_params
    TypeError:
    nil can't be coerced into BigDecimal

    ./app/models/order.rb:18:in `*'

    ./app/models/order.rb:18:in`block in set_total!'

    ./app/models/order.rb:17:in `set_total!'

    ./app/controllers/api/v1/orders_controller.rb:17:in`create'

    ./spec/controllers/api/v1/orders_controller_spec.rb:57:in `block (3 levels) in <top (required)>'

  2. Api::V1::OrdersController POST #create embeds the two product objects related to the order
    Failure/Error: post :create, user_id: current_user.id, order: order_params
    TypeError:
    nil can't be coerced into BigDecimal

    ./app/models/order.rb:18:in `*'

    ./app/models/order.rb:18:in`block in set_total!'

    ./app/models/order.rb:17:in `set_total!'

    ./app/controllers/api/v1/orders_controller.rb:17:in`create'

    ./spec/controllers/api/v1/orders_controller_spec.rb:57:in `block (3 levels) in <top (required)>'

  3. Api::V1::OrdersController POST #create
    Failure/Error: post :create, user_id: current_user.id, order: order_params
    TypeError:
    nil can't be coerced into BigDecimal

    ./app/models/order.rb:18:in `*'

    ./app/models/order.rb:18:in`block in set_total!'

    ./app/models/order.rb:17:in `set_total!'

    ./app/controllers/api/v1/orders_controller.rb:17:in`create'

    ./spec/controllers/api/v1/orders_controller_spec.rb:57:in `block (3 levels) in <top (required)>'

Finished in 2.36 seconds
107 examples, 3 failures

Failed examples:

rspec ./spec/controllers/api/v1/orders_controller_spec.rb:60 # Api::V1::OrdersController POST #create returns the just user order record
rspec ./spec/controllers/api/v1/orders_controller_spec.rb:65 # Api::V1::OrdersController POST #create embeds the two product objects related to the order
rspec ./spec/controllers/api/v1/orders_controller_spec.rb:70 # Api::V1::OrdersController POST #create

Randomized with seed 62385

from market_place_api.

kurenn avatar kurenn commented on July 29, 2024

@rohitgoyal it seems to be related with the order model, probably a migration is missing or the factory is not right, could you share those files?

from market_place_api.

rohitgoyal avatar rohitgoyal commented on July 29, 2024

@kurenn Here you go
https://bitbucket.org/rohitgoyal/market_place_api

from market_place_api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.