diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index caa17e7..9cc2a54 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -15,12 +15,12 @@ jobs: - uses: actions/checkout@v4 - run: echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY}:$(git log -1 --pretty=%ad --date=format:%Y-%m-%d)-$(git log --pretty=format:'%h' -n 1)" >> $GITHUB_ENV - run: docker build -t $IMAGE . - - uses: docker/login-action@v2 + - uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/build-push-action@v4 + - uses: docker/build-push-action@v5 with: push: true tags: ${{ env.IMAGE }} diff --git a/lib/api.rb b/lib/api.rb index fdb2cdd..905732e 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -45,7 +45,7 @@ class G < Grape::API helpers do params :grunnbeløp do - optional :dato, type: Date, coerce_with: DateTime.method(:iso8601) + optional :dato, type: Date end def logger @@ -85,7 +85,7 @@ def logger detail 'Man kan få historikk fra en spesifikk dato ved å spesifisere ?fra=' end params do - optional :fra, type: Date, coerce_with: DateTime.method(:iso8601) + optional :fra, type: Date end get :historikk do fra = params[:fra] diff --git a/lib/g.rb b/lib/g.rb index 452e5f8..20e31a0 100644 --- a/lib/g.rb +++ b/lib/g.rb @@ -4,7 +4,7 @@ require 'json' module Grunnbeløp - @grunnbeløp_data = JSON.parse(File.read(ENV.fetch('GRUNNBELOP', nil)), object_class: Hash) + @grunnbeløp_data = JSON.parse(File.read(ENV.fetch('GRUNNBELOP', './grunnbeløp.json')), object_class: Hash) @date_format = '%Y-%m-%d' def self.by_date(needle) diff --git a/test/test_api.rb b/test/test_api.rb index e96a5f7..fcc5520 100644 --- a/test/test_api.rb +++ b/test/test_api.rb @@ -31,10 +31,12 @@ def app JSON.parse(last_response.body)) end - it 'returnere feilkode ved ugyldige datoer' do + it 'vi støtter norsk talemål å skrive dato på' do get '/api/v1/grunnbeloep?dato=24-08-2010' - assert_equal 400, last_response.status - assert_equal 'dato is invalid', JSON.parse(last_response.body)['error'] + assert last_response.ok? + assert_equal({ 'dato' => '1996-05-01', 'grunnbeloep' => 41_000, 'grunnbeloepPerMaaned' => 3_417, + 'gjennomsnittPerAar' => 40_410, 'omregningsfaktor' => 1.045119 }, + JSON.parse(last_response.body)) end it 'returnerer all historikk for grunnbeløp' do