Skip to content

Commit

Permalink
add ontologies controller tests
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Nov 7, 2023
1 parent 69b2a21 commit 50526ca
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 15 deletions.
13 changes: 6 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ GEM
ast (2.4.2)
autoprefixer-rails (10.4.15.0)
execjs (~> 2)
base64 (0.1.1)
bcrypt_pbkdf (1.1.0)
better_html (2.0.2)
actionview (>= 6.0)
Expand Down Expand Up @@ -345,7 +344,7 @@ GEM
public_suffix (5.0.3)
puma (5.6.7)
nio4r (~> 2.0)
racc (1.7.1)
racc (1.7.3)
rack (2.2.8)
rack-accept (0.4.5)
rack (>= 0.4)
Expand Down Expand Up @@ -399,7 +398,7 @@ GEM
recaptcha (5.9.0)
json
redcarpet (3.6.0)
regexp_parser (2.8.1)
regexp_parser (2.8.2)
reline (0.3.8)
io-console (~> 0.5)
rest-client (2.1.0)
Expand All @@ -426,8 +425,7 @@ GEM
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-support (3.12.1)
rubocop (1.56.3)
base64 (~> 0.1.1)
rubocop (1.57.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -438,7 +436,7 @@ GEM
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
Expand Down Expand Up @@ -536,6 +534,7 @@ GEM

PLATFORMS
x86_64-darwin-21
x86_64-darwin-23
x86_64-linux
x86_64-linux-musl

Expand Down Expand Up @@ -616,4 +615,4 @@ DEPENDENCIES
will_paginate (~> 3.0)

BUNDLED WITH
2.4.12
2.4.21
3 changes: 1 addition & 2 deletions config/database.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
default: &default
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: bp_user
host: db
host: 127.0.0.1

development:
<<: *default
Expand Down
10 changes: 6 additions & 4 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require "active_support/core_ext/integer/time"
# frozen_string_literal: true

require 'active_support/core_ext/integer/time'

# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
Expand All @@ -14,18 +16,18 @@
# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a continuous integration
# system, or in some way before deploying your code.
config.eager_load = ENV["CI"].present?
config.eager_load = ENV['CI'].present?

# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
}

# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.cache_store = :null_store
config.cache_store = ActiveSupport::Cache::MemCacheStore.new('localhost:11211', namespace: 'BioPortal')

# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
Expand Down
15 changes: 15 additions & 0 deletions test/controllers/application_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require 'test_helper'

class ApplicationControllerTest < ActionDispatch::IntegrationTest
test 'should show home page' do
get ''
assert_response :success
end

test 'should show projects page' do
get '/projects'
assert_response :success
end
end
6 changes: 4 additions & 2 deletions test/controllers/landscape_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

require 'test_helper'

class LandscapeControllerTest < ActionController::TestCase
test "should get index" do
test 'should get index' do
skip('take too much time')
get :index
assert_response :success
end

end
21 changes: 21 additions & 0 deletions test/controllers/ontologies_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'test_helper'

class OntologiesControllerTest < ActionDispatch::IntegrationTest
ONTOLOGIES = LinkedData::Client::Models::Ontology.all(include: 'acronym')
PAGES = %w[summary classes properties notes mappings schemes collections widgets].freeze

test 'should return all the ontologies' do
get ontologies_path
assert_response :success
end

ONTOLOGIES.sample(5).flat_map { |ont| PAGES.map { |page| [ont, page] } }.each do |ont, page|
test "should get page #{page} of #{ont.acronym} ontology" do
path = "#{ontologies_path}/#{ont.acronym}?p=#{page}"
get path
assert_response :success, "GET #{path} returned #{response.status}"
end
end
end

0 comments on commit 50526ca

Please sign in to comment.