From dd85700a3e06ecec424ffc9f623f9407b007b229 Mon Sep 17 00:00:00 2001 From: ysksn Date: Wed, 19 Dec 2018 00:43:03 +0900 Subject: Add spec for AccountableConcern#log_action (#9559) --- .../concerns/accountable_concern_spec.rb | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 spec/controllers/concerns/accountable_concern_spec.rb (limited to 'spec') diff --git a/spec/controllers/concerns/accountable_concern_spec.rb b/spec/controllers/concerns/accountable_concern_spec.rb new file mode 100644 index 000000000..e3c06b494 --- /dev/null +++ b/spec/controllers/concerns/accountable_concern_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe AccountableConcern do + class Hoge + include AccountableConcern + attr_reader :current_account + + def initialize(current_account) + @current_account = current_account + end + end + + let(:user) { Fabricate(:user, account: Fabricate(:account)) } + let(:target) { Fabricate(:user, account: Fabricate(:account)) } + let(:hoge) { Hoge.new(user.account) } + + describe '#log_action' do + it 'creates Admin::ActionLog' do + expect do + hoge.log_action(:create, target.account) + end.to change { Admin::ActionLog.count }.by(1) + end + end +end -- cgit