Skip to content

Commit

Permalink
Merge pull request #692 from alphagov/fix_csv_preview
Browse files Browse the repository at this point in the history
Add check to Dataset `organogram?` to return false for items without a schema id
  • Loading branch information
edwardkerry authored Oct 8, 2019
2 parents 46b29ef + 0359586 commit 8b94660
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
8 changes: 4 additions & 4 deletions app/controllers/map_previews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ def getinfo
base_wms_url = url_param.gsub(/;jsessionid=[a-z0-9]+/i, ';jsessionid=')
response = URI(base_wms_url).read
render xml: Nokogiri::XML(response)
rescue StandardError => exception
Raven.capture_exception(exception)
rescue StandardError => e
Raven.capture_exception(e)
head :bad_request
end

def proxy
url = correct_url(url_param)
response = URI(url).read.force_encoding("ISO-8859-1").encode("UTF-8")
render xml: Nokogiri::XML(response)
rescue StandardError => exception
Raven.capture_exception(exception)
rescue StandardError => e
Raven.capture_exception(e)
head :bad_request
end

Expand Down
2 changes: 2 additions & 0 deletions app/models/dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def editable?
end

def organogram?
return false unless @schema_id

schema_id = @schema_id.gsub(/\["|"\]/, '')
ORGANOGRAM_SCHEMA_IDS.include?(schema_id)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(ticket_details = {})
@support = ticket_details[:support]
end

def to_json
def to_json(*_args)
{ "requester": { "name": name, "email": email },
"subject": support_queue + " Find open data - #{support} request",
"comment": { "body": content } }
Expand Down
6 changes: 3 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
# Route everything else to CKAN
if ENV["CKAN_REDIRECTION_URL"].present?
match '*path',
to: redirect(domain: ENV['CKAN_REDIRECTION_URL'], subdomain: '', path: "/%{path}"),
via: :all,
constraints: { path: /(?!#{Regexp.quote(Rails.application.config.assets.prefix[1..-1])}).+/ }
to: redirect(domain: ENV['CKAN_REDIRECTION_URL'], subdomain: '', path: "/%{path}"),
via: :all,
constraints: { path: /(?!#{Regexp.quote(Rails.application.config.assets.prefix[1..-1])}).+/ }
end
end
2 changes: 1 addition & 1 deletion spec/features/dataset_show_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

scenario 'Link to licence with additional info' do
dataset = build :dataset, :with_ogl_licence,
licence_custom: 'Special case'
licence_custom: 'Special case'

index_and_visit(dataset)

Expand Down
5 changes: 5 additions & 0 deletions spec/models/dataset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@
dataset = build :dataset, schema_id: 'non-organogram'
expect(dataset.organogram?).to be false
end

it 'does not recognise nil ids as an organogram' do
dataset = build :dataset, schema_id: nil
expect(dataset.organogram?).to be false
end
end
end

0 comments on commit 8b94660

Please sign in to comment.