describe ContentNewVersionEventJob do
let(:user) { create(:user) }
let(:file_set) { create(:file_set, title: ['Hamlet'], user: user) }
let(:generic_work) { create(:generic_work, title: ['BethsMac'], user: user) }
let(:mock_time) { Time.zone.at(1) }
let(:event) { { action: "User #{user.user_key} has added a new version of Hamlet", timestamp: '1' } }
before do
allow(Time).to receive(:now).at_least(:once).and_return(mock_time)
end
it "logs the event to the depositor's profile and the FileSet" do
expect do
described_class.perform_now(file_set, user)
end.to change { user.profile_events.length }.by(1)
.and change { file_set.events.length }.by(1)
expect(user.profile_events.first).to eq(event)
expect(file_set.events.first).to eq(event)
end
end