forked from demarches-simplifiees/demarches-simplifiees.fr
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from govpf/feature/ci_rdp
fix: CI
- Loading branch information
Showing
24 changed files
with
166 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
app/graphql/types/champs/descriptor/referentiel_de_polynesie_champ_descriptor_type.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Types::Champs::Descriptor | ||
class ReferentielDePolynesieChampDescriptorType < Types::BaseObject | ||
implements Types::ChampDescriptorType | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
app/graphql/types/champs/referentiel_de_polynesie_champ_type.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Types::Champs | ||
class ReferentielDePolynesieChampType < Types::BaseObject | ||
implements Types::ChampType | ||
|
||
field :table_id, ID, null: true | ||
field :search_field, String, null: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...dossier_with_referentiel_de_polynesie.yml → ...dossier_with_referentiel_de_polynesie.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
spec/lib/tasks/deployment/20220705164551_remove_unused_champs_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
describe '20220705164551_remove_unused_champs' do | ||
let(:rake_task) { Rake::Task['after_party:remove_unused_champs'] } | ||
let(:procedure) { create(:procedure, :with_all_champs) } | ||
let(:dossier) { create(:dossier, :with_populated_champs, procedure: procedure) } | ||
let(:champ_repetition) { dossier.champs_public.find(&:repetition?) } | ||
let(:champ_count) { 51 } | ||
|
||
subject(:run_task) do | ||
dossier | ||
rake_task.invoke | ||
end | ||
|
||
before { champ_repetition.champs.first.update(type_de_champ: create(:type_de_champ)) } | ||
after { rake_task.reenable } | ||
|
||
describe 'remove_unused_champs' do | ||
it "with bad champs" do | ||
expect(Champ.where(dossier: dossier).count).to eq(champ_count) | ||
|
||
run_task | ||
|
||
expect(Champ.where(dossier: dossier).count).to eq(champ_count - 1) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,63 @@ | ||
require 'rails_helper' | ||
require 'webmock/rspec' | ||
require 'vcr' | ||
|
||
RSpec.describe ReferentielDePolynesie::BaserowAPI, type: :model do | ||
describe '#search' do | ||
it 'search in a Baserow table and return the result', :vcr do | ||
it 'searches in a Baserow table and returns the result', vcr: { cassette_name: 'baserow/baserow_search' } do | ||
allow(ReferentielDePolynesie::BaserowAPI).to receive(:config).and_return({ | ||
'Table' => '202600', | ||
'Champ de recherche' => 'search_field', | ||
'Token' => ENV['API_BASEROW_TOKEN'].to_s | ||
}) | ||
|
||
VCR.use_cassette('baserow_search') do | ||
results = ReferentielDePolynesie::BaserowAPI.search(123, "term") | ||
results = ReferentielDePolynesie::BaserowAPI.search(123, "term") | ||
|
||
expect(results).to be_an(Array) | ||
expect(results.length).to be > 0 | ||
expect(results.first).to have_key(:name) | ||
expect(results.first).to have_key(:id) | ||
end | ||
expect(results).to be_an(Array) | ||
expect(results.length).to be > 0 | ||
expect(results.first).to have_key(:name) | ||
expect(results.first).to have_key(:id) | ||
end | ||
end | ||
|
||
describe '#fetch_row' do | ||
it 'fetch a specific line in a Baserow table', :vcr do | ||
it 'fetches a specific line in a Baserow table', vcr: { cassette_name: 'baserow/baserow_fetch_row' } do | ||
allow(ReferentielDePolynesie::BaserowAPI).to receive(:config).and_return({ | ||
'Table' => '202600', | ||
'Token' => ENV['API_BASEROW_TOKEN'].to_s | ||
}) | ||
|
||
VCR.use_cassette('baserow_fetch_row') do | ||
result = ReferentielDePolynesie::BaserowAPI.fetch_row(123, 1) | ||
result = ReferentielDePolynesie::BaserowAPI.fetch_row(123, 1) | ||
|
||
expect(result[:row]["Nom"]).to eq("Communes de polynésie") | ||
expect(result[:row]["Notes"]).to eq("") | ||
expect(result[:row]["Actif"]).to eq(true) | ||
expect(result[:row]["Table"]).to eq("202578") | ||
expect(result[:row]["Champs usager"]).to eq("1391747,1391750,1391755,1391756") | ||
expect(result[:row]["Champ de recherche"]).to eq("1391747") | ||
expect(result[:row]["Champs instructeur"]).to eq("1391747,1391750,1391755,1391756") | ||
end | ||
expect(result[:row]["Nom"]).to eq("Communes de polynésie") | ||
expect(result[:row]["Notes"]).to eq("") | ||
expect(result[:row]["Actif"]).to eq(true) | ||
expect(result[:row]["Table"]).to eq("202578") | ||
expect(result[:row]["Champs usager"]).to eq("1391747,1391750,1391755,1391756") | ||
expect(result[:row]["Champ de recherche"]).to eq("1391747") | ||
expect(result[:row]["Champs instructeur"]).to eq("1391747,1391750,1391755,1391756") | ||
end | ||
|
||
it 'return a 404 error if the row does not exist', :vcr do | ||
it 'returns a 404 error if the row does not exist', vcr: { cassette_name: 'baserow/baserow404_error' } do | ||
allow(ReferentielDePolynesie::BaserowAPI).to receive(:config).and_return({ | ||
'Table' => '202600', | ||
'Token' => ENV['API_BASEROW_TOKEN'].to_s | ||
}) | ||
|
||
VCR.use_cassette('baserow404_error') do | ||
results = ReferentielDePolynesie::BaserowAPI.fetch_row(123, 99999) | ||
results = ReferentielDePolynesie::BaserowAPI.fetch_row(123, 99999) | ||
|
||
expect(results).to eq(nil) | ||
end | ||
expect(results).to eq(nil) | ||
end | ||
end | ||
|
||
describe '#available_tables' do | ||
it 'fetch the available tables', :vcr do | ||
it 'fetches the available tables', vcr: { cassette_name: 'baserow/baserow_api_available_tables' } do | ||
allow(ReferentielDePolynesie::BaserowAPI).to receive(:config) | ||
|
||
VCR.use_cassette('baserow_available_tables') do | ||
results = ReferentielDePolynesie::BaserowAPI.available_tables | ||
results = ReferentielDePolynesie::BaserowAPI.available_tables | ||
|
||
expect(results).to be_an(Array) | ||
expect(results.first[:name]).to eq("Communes de polynésie") | ||
expect(results.first[:id]).to eq(1) | ||
end | ||
expect(results).to be_an(Array) | ||
expect(results.first[:name]).to eq("Communes de polynésie") | ||
expect(results.first[:id]).to eq(1) | ||
end | ||
end | ||
end |
Oops, something went wrong.