Comments (5)
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.
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
endAnd 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
endendThen 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.
@kurenn
1st error got resolved by the changes you have suggested.
But I am still failing the user controller tests.
Failures:
-
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)>'
-
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)>'
-
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.
@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.
@kurenn Here you go
https://bitbucket.org/rohitgoyal/market_place_api
from market_place_api.
Related Issues (20)
- Body is blank.? --I can not do DELETE/ POST / PUT / interface Sabisu_Rails HOT 3
- Listing: 6.5: Failure/Error: @user.destroy HOT 1
- Chapter 6 should_not be_published HOT 1
- Unable to access api endpoint (via cURL and in browser) HOT 1
- Found an error in the beginning of Chapter 8.1
- Latest updates of this project HOT 4
- Chapter 10 Pagination issue: Meta object in render json: products, meta: is not rendered in ActiveModelSerializer 0.10.2 HOT 1
- json render format; chapter 7 HOT 1
- Filter chain halted as :authenticate_with_token! rendered or redirected Completed 401 Unauthorized HOT 3
- Rspec test failing in Rails 5 HOT 6
- Rails 5.0.1: Sass::SyntaxError in SabisuRails::Explorer#index HOT 5
- Listing 5.12 HOT 3
- How do I do a log out(destroy the session) using cUrl? HOT 5
- 500 error when user not exist HOT 5
- sign_in in sessions controller does not affect tests HOT 4
- Chapter 6.1.3 Dependency Destroy Factory HOT 3
- I have been getting a 404 for the same request which is successful on another POSTMAN. HOT 1
- Chapter 6.2.6: ActionController::UrlGenerationError: No route matches {:action=>"destroy", :controller=>"api/v1/products" ... HOT 1
- Chapter 6 ActionController::UrlGenerationError:
- Chapter 5 Authentication Rails 5.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from market_place_api.