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.
fix: resolve VCR cassette usage and sync GraphQL schema comparison fix: increase field count fix: add wait time for cassette taking too long fix: add BASEROW_URL to Dockerfile fix: add BASEROW_CONFIG_TABLE to Dockerfile fix: add var to ci fix: remove useless file fix: env in ci fix: increase max_wait_time of capybara due to slow DOM
- Loading branch information
Showing
23 changed files
with
146 additions
and
104 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 |
21 changes: 21 additions & 0 deletions
21
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,21 @@ | ||
module Types::Champs | ||
class ReferentielDePolynesieChampType < Types::BaseObject | ||
implements Types::ChampType | ||
|
||
field :selected_value, String, null: true | ||
field :table_id, ID, null: true | ||
field :search_field, String, null: true | ||
|
||
def selected_value | ||
object.value | ||
end | ||
|
||
def table_id | ||
object.table_id | ||
end | ||
|
||
def search_field | ||
object.search_field | ||
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
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.
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
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 |
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
Oops, something went wrong.