Skip to content

Commit

Permalink
Add Alchemy::Language.has_many :nodes
Browse files Browse the repository at this point in the history
We need those association declarations for better preloading.
  • Loading branch information
mamhoff committed May 4, 2020
1 parent 489181e commit 0e01bfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/alchemy/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module Alchemy
class Language < BaseRecord
belongs_to :site
has_many :pages
has_many :nodes

before_validation :set_locale, if: -> { locale.blank? }

Expand Down
2 changes: 2 additions & 0 deletions spec/models/alchemy/language_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

module Alchemy
describe Language do
it { is_expected.to have_many(:nodes) }

let(:default_language) { create(:alchemy_language) }
let(:language) { create(:alchemy_language, :klingon) }
let(:page) { create(:alchemy_page, language: language) }
Expand Down

0 comments on commit 0e01bfa

Please sign in to comment.