Sha256: 6cab3370005f6911809e3ae26815d6b86ee9ca4f30758e56b868d7219e4fd2cc
Contents?: true
Size: 1.06 KB
Versions: 15
Compression:
Stored size: 1.06 KB
Contents
require 'rails_helper' # This is a controller mixin, but testing as a model spec! RSpec.describe Journaled::Actor do let(:user) { double("User") } let(:klass) do Class.new do cattr_accessor :before_actions self.before_actions = [] def self.before_action(&hook) before_actions << hook end include Journaled::Actor self.journaled_actor = :current_user def current_user nil end def trigger_before_actions before_actions.each { |proc| instance_eval(&proc) } end end end subject { klass.new } it "Stores a thunk returning nil if current_user returns nil" do subject.trigger_before_actions allow(subject).to receive(:current_user).and_return(nil) expect(RequestStore.store[:journaled_actor_proc].call).to eq nil end it "Stores a thunk returning current_user if it is set when called" do subject.trigger_before_actions allow(subject).to receive(:current_user).and_return(user) expect(RequestStore.store[:journaled_actor_proc].call).to eq user end end
Version data entries
15 entries across 15 versions & 1 rubygems