Skip to content

Commit

Permalink
Merge pull request #1650 from coderdojo-japan/fix_static_yaml_event_t…
Browse files Browse the repository at this point in the history
…est_setup

rspec修正: static_yamlイベント集計時のエラーを解消
  • Loading branch information
yasulab authored Jan 1, 2025
2 parents 449c13d + d12f085 commit d097157
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions spec/lib/statistics/aggregation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,25 @@
end

describe '.run' do
let(:yaml_provider) { instance_double(EventService::Providers::StaticYaml) }

before do
d1 = create(:dojo, name: 'Dojo1', email: '[email protected]', description: 'CoderDojo1', tags: %w(CoderDojo1), url: 'https://dojo1.com')
d2 = create(:dojo, name: 'Dojo2', email: '[email protected]', description: 'CoderDojo2', tags: %w(CoderDojo2), url: 'https://dojo2.com')
create(:dojo_event_service, dojo_id: d1.id, name: :connpass, group_id: 9876)
create(:dojo_event_service, dojo_id: d2.id, name: :doorkeeper, group_id: 5555)

create(:dojo, id: 194, name: 'Dojo194', email: '[email protected]', description: 'CoderDojo194', tags: %w(CoderDojo194), url: 'https://dojo194.com')
allow(EventService::Providers::StaticYaml).to receive(:new).and_return(yaml_provider)
allow(yaml_provider).to receive(:fetch_events).and_return([
{ 'dojo_id' => 194, 'event_url' => 'https://example.com/event/12345', 'evented_at' => '2023-12-10 14:00', 'participants' => 1 }
])
end

subject { Statistics::Aggregation.new(from: Time.zone.today.prev_month.strftime('%Y%m')).run }

it do
expect{ subject }.to change{ EventHistory.count }.from(0).to(2)
expect{ subject }.to change{ EventHistory.count }.from(0).to(3)
end
end

Expand Down Expand Up @@ -94,7 +102,7 @@
['201808', '2018-08-01'.to_date],
['2018/09', '2018-09-01'.to_date],
['2018-10', '2018-10-01'.to_date]]

list.each do |d|
expect(sa.send(:date_from, d[0])).to eq(d[1])
end
Expand Down

0 comments on commit d097157

Please sign in to comment.