Sha256: 5711ab66cd575111c74c9e1c29647eed724758a935337377acec42978167893e

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

describe FileSetAttachedEventJob do
  let(:user) { create(:user) }
  let(:mock_time) { Time.zone.at(1) }

  before do
    allow_any_instance_of(User).to receive(:can?).and_return(true)
    allow(Time).to receive(:now).at_least(:once).and_return(mock_time)
  end

  context 'with a FileSet' do
    let(:file_set) { curation_concern.file_sets.first }
    let(:curation_concern) { create(:work_with_one_file, title: ['MacBeth'], user: user) }
    let(:event) do
      {
        action: "User <a href=\"/users/#{user.to_param}\">#{user.user_key}</a> has attached <a href=\"/concern/file_sets/#{file_set.id}\">A Contained FileSet</a> to <a href=\"/concern/generic_works/#{curation_concern.id}\">MacBeth</a>",
        timestamp: '1'
      }
    end

    it "logs the event to the right places" 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)
        .and change { curation_concern.events.length }.by(1)

      expect(user.profile_events.first).to eq(event)
      expect(curation_concern.events.first).to eq(event)
      expect(file_set.events.first).to eq(event)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sufia-7.4.1 spec/jobs/file_set_attached_event_job_spec.rb
sufia-7.4.0 spec/jobs/file_set_attached_event_job_spec.rb
sufia-7.3.1 spec/jobs/file_set_attached_event_job_spec.rb
sufia-7.3.0 spec/jobs/file_set_attached_event_job_spec.rb
sufia-7.3.0.rc3 spec/jobs/file_set_attached_event_job_spec.rb
sufia-7.3.0.rc2 spec/jobs/file_set_attached_event_job_spec.rb
sufia-7.3.0.rc1 spec/jobs/file_set_attached_event_job_spec.rb
sufia-7.2.0 spec/jobs/file_set_attached_event_job_spec.rb