Skip to content

Commit

Permalink
Merge branch 'puzzle:master' into olibrian-ptime-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
olibrian authored Mar 1, 2024
2 parents dbb9b94 + 3c36e4f commit d5a1ef5
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 47 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/reusable-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ jobs:
with:
file: Dockerfile
build-args: |
BUILD_REPO=$GITHUB_REPOSITORY
BUILD_REF=$GITHUB_REF_NAME
BUILD_COMMIT=$GITHUB_SHA
GITHUB_REF_NAME=${{ github.ref_name }}
GITHUB_REPOSITORY=${{ github.repository }}
GITHUB_REPOSITORY_URL=${{ github.repositoryUrl }}
GITHUB_SHA=${{ github.sha }}
target: app
tags: |
${{ inputs.registry }}/ptime/${{ inputs.project_name }}:latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/reusable-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
CI: 'true'
PGDATESTYLE: German
run: |
sudo apt-get -yqq update
sudo apt-get -yqq install libpq-dev libvips-dev
gem install bundler --version '~> 2'
bundle install --jobs 4 --retry 3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# Ignore local config files
/.envrc
/.env*
.idea/
*.iml
/.byebug_history
Expand Down
22 changes: 16 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ ARG RAILS_HOST_NAME="unused.example.net"
ARG SECRET_KEY_BASE="needs-to-be-set"
ARG RAILS_DB_ADAPTER="nulldb"

# If you want to directly specify build infos
ARG BUILD_COMMIT
ARG BUILD_REPO
ARG BUILD_REPO_URL
ARG BUILD_REF

# Github specific
ARG GITHUB_SHA
ARG GITHUB_REPOSITORY
ARG GITHUB_REPOSITORY_URL
ARG GITHUB_REF_NAME
ARG BUILD_COMMIT="$GITHUB_SHA"
ARG BUILD_REPO="$GITHUB_REPOSITORY"
ARG BUILD_REF="$GITHUB_REF_NAME"

# # Gitlab specific
# ARG CI_COMMIT_SHA
Expand Down Expand Up @@ -158,18 +162,24 @@ ARG RAILS_ENV
# data persisted in the image
ARG PS1
ARG TZ
ARG GITHUB_SHA
ARG GITHUB_REPOSITORY
ARG GITHUB_REPOSITORY_URL
ARG GITHUB_REF_NAME
ARG BUILD_COMMIT
ARG BUILD_REPO
ARG BUILD_REPO_URL
ARG BUILD_REF

# Custom ARGs
ARG SKIP_MEMCACHE_CHECK

ENV PS1="${PS1}" \
TZ="${TZ}" \
BUILD_REPO="${BUILD_REPO}" \
BUILD_REF="${BUILD_REF}" \
BUILD_COMMIT="${BUILD_COMMIT}" \
BUILD_REPO="${BUILD_REPO:-${GITHUB_REPOSITORY}}" \
BUILD_REPO_URL="${BUILD_REPO_URL:-${GITHUB_REPOSITORY_URL}}" \
BUILD_REF="${BUILD_REF:-${GITHUB_REF_NAME}}" \
BUILD_COMMIT="${BUILD_COMMIT:-${GITHUB_SHA}}" \
RAILS_ENV="${RAILS_ENV}" \
RACK_ENV="${RACK_ENV}"

Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ group :test do
gem 'cuprite'
gem 'database_cleaner'
gem 'fabrication'
gem 'm'
gem 'mocha', require: false
gem 'rails-controller-testing'
gem 'webmock'
gem 'selenium-webdriver'
gem 'webdrivers'
gem 'webmock'
end
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ GEM
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
m (1.6.2)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
Expand Down Expand Up @@ -720,6 +723,7 @@ DEPENDENCIES
kaminari
kaminari-bootstrap
listen
m
matrix
mini_racer
minitest-reporters
Expand Down
24 changes: 12 additions & 12 deletions app/assets/javascripts/order_controlling.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ app.initOrderControllingChart = (labels, datasets, budget, currency, currentLabe
canvas = document.getElementById('order_controlling_chart')
ctx = canvas.getContext('2d')

Chart.defaults.global.defaultFontFamily = 'Roboto, Helvetica, Arial, sans-serif'
Chart.defaults.global.defaultFontColor = '#444444'
Chart.defaults.global.defaultFontSize = 14
Chart.defaults.font.family = 'Roboto, Helvetica, Arial, sans-serif'
Chart.defaults.color = '#444444'
Chart.defaults.font.size = 14

budgetColor = '#B44B5B'
todayColor = '#f0ad4e'
Expand All @@ -31,13 +31,13 @@ app.initOrderControllingChart = (labels, datasets, budget, currency, currentLabe
options: {
responsive: false,
scales: {
xAxes: [{
x: {
stacked: true,
gridLines: {
color: gridColor
}
}],
yAxes: [{
},
y: {
stacked: true,
ticks: {
beginAtZero: true,
Expand All @@ -47,11 +47,11 @@ app.initOrderControllingChart = (labels, datasets, budget, currency, currentLabe
color: gridLightColor,
zeroLineColor: gridColor
},
}],
},
},
legend: {
labels: {
boxWidth: Chart.defaults.global.defaultFontSize
boxWidth: Chart.defaults.font.size
}
},
tooltips: {
Expand All @@ -76,8 +76,8 @@ app.initOrderControllingChart = (labels, datasets, budget, currency, currentLabe
xPadding: 2,
yPadding: 3,
backgroundColor: '#ffffff'
fontFamily: Chart.defaults.global.defaultFontFamily,
fontSize: Chart.defaults.global.defaultFontSize,
fontFamily: Chart.defaults.font.family,
fontSize: Chart.defaults.font.size,
fontStyle: 'normal',
fontColor: todayColor
}
Expand All @@ -94,8 +94,8 @@ app.initOrderControllingChart = (labels, datasets, budget, currency, currentLabe
position: 'left',
yAdjust: 11,
backgroundColor: 'transparent',
fontFamily: Chart.defaults.global.defaultFontFamily,
fontSize: Chart.defaults.global.defaultFontSize,
fontFamily: Chart.defaults.font.family,
fontSize: Chart.defaults.font.size,
fontStyle: 'normal',
fontColor: budgetColor
}
Expand Down
6 changes: 1 addition & 5 deletions app/assets/stylesheets/_employees.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@

.master-data-vcard-qrcode {
display: block;
width: 100px;
width: 200px;
padding-bottom: 1em;

@media (min-width: $screen-md-min) {
padding-top: 20px;
}
}

.employee-positions {
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/employee_master_data_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def show

respond_to do |format|
format.html
format.vcf { render plain: vcard }
format.vcf { send_data vcard, filename: vcard_filename }
format.svg { render plain: qr_code.as_svg(fill: 'fff') }
format.png { render plain: qr_code.as_png(fill: 'fff') }
end
Expand Down Expand Up @@ -107,6 +107,10 @@ def vcard(include: nil)
Employees::Vcard.new(@employee, include:).render
end

def vcard_filename
ActiveStorage::Filename.new("#{@employee.to_s}.vcf").sanitized
end

def qr_code
vcf = vcard(include: %i[firstname lastname fullname phone_office phone_private email])
RQRCode::QRCode.new(vcf)
Expand Down
9 changes: 5 additions & 4 deletions app/helpers/format_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def f(value)
case value
when Float, BigDecimal
number_with_precision(value, precision: t('number.format.precision'),
delimiter: t('number.format.delimiter'))
delimiter: t('number.format.delimiter').html_safe)
when Integer
number_with_delimiter(value, delimiter: t('number.format.delimiter'))
number_with_delimiter(value, delimiter: t('number.format.delimiter').html_safe)
when Date then l(value, format: :long)
when Time then "#{l(value.to_date)} #{l(value, format: :time)}"
when true then t('global.yes')
Expand All @@ -43,7 +43,8 @@ def format_attr(obj, attr)
end

def format_number(number, precision = 2)
number_with_precision(number, precision:, delimiter: '\'')
delimiter = t('number.format.delimiter').html_safe
number_with_precision(number, precision:, delimiter:)
end

def format_hour(hour, precision = 2)
Expand Down Expand Up @@ -173,7 +174,7 @@ def format_type(obj, attr)
when :decimal
number_with_precision(val.to_s.to_f,
precision: column_property(obj, attr, :scale),
delimiter: t('number.format.delimiter'))
delimiter: t('number.format.delimiter').html_safe)
else f(val)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/employee_master_data/_attrs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
= link_to @employee.email, "mailto:#{@employee.email}"
.col-md-6
= link_to({format: :png}, target: :_blank) do
= image_tag('qr-code-scan-icon.svg', class: 'qr-code master-data-vcard-qrcode')
%img.qr-code.master-data-vcard-qrcode{src: employee_master_datum_url(id: @employee.id, format: :svg) }
= link_to format: :vcf do
vCard herunterladen

Expand Down
6 changes: 3 additions & 3 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ def self.build_version
end

def self.commit_hash(short: false)
return unless File.exist?(Rails.root.join('BUILD_INFO').to_s)
return unless ENV['BUILD_COMMIT']

commit = File.open(Rails.root.join('BUILD_INFO').to_s).first.chomp
return commit.first(7) if short
commit = ENV['BUILD_COMMIT'].chomp
return commit.first(8) if short

commit
end
Expand Down
8 changes: 4 additions & 4 deletions test/helpers/format_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ def format_string_size(obj)
assert_equal '0.00', format_number(0.0001)
assert_equal '0.50', format_number(0.5)
assert_equal '8.33', format_number(8.33333)
assert_equal '1'234.56', format_number(1234.56)
assert_equal "1'234.56", format_number(1234.56)
end

test 'format hour' do
assert_nil format_hour(nil)
assert_equal '0.00 h', format_hour(0.0001)
assert_equal '0.50 h', format_hour(0.5)
assert_equal '8.33 h', format_hour(8.33333)
assert_equal '1'234.56 h', format_hour(1234.56)
assert_equal "1'234.56 h", format_hour(1234.56)
end

test 'format day' do
Expand Down Expand Up @@ -131,7 +131,7 @@ def format_string_size(obj)

m.children = 10_000

assert_equal '10'000', format_type(m, :children)
assert_equal "10'000", format_type(m, :children)
end

unless ENV['NON_LOCALIZED'] # localization dependent tests
Expand All @@ -148,7 +148,7 @@ def format_string_size(obj)
test 'format decimal column' do
m = crud_test_models(:AAAAA)

assert_equal '10'000'000.1111', format_type(m, :income)
assert_equal "10'000'000.1111", format_type(m, :income)
end

test 'format date column' do
Expand Down
17 changes: 10 additions & 7 deletions test/integration/invoice_form_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,8 @@ class NewInvoiceTest < ActionDispatch::IntegrationTest
end

test 'sets calculated total on page load' do
expected_total = '%.2f' % (billable_hours * rate).round(2)

text_on_page =
find('#invoice_total_amount')
.text
.delete("'")
.delete('&#39;')
expected_total = delimited_number(billable_hours * rate)
text_on_page = find('#invoice_total_amount').text

assert_match expected_total, text_on_page
end
Expand Down Expand Up @@ -213,4 +208,12 @@ def assert_checkboxes(checkboxes, models, checked = models)
send assertion, checkboxes.find { |checkbox| checkbox.value == model.id.to_s }.checked?
end
end

def delimited_number(number)
ActiveSupport::NumberHelper.number_to_rounded(
number,
precision: 2,
delimiter: "'"
)
end
end

0 comments on commit d5a1ef5

Please sign in to comment.