summaryrefslogtreecommitdiff
path: root/spec/workers/export_csv_worker_spec.rb
blob: 87285b6264a75c035058ec2cece01d58bd18efbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

require 'spec_helper'

describe ExportCsvWorker do
  let(:user) { create(:user) }
  let(:project) { create(:project, creator: user) }

  def perform(params = {})
    described_class.new.perform(user.id, project.id, params)
  end

  it 'emails a CSV' do
    expect {perform}.to change(ActionMailer::Base.deliveries, :size).by(1)
  end

  it 'ensures that project_id is passed to issues_finder' do
    expect(IssuesFinder).to receive(:new).with(anything, hash_including(project_id: project.id)).and_call_original

    perform
  end

  it 'removes sort parameter' do
    expect(IssuesFinder).to receive(:new).with(anything, hash_not_including(:sort)).and_call_original

    perform
  end

  it 'converts controller string keys to symbol keys for IssuesFinder' do
    expect(IssuesFinder).to receive(:new).with(anything, hash_including(test_key: true)).and_call_original

    perform('test_key' => true)
  end
end