tests
This commit is contained in:
parent
d18d89b41b
commit
058d6baae6
9 changed files with 158 additions and 2 deletions
19
spec/jobs/cron/datagouv/account_by_month_job_spec.rb
Normal file
19
spec/jobs/cron/datagouv/account_by_month_job_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
RSpec.describe Cron::Datagouv::AccountByMonthJob, type: :job do
|
||||
let!(:user) { create(:user, created_at: 1.month.ago) }
|
||||
let(:status) { 200 }
|
||||
let(:body) { "ok" }
|
||||
let(:stub) { stub_request(:post, /https:\/\/www.data.gouv.fr\/api\/.*\/upload\//) }
|
||||
|
||||
describe 'perform' do
|
||||
before do
|
||||
stub
|
||||
end
|
||||
|
||||
subject { Cron::Datagouv::AccountByMonthJob.perform_now }
|
||||
|
||||
it 'send POST request to datagouv' do
|
||||
subject
|
||||
expect(stub).to have_been_requested
|
||||
end
|
||||
end
|
||||
end
|
19
spec/jobs/cron/datagouv/administrateur_by_month_job_spec.rb
Normal file
19
spec/jobs/cron/datagouv/administrateur_by_month_job_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
RSpec.describe Cron::Datagouv::AdministrateurByMonthJob, type: :job do
|
||||
let!(:administrateur) { create(:administrateur, created_at: 1.month.ago) }
|
||||
let(:status) { 200 }
|
||||
let(:body) { "ok" }
|
||||
let(:stub) { stub_request(:post, /https:\/\/www.data.gouv.fr\/api\/.*\/upload\//) }
|
||||
|
||||
describe 'perform' do
|
||||
before do
|
||||
stub
|
||||
end
|
||||
|
||||
subject { Cron::Datagouv::AdministrateurByMonthJob.perform_now }
|
||||
|
||||
it 'send POST request to datagouv' do
|
||||
subject
|
||||
expect(stub).to have_been_requested
|
||||
end
|
||||
end
|
||||
end
|
19
spec/jobs/cron/datagouv/file_by_month_job_spec.rb
Normal file
19
spec/jobs/cron/datagouv/file_by_month_job_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
RSpec.describe Cron::Datagouv::FileByMonthJob, type: :job do
|
||||
let!(:dossier) { create(:dossier, created_at: 1.month.ago) }
|
||||
let(:status) { 200 }
|
||||
let(:body) { "ok" }
|
||||
let(:stub) { stub_request(:post, /https:\/\/www.data.gouv.fr\/api\/.*\/upload\//) }
|
||||
|
||||
describe 'perform' do
|
||||
before do
|
||||
stub
|
||||
end
|
||||
|
||||
subject { Cron::Datagouv::FileByMonthJob.perform_now }
|
||||
|
||||
it 'send POST request to datagouv' do
|
||||
subject
|
||||
expect(stub).to have_been_requested
|
||||
end
|
||||
end
|
||||
end
|
19
spec/jobs/cron/datagouv/instructeur_by_month_job_spec.rb
Normal file
19
spec/jobs/cron/datagouv/instructeur_by_month_job_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
RSpec.describe Cron::Datagouv::InstructeurByMonthJob, type: :job do
|
||||
let!(:instructeur) { create(:instructeur, created_at: 1.month.ago) }
|
||||
let(:status) { 200 }
|
||||
let(:body) { "ok" }
|
||||
let(:stub) { stub_request(:post, /https:\/\/www.data.gouv.fr\/api\/.*\/upload\//) }
|
||||
|
||||
describe 'perform' do
|
||||
before do
|
||||
stub
|
||||
end
|
||||
|
||||
subject { Cron::Datagouv::InstructeurByMonthJob.perform_now }
|
||||
|
||||
it 'send POST request to datagouv' do
|
||||
subject
|
||||
expect(stub).to have_been_requested
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
RSpec.describe Cron::Datagouv::InstructeurConnectedByMonthJob, type: :job do
|
||||
let!(:user) { create(:user) }
|
||||
let!(:instructeur) { create(:instructeur, user: user, created_at: 1.month.ago) }
|
||||
let(:status) { 200 }
|
||||
let(:body) { "ok" }
|
||||
let(:stub) { stub_request(:post, /https:\/\/www.data.gouv.fr\/api\/.*\/upload\//) }
|
||||
|
||||
describe 'perform' do
|
||||
before do
|
||||
stub
|
||||
end
|
||||
|
||||
subject { Cron::Datagouv::InstructeurConnectedByMonthJob.perform_now }
|
||||
|
||||
it 'send POST request to datagouv' do
|
||||
subject
|
||||
expect(stub).to have_been_requested
|
||||
end
|
||||
end
|
||||
end
|
19
spec/jobs/cron/datagouv/procedure_by_month_job_spec.rb
Normal file
19
spec/jobs/cron/datagouv/procedure_by_month_job_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
RSpec.describe Cron::Datagouv::ProcedureByMonthJob, type: :job do
|
||||
let!(:procedure) { create(:procedure, created_at: 1.month.ago) }
|
||||
let(:status) { 200 }
|
||||
let(:body) { "ok" }
|
||||
let(:stub) { stub_request(:post, /https:\/\/www.data.gouv.fr\/api\/.*\/upload\//) }
|
||||
|
||||
describe 'perform' do
|
||||
before do
|
||||
stub
|
||||
end
|
||||
|
||||
subject { Cron::Datagouv::ProcedureByMonthJob.perform_now }
|
||||
|
||||
it 'send POST request to datagouv' do
|
||||
subject
|
||||
expect(stub).to have_been_requested
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
RSpec.describe Cron::Datagouv::ProcedureClosedByMonthJob, type: :job do
|
||||
let!(:procedure) { create(:procedure, closed_at: 1.month.ago) }
|
||||
let(:status) { 200 }
|
||||
let(:body) { "ok" }
|
||||
let(:stub) { stub_request(:post, /https:\/\/www.data.gouv.fr\/api\/.*\/upload\//) }
|
||||
|
||||
describe 'perform' do
|
||||
before do
|
||||
stub
|
||||
end
|
||||
|
||||
subject { Cron::Datagouv::ProcedureClosedByMonthJob.perform_now }
|
||||
|
||||
it 'send POST request to datagouv' do
|
||||
subject
|
||||
expect(stub).to have_been_requested
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
RSpec.describe Cron::Datagouv::ProcedureDeletedByMonthJob, type: :job do
|
||||
let!(:procedure) { create(:procedure, hidden_at: 1.month.ago) }
|
||||
let(:status) { 200 }
|
||||
let(:body) { "ok" }
|
||||
let(:stub) { stub_request(:post, /https:\/\/www.data.gouv.fr\/api\/.*\/upload\//) }
|
||||
|
||||
describe 'perform' do
|
||||
before do
|
||||
stub
|
||||
end
|
||||
|
||||
subject { Cron::Datagouv::ProcedureDeletedByMonthJob.perform_now }
|
||||
|
||||
it 'send POST request to datagouv' do
|
||||
subject
|
||||
expect(stub).to have_been_requested
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +1,12 @@
|
|||
describe APIDatagouv::API do
|
||||
describe '#upload' do
|
||||
let(:subject) { APIDatagouv::API.upload(Tempfile.new.path) }
|
||||
let(:dataset) { :descriptif_demarches_dataset }
|
||||
let(:resource) { :descriptif_demarches_resource }
|
||||
let(:datagouv_secret) { Rails.application.secrets.datagouv }
|
||||
let(:subject) { APIDatagouv::API.upload(Tempfile.new, dataset, resource) }
|
||||
|
||||
before do
|
||||
stub_request(:post, /https:\/\/www.data.gouv.fr\/api/)
|
||||
stub_request(:post, /https:\/\/www.data.gouv.fr\/api\/1\/datasets\/#{datagouv_secret[dataset]}\/resources\/#{datagouv_secret[resource]}\/upload\//)
|
||||
.to_return(body: body, status: status)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue