🐛 Add authors#mods_count that wasn't being used
parent
4fd57f33fe
commit
a3cb596db8
|
@ -1,4 +1,4 @@
|
|||
class AuthorsMod < ActiveRecord::Base
|
||||
belongs_to :mod
|
||||
belongs_to :author
|
||||
belongs_to :author, counter_cache: :mods_count
|
||||
end
|
||||
|
|
|
@ -7,4 +7,15 @@ describe AuthorsMod, type: :model do
|
|||
it { expect(authors_mod.build_author).to be_kind_of Author }
|
||||
it { is_expected.to respond_to :sort_order }
|
||||
it { expect(authors_mod.sort_order).to be_kind_of Integer }
|
||||
|
||||
describe '#mods_count' do
|
||||
it 'should increase with mods' do
|
||||
a = create :author
|
||||
create :mod, authors: [a]
|
||||
create :mod, authors: [a]
|
||||
create :mod, authors: [a]
|
||||
a.reload
|
||||
expect(a.mods_count).to eq 3
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue