Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/gems-29d951406f
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrremann committed Sep 22, 2023
2 parents aaa124e + b846e18 commit a4b5461
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions lib/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -85,7 +85,7 @@ def logger
detail 'Man kan få historikk fra en spesifikk dato ved å spesifisere ?fra=<ISO 8601>'
end
params do
optional :fra, type: Date, coerce_with: DateTime.method(:iso8601)
optional :fra, type: Date
end
get :historikk do
fra = params[:fra]
Expand Down
2 changes: 1 addition & 1 deletion lib/g.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions test/test_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a4b5461

Please sign in to comment.