Skip to content

Commit

Permalink
updated billing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Dec 18, 2023
1 parent 722cf8f commit 8aeb5bd
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 112 deletions.
104 changes: 13 additions & 91 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,99 +1,21 @@
# FROM internetee/ruby:3.0-buster
FROM internetee/ruby:3.2.2-refactor as base

# RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install wkhtmltopdf -y > /dev/null

# RUN npm install -g yarn@latest
# WORKDIR /opt/webapps/app
# COPY Rakefile Gemfile Gemfile.lock ./
# RUN gem install bundler && bundle install --jobs 20 --retry 5
# COPY package.json yarn.lock ./
# RUN yarn install --check-files


FROM internetee/ruby:3.2.2

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends > /dev/null \
build-essential=* \
imagemagick=* \
curl \
wget \
gnupg2 \
git \
apt-utils \
&& apt-get dist-upgrade -yf\
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
RUN sed -i -e 's/# et_EE.UTF-8 UTF-8/et_EE.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=et_EE.UTF-8

ENV LANG et_EE.UTF-8
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc -s | apt-key add -
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends > /dev/null \
postgresql-client-13=* \
libpq-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# add repository for Node.js in the LTS version
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -

RUN apt-get install -y --no-install-recommends > /dev/null \
nodejs=* \
qt5-default=* \
libqt5webkit5-dev=* \
gstreamer1.0-plugins-base=* \
libappindicator3-1=* \
gstreamer1.0-tools=* \
qtdeclarative5-dev=* \
fonts-liberation=* \
gstreamer1.0-x=* \
libasound2=* \
libnspr4=* \
libnss3=* \
libxss1=* \
libxtst6=* \
xdg-utils=* \
qtdeclarative5-dev=* \
fonts-liberation=* \
gstreamer1.0-x=* \
wkhtmltopdf \
libxslt1-dev \
libxml2-dev \
python-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN npm install -g yarn@latest
COPY --link Gemfile Gemfile.lock ./
RUN gem install bundler && bundle install --jobs 20 --retry 5
COPY --link package.json yarn.lock ./
RUN yarn install --frozen-lockfile

# RUN curl https://chromedriver.storage.googleapis.com/2.46/chromedriver_linux64.zip -o /chromedriver_linux64.zip
# RUN apt-get update > /dev/null \
# && apt-get install -yf --no-install-recommends > /dev/null unzip=* \
# && apt-get clean \
# && rm -rf /var/lib/apt/lists/*
# RUN unzip chromedriver_linux64.zip -d /usr/local/bin
# RUN rm /chromedriver_linux64.zip
FROM base

# RUN npm install --global yarn
RUN npm install -g yarn@latest
RUN useradd rails
RUN mkdir -p /home/rails && chown rails:rails /home/rails

RUN curl https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /chrome.deb
RUN dpkg -i /chrome.deb || apt-get update > /dev/null \
&& apt-get install -yf --no-install-recommends > /dev/null && apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN dpkg -i /chrome.deb
RUN rm /chrome.deb
RUN sed -i 's/SECLEVEL=2/SECLEVEL=1/' /etc/ssl/openssl.cnf
USER rails:rails

RUN mkdir -p /opt/webapps/app/tmp/pids
WORKDIR /opt/webapps/app
RUN mkdir -p /opt/webapps/app/tmp/pids

COPY Rakefile Gemfile Gemfile.lock ./
RUN gem install bundler && bundle install --jobs 20 --retry 5
COPY package.json yarn.lock ./
RUN yarn install --check-files
COPY --from=base --chown=rails:rails /usr/local/bundle /usr/local/bundle
COPY --from=base --chown=rails:rails /opt/webapps/app /opt/webapps/app

EXPOSE 3000
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ group :test do
gem 'capybara', '~> 3.39.2'
gem 'cuprite'
# gem 'selenium-webdriver', '4.10.0'
gem 'webdrivers'
# gem 'webdrivers'
gem 'simplecov', '~> 0.10', '< 0.18', require: false
gem 'spy'
gem 'webmock'
Expand Down
11 changes: 0 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,9 @@ GEM
faraday-multipart (>= 1)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
scenic (1.7.0)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
selenium-webdriver (4.12.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
simplecov (0.17.1)
docile (~> 1.1)
json (>= 1.8, < 3)
Expand Down Expand Up @@ -445,10 +440,6 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (5.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webfinger (1.2.0)
activesupport
httpclient (>= 2.4)
Expand All @@ -460,7 +451,6 @@ GEM
hkdf (~> 0.2)
jwt (~> 2.0)
webrick (1.8.1)
websocket (1.2.10)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down Expand Up @@ -528,7 +518,6 @@ DEPENDENCIES
valvat
view_component
web-console (>= 3.3.0)
webdrivers
webmock
webpush

Expand Down
5 changes: 5 additions & 0 deletions app/controllers/billing_profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ class BillingProfilesController < ApplicationController
before_action :authorize_billing_profile_for_user, except: %i[new index create]
before_action :store_location, only: :new

rescue_from ActiveRecord::RecordNotUnique do |_exception|
flash[:alert] = t('billing_profiles.vat_code_already_exists')
render turbo_stream: turbo_stream.replace('flash', partial: 'common/flash', locals: { flash: })
end

# GET /billing_profiles
def index
@billing_profiles = BillingProfile.accessible_by(current_ability)
Expand Down
1 change: 1 addition & 0 deletions config/locales/billing_profiles.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ en:
updated: "Billing profile successfully updated!"
deleted: "Billing profile successfully deleted!"
vat_validation_error: "VAT code is not registered or not valid according to VIES"
vat_code_already_exists: "VAT code is already in use"

edit:
title: "Edit billing profile"
Expand Down
1 change: 1 addition & 0 deletions config/locales/billing_profiles.et.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ et:
updated: "Arveldusprofiil edukalt uuendatud!"
deleted: "Arveldusprofiil edukalt kustutatud!"
vat_validation_error: "Käibemaksukood ei ole registreeritud või ei ole VIESi kohaselt kehtiv."
vat_code_already_exists: "Käibemaksukood on juba kasutusel."

edit:
title: "Muuda arve aadressi"
Expand Down
6 changes: 6 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def using_session(name, &block)

Capybara.server = :puma, { Silent: true }

def take_screenshot
return super unless Capybara.last_used_session

Capybara.using_session(Capybara.last_used_session) { super }
end

private

def extract_primary_link_from_last_mail
Expand Down
25 changes: 23 additions & 2 deletions test/system/auctions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def test_filter_auction_list
# AUTOBIDER ========================================

def test_autobider_available_only_for_english_type_auctions
Autobider.destroy_all
sign_in @user

visit('/')
Expand Down Expand Up @@ -153,11 +154,31 @@ def test_autobider_not_available_for_blind_auctions
refute(page.has_content?(:visible, "#{I18n.t('english_offers.form.autobider')}: #{I18n.t('english_offers.form.nope')}" ))
end

def test_autobidder_could_not_be_enable_if_price_is_less_than_minimum_required
def test_user_can_set_autobider_and_unset_autobider
Autobider.destroy_all

sign_in @user

visit('/')

within("tr[data-platform='english']", match: :first) do
assert(page.has_content?(:visible, '0.0 €'))

click_link_or_button(I18n.t('auctions.bid'))
end

assert_selector '.c-modal', visible: true

assert(page.has_content?(:visible, "#{I18n.t('english_offers.form.autobider')}: #{I18n.t('english_offers.form.nope')}" ))

find('#autobider_price').set('100')
# find('.o-checkbox__slider').click
find('#checkbox').set(true)

# TODO: Turbo stream not work in test mode
# assert(page.has_content?(:visible, "#{I18n.t('english_offers.form.autobider')}: #{I18n.t('english_offers.form.yep')}" ))
end

def test_user_can_set_autobider_and_unset_autobider

# def setup
# super
Expand Down
64 changes: 57 additions & 7 deletions test/system/billing_profiles_test.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,64 @@
require 'application_system_test_case'

class BillingProfilesTest < ApplicationSystemTestCase
# def setup
# super

# @user = users(:participant)
# @billing_profile = billing_profiles(:private_person)
# @company_billing_profile = billing_profiles(:company)
# sign_in(@user)
# end
def setup
super

@user = users(:participant)
@billing_profile = billing_profiles(:private_person)
@company_billing_profile = billing_profiles(:company)
sign_in(@user)
end

def test_user_can_change_his_billing_profile
Offer.destroy_all
@user.reload
@billing_profile.reload

visit billing_profiles_path

user_name_field = find('.o-card__title.c-account__title', match: :first)
assert_equal @user.display_name, user_name_field.value
assert user_name_field[:readonly]

vap_code_field = find('#input1', match: :first)
assert_equal @billing_profile.vat_code, vap_code_field.value.empty? ? nil : @billing_profile.vat_code
assert vap_code_field[:readonly]

street_field = find('#input2', match: :first)
assert_equal @billing_profile.street, street_field.value
assert street_field[:readonly]

city_field = find('#input3', match: :first)
assert_equal @billing_profile.city, city_field.value
assert city_field[:readonly]

postal_code_field = find('#input4', match: :first)
assert_equal @billing_profile.postal_code, postal_code_field.value
assert postal_code_field[:readonly]

find("a.c-btn.c-btn--ghost.c-btn--icon[href='/billing_profiles/762b09cb-bf40-4cf7-bdab-09cf677d0d0f/edit']").click

# TODO:
# Here should be wot turbo request format

find('input[name="billing_profile[name]"]').set('Sasha Belyi')
find('input[name="billing_profile[street]"]').set('Paldiski mnt 12')
find('input[name="billing_profile[city]"]').set('Tallinn')
find('input[name="billing_profile[postal_code]"]').set('10137')
find('select[name="billing_profile[country_code]"]').select('Estonia')

find('.c-btn.c-btn--ghost.c-btn--icon.js-modal-delete-toggle').click

user_name_field = find('.o-card__title.c-account__title', match: :first)
assert_equal 'Sasha Belyi', user_name_field.value
assert user_name_field[:readonly]
end

def test_user_can_delete_his_billing_profile

end

# def test_user_details_contains_a_link_to_billing
# visit user_path(@user.uuid)
Expand Down

0 comments on commit 8aeb5bd

Please sign in to comment.