|
14 | 14 | end
|
15 | 15 |
|
16 | 16 | describe '.run' do
|
| 17 | + let(:yaml_provider) { instance_double(EventService::Providers::StaticYaml) } |
| 18 | + |
17 | 19 | before do
|
18 | 20 | d1 = create(:dojo, name: 'Dojo1', email: '[email protected]', description: 'CoderDojo1', tags: %w(CoderDojo1), url: 'https://dojo1.com')
|
19 | 21 | d2 = create(:dojo, name: 'Dojo2', email: '[email protected]', description: 'CoderDojo2', tags: %w(CoderDojo2), url: 'https://dojo2.com')
|
20 | 22 | create(:dojo_event_service, dojo_id: d1.id, name: :connpass, group_id: 9876)
|
21 | 23 | create(:dojo_event_service, dojo_id: d2.id, name: :doorkeeper, group_id: 5555)
|
| 24 | + |
| 25 | + create(:dojo, id: 194, name: 'Dojo194', email: '[email protected]', description: 'CoderDojo194', tags: %w(CoderDojo194), url: 'https://dojo194.com') |
| 26 | + allow(EventService::Providers::StaticYaml).to receive(:new).and_return(yaml_provider) |
| 27 | + allow(yaml_provider).to receive(:fetch_events).and_return([ |
| 28 | + { 'dojo_id' => 194, 'event_url' => 'https://example.com/event/12345', 'evented_at' => '2023-12-10 14:00', 'participants' => 1 } |
| 29 | + ]) |
22 | 30 | end
|
23 | 31 |
|
24 | 32 | subject { Statistics::Aggregation.new(from: Time.zone.today.prev_month.strftime('%Y%m')).run }
|
25 | 33 |
|
26 | 34 | it do
|
27 |
| - expect{ subject }.to change{ EventHistory.count }.from(0).to(2) |
| 35 | + expect{ subject }.to change{ EventHistory.count }.from(0).to(3) |
28 | 36 | end
|
29 | 37 | end
|
30 | 38 |
|
|
94 | 102 | ['201808', '2018-08-01'.to_date],
|
95 | 103 | ['2018/09', '2018-09-01'.to_date],
|
96 | 104 | ['2018-10', '2018-10-01'.to_date]]
|
97 |
| - |
| 105 | + |
98 | 106 | list.each do |d|
|
99 | 107 | expect(sa.send(:date_from, d[0])).to eq(d[1])
|
100 | 108 | end
|
|
0 commit comments