solidusio / solidus

🛒 Solidus, the open-source eCommerce framework for industry trailblazers.
https://solidus.io
Other
5.01k stars 1.29k forks source link

Uninitialized constant Spree::StockConfiguration #725

Closed CallMeSH closed 8 years ago

CallMeSH commented 8 years ago

Hello everyone,

Since commit ba839c005b9fa54b7944aefc9a257bc2daef8242, trying to access the current estimator creates a "Uninitialized constant Spree::StockConfiguration" exception. Removing the leading double colons in this line seems to solve the bug: https://github.com/solidusio/solidus/blob/eb761fb790d67732ac5fa59a4f6205ab749b5053/core/lib/spree/core/stock_configuration.rb#L4

jhawthorn commented 8 years ago

Thanks for the report @CallMeSH

I've been trying, but can't reproduce this either on a sandbox or a fresh store. Do you have any customizations in your store?

Would you mind sharing your Gemfile.lock and ruby version?

CallMeSH commented 8 years ago

Hey,

Here is my Gemfile.lock:

GIT
  remote: https://github.com/solidusio/solidus.git
  revision: 56227745e8de5ec8d1be40f5d050ddd68b668016
  tag: v1.2.0.rc1
  specs:
    solidus_api (1.2.0.rc1)
      rabl (>= 0.9.4.pre1, < 0.12.0)
      solidus_core (= 1.2.0.rc1)
      versioncake (~> 2.3.1)
    solidus_backend (1.2.0.rc1)
      bourbon (>= 4, < 6)
      handlebars_assets
      jquery-rails
      jquery-ui-rails (~> 5.0.0)
      select2-rails (= 3.5.9.1)
      solidus_api (= 1.2.0.rc1)
      solidus_core (= 1.2.0.rc1)
    solidus_core (1.2.0.rc1)
      activemerchant (~> 1.48.0)
      acts_as_list (~> 0.3)
      awesome_nested_set (~> 3.0.1)
      cancancan (~> 1.10)
      carmen (~> 1.0.0)
      ffaker (~> 1.16)
      font-awesome-rails (~> 4.0)
      friendly_id (~> 5.0)
      highline (~> 1.6.18)
      json (~> 1.7)
      kaminari (~> 0.15, >= 0.15.1)
      monetize (~> 1.1)
      paperclip (~> 4.2.0)
      paranoia (~> 2.1.4)
      premailer-rails
      rails (~> 4.2.0)
      ransack (~> 1.6.0)
      responders
      sprockets-rails (~> 2.0)
      state_machines-activerecord (~> 0.2)
      stringex (~> 1.5.1)
      truncate_html (= 0.9.2)
      twitter_cldr (~> 3.0)

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.2.5)
      actionpack (= 4.2.5)
      actionview (= 4.2.5)
      activejob (= 4.2.5)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.5)
      actionview (= 4.2.5)
      activesupport (= 4.2.5)
      rack (~> 1.6)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (4.2.5)
      activesupport (= 4.2.5)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    activejob (4.2.5)
      activesupport (= 4.2.5)
      globalid (>= 0.3.0)
    activemerchant (1.48.0)
      activesupport (>= 3.2.14, < 5.0.0)
      builder (>= 2.1.2, < 4.0.0)
      i18n (>= 0.6.9)
      nokogiri (~> 1.4)
    activemodel (4.2.5)
      activesupport (= 4.2.5)
      builder (~> 3.1)
    activerecord (4.2.5)
      activemodel (= 4.2.5)
      activesupport (= 4.2.5)
      arel (~> 6.0)
    activerecord-postgis-adapter (3.1.3)
      activerecord (~> 4.2)
      rgeo-activerecord (>= 4.0.4)
    activesupport (4.2.5)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    acts_as_list (0.7.2)
      activerecord (>= 3.0)
    addressable (2.4.0)
    arel (6.0.3)
    awesome_nested_set (3.0.2)
      activerecord (>= 4.0.0, < 5)
    bcrypt (3.1.10)
    binding_of_caller (0.7.2)
      debug_inspector (>= 0.0.1)
    bourbon (4.2.6)
      sass (~> 3.4)
      thor (~> 0.19)
    builder (3.2.2)
    byebug (8.2.1)
    camertron-eprun (1.1.0)
    cancancan (1.13.1)
    carmen (1.0.2)
      activesupport (>= 3.0.0)
    cldr-plurals-runtime-rb (1.0.1)
    climate_control (0.0.3)
      activesupport (>= 3.0)
    cocaine (0.5.8)
      climate_control (>= 0.0.3, < 1.0)
    coffee-rails (4.1.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.1.x)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.10.0)
    colorize (0.7.7)
    concurrent-ruby (1.0.0)
    css_parser (1.3.7)
      addressable
    debug_inspector (0.0.2)
    deface (1.0.2)
      colorize (>= 0.5.8)
      nokogiri (~> 1.6.0)
      polyglot
      rails (>= 3.1)
    devise (3.5.4)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      responders
      thread_safe (~> 0.1)
      warden (~> 1.2.3)
    devise-encryptable (0.1.2)
      devise (>= 2.1.0)
    diff-lcs (1.2.5)
    doorkeeper (3.1.0)
      railties (>= 3.2)
    erubis (2.7.0)
    execjs (2.6.0)
    factory_girl (4.5.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.5.0)
      factory_girl (~> 4.5.0)
      railties (>= 3.0.0)
    ffaker (1.32.1)
    font-awesome-rails (4.5.0.0)
      railties (>= 3.2, < 5.0)
    friendly_id (5.1.0)
      activerecord (>= 4.0.0)
    globalid (0.3.6)
      activesupport (>= 4.1.0)
    handlebars_assets (0.22.0)
      execjs (~> 2.0)
      multi_json (~> 1.0)
      sprockets (>= 2.0.0, < 4.0)
      tilt (~> 1.2)
    highline (1.6.21)
    htmlentities (4.3.4)
    i18n (0.7.0)
    jbuilder (2.4.0)
      activesupport (>= 3.0.0, < 5.1)
      multi_json (~> 1.2)
    jquery-rails (4.1.0)
      rails-dom-testing (~> 1.0)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (5.0.5)
      railties (>= 3.2.16)
    json (1.8.3)
    kaminari (0.16.3)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    mime-types (2.99)
    mini_portile2 (2.0.0)
    minitest (5.8.3)
    monetize (1.4.0)
      money (~> 6.7)
    money (6.7.0)
      i18n (>= 0.6.4, <= 0.7.0)
      sixarm_ruby_unaccent (>= 1.1.1, < 2)
    multi_json (1.11.2)
    nokogiri (1.6.7.1)
      mini_portile2 (~> 2.0.0.rc2)
    orm_adapter (0.5.0)
    paperclip (4.2.4)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
      cocaine (~> 0.5.5)
      mime-types
    paranoia (2.1.5)
      activerecord (~> 4.0)
    pg (0.18.4)
    polyamorous (1.3.0)
      activerecord (>= 3.0)
    polyglot (0.3.5)
    premailer (1.8.6)
      css_parser (>= 1.3.6)
      htmlentities (>= 4.0.0)
    premailer-rails (1.9.0)
      actionmailer (>= 3, < 5)
      premailer (~> 1.7, >= 1.7.9)
    rabl (0.11.8)
      activesupport (>= 2.3.14)
    rack (1.6.4)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.5)
      actionmailer (= 4.2.5)
      actionpack (= 4.2.5)
      actionview (= 4.2.5)
      activejob (= 4.2.5)
      activemodel (= 4.2.5)
      activerecord (= 4.2.5)
      activesupport (= 4.2.5)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.5)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.7)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.2)
      loofah (~> 2.0)
    railties (4.2.5)
      actionpack (= 4.2.5)
      activesupport (= 4.2.5)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.5.0)
    ransack (1.6.6)
      actionpack (>= 3.0)
      activerecord (>= 3.0)
      activesupport (>= 3.0)
      i18n
      polyamorous (~> 1.2)
    rdoc (4.2.1)
      json (~> 1.4)
    responders (2.1.1)
      railties (>= 4.2.0, < 5.1)
    rgeo (0.5.2)
    rgeo-activerecord (4.0.5)
      activerecord (~> 4.2)
      rgeo (~> 0.3)
    rspec-core (3.4.1)
      rspec-support (~> 3.4.0)
    rspec-expectations (3.4.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.4.0)
    rspec-mocks (3.4.1)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.4.0)
    rspec-rails (3.4.0)
      actionpack (>= 3.0, < 4.3)
      activesupport (>= 3.0, < 4.3)
      railties (>= 3.0, < 4.3)
      rspec-core (~> 3.4.0)
      rspec-expectations (~> 3.4.0)
      rspec-mocks (~> 3.4.0)
      rspec-support (~> 3.4.0)
    rspec-support (3.4.1)
    sass (3.4.21)
    sass-rails (5.0.4)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    sdoc (0.4.1)
      json (~> 1.7, >= 1.7.7)
      rdoc (~> 4.0)
    select2-rails (3.5.9.1)
      thor (~> 0.14)
    sixarm_ruby_unaccent (1.1.1)
    solidus_auth_devise (1.3.0)
      deface (~> 1.0.0)
      devise (~> 3.5.1)
      devise-encryptable (= 0.1.2)
      json
      multi_json
      solidus_core (>= 1.1.0.alpha, < 2)
    spring (1.6.2)
    sprockets (3.5.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (2.3.3)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (>= 2.8, < 4.0)
    state_machines (0.4.0)
    state_machines-activemodel (0.3.0)
      activemodel (~> 4.1)
      state_machines (>= 0.4.0)
    state_machines-activerecord (0.3.0)
      activerecord (~> 4.1)
      state_machines-activemodel (>= 0.3.0)
    stringex (1.5.1)
    thor (0.19.1)
    thread_safe (0.3.5)
    tilt (1.4.1)
    timecop (0.8.0)
    timeliness (0.3.8)
    truncate_html (0.9.2)
    turbolinks (2.5.3)
      coffee-rails
    twitter_cldr (3.2.1)
      camertron-eprun
      cldr-plurals-runtime-rb (~> 1.0.0)
      json
      tzinfo
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    uglifier (2.7.2)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    validates_timeliness (4.0.2)
      timeliness (~> 0.3.7)
    versioncake (2.3.1)
      actionpack (>= 3.2)
      activesupport (>= 3.2)
      railties (>= 3.2)
      tzinfo
    warden (1.2.4)
      rack (>= 1.0)
    web-console (2.2.1)
      activemodel (>= 4.0)
      binding_of_caller (>= 0.7.2)
      railties (>= 4.0)
      sprockets-rails (>= 2.0, < 4.0)

PLATFORMS
  ruby

DEPENDENCIES
  activerecord-postgis-adapter (~> 3.1)
  byebug
  coffee-rails (~> 4.1.0)
  doorkeeper (~> 3.1)
  factory_girl_rails (~> 4.5)
  jbuilder (~> 2.0)
  jquery-rails
  pg (~> 0.18.4)
  rabl (~> 0.11.8)
  rails (= 4.2.5)
  rspec-rails (~> 3.0)
  sass-rails (~> 5.0)
  sdoc (~> 0.4.0)
  solidus_auth_devise (~> 1.3, >= 1.3.0)
  solidus_backend!
  solidus_core!
  spring
  timecop (~> 0.8.0)
  turbolinks
  uglifier (>= 1.3.0)
  validates_timeliness (~> 4.0)
  versioncake (~> 2.3.1)
  web-console (~> 2.0)

BUNDLED WITH
   1.10.6

No particular configuration made, no stock configuration made.

The exception happens when I run next! on that order:

{
  "id": 4,
  "number": "R797163544",
  "item_total": "15.0",
  "total": "15.0",
  "ship_total": "0.0",
  "state": "address",
  "adjustment_total": "0.0",
  "user_id": null,
  "created_at": "2016-01-21T18:34:02.551+01:00",
  "updated_at": "2016-01-21T18:44:44.567+01:00",
  "completed_at": null,
  "payment_total": "0.0",
  "shipment_state": null,
  "payment_state": null,
  "email": null,
  "special_instructions": null,
  "channel": "spree",
  "included_tax_total": "0.0",
  "additional_tax_total": "0.0",
  "display_included_tax_total": "€0.00",
  "display_additional_tax_total": "€0.00",
  "tax_total": "0.0",
  "currency": "EUR",
  "covered_by_store_credit": false,
  "display_total_applicable_store_credit": "€0.00",
  "order_total_after_store_credit": "15.0",
  "display_order_total_after_store_credit": "€15.00",
  "total_applicable_store_credit": 0.0,
  "display_total_available_store_credit": "€0.00",
  "display_store_credit_remaining_after_capture": "€0.00",
  "display_item_total": "€15.00",
  "total_quantity": 5,
  "display_total": "€15.00",
  "display_ship_total": "€0.00",
  "display_tax_total": "€0.00",
  "token": "sgjtrDj3ePeRWa2aptA6zQ",
  "checkout_steps": [
    "address",
    "delivery",
    "payment",
    "confirm",
    "complete"
  ],
  "payment_methods": [],
  "bill_address": {
    "id": 1,
    "firstname": "Charles-Henri",
    "lastname": "DUMALIN",
    "full_name": "Charles-Henri DUMALIN",
    "address1": "36 Rue des Tours",
    "address2": null,
    "city": "Paris",
    "zipcode": "75000",
    "phone": "06666666",
    "company": null,
    "alternative_phone": null,
    "country_id": 75,
    "state_id": 924,
    "state_name": null,
    "state_text": "O",
    "country": {
      "id": 75,
      "iso_name": "FRANCE",
      "iso": "FR",
      "iso3": "FRA",
      "name": "France",
      "numcode": 250
    },
    "state": {
      "id": 924,
      "name": "Nord-Pas-de-Calais",
      "abbr": "O",
      "country_id": 75
    }
  },
  "ship_address": {
    "id": 1,
    "firstname": "Charles-Henri",
    "lastname": "DUMALIN",
    "full_name": "Charles-Henri DUMALIN",
    "address1": "36 Rue des Tours",
    "address2": null,
    "city": "Paris",
    "zipcode": "75000",
    "phone": "06666666",
    "company": null,
    "alternative_phone": null,
    "country_id": 75,
    "state_id": 924,
    "state_name": null,
    "state_text": "O",
    "country": {
      "id": 75,
      "iso_name": "FRANCE",
      "iso": "FR",
      "iso3": "FRA",
      "name": "France",
      "numcode": 250
    },
    "state": {
      "id": 924,
      "name": "Nord-Pas-de-Calais",
      "abbr": "O",
      "country_id": 75
    }
  },
  "line_items": [
    {
      "id": 2,
      "quantity": 5,
      "price": "3.0",
      "variant_id": 2,
      "variant": {
        "product_id": 2,
        "id": 2,
        "name": "Vin de pays",
        "sku": "VIN-123",
        "price": "3.0",
        "weight": "0.0",
        "height": null,
        "width": null,
        "depth": null,
        "is_master": true,
        "slug": "vin-de-pays",
        "description": "",
        "track_inventory": false,
        "option_values": [],
        "images": [],
        "display_price": "€3.00",
        "options_text": "",
        "in_stock": true,
        "is_backorderable": true,
        "total_on_hand": null,
        "is_destroyed": false
      },
      "adjustments": [],
      "single_display_amount": "€3.00",
      "display_amount": "€15.00",
      "total": "15.0"
    }
  ],
  "payments": [],
  "shipments": [
    {
      "id": 15,
      "tracking": null,
      "number": "H07521527448",
      "cost": "0.0",
      "shipped_at": null,
      "state": "pending",
      "shipping_rates": [
        {
          "id": 1,
          "name": "Test shipping",
          "cost": "5.0",
          "selected": true,
          "shipping_method_id": 1,
          "shipping_method_code": "",
          "display_cost": "€5.00"
        }
      ],
      "selected_shipping_rate": {
        "id": 1,
        "name": "Test shipping",
        "cost": "5.0",
        "selected": true,
        "shipping_method_id": 1,
        "shipping_method_code": "",
        "display_cost": "€5.00"
      },
      "shipping_methods": [
        {
          "id": 1,
          "code": "",
          "name": "Test shipping",
          "zones": [
            {
              "id": 1,
              "name": "EU_VAT",
              "description": "Countries that make up the EU VAT zone."
            }
          ],
          "shipping_categories": [
            {
              "id": 1,
              "name": "Default"
            }
          ]
        }
      ],
      "manifest": [
        {
          "variant_id": 2,
          "quantity": 5,
          "states": {
            "on_hand": 5
          }
        }
      ],
      "adjustments": [],
      "order_id": "R797163544",
      "stock_location_name": "default"
    }
  ],
  "adjustments": [],
  "credit_cards": []
}
jhawthorn commented 8 years ago

Thank you. I've made progress and can now reproduce this.

$ rails c
Running via Spring preloader in process 30840
Loading development environment (Rails 4.2.5)
irb(main):001:0> reload!
Reloading...
S=> true
irb(main):002:0> Spree::Config.stock
NameError: uninitialized constant Spree::StockConfiguration
        from /home/jhawthorn/src/solidus_constant_test/vendor/bundle/gems/solidus_core-1.2.0.rc1/app/models/spree/app_configuration.rb:316:in `stock'
        from (irb):2
        from /home/jhawthorn/src/solidus_constant_test/vendor/bundle/gems/railties-4.2.5/lib/rails/commands/console.rb:110:in `start'
        from /home/jhawthorn/src/solidus_constant_test/vendor/bundle/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
        from /home/jhawthorn/src/solidus_constant_test/vendor/bundle/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
        from /home/jhawthorn/src/solidus_constant_test/vendor/bundle/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from /home/jhawthorn/src/solidus_constant_test/vendor/bundle/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
        from /home/jhawthorn/src/solidus_constant_test/vendor/bundle/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
        from /home/jhawthorn/src/solidus_constant_test/vendor/bundle/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
        from /home/jhawthorn/src/solidus_constant_test/bin/rails:9:in `<top (required)>'
        from /home/jhawthorn/.rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/jhawthorn/.rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from -e:1:in `<main>'