forked from hitobito/hitobito
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subgroups_export_job_spec.rb
37 lines (27 loc) · 1.08 KB
/
subgroups_export_job_spec.rb
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
35
36
37
# encoding: utf-8
# Copyright (c) 2018, Schweizer Blasmusikverband. This file is part of
# hitobito and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito.
require 'spec_helper'
describe Export::SubgroupsExportJob do
subject { Export::SubgroupsExportJob.new(user.id, group, filename: 'subgroups_export') }
let(:user) { people(:top_leader) }
let(:group) { groups(:top_layer) }
let(:year) { 2012 }
let(:filepath) { AsyncDownloadFile::DIRECTORY.join('subgroups_export') }
before do
SeedFu.quiet = true
SeedFu.seed [Rails.root.join('db', 'seeds')]
end
context 'creates a CSV-Export' do
it 'and saves it' do
subject.perform
lines = File.readlines("#{filepath}.csv")
expect(lines.size).to eq(10)
expect(lines[0]).to match(/^Id;Elterngruppe;Name;.*/)
expect(lines[1]).to match(/^#{group.id};;Top;.*/)
expect(lines[2]).to match(/^#{groups(:bottom_layer_one).id};#{group.id};Bottom One;.*/)
end
end
end