Skip to content

Commit 23aa029

Browse files
committed
add&fix test ci skip
1 parent 57d273c commit 23aa029

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

app/presenters/gobierto_data/dataset_presenter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def url_helpers
5858
end
5959

6060
def site_locale
61-
site.configuration_data["default_locale"]
61+
site.configuration.default_locale
6262
end
6363

6464
def description_custom_field_record(dataset)

app/views/gobierto_data/api/v1/datasets/catalog.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
xmlns:foaf="http://xmlns.com/foaf/0.1/"
77
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
88
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
9-
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><% cache @catalog do %>
9+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
1010
<dcat:Catalog rdf:about="https://data.some.org/catalog">
1111
<dct:identifier><%= @catalog[:identifier_uri] %></dct:identifier>
1212
<dct:title><%= @catalog[:title] %></dct:title>
@@ -43,5 +43,5 @@
4343
<% end %>
4444
</dcat:Dataset>
4545
</dcat:dataset><% end %>
46-
</dcat:Catalog><% end %>
46+
</dcat:Catalog>
4747
</rdf:RDF>

config/locales/gobierto_data/presenters/ca.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ ca:
44
gobierto_data:
55
catalog:
66
description: Catàleg public de dades dels conjunts de dades publicades per%
7-
{site}, a través de la URL% {publisher_url}
7+
{site}, a través de la URL %{publisher_url}
88
title: Catàleg DCAT de conjunts de dades de %{site} en format rdf/xml dcat

config/routes.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,7 @@
641641
resources :favorites, only: [:index]
642642
collection do
643643
get :meta
644-
# get :catalog
645-
get "catalog" => "datasets#catalog"
644+
get :catalog
646645
end
647646
member do
648647
get "meta" => "datasets#dataset_meta"

test/controllers/gobierto_data/api/v1/datasets_controller_test.rb

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def datasets_md_with_translations
6767
@datasets_md_with_translations ||= gobierto_common_custom_fields(:madrid_data_datasets_custom_field_md_with_translations)
6868
end
6969

70+
def datasets_descriptions
71+
@datasets_descriptions ||= gobierto_common_custom_fields(:madrid_data_datasets_custom_field_description)
72+
end
73+
7074
def other_site_dataset
7175
@other_site_dataset ||= gobierto_data_datasets(:santander_dataset)
7276
end
@@ -93,7 +97,8 @@ def array_data(dataset)
9397
dataset.rails_model&.columns_hash&.transform_values(&:type)&.to_s,
9498
GobiertoCommon::CustomFieldRecord.find_by(item: dataset, custom_field: datasets_category)&.value_string,
9599
GobiertoCommon::CustomFieldRecord.find_by(item: dataset, custom_field: datasets_md_without_translations)&.value_string,
96-
GobiertoCommon::CustomFieldRecord.find_by(item: dataset, custom_field: datasets_md_with_translations)&.value_string
100+
GobiertoCommon::CustomFieldRecord.find_by(item: dataset, custom_field: datasets_md_with_translations)&.value_string || "",
101+
GobiertoCommon::CustomFieldRecord.find_by(item: dataset, custom_field: datasets_descriptions)&.value_string
97102
]
98103
end
99104

@@ -168,8 +173,9 @@ def test_index_as_csv
168173
parsed_csv = CSV.parse(response_data).map { |row| row.map(&:to_s) }
169174

170175
assert_equal active_datasets_count + 1, parsed_csv.count
171-
assert_equal %w(id name slug table_name data_updated_at columns category md-without-translations md-with-translations), parsed_csv.first
172-
assert_includes parsed_csv, array_data(dataset)
176+
assert_equal %w(id name slug table_name data_updated_at columns category md-without-translations md-with-translations description), parsed_csv.first
177+
178+
assert_includes parsed_csv.drop(1).take(1), array_data(dataset)
173179
refute_includes parsed_csv, array_data(other_site_dataset)
174180
end
175181
end
@@ -202,7 +208,7 @@ def test_index_xlsx_format
202208
assert_equal 1, parsed_xlsx.worksheets.count
203209
sheet = parsed_xlsx.worksheets.first
204210
assert_nil sheet[active_datasets_count + 1]
205-
assert_equal %w(id name slug table_name data_updated_at columns category md-without-translations md-with-translations), sheet[0].cells.map(&:value)
211+
assert_equal %w(id name slug table_name data_updated_at columns category md-without-translations md-with-translations description), sheet[0].cells.map(&:value)
206212
values = (1..active_datasets_count).map do |row_number|
207213
sheet[row_number].cells.map { |cell| cell.value.to_s }
208214
end
@@ -315,12 +321,28 @@ def test_index_when_md_custom_field_changes_translations_availability
315321
parsed_csv = CSV.parse(response_data).map { |row| row.map(&:to_s) }
316322

317323
assert_equal active_datasets_count + 1, parsed_csv.count
318-
assert_equal %w(id name slug table_name data_updated_at columns category md-without-translations md-with-translations), parsed_csv.first
324+
assert_equal %w(id name slug table_name data_updated_at columns category md-without-translations md-with-translations description), parsed_csv.first
319325
assert_includes parsed_csv, array_data(dataset)
320326
refute_includes parsed_csv, array_data(other_site_dataset)
321327
end
322328
end
323329

330+
def test_catalog
331+
with(site: site) do
332+
get catalog_gobierto_data_api_v1_datasets_path(format: :xml), as: :xml
333+
assert_response :success
334+
335+
response_xml = response.parsed_body
336+
assert_includes response_xml, '<?xml version="1.0" encoding="utf-8" ?>'
337+
assert_includes response_xml, '<rdf:RDF'
338+
assert_includes response_xml, '<dcat:Catalog rdf:about="https://data.some.org/catalog">'
339+
assert_includes response_xml, '<dcat:dataset>'
340+
assert_includes response_xml, '</dcat:dataset>'
341+
assert_includes response_xml, '</dcat:Catalog>'
342+
assert_includes response_xml, '</rdf:RDF>'
343+
end
344+
end
345+
324346
end
325347
end
326348
end

0 commit comments

Comments
 (0)