diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6aa334d..d9f808f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,6 +31,5 @@ jobs: with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically -# No tests yet -# - name: Run tests -# run: bundle exec rake + - name: Run tests + run: bundle exec rake diff --git a/Gemfile b/Gemfile index c8c3ea0..d61d928 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" gem 'sinatra' gem 'passenger' gem 'rest-client' -gem 'cqm-reports', '4.1.1' +gem 'cqm-reports', '4.1.2' gem 'rackup', '~> 2.1' gem 'rack-contrib', '~> 2.5', '>= 2.5.0' gem 'jwt' diff --git a/Gemfile.lock b/Gemfile.lock index 46fcf06..5df8807 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -22,10 +22,10 @@ GEM tzinfo (~> 2.0) base64 (0.2.0) bigdecimal (3.1.8) - bson (5.0.0) - concurrent-ruby (1.3.3) + bson (5.0.1) + concurrent-ruby (1.3.4) connection_pool (2.4.1) - cqm-reports (4.1.1) + cqm-reports (4.1.2) cqm-models (~> 4.0) cqm-validators (~> 4.0) erubis (~> 2.7) @@ -57,31 +57,30 @@ GEM mime-types-data (3.2024.0206) mini_portile2 (2.8.7) minitest (5.22.2) - mongo (2.20.0) + mongo (2.20.1) bson (>= 4.14.1, < 6.0.0) - mongoid (8.1.5) + mongoid (9.0.1) activemodel (>= 5.1, < 7.2, != 7.0.0) concurrent-ruby (>= 1.0.5, < 2.0) mongo (>= 2.18.0, < 3.0.0) - ruby2_keywords (~> 0.0.5) - mongoid-tree (2.2.0) - mongoid (>= 4.0, < 9) + mongoid-tree (2.3.0) + mongoid (>= 4.0, < 10) mustache (1.1.1) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) mutex_m (0.2.0) netrc (0.11.0) - nokogiri (1.16.6) + nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.16.6-arm64-darwin) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.6-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) passenger (6.0.20) rack rake (>= 0.8.1) - racc (1.8.0) + racc (1.8.1) rack (3.1.4) rack-contrib (2.5.0) rack (< 4) @@ -126,7 +125,7 @@ PLATFORMS DEPENDENCIES cqm-models! - cqm-reports (= 4.1.1) + cqm-reports (= 4.1.2) jwt minitest passenger diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..06d32d3 --- /dev/null +++ b/Rakefile @@ -0,0 +1,5 @@ +task default: %w[test] + +task :test do + ruby "test/service/web_controller_test.rb" +end \ No newline at end of file diff --git a/service/web_controller.rb b/service/web_controller.rb index 6758717..096c76c 100644 --- a/service/web_controller.rb +++ b/service/web_controller.rb @@ -71,7 +71,10 @@ def as_json(*args) measure_dto = request.params # Uses the Rack::JSONBodyParser middleware # Prepare CQM Measure - madie_measure = JSON.parse(measure_dto["measure"],max_nesting: 512) + if measure_dto["measure"].nil? + return [400, "Measure is empty."] + end + madie_measure = JSON.parse(measure_dto["measure"], max_nesting: 512) measure = CQM::Measure.new(madie_measure) unless measure_dto["measure"].nil? if measure.nil? return [400, "Measure is empty."]