Giter Site home page Giter Site logo

Comments (20)

florentferry avatar florentferry commented on June 27, 2024 1

I reproduce the error with your cloned repo, and I have similar issue. If you change your active_model_serializers to 0.8.3, all tests are passing.

gem 'active_model_serializers', '0.8.3'

from market_place_api.

kurenn avatar kurenn commented on June 27, 2024

@enilsen16 can you give me more details about the rspec version you are running, I'm running specs from chapter 8 and they are running fine.

from market_place_api.

enilsen16 avatar enilsen16 commented on June 27, 2024

I'm using rspec 3.2.1. rspec 2.x.x was giving me errors and depreciations with rails 4.2.1.
I had similar issues using active_model_serializers 0.8.0 and rails 4.2.1.

my entire gemfile:

source 'https://rubygems.org'

gem 'active_model_serializers', git: 'https://github.com/rails-api/active_model_serializers.git'
gem 'coffee-rails', '~> 4.1.0'
gem 'compass-rails'
gem 'devise'
gem 'font-awesome-rails'
gem 'furatto'
gem 'jquery-rails'
gem 'rails', '4.2.1'
gem 'sabisu_rails', github: 'IcaliaLabs/sabisu-rails', branch: 'master'
gem 'sass-rails', '~> 5.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'simple_form'
gem 'uglifier', '>= 1.3.0'

group :development do
  gem 'sqlite3'
end

group :development, :test do
  gem 'byebug'
  gem 'factory_girl_rails'
  gem 'ffaker'
  gem 'spring'
  gem 'web-console', '~> 2.0'
end

group :test do
  gem 'rspec-collection_matchers'
  gem 'rspec-rails'
  gem 'shoulda-matchers'
end

The repository can be found here: https://github.com/enilsen16/rails-devise-api

Any idea what's up?

from market_place_api.

kurenn avatar kurenn commented on June 27, 2024

I cannot reproduce the error, I cloned your repo and ran all the tests, and they all work. What are you doing exactly?

screen shot 2015-05-01 at 4 30 25 pm

from market_place_api.

enilsen16 avatar enilsen16 commented on June 27, 2024

@kurenn Hmm... ok

git pull for the lastest code and then try. There should be 72 examples...

I really appreciate your help troubleshooting 😄

from market_place_api.

kurenn avatar kurenn commented on June 27, 2024

Did it worked?

from market_place_api.

enilsen16 avatar enilsen16 commented on June 27, 2024

No I still have these errors. I'll run through chapter 7 again, just to make sure I did everything right.

from market_place_api.

kurenn avatar kurenn commented on June 27, 2024

@enilsen16 try @florentferry solution and let me know how it goes!

from market_place_api.

enilsen16 avatar enilsen16 commented on June 27, 2024

@florentferry @kurenn Is it a syntax issue then with 'active_model_serializers', '0.10.0'?

Now that I am using an older version everything passes.

from market_place_api.

florentferry avatar florentferry commented on June 27, 2024

No, the problem comes from the gem itself and/or dependencies with Rails 4.2 and RSpec 3. I check in active_model_serializers and find 0.8.3 works well with this stack.

from market_place_api.

pedrovcenteno avatar pedrovcenteno commented on June 27, 2024

Hi,
I'm not an expert but at GitHub's page for active_model_serializers says:

This [version 0.10.0] is not backward compatible with 0.9.0 or 0.8.0.

from market_place_api.

pedrovcenteno avatar pedrovcenteno commented on June 27, 2024

I was having the same problems and after having changed active_model_serializers to 0.8.3, as your suggestion, solved them.

I has caused problems on PRAX too: its Linux process was crashing. It's ok now.

Having read the console RSpec's output of the tests, it seems the version of active_model_serializers I had before caused some infinite loop and crashed. The output, may it be important:

~/projects/marketplaceapi$ bundle exec rspec spec/controllers/api/v1/products_controller_spec.rb
DEPRECATION WARNING: ** Notice: embed is deprecated. **
The use of .embed method on a Serializer will be soon removed, as this should have a global scope and not a class scope.
Please use the global .setup method instead:
ActiveModel::Serializer.setup do |config|
config.embed = :ids
config.embed_in_root = false
end
(called from class:UserSerializer at /home/pvc/projects/marketplaceapi/app/serializers/user_serializer.rb:2)
FFDEPRECATION WARNING: named_routes.helpers is deprecated, please use route_defined?(route_name) to see if a named route was defined. (called from block (4 levels) in <top (required)> at /home/pvc/projects/marketplaceapi/spec/controllers/api/v1/products_controller_spec.rb:116)
...FFDEPRECATION WARNING: named_routes.helpers is deprecated, please use route_defined?(route_name) to see if a named route was defined. (called from block (4 levels) in <top (required)> at /home/pvc/projects/marketplaceapi/spec/controllers/api/v1/products_controller_spec.rb:161)
...FFFFFFF.

Failures:

  1. Api::V1::ProductsController POST #create when is successfully created renders the json representation for the product record just created
    Failure/Error: post :create, { user_id: user.id, product: @product_attributes }
    SystemStackError:
    stack level too deep

    ./app/controllers/api/v1/products_controller.rb:24:in `create'

    ./spec/controllers/api/v1/products_controller_spec.rb:94:in`block (4 levels) in <top (required)>'

  2. Api::V1::ProductsController POST #create when is successfully created
    Failure/Error: post :create, { user_id: user.id, product: @product_attributes }
    SystemStackError:
    stack level too deep

    ./app/controllers/api/v1/products_controller.rb:24:in `create'

    ./spec/controllers/api/v1/products_controller_spec.rb:94:in`block (4 levels) in <top (required)>'

  3. Api::V1::ProductsController PUT/PATCH #update when is successfully updated renders the json representation for the updated product
    Failure/Error: patch :update, { user_id: @user.id, id: @product.id,
    SystemStackError:
    stack level too deep

    ./app/controllers/api/v1/products_controller.rb:35:in `update'

    ./spec/controllers/api/v1/products_controller_spec.rb:141:in`block (4 levels) in <top (required)>'

  4. Api::V1::ProductsController PUT/PATCH #update when is successfully updated
    Failure/Error: patch :update, { user_id: @user.id, id: @product.id,
    SystemStackError:
    stack level too deep

    ./app/controllers/api/v1/products_controller.rb:35:in `update'

    ./spec/controllers/api/v1/products_controller_spec.rb:141:in`block (4 levels) in <top (required)>'

  5. Api::V1::ProductsController GET #show returns the information about a reporter on a hash
    Failure/Error: get :show, id: @product.id
    SystemStackError:
    stack level too deep

    ./app/controllers/api/v1/products_controller.rb:16:in `show'

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

  6. Api::V1::ProductsController GET #show has the user as an embedded object
    Failure/Error: get :show, id: @product.id
    SystemStackError:
    stack level too deep

    ./app/controllers/api/v1/products_controller.rb:16:in `show'

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

  7. Api::V1::ProductsController GET #show
    Failure/Error: get :show, id: @product.id
    SystemStackError:
    stack level too deep

    ./app/controllers/api/v1/products_controller.rb:16:in `show'

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

  8. Api::V1::ProductsController GET #index when is not receiving any product_ids parameter returns 4 records from the database
    Failure/Error: get :index
    SystemStackError:
    stack level too deep

    ./app/controllers/api/v1/products_controller.rb:12:in `index'

    ./spec/controllers/api/v1/products_controller_spec.rb:41:in`block (4 levels) in <top (required)>'

  9. Api::V1::ProductsController GET #index when is not receiving any product_ids parameter returns the user object into each product
    Failure/Error: get :index
    SystemStackError:
    stack level too deep

    ./app/controllers/api/v1/products_controller.rb:12:in `index'

    ./spec/controllers/api/v1/products_controller_spec.rb:41:in`block (4 levels) in <top (required)>'

  10. Api::V1::ProductsController GET #index when is not receiving any product_ids parameter
    Failure/Error: get :index
    SystemStackError:
    stack level too deep
    # ./app/controllers/api/v1/products_controller.rb:12:in index' # ./spec/controllers/api/v1/products_controller_spec.rb:41:inblock (4 levels) in <top (required)>'

  11. Api::V1::ProductsController GET #index when product_ids parameter is sent returns just the products that belong to the user
    Failure/Error: get :index, product_ids: @user.product_ids
    SystemStackError:
    stack level too deep
    # ./app/controllers/api/v1/products_controller.rb:12:in index' # ./spec/controllers/api/v1/products_controller_spec.rb:67:inblock (4 levels) in <top (required)>'

Finished in 2.33 seconds
18 examples, 11 failures

Failed examples:

rspec ./spec/controllers/api/v1/products_controller_spec.rb:97 # Api::V1::ProductsController POST #create when is successfully created renders the json representation for the product record just created
rspec ./spec/controllers/api/v1/products_controller_spec.rb:102 # Api::V1::ProductsController POST #create when is successfully created
rspec ./spec/controllers/api/v1/products_controller_spec.rb:145 # Api::V1::ProductsController PUT/PATCH #update when is successfully updated renders the json representation for the updated product
rspec ./spec/controllers/api/v1/products_controller_spec.rb:150 # Api::V1::ProductsController PUT/PATCH #update when is successfully updated
rspec ./spec/controllers/api/v1/products_controller_spec.rb:12 # Api::V1::ProductsController GET #show returns the information about a reporter on a hash
rspec ./spec/controllers/api/v1/products_controller_spec.rb:17 # Api::V1::ProductsController GET #show has the user as an embedded object
rspec ./spec/controllers/api/v1/products_controller_spec.rb:22 # Api::V1::ProductsController GET #show
rspec ./spec/controllers/api/v1/products_controller_spec.rb:44 # Api::V1::ProductsController GET #index when is not receiving any product_ids parameter returns 4 records from the database
rspec ./spec/controllers/api/v1/products_controller_spec.rb:49 # Api::V1::ProductsController GET #index when is not receiving any product_ids parameter returns the user object into each product
rspec ./spec/controllers/api/v1/products_controller_spec.rb:57 # Api::V1::ProductsController GET #index when is not receiving any product_ids parameter
rspec ./spec/controllers/api/v1/products_controller_spec.rb:70 # Api::V1::ProductsController GET #index when product_ids parameter is sent returns just the products that belong to the user

Randomized with seed 55815

from market_place_api.

RobinCaroff avatar RobinCaroff commented on June 27, 2024

I have exactly the same thing as @pedrovcenteno . Reading the DEPRECATION WARNING:
"The use of .embed method on a Serializer will be soon removed, as this should have a global scope and not a class scope."

I wonder then : does it still a good solution to use the embed ids and the old version of the gem or should we use something different such as the 'meta attribute' solution suggested by @kurenn in Box 7.2 ?

from market_place_api.

kurenn avatar kurenn commented on June 27, 2024

@RobinCaroff I would say it's fine as long you don't update to version 0.10, otherwise it will cause problems.

It is a good solution, the only thing with version 0.10 is that uses the new JSON API standard http://jsonapi.org/ but at the end of the day you choose how you want to structure the JSON response.

from market_place_api.

AdamYang121 avatar AdamYang121 commented on June 27, 2024

Hi, I just solve the problem, it's just the change of GET request syntax. You don't need rollback to old version active_model_serializers.
Try this:
get :show, params: { id: @product.id }
instead of
get :show, id: @product.id

Hope it is helpful. Good luck.

from market_place_api.

kurenn avatar kurenn commented on June 27, 2024

@RobinCaroff can you try with @AdamYang121's solution?

from market_place_api.

shogmar avatar shogmar commented on June 27, 2024

I was having the same problems and after having changed active_model_serializers to 0.8.3, as your suggestion, solved them. But I have a version of rails 6, ruby 2.6.5.

12
123

from market_place_api.

kurenn avatar kurenn commented on June 27, 2024

@shogmar Were you able to keep moving forward?

from market_place_api.

shogmar avatar shogmar commented on June 27, 2024

@shogmar Were you able to keep moving forward?

Yes, I changed the version to 0.8.3

from market_place_api.

kurenn avatar kurenn commented on June 27, 2024

Glad to read it!

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.