Skip to content

Commit 38fe97a

Browse files
Implement job overview (hitobito/hitobito#4020)
- Use new spec helper to read content from generated files in export job specs - Update export enqueued translations to include link to job overview
1 parent 8814186 commit 38fe97a

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

spec/controllers/event/participations_controller_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
it "exports csv files" do
3737
expect do
3838
get :index, params: {group_id: group, event_id: course.id}, format: :csv
39-
expect(flash[:notice]).to match(/Export wird im Hintergrund gestartet und nach Fertigstellung heruntergeladen./)
39+
expect(flash[:notice]).to match(
40+
/Export wird im Hintergrund gestartet und kann nach Fertigstellung auf der Jobübersicht/
41+
)
4042
end.to change(Delayed::Job, :count).by(1)
4143
end
4244
end

spec/jobs/export/event_participations_export_job_spec.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
require "spec_helper"
77

88
describe Export::EventParticipationsExportJob do
9+
include JobObservationSpecHelper
10+
911
subject {
1012
Export::EventParticipationsExportJob.new(format,
1113
user.id,
1214
course.id,
1315
group.id,
14-
params.merge(filename: filename))
16+
params.merge(filename: "event_participation_export"))
1517
}
1618

1719
let(:user) { people(:top_leader) }
@@ -30,23 +32,23 @@
3032
answer.update!(answer: "756.1234.5678.97")
3133
p
3234
end
33-
let(:filename) { AsyncDownloadFile.create_name("event_participation_export", user.id) }
34-
let(:file) { AsyncDownloadFile.from_filename(filename, format) }
35+
let(:file) { subject.job_observation }
3536

3637
before do
3738
SeedFu.quiet = true
3839
SeedFu.seed [Rails.root.join("db", "seeds")]
3940
participation
41+
42+
subject.enqueue!
43+
subject.perform
4044
end
4145

4246
context "exports csv files" do
4347
let(:format) { :csv }
4448
let(:params) { {filter: "all"} }
4549

4650
it "and saves it" do
47-
subject.perform
48-
49-
lines = file.read.lines
51+
lines = read_data_from_generated_file(file).lines
5052
expect(lines.size).to eq(4)
5153

5254
expect(lines[0]).to match(Regexp.new("^#{Export::Csv::UTF8_BOM}Vorname;Nachname;Übername;Firmenname;Firma;Haupt-E-Mail;zusätzliche Adresszeile;Strasse;Hausnummer;Postfach;PLZ;Ort;Land;Hauptebene;Rollen;Weitere E-Mail Privat;Weitere E-Mail Arbeit;Weitere E-Mail Vater;Weitere E-Mail Mutter;Weitere E-Mail Andere;Weitere E-Mails Freitext;Telefonnummer Privat;Telefonnummer Mobil;Telefonnummer Arbeit;Telefonnummer Vater;Telefonnummer Mutter;Telefonnummer Fax;Telefonnummer Andere"))
@@ -60,9 +62,7 @@
6062
let(:params) { {filter: "all", nds_course: true} }
6163

6264
it "and saves it" do
63-
subject.perform
64-
65-
lines = file.read.lines
65+
lines = read_data_from_generated_file(file).lines
6666
expect(lines.size).to eq(4)
6767
expect(lines[0]).to eq("#{Export::Csv::UTF8_BOM}#{nds_course_csv_header}\n")
6868
expect(lines[3]).to eq("#{person_nds_csv_row}\n")
@@ -76,9 +76,7 @@
7676
let(:params) { {filter: "all", nds_camp: true} }
7777

7878
it "and saves it" do
79-
subject.perform
80-
81-
lines = file.read.lines
79+
lines = read_data_from_generated_file(file).lines
8280
expect(lines.size).to eq(4)
8381
expect(lines[0]).to eq("#{Export::Csv::UTF8_BOM}#{nds_camp_csv_header}\n")
8482
expect(lines[0].split(";").count).to match(14)

0 commit comments

Comments
 (0)