norman / friendly_id

FriendlyId is the “Swiss Army bulldozer” of slugging and permalink plugins for ActiveRecord. It allows you to create pretty URL’s and work with human-friendly strings as if they were numeric ids for ActiveRecord models.
http://norman.github.io/friendly_id/
MIT License
6.13k stars 588 forks source link

Setting slug_limit in initialiser crashes rspec tests #992

Open ConfusedVorlon opened 2 years ago

ConfusedVorlon commented 2 years ago

uncommenting in the initialiser:

config.slug_limit = 255

immediately throws an error when any rspec test is run

friendly_id (5.4.2) rails 7.0.2

An error occurred while loading ./spec/models/meditation_hls_spec.rb.
Failure/Error: extend FriendlyId

NoMethodError:
  undefined method `slug_limit=' for #<#<Class:0x000000016e1f7790>:0x000000016e1f7718 @base=nil, @model_class=Meditation(id: integer, slug: string, title: string, description: text, duration: integer, published: boolean, account_id: integer, created_at: datetime, updated_at: datetime, time_of_day: integer, brain_state: integer, guide_id: integer, artist_id: integer, hls_transcode_id: integer), @defaults={}, @modules=[], @finder_methods=FriendlyId::FinderMethods, @routes=:friendly, @reserved_words=["new", "edit", "index", "session", "login", "logout", "users", "admin", "stylesheets", "assets", "javascripts", "images"]>

    config.slug_limit = 25
          ^^^^^^^^^^^^^
# ./config/initializers/friendly_id.rb:63:in `block in <main>'
# /Users/rob/.rvm/gems/ruby-3.1.2/gems/friendly_id-5.4.2/lib/friendly_id.rb:85:in `block in extended'
# /Users/rob/.rvm/gems/ruby-3.1.2/gems/friendly_id-5.4.2/lib/friendly_id.rb:82:in `class_eval'
# /Users/rob/.rvm/gems/ruby-3.1.2/gems/friendly_id-5.4.2/lib/friendly_id.rb:82:in `extended'
# ./app/models/meditation.rb:48:in `extend'
# ./app/models/meditation.rb:48:in `<class:Meditation>'
# ./app/models/meditation.rb:36:in `<main>'
# /Users/rob/.rvm/gems/ruby-3.1.2/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
# /Users/rob/.rvm/gems/ruby-3.1.2/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
# /Users/rob/.rvm/gems/ruby-3.1.2/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'
# ./spec/models/meditation_hls_spec.rb:38:in `<main>'
# /Users/rob/.rvm/gems/ruby-3.1.2/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `load'
# /Users/rob/.rvm/gems/ruby-3.1.2/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `load'

this is a dupe of https://github.com/norman/friendly_id/issues/982 because I couldn't see a way to remove the stale label

ConfusedVorlon commented 2 years ago

setting slug_limit directly in the model works without an issue

initialiser is as generated by friendly_id

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ConfusedVorlon commented 1 year ago

Bump