🐛 Add authors#mods_count that wasn't being used

master
Zequez 2015-08-06 10:54:33 -03:00
parent 4fd57f33fe
commit a3cb596db8
2 changed files with 12 additions and 1 deletions

View File

@ -1,4 +1,4 @@
class AuthorsMod < ActiveRecord::Base
belongs_to :mod
belongs_to :author
belongs_to :author, counter_cache: :mods_count
end

View File

@ -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