diff options
author | pluralcafe-docker <git@plural.cafe> | 2018-12-11 19:07:50 +0000 |
---|---|---|
committer | pluralcafe-docker <git@plural.cafe> | 2018-12-11 19:07:50 +0000 |
commit | 68c00c4011d62814b035ff5921822bf0bfb53d64 (patch) | |
tree | cf9e0ee2d9d76b779f41c6e7a0d1af689e0045b8 /spec/models | |
parent | 1c0b2479045015b96907eaa7567bfd14e4593424 (diff) | |
parent | c6b7b984891413cb1db673df2cbea12f8e6f0f05 (diff) |
Merge branch 'glitch'
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/account_pin_spec.rb | 5 | ||||
-rw-r--r-- | spec/models/account_tag_stat_spec.rb | 38 |
2 files changed, 38 insertions, 5 deletions
diff --git a/spec/models/account_pin_spec.rb b/spec/models/account_pin_spec.rb deleted file mode 100644 index 4f226b127..000000000 --- a/spec/models/account_pin_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe AccountPin, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/account_tag_stat_spec.rb b/spec/models/account_tag_stat_spec.rb new file mode 100644 index 000000000..6d3057f35 --- /dev/null +++ b/spec/models/account_tag_stat_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe AccountTagStat, type: :model do + key = 'accounts_count' + let(:account_tag_stat) { Fabricate(:tag).account_tag_stat } + + describe '#increment_count!' do + it 'calls #update' do + args = { key => account_tag_stat.public_send(key) + 1 } + expect(account_tag_stat).to receive(:update).with(args) + account_tag_stat.increment_count!(key) + end + + it 'increments value by 1' do + expect do + account_tag_stat.increment_count!(key) + end.to change { account_tag_stat.accounts_count }.by(1) + end + end + + describe '#decrement_count!' do + it 'calls #update' do + args = { key => [account_tag_stat.public_send(key) - 1, 0].max } + expect(account_tag_stat).to receive(:update).with(args) + account_tag_stat.decrement_count!(key) + end + + it 'decrements value by 1' do + account_tag_stat.update(key => 1) + + expect do + account_tag_stat.decrement_count!(key) + end.to change { account_tag_stat.accounts_count }.by(-1) + end + end +end |