Skip to content

Commit

Permalink
Merge branch 'master' into webpack-v5
Browse files Browse the repository at this point in the history
  • Loading branch information
DinSmol authored Dec 10, 2021
2 parents 66b937a + 06ec468 commit 40c9967
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 9 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/build_deploy_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
SHORT_SHA=$(echo $GITHUB_SHA | cut -c 1-7) #pr-s test commit of merged state
echo "TAG=ghcr.io/internetee/auction_center:RC-$SHORT_SHA" >> $GITHUB_ENV
echo "STATIC_TAG=ghcr.io/internetee/auction_center:STATIC_RC-$SHORT_SHA" >> $GITHUB_ENV
echo "REGISTRY_TAG=ghcr.io/internetee/auction_center:REGISTRY_RC-$SHORT_SHA" >> $GITHUB_ENV
echo "SHORT_TAG=RC-$SHORT_SHA" >> $GITHUB_ENV
- name: Set config files for build
Expand All @@ -55,10 +56,27 @@ jobs:
docker cp rails:/opt/webapps/app/public/ ./public/
docker build -t $STATIC_TAG -f Dockerfile.generic-static .
- name: Clone registry project
run: |
git clone https://github.com/internetee/registry.git
- name: Build registry image
env:
KEY_BASE: ${{ secrets.KEY_BASE}}
ST_APP: ${{ secrets.ST_REGISTRY_APPLICATION_YML}}
run: |
cd registry
mkdir log
echo $ST_APP | base64 -di > config/application.yml
cp config/database.yml.sample config/database.yml
sed -i -e 's/LABEL org.opencontainers.image.source=https:\/\/github.com\/internetee\/registry/LABEL org.opencontainers.image.source=https:\/\/github.com\/internetee\/auction_center/' Dockerfile.preinstalled_gems
docker build -t $REGISTRY_TAG --build-arg RAILS_ENV=staging --build-arg SECRET_KEY_BASE="$KEY_BASE" -f Dockerfile.preinstalled_gems .
- name: Push Docker images to gh container registry
run: |
docker push $TAG
docker push $STATIC_TAG
docker push $REGISTRY_TAG
- name: Get pull request reference number
run: |
Expand Down Expand Up @@ -115,11 +133,13 @@ jobs:
export KUBECONFIG=./kubeconfig
helm repo add eisrepo https://internetee.github.io/helm-charts/
helm repo update
helm upgrade --install auction-st-"$PR_REF" --set image.tag="$SHORT_TAG",reference="$PR_REF" eisrepo/auction -n auction-staging
helm upgrade --install auction-st-"$PR_REF" --set image.tag="$SHORT_TAG",reference="$PR_REF",scheduler.enabled="true" eisrepo/auction -n auction-staging
helm upgrade --install auction-reg-api-"$PR_REF" --set nameOverride="reg-api-auction",image.repository="ghcr.io/internetee/auction_center",image.tag="REGISTRY_"$SHORT_TAG"",reference="$PR_REF" eisrepo/registry-api -n reg-api
rm kubeconfig
echo "server obs.tld.ee
zone pilv.tld.ee
update add auction-"$PR_REF".pilv.tld.ee. 3600 CNAME riigi.pilv.tld.ee.
update add reg-api-auction-"$PR_REF".pilv.tld.ee. 3600 CNAME riigi.pilv.tld.ee.
send
" | nsupdate -k ~/Kgh-runner.infra.tld.ee.+165+27011.key
if [ "$?" -eq "0" ]; then
Expand All @@ -140,4 +160,5 @@ jobs:
|:-----------|:----------------------:|:------------------------------------------:|
| **'$REPO'**|'${{ github.head_ref }}'| https://auction-'$PR_REF'.pilv.tld.ee |
"
}' $NOTIFICATION_URL
}' $NOTIFICATION_URL
2 changes: 2 additions & 0 deletions .github/workflows/remove_st_after_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ jobs:
cd "$REPO"/"$PR_REF"
export KUBECONFIG=./kubeconfig
helm delete auction-st-"$PR_REF" -n auction-staging
helm delete auction-reg-api-"$PR_REF" -n reg-api
rm kubeconfig
echo "server obs.tld.ee
zone pilv.tld.ee
update delete auction-"$PR_REF".pilv.tld.ee.
update delete reg-api-auction-"$PR_REF".pilv.tld.ee.
send
" | nsupdate -k ~/Kgh-runner.infra.tld.ee.+165+27011.key
if [ "$?" -eq "0" ]; then
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Save coverage
run: ./cc-test-reporter format-coverage --output coverage/codeclimate.${{ matrix.ruby }}.json

- uses: actions/upload-artifact@v2.2.4
- uses: actions/upload-artifact@v2.3.0
with:
name: coverage-${{ matrix.ruby }}
path: coverage/codeclimate.${{ matrix.ruby }}.json
Expand All @@ -110,7 +110,7 @@ jobs:
- name: Give test coverage reporter executable permissions
run: chmod +x cc-test-reporter

- uses: actions/download-artifact@v2.0.10
- uses: actions/download-artifact@v2.1.0
with:
name: coverage-${{ matrix.ruby }}
path: coverage
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
25.11.2021
* unsubscribe link to daily auction broadcast emails [#845](https://github.com/internetee/auction_center/issues/845)

06.10.2021
* Invoice nr is now used as order ref for linkpay payments [#836](https://github.com/internetee/auction_center/issues/836)
* Improved error handling and logging for linkpay payments [#838](https://github.com/internetee/auction_center/pull/838)
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile.generic
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
FROM internetee/ruby:2.7
FROM internetee/ruby_base:3.0
LABEL org.opencontainers.image.source=https://github.com/internetee/auction_center
ARG YARN_VER='1.22.10'
ARG RAILS_ENV
ARG SECRET_KEY_BASE

ENV RAILS_ENV "$RAILS_ENV"
ENV SECRET_KEY_BASE "$SECRET_KEY_BASE"

RUN npm install -g yarn@"$YARN_VER"

COPY Gemfile Gemfile.lock ./
RUN gem install bundler && bundle config set without 'development test' && bundle install --jobs 20 --retry 5
RUN yarn install --check-files

COPY . .

RUN bundle exec rails assets:precompile
23 changes: 23 additions & 0 deletions app/controllers/unsubscribe_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class UnsubscribeController < ApplicationController
def unsubscribe
user = Rails.application.message_verifier(:unsubscribe).verify(params[:id])
@user = User.find(user)
end

def update
@user = User.find(params[:id])
if @user.update(user_params)
flash[:notice] = 'Subscription Cancelled'
redirect_to root_url
else
flash[:alert] = 'Something wrong'
render :unsubscribe
end
end

private

def user_params
params.require(:user).permit(:daily_summary)
end
end
4 changes: 3 additions & 1 deletion app/jobs/daily_broadcast_auctions_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ class DailyBroadcastAuctionsJob < ApplicationJob
def perform
User.subscribed_to_daily_summary.each do |user|
I18n.with_locale(user.locale) do
unsubscribe = Rails.application.message_verifier(:unsubscribe).generate(user.id)
NotificationMailer.daily_auctions_broadcast_email(
recipient: user.email,
auctions: active_auctions
auctions: active_auctions,
unsubscribe: unsubscribe
).deliver_later
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/mailers/notification_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ def daily_summary_email(addressee, summary_report = nil)
mail(to: addressee.email, subject: t('.subject', date: Date.yesterday))
end

def daily_auctions_broadcast_email(recipient:, auctions:)
def daily_auctions_broadcast_email(recipient:, auctions:, unsubscribe: nil)
@auctions = auctions
@unsubscribe = unsubscribe
mail(to: recipient)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
</table>

<%= t('common_mailer.footer_html') %>
<%= link_to t('unsubscribe_mailer_text'), unsubscribe_unsubscribe_url(id: @unsubscribe) %>
16 changes: 16 additions & 0 deletions app/views/unsubscribe/unsubscribe.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<% content_for :hero do %>
<div class="hero orange">
<h1><%= t('header_text') %></h1>
</div>
<% end %>

<div class="u-container">
<div class="margin-block">
<%= form_for(@user, url: unsubscribe_update_path(id: @user.id)) do |f| %>
<h3><%= t('unsubscribe_text') %></h3>
<%= f.hidden_field(:daily_summary, value: false) %>
<%= f.submit t('unsubscribe_btn'), class: "ui button big primary red" %>
<%= link_to t('cancel_btn'), root_url, class: "ui button big secondary" %>
<% end %>
</div>
</div>
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ en:
errors_name: "Errors"
statistics_name: "Statistics"

unsubscribe_mailer_text: "I do not wish to receive daily summary about currently auctioned domains any more"

user: "User"
deleted_user: "User was deleted"
banned: |
Expand Down
2 changes: 2 additions & 0 deletions config/locales/et.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ et:
bans_name: "Keelud"
errors_name: "Vead"

unsubscribe_mailer_text: "Ei soovi enam saada oksjonil olevate domeenide nimekirja meilile"

user: "Kasutaja"
deleted_user: "Kasutaja kustutatud"
banned: |
Expand Down
5 changes: 5 additions & 0 deletions config/locales/unsubscribe.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
en:
header_text: "Unsubscribe"
unsubscribe_text: "Please confirm that you no longer wish to receive daily summary"
unsubscribe_btn: "Unsubscribe"
cancel_btn: "Cancel"
5 changes: 5 additions & 0 deletions config/locales/unsubscribe.et.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
et:
header_text: "Tellimusest loobumine"
unsubscribe_text: "Palun kinnita et Sa ei soovi enam saada oksjonil olevate domeenide nimekirja"
unsubscribe_btn: "Loobun nimekirjast"
cancel_btn: "Mõtlesin ümber"
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
end

Rails.application.routes.draw do
get 'unsubscribe/unsubscribe'
patch 'unsubscribe/update'
root to: 'auctions#index'

concern :auditable do
Expand Down
24 changes: 24 additions & 0 deletions test/system/unsubscribe_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'application_system_test_case'

class UnsubscribeTest < ApplicationSystemTestCase
def setup
@participant = users(:participant)
@unsubscribe = Rails.application.message_verifier(:unsubscribe).generate(@participant.id)
end

def test_unsubscribe_user
@participant.daily_summary = true
@participant.save

assert_equal(@participant.daily_summary, true)

visit(unsubscribe_unsubscribe_url(id: @unsubscribe))
assert_text 'Please confirm that you no longer wish to receive daily summary'

click_link_or_button('Unsubscribe')
assert_text 'Subscription Cancelled'

@participant.reload
assert_equal(@participant.daily_summary, false)
end
end

0 comments on commit 40c9967

Please sign in to comment.